added duration from asesprite json, background animation, prepared
idle animation
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"log/slog"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
)
|
||||
@@ -23,6 +24,7 @@ type assetData struct {
|
||||
Registry AssetRegistry
|
||||
}
|
||||
|
||||
// to parse asesprite animation json
|
||||
type AnimationGeo struct {
|
||||
X int `json:"x"`
|
||||
Y int `json:"y"`
|
||||
@@ -32,7 +34,7 @@ type AnimationGeo struct {
|
||||
|
||||
type AnimationFrame struct {
|
||||
Position AnimationGeo `json:"frame"`
|
||||
Duration int
|
||||
Duration int `json:"duration"`
|
||||
}
|
||||
|
||||
type AnimationMeta struct {
|
||||
@@ -46,10 +48,15 @@ type AnimationJSON struct {
|
||||
Frames []AnimationFrame `json:"frames"`
|
||||
}
|
||||
|
||||
// Animation data
|
||||
// used to store Animation data
|
||||
type AnimationSprite struct {
|
||||
Sprite *ebiten.Image
|
||||
Duration time.Duration
|
||||
}
|
||||
|
||||
type AnimationSet struct {
|
||||
Width, Height int
|
||||
Sprites []*ebiten.Image
|
||||
Sprites []AnimationSprite
|
||||
File string
|
||||
}
|
||||
|
||||
@@ -153,11 +160,12 @@ func ProcessAnimations(rawanimations []AnimationJSON, imagedata *assetData) Anim
|
||||
frame.Position.Y+frame.Position.Height,
|
||||
)).(*ebiten.Image)
|
||||
|
||||
animationset.Sprites = append(animationset.Sprites, sprite)
|
||||
animationset.Sprites = append(animationset.Sprites,
|
||||
AnimationSprite{Sprite: sprite, Duration: time.Duration(frame.Duration)})
|
||||
}
|
||||
|
||||
animationset.Width = animationset.Sprites[0].Bounds().Dx()
|
||||
animationset.Height = animationset.Sprites[0].Bounds().Dy()
|
||||
animationset.Width = animationset.Sprites[0].Sprite.Bounds().Dx()
|
||||
animationset.Height = animationset.Sprites[0].Sprite.Bounds().Dy()
|
||||
|
||||
animations[animationset.File] = animationset
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 500
|
||||
"duration": 2000
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 1.ase",
|
||||
@@ -24,7 +24,7 @@
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 500
|
||||
"duration": 100
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 3.ase",
|
||||
@@ -42,7 +42,7 @@
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 500
|
||||
"duration": 2000
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 5.ase",
|
||||
@@ -52,6 +52,114 @@
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 100
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 6.ase",
|
||||
"frame": { "x": 3840, "y": 0, "w": 640, "h": 384 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 100
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 7.ase",
|
||||
"frame": { "x": 4480, "y": 0, "w": 640, "h": 384 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 100
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 8.ase",
|
||||
"frame": { "x": 5120, "y": 0, "w": 640, "h": 384 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 2000
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 9.ase",
|
||||
"frame": { "x": 5760, "y": 0, "w": 640, "h": 384 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 100
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 10.ase",
|
||||
"frame": { "x": 6400, "y": 0, "w": 640, "h": 384 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 100
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 11.ase",
|
||||
"frame": { "x": 7040, "y": 0, "w": 640, "h": 384 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 100
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 12.ase",
|
||||
"frame": { "x": 7680, "y": 0, "w": 640, "h": 384 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 2000
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 13.ase",
|
||||
"frame": { "x": 8320, "y": 0, "w": 640, "h": 384 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 100
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 14.ase",
|
||||
"frame": { "x": 8960, "y": 0, "w": 640, "h": 384 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 100
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 15.ase",
|
||||
"frame": { "x": 9600, "y": 0, "w": 640, "h": 384 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 100
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 16.ase",
|
||||
"frame": { "x": 10240, "y": 0, "w": 640, "h": 384 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 100
|
||||
},
|
||||
{
|
||||
"filename": "backgroundstars 17.ase",
|
||||
"frame": { "x": 10880, "y": 0, "w": 640, "h": 384 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 640, "h": 384 },
|
||||
"sourceSize": { "w": 640, "h": 384 },
|
||||
"duration": 2000
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
@@ -59,12 +167,13 @@
|
||||
"version": "1.x-dev",
|
||||
"image": "backgroundstars-animated.png",
|
||||
"format": "RGBA8888",
|
||||
"size": { "w": 3840, "h": 384 },
|
||||
"size": { "w": 11520, "h": 384 },
|
||||
"scale": "1",
|
||||
"frameTags": [
|
||||
],
|
||||
"layers": [
|
||||
{ "name": "Layer", "opacity": 255, "blendMode": "normal" }
|
||||
{ "name": "background", "opacity": 255, "blendMode": "normal" },
|
||||
{ "name": "stars", "opacity": 124, "blendMode": "normal" }
|
||||
],
|
||||
"slices": [
|
||||
]
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 52 KiB |
Binary file not shown.
67
assets/sprites/collectible-idle.json
Normal file
67
assets/sprites/collectible-idle.json
Normal file
@@ -0,0 +1,67 @@
|
||||
{ "frames": [
|
||||
{
|
||||
"filename": "collectible #Idle 0.ase",
|
||||
"frame": { "x": 0, "y": 0, "w": 64, "h": 64 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
|
||||
"sourceSize": { "w": 64, "h": 64 },
|
||||
"duration": 200
|
||||
},
|
||||
{
|
||||
"filename": "collectible #Idle 1.ase",
|
||||
"frame": { "x": 64, "y": 0, "w": 64, "h": 64 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
|
||||
"sourceSize": { "w": 64, "h": 64 },
|
||||
"duration": 200
|
||||
},
|
||||
{
|
||||
"filename": "collectible #Idle 2.ase",
|
||||
"frame": { "x": 128, "y": 0, "w": 64, "h": 64 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
|
||||
"sourceSize": { "w": 64, "h": 64 },
|
||||
"duration": 200
|
||||
},
|
||||
{
|
||||
"filename": "collectible #Idle 3.ase",
|
||||
"frame": { "x": 192, "y": 0, "w": 64, "h": 64 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
|
||||
"sourceSize": { "w": 64, "h": 64 },
|
||||
"duration": 200
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"app": "http://www.aseprite.org/",
|
||||
"version": "1.x-dev",
|
||||
"image": "collectible-idle.png",
|
||||
"format": "I8",
|
||||
"size": { "w": 256, "h": 64 },
|
||||
"scale": "1",
|
||||
"frameTags": [
|
||||
{ "name": "Detonation", "from": 1, "to": 14, "direction": "forward" },
|
||||
{ "name": "Idle", "from": 15, "to": 18, "direction": "forward" }
|
||||
],
|
||||
"layers": [
|
||||
{ "name": "Yellow Sphere", "opacity": 255, "blendMode": "normal" },
|
||||
{ "name": "Layer 8", "opacity": 255, "blendMode": "normal" },
|
||||
{ "name": "Layer 7", "opacity": 255, "blendMode": "normal" },
|
||||
{ "name": "Layer 6", "opacity": 255, "blendMode": "normal" },
|
||||
{ "name": "Layer 5", "opacity": 255, "blendMode": "normal" },
|
||||
{ "name": "Layer 4", "opacity": 255, "blendMode": "normal" },
|
||||
{ "name": "Layer 3", "opacity": 255, "blendMode": "normal" },
|
||||
{ "name": "Layer 2", "opacity": 255, "blendMode": "normal" },
|
||||
{ "name": "Layer 1", "opacity": 255, "blendMode": "normal" },
|
||||
{ "name": "Blitz Outer", "opacity": 70, "blendMode": "normal" },
|
||||
{ "name": "Blitz Middle", "opacity": 84, "blendMode": "normal" },
|
||||
{ "name": "Blitz Inner", "opacity": 97, "blendMode": "normal" }
|
||||
],
|
||||
"slices": [
|
||||
]
|
||||
}
|
||||
}
|
||||
BIN
assets/sprites/collectible-idle.png
Normal file
BIN
assets/sprites/collectible-idle.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 685 B |
Binary file not shown.
BIN
assets/sprites/stars.ase
Normal file
BIN
assets/sprites/stars.ase
Normal file
Binary file not shown.
Reference in New Issue
Block a user