Page 1 of 1
Animation acting weird!
Posted: Sun Nov 23, 2008 2:23 pm
by Ripe
Hey guys, I've started putting animation test together and ran into a problem. For some mysterious reason when I turn left and release the key it'll create weird offset between the standing image and the walking animation but works fine walking right. A little hard to explain so I attached the demo, the code isn't very large so someone who love-savvy should see what I've done wrong reasonably fast. I also including the images in case it's something I missed there.
Any help is much appreciated!
Re: Animation acting weird!
Posted: Sun Nov 23, 2008 3:23 pm
by rude
... what the hell!? Seems like there's something wrong with the offset when you flip the image.
I wish I had the time to insta-fix bugs as they show up, but I don't ... damn you, life!
Workarounds: use separate images or make it part of the animation and use :seek().
Re: Animation acting weird!
Posted: Sun Nov 23, 2008 5:16 pm
by bartbes
Something I could've guessed, the problem is in the 0.3*direction (of stand). Couldn't find the exact problem, but I've come up with a temporary fix:
Code: Select all
player.x-((player.direction-1)*-0.5*30),
Instead of the old player.x argument of the draw which is called when stand is needed.
Oh, and the title should be changed, the animation is correct, the image of stand is wrong (I used a dot to figure that one out)
Re: Animation acting weird!
Posted: Mon Nov 24, 2008 2:50 am
by Ripe
Thanks that works. Although I don't understand how it works
Re: Animation acting weird!
Posted: Wed Nov 26, 2008 7:29 pm
by bartbes
the
is just a piece of math translating to:
Code: Select all
if player.direction == -1 then
player.x = player.x-30
end
don't know why the offset of 30 is in place, I guess there are 30 pixels added to the right side, which you don't notice when you are looking to the right, but you do when you 'rotate'