Mirai-Team / mirai-project

C++ library for games making purposes.
Other
3 stars 0 forks source link

Improve animated sprite and animation classes #71

Open Lomadriel opened 9 years ago

Lomadriel commented 9 years ago

Firstly, users can't currently choose size for each frames. For example, if you use an animation where a human turns into a monster which is bigger than the human you can't use them.

So this would be better if you can make an animation like that:

mp::Animation myAnimation("transformation into monster");
myAnimation.addFrame(sf::IntRect(0, 0, 30, 36));
myAnimation.addFrame(sf::IntRect(0, 30, 40, 90));
…
mp::AnimatedSprite myCharacter(mySpriteSheet);
myCharacter.addAnimation(myAnimation);
…

Secondly, we can't add animations which come from different files, we could simply do this:

mp::Animation myAnimation("transformation into monster");
myAnimation.setSpriteSheet(mySpriteSheet);
myAnimation.addFrame(sf::IntRect(0, 0, 30, 36));
myAnimation.addFrame(sf::IntRect(0, 30, 40, 90));
…
mp::AnimatedSprite myCharacter;
myCharacter.addAnimation(myAnimation);
…
CBenoit commented 9 years ago

I'm OK with you first idea, although object's size will grow to keep all frames size. About the second one, it could be useful indeed, but I keep in mind that priority is to avoid changing the texture. So, I'll try to detect if several animations uses same texture in order to avoid the problem. PS : Note that in some cases, using another sprite could be better than playing with animations.

Lomadriel commented 9 years ago

Yeah indeed but we should add a class which could manage several AnimatedSprites. Some entities will just use one AnimatedSprite but if an entity uses 2 or 3 AnimatedSprites (example: a character who can equip an armor), we can't use one AnimatedSprite.