Open amyspark-ng opened 3 months ago
I don't understand, would you provide example code?
Let's say you have a sprite with animations walk (frames 0 to 3) and jumping (4 to 8)
So if you do something like
player.play("walk") debug.log(player.frame)
this would return well any number between 0 to 3, but if you do
player.play("jumping") debug.log(player.frame)
this would return a number between 4 to 8!!! which doesn't make much sense to me, it should return a number between 0 to 4 (the amount of frames the jumping animation has)
This should be a new getter relativeFrame, because the other one is the absolute frame of the animation and shouldn't be changed.
fair
get relativeFrame() {
if (!spriteData || !curAnim || curAnimDir === null) {
return this.frame;
}
const anim = spriteData.anims[curAnim.name];
if (typeof anim === "number") {
return anim;
}
return this.frame - anim.from;
},
oh i see, could work as a method in the type
after a cursory look at this
get relativeFrame() {
if (!spriteData || !curAnim || curAnimDir === null) {
return this.frame;
}
const anim = spriteData.anims[curAnim.name];
if (typeof anim === "number") {
return anim;
}
- return this.frame - anim.from;
+ return this.frame - Math.min(anim.from, anim.to);
},
because the anim can have from > to
for reverse playing
i might make a pr for adding this!
Describe the bug
A clear and concise description of what the bug is.
Not sure if this is actually a bug, but right now, when you want to get the current frame, it treats all animations of an object as a single animation and returns the frame in this "single animation" thing, instead of returning the frame for the current animation
let's say i have an object with an idle animation (4 frames) and a run animation(3 frames) if im running, the frame would be something above 3, which doesn't make sense