Request framePerSecond attribute for every animation
pixelpicosean opened this issue · 3 comments
Currently every SpriteSheet has only one framePerSecond attribute, which forces sprite assets to have the same interval. One fps per animation is REALLY useful so that I'll not have to change assets every time when I want to change some animation's speed (just like sprite animation of flixel).
Good one @pixelpicosean :)
I've just created SpriteAnimation to control framesPerSecond
, allowing you to configure SpriteSheet
s like this:
var sheet = new Joy.SpriteSheet({
src: "spritesheet.png",
framesPerSecond: 12, // optional, 24 by default
width: 120,
height: 120,
animations: {
"walking": { frames: [0, 30], framesPerSecond: 32 },
"idle": { frames: [31, 39], framesPerSecond: 24 },
"jumping": [40, 59] // framesPerSecond is optional, will be 12 here
}
});
What do you think?
OBS: It would be awesome to have "reverse" and non-linear frame support on SpriteAnimation too.
Wow, that looks amazing. Does non-linear mean configuring different time between every 2 frames or using a tween to control the anmiation? Sounds cool!
@pixelpicosean I didn't mean that, but really sounds cool what you said. :)
with non-linear I mean using frames without a sequence, like: [1,2,1,3]. Actually it's supporting only frame ranges, like: [1,4] = 1,2,3,4
(I've closed this pull request, but feel free to open it again if you have some trouble)