Animation acting weird!

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Ripe
Prole
Posts: 11
Joined: Wed Nov 19, 2008 3:28 pm
Location: Australia

Animation acting weird!

Post 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!
Attachments
ONNZ.love
(27.79 KiB) Downloaded 215 times
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Animation acting weird!

Post 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().
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Animation acting weird!

Post 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)
Ripe
Prole
Posts: 11
Joined: Wed Nov 19, 2008 3:28 pm
Location: Australia

Re: Animation acting weird!

Post by Ripe »

Thanks that works. Although I don't understand how it works :P
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Animation acting weird!

Post by bartbes »

the

Code: Select all

((player.direction-1)*-0.5*30)
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'
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests