No way to animate a rectangle/ellipsis
Or maybe it's not documented? I need to animate a Rectangle's opacity and I don't see how that could be done.
Fade a sprite opacity to 0.5 over 2 seconds: scene.run(sprite_id, &Action(FadeTo(2.0, 0.5)))
Not sure best place for documentation, I normally just have the source open. Ref:
- https://github.com/PistonDevelopers/sprite/blob/master/src/animation.rs#L63
- https://github.com/PistonDevelopers/sprite/blob/master/src/scene.rs#L98
@xaviershay Yeah, but where do I get the sprite_id?
It's returned from scene.add_child. Here is an example: https://github.com/xaviershay/rust-puzzlefighter/blob/master/src/renderer.rs#L58
@xaviershay Let me rephrase, how do I get a Texture from a Rectangle to create a sprite?
ah I'm sorry, I didn't realise Rectangle was an actual type!! I'm pretty new to the library, was just trying to be helpful :)
Will have a poke around for you tonight.
so looking at things, I don't think this is possible right now since Rectangle isn't implemented as a Sprite with a texture.
To enable this, I think we'd need to have a Sprite trait, and then provide an implementation for ... probably the Contexts in graphics, though I'm not familiar enough with the architecture (either with that heirachy or the relationship between this library and it) there to be sure. Seems like the required implementations should be pretty straightforward.
Perhaps one of the core team can drop in with a better suggestion.