added duration from asesprite json, background animation, prepared
idle animation
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"openquell/assets"
|
||||
"openquell/config"
|
||||
"time"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
)
|
||||
@@ -11,7 +13,7 @@ type Animation struct {
|
||||
Active bool // animation is running
|
||||
Loop bool // remove the entity if false, loop endless otherwise
|
||||
Index int // where we are currently
|
||||
Tiles []*ebiten.Image
|
||||
Sprites []assets.AnimationSprite
|
||||
Width, Height int // single sprite measurements
|
||||
Timer Timer
|
||||
Trigger string
|
||||
@@ -24,6 +26,7 @@ type Renderable struct {
|
||||
Damaged int
|
||||
Shader *ebiten.Shader
|
||||
Animate Animation
|
||||
IdleAnimate Animation
|
||||
Hidden bool
|
||||
}
|
||||
|
||||
@@ -41,3 +44,11 @@ func (render *Renderable) StartAnimation() {
|
||||
render.Animate.Loop = true
|
||||
}
|
||||
}
|
||||
|
||||
func (animation *Animation) GetSprite() *ebiten.Image {
|
||||
return animation.Sprites[animation.Index].Sprite
|
||||
}
|
||||
|
||||
func (animation *Animation) GetDuration() time.Duration {
|
||||
return animation.Sprites[animation.Index].Duration * time.Millisecond
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user