Tween jerkiness

Up to now I’ve been animating values fairly laboriously, but the time has come for me to harness tween power. I thought I would start with a simple linear tween of an object moving onto screen, but the animation is all over the place. It’s clearly not a frame rate issue because the object jerks back and forth. A video probably illustrates it best.

http://youtu.be/vVRgpLMs5Go

Here’s a snippet of the code I’m using. The book object which is drawn by TheBook:DrawCard() is entirely static, and I’ve been animating it the laborious way with no issues. The offscreen starting vector “bookpos” is defined in setup and is not manipulated at all aside from this tween function. Has anyone else had (and preferably solved!) these issues?


function ShowCharacter:BookAnim()
    pushMatrix()

    translate(bookpos.x, bookpos.y)
    TheBook:DrawCard()
    tween(2, bookpos, {x = 300}, tween.easing.linear)

    popMatrix()
end

@epicurus101 - it looks as though you are running the tween each time you draw, so it is interrupting itself all the time

Run it once, then leave it alone until it’s done.

Thanks, that was certainly the issue. I was putting it in draw because I was going to modify it to only be run when a particular condition was met (a “Proceed” button being pressed). However, since that’s not going to work, I put it in its own little function with a one-time switch. Slightly more cumbersome, but it works.