Page 1 of 1

Animation Smoothness

Posted: Sun Feb 24, 2013 1:06 am
by CagedWalrus
Issue

I've been playing around with sprite animation for the past day or two, and today I encountered an issue dealing with animation smoothness. I've attached an example of what I mean in to this post, for reference. Basically, when moving left the animation is very smooth, but when moving right the animation because much less smooth (moves to the left and right, and doesn't stay as steady). After a few hours of changing various variables, and inspecting my code, I came to the realization that the issue is probably spawned from the fact that the engine pulls the sprites starting from the upper left (x,y) position.

Before I figured out how to mirror sprites in game, I had mirrored them on the sprite sheet. This is what I believe to be causing the difference in animation smoothness.

Inquiry

Does anyone know of a way of preventing this? Am I just overlooking something that is incredibly simple? Any suggestions are appreciated.

Thank you!

Re: Animation Smoothness

Posted: Sun Feb 24, 2013 3:34 am
by Taehl
All I see is a white box. Looks like PO2 Syndrome strikes again! (Wasn't Love 0.8.0 supposed to end that?)

To fix the white box issue, you need to ensure your images have dimensions that are a power of 2. So an image sized 256x512 would be okay, but 200x500 would not. This is the PO2 sequence:
1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, ...

Then again, none of your images are PO2-compliant, so maybe the problem is being caused by your sprite sheet being too big?

Re: Animation Smoothness

Posted: Sun Feb 24, 2013 3:49 am
by slime
Many old or Intel GMA video cards don't support images with dimensions greater than 2048x2048.
http://feedback.wildfiregames.com/repor ... XTURE_SIZE

Re: Animation Smoothness

Posted: Sun Feb 24, 2013 4:21 am
by CagedWalrus
I went ahead and reduced the image size. It's still not within the parameters for PO2, but I decided to play around with these sprites after I read that it was no longer an issue.

Also, this is an older piece of code, but it highlights the issue more clearly than other examples I could find.

Re: Animation Smoothness

Posted: Sun Feb 24, 2013 11:03 am
by bartbes
When I use half the quad's width and height as origin coordinates, it seems to be as smooth, both ways, and the left-to-right movement seems as intended.

Re: Animation Smoothness

Posted: Sun Feb 24, 2013 3:23 pm
by CagedWalrus
When you are referring to origin coordinates, do you mean the origin offset (in love.graphics.drawq)? Since the width and height change, I tried getting the variable directly from the table, but it kept returning nil (attempting to perform arithmetic on a nil value).

I'm fairly new to Lua, would you mind explaining how I could accomplish something like that.

Thank you for your time and patience.

Re: Animation Smoothness

Posted: Sun Feb 24, 2013 4:04 pm
by bartbes
Quads have a getViewport function which gives the width and height, I used something like

Code: Select all

local _, _, w, h = currentQuad:getViewport()
then used w/2 and h/2 for ox and oy respectively.

Re: Animation Smoothness

Posted: Sun Feb 24, 2013 4:42 pm
by CagedWalrus
That did the job. Thank you for the info!