You are almost there! The only thing is that SecondsPassed just gives frame duration, not total time since some event. This means you have 33-62 frames per second running. E.g. you can do it this way: procedure TPlayer.Update; begin Self.InternalTime += CastleControl1.Fps.SecondsPassed; {this way we increase internal time by SecondsPassed each frame; obviously, you'll have to call Player.Update for this feature to work correctly} if Self.AnimationDuration < Self.InternalTime then begin Self.CurrentAnimation...
You are almost there! The only thing is that SecondsPassed just gives frame duration, not total time since some event. This means you have 33-62 frames per second running. E.g. you can do it this way: procedure TPlayer.Update; begin Self.InternalTime += CastleControl1.Fps.SecondsPassed; {this way we increase internal time by SecondsPassed each frame; obviously, you'll have to call Player.Update for this feature to work correctly} if Self.AnimationDuration < Self.InternalTime then Self.CurrentAnimation...
I confess that I'm not really a lover of 2d but rather of 2.5d. Then you might also like the fact, that TCastle2DScene is compatible with 3D world. I.e. in Castle Game Engine you can mix 2D and 3D objects freely (e.g. character sprites and 3D or pseudo-3D environment). I didn't try it yet, but it doesn't seem too difficult. As of 2.5D you might want to look at orthographic projection for 3D world (unfortunatly I don't have any experience here - I just know it should work out-of-the-box) or using...
Valter Buccina, hi! Unfortunately in practice I've never had so many animations in one class before. And my animations approach for 3D models was relatively complex, because I needed a lot of control over them. So, first thing first: this is an overkill and inefficient solution, but it answers your question directly: Variant A: const AnimationLeft = 1; AnimationRight = 2; type TPlayer = class private MyAnimation1, MyAnimation2: TSprite public CurrentAnimationID: Integer; function CurrentAnimation:...
Valter Buccina, hi! Unfortunately in practice I've never had so many animations in one class before. And my animations approach for 3D models was relatively complex, because I needed a lot of control over them. So, first thing first: this is an overkill and inefficient solution, but it answers your question directly: Variant A: const AnimationLeft = 1; AnimationRight = 2; type TPlayer = class private MyAnimation1, MyAnimation2: TSprite public CurrentAnimationID: Integer; function CurrentAnimation:...
P.S. You may also have a look at "middle" solution, TSprite can contain multiple animations, not just one. You can load all the animations into a single TSprite - see https://castle-engine.io/apidoc-unstable/html/CastleGLImages.TSprite.html#AddAnimation and https://castle-engine.io/apidoc-unstable/html/CastleGLImages.TSprite.html#SwitchToAnimation
Valter Buccina, hi! Unfortunately in practice I've never had so many animations in one class before. And my animations approach for 3D models was relatively complex, because I needed a lot of control over them. So, first thing first: this is an overkill and inefficient solution, but it answers your question directly: Variant A: const AnimationLeft = 1; AnimationRight = 2; type TPlayer = class private MyAnimation1, MyAnimation2: TSprite public CurrentAnimationID: Integer; function CurrentAnimation:...
Valter Buccina, hi! Unfortunately in practice I've never had so many animations in one class before. And my animations approach for 3D models was relatively complex, because I needed a lot of control over them. So, first thing first: this is an overkill and inefficient solution, but it answers your question directly: Variant A: const AnimationLeft = 1; AnimationRight = 2; type TPlayer = class private MyAnimation1, MyAnimation2: TSprite public CurrentAnimationID: Integer; function CurrentAnimation:...