kittykatattack / hexi

Make games the fun way!
MIT License
555 stars 83 forks source link

Reusing sprite indices in animations #15

Closed neckutrek closed 7 years ago

neckutrek commented 8 years ago

While reading /examples/bin/animationStates.js I found no way of reusing animation indices for different sprite states. Imagine one would want the animation sequence [0, 1, 2, 1], where index 1 is for example standing still and 0 and 2 are using the left and the right foot to walk, then there is no way of executing this custom sprite index order? (playAnimation() only accepts starting and ending index it seems) Or is this solved using some other facility of hexi?

Btw, thanks for a nice library!

lawalm commented 8 years ago

ScrollingWorldCamera file has an example of animation states.

elf.states = { up: 0, left: 9, down: 18, right: 27, walkUp: [1, 8], walkLeft: [10, 17], walkDown: [19, 26], walkRight: [28, 35] };

neckutrek commented 8 years ago

Yes, but it seems to me that it's not allowed to customize the order of the frame indexes. Instead of playing frame indexes [28, 29, 30, 31, 32, 33, 34, 35], I might want to play [28, 30, 32, 34, 34, 36] for example. A good reason for being able to customize this is that tilesets sometimes does not provide frames in the same order as the animations are in order to save space. If an image in an animation appears many times it might only be placed at one single place in the tileset image file.

kittykatattack commented 8 years ago

Hi neckutreck,,

Yes, you're correct, the feature you are requesting is currently out-of-scope.

But if anyone wishes to contribute this feature, please visit the SpriteUtilities module, and open and Issue with a proposal on how to implement it. Here's the relevant code:

https://github.com/kittykatattack/spriteUtilities/blob/master/src/spriteUtilities.js#L133

kittykatattack commented 8 years ago

@neckutrek Oops, I completely forgot! :smile:

You can use the frames method to supply a custom array of non-contiguous tileset frames that could be used for sequential animation frames:

https://github.com/kittykatattack/spriteUtilities#frames

...Would that work for you?

neckutrek commented 8 years ago

Hi,

That looks very promising, thanks!


Med vänlig hälsning / Best regards, Marcus A Johansson +46 (0)70 315 73 77

2016-08-29 17:44 GMT+02:00 kittykatattack notifications@github.com:

@neckutrek https://github.com/neckutrek Oops, I completely forgot! 😄

You can use the frames method to supply a custom array of non-contiguous tileset frames that could be used for sequential animation frames:

https://github.com/kittykatattack/spriteUtilities#frames

...Would that work for you?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kittykatattack/hexi/issues/15#issuecomment-243163466, or mute the thread https://github.com/notifications/unsubscribe-auth/ADmjhSLKwhyRjElJ5mCyrGv1gnXapkDdks5qkv5bgaJpZM4JuZjT .