-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a60468f
commit 23ad81d
Showing
3 changed files
with
102 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
[![Go Reference](https://pkg.go.dev/badge/github.com/temidaradev/esset.svg)](https://pkg.go.dev/github.com/temidaradev/esset) | ||
|
||
# Esset | ||
|
||
Esset は、ebitengine の基本的なアセット実装者です。 | ||
|
||
# 使用法 | ||
|
||
まず `github.com/temidaradev/esset`にアクセスし、アセットフォルダを作成します(まだ作成していない場合)。フォルダを作成したら`.png`アセットをそのフォルダに入れて`assets.go`を作成します。その後、以下を追加します。 | ||
|
||
``` | ||
//go:embed * | ||
var assets embed.FS | ||
``` | ||
|
||
この埋め込みステートメントは、インポート部分の後にあります。これで、esset をアセット実装者として使用できます。最初に埋め込みステートメント、次に「asset.png」という 2 つのパラメータが必要です。 | ||
|
||
## GetAsset | ||
|
||
例: `var Idle = esset.GetAsset(assets, "path/to/your/asset.png")` | ||
|
||
## GetMultipleAssets | ||
|
||
重要なのは、フォルダを作成し、すべてのタイルアイテム「.png」を次のように配置することです。 | ||
|
||
<img src="resources/image.png" height="400"> | ||
|
||
そして、その関数は次のように簡単に使用できます: `var Tile = esset.GetMultipleAssets(assets, "path/to/your/*.png")` 1 つ以上の画像を選択しているため、`*ebiten.Image` は次のようにインデックスで選択できるスライスです: `TileComponent := asset.Tile[0]` または、そのフォルダーからランダムなアセットを取得する必要がある場合は、次のように実行できます: `TileRandom := asset.Tile[rand.Intn(len(assets.Tile))]` | ||
|
||
## UseFont | ||
|
||
フォントの場合は、次のようにフォントを個別に埋め込む必要があります。 | ||
|
||
``` | ||
//go:embed path/to/your/font.ttf | ||
var MyFont []byte | ||
``` | ||
|
||
その後、次のように `Draw()` 関数に `&text.DrawOptions{}` を作成する必要があります。 | ||
|
||
``` | ||
opF := &text.DrawOptions{} | ||
opF.GeoM.Translate(x, y) | ||
opF.ColorScale.ScaleWithColor(color.White) | ||
``` | ||
|
||
その後、`esset.UseFont` 関数を次のように使用できます: `esset.UseFont(screen, asset.MyFont, "wassup", 24, opF)` | ||
|
||
ソースサポートをしてくれた [@m110](https://github.com/m110) に感謝します <3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
[![Go Reference](https://pkg.go.dev/badge/github.com/temidaradev/esset.svg)](https://pkg.go.dev/github.com/temidaradev/esset) | ||
|
||
# Esset | ||
|
||
Esset, ebitengine için bast bir asset yükleyici. | ||
|
||
# Kullanım | ||
|
||
Önce `go get github.com/temidaradev/esset` ile go modülünüze ekleyin. Eğer yoksa bir asset klasörü oluşturun. Klasörü oluşturduktan sonra .png varlıklarını bu klasöre koyun ve `assets.go` dosyasını oluşturun. Bundan sonra | ||
|
||
``` | ||
//go:embed * | ||
var asset embed.FS | ||
``` | ||
|
||
bu embed ifadesini içe aktarma kısmından sonra ekleyin. Artık esset'i asset yükleyici olarak kullanabilirsiniz. Sizden öncelikle embed ifadesi ve ardından `"asset.png"` olmak üzere 2 parametre ister. | ||
|
||
## GetAsset | ||
|
||
İşte bir örnek: `var Idle = esset.GetAsset(assets, "path/to/your/asset.png")` | ||
|
||
## GetMultipleAssets | ||
|
||
Önemli olan bir klasör oluşturmak ve her bir tile öğesini (.png) şu şekilde koymaktır | ||
|
||
<img src="resources/image.png" height="400"> | ||
|
||
ve sonra bu işlevi şu şekilde kolayca kullanabilirsiniz: `var Tile = esset.GetMultipleAssets(assets, "path/to/your/*.png")` 1'den fazla resim seçtiğiniz için `*ebiten.Image`'imiz şu şekilde dizine göre seçebileceğiniz bir slice'dır: `TileComponent := asset.Tile[0]` veya bu klasörden rastgele bir varlık almanız gerekiyorsa şu şekilde yapabilirsiniz: `TileRandom := asset.Tile[rand.Intn(len(assets.Tile))]` | ||
|
||
## UseFont | ||
|
||
Yazı tipleri için yazı tiplerini ayrı ayrı gömmeniz gerekir: | ||
|
||
``` | ||
//go:embed font/OpenSans-Medium.ttf | ||
var MyFont []byte | ||
``` | ||
|
||
Bundan sonra `Draw()` fonksiyonunuzda `&text.DrawOptions{}` fonksiyonunu şu şekilde oluşturmalısınız: | ||
|
||
``` | ||
opF := &text.DrawOptions{} | ||
opF.GeoM.Translate(x, y) | ||
opF.ColorScale.ScaleWithColor(color.White) | ||
``` | ||
|
||
Bundan sonra `esset.UseFont` fonksiyonunu şu şekilde kullanabilirsiniz: `esset.UseFont(screen, asset.MyFont, "naber", 24, opF)` | ||
|
||
Çok teşekkürler Kaynak desteği için [@m110](https://github.com/m110) <3 |