Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for sprite animation #8

Open
coeuvre opened this issue Sep 16, 2014 · 4 comments
Open

Add support for sprite animation #8

coeuvre opened this issue Sep 16, 2014 · 4 comments
Labels

Comments

@coeuvre
Copy link
Member

coeuvre commented Sep 16, 2014

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:

  1. How many frames does it have?
  2. Which texture(or sub texture) does each frame use?
  3. What the delay between each frames?
  4. Will the animation loop or not? If it will loop, how many times will it loop? or loop forever?
  5. 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.

We should focus on this after #6 finished.

Any suggestions?

@coeuvre coeuvre added the draft label Sep 16, 2014
@abonander
Copy link

Animation from GIFs? Is that a good idea?

@coeuvre
Copy link
Member Author

coeuvre commented Sep 16, 2014

It's a good idea! So we need a library to read GIF format first.

@abonander
Copy link

rust-image is a good start. I think it can read animated GIFs but it doesn't have a good API for using them.

@bvssvni
Copy link
Member

bvssvni commented Sep 16, 2014

One idea would be to improve the API or building something on top of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants