You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now we can change the sprite's texture easily by sprite.set_texture(...). We can manually set the sprite's texture to do animation but we should have a convenient way to do it.
One way in my mind is that we can define a struct Animation to describe the animation which may contain information like:
How many frames does it have?
Which texture(or sub texture) does each frame use?
What the delay between each frames?
Will the animation loop or not? If it will loop, how many times will it loop? or loop forever?
After the animation stopped, which frame will the sprite use?
Once we have the Animation, we can construct an Action for it. So to do animation, the code may look like:
scene.run_action(sprite, Action(Animation(a)));
As we can pause/resume/toggle/stop actions, we can easily pause/resume/toggle/stop animations.
Now we can change the sprite's texture easily by
sprite.set_texture(...)
. We can manually set the sprite's texture to do animation but we should have a convenient way to do it.One way in my mind is that we can define a struct
Animation
to describe the animation which may contain information like:Once we have the
Animation
, we can construct anAction
for it. So to do animation, the code may look like:As we can pause/resume/toggle/stop actions, we can easily pause/resume/toggle/stop animations.
We should focus on this after #6 finished.
Any suggestions?
The text was updated successfully, but these errors were encountered: