Sprite

I have this code for the sprite

[lua]local function spriteMove(event)
if xmovement > 0 or xmovement < 0 then
guy:prepare(“guymove”)
guy:play(“guymove”)
elseif xmovement == 0 then
guy:prepare(“guystop”)
guy:play(“guystop”)
end
end

Runtime:addEventListener( “enterFrame”, spriteMove )[/lua]

the problem is that it only shows the first picture of the sprite for some reason (sprite doesn’t play)

Any ideas? [import]uid: 104376 topic_id: 22130 reply_id: 322130[/import]

You are preparing the sprite every frame which is not necessary.

See this tutorial; http://techority.com/2011/05/01/using-sprites-in-your-corona-iphone-application/

Peach :slight_smile: [import]uid: 52491 topic_id: 22130 reply_id: 88015[/import]

Yeah, I’ve looked at that, and as far as I know I did the same thing in my code. Could you help me fix it?
I need to play “guymove” when movementx Isn’t equal to 0, and play “guystop” when movementx = 0.

And maybe instead of sprite I could use movieclip, and play it when movementx isn’t equal to zero. [import]uid: 104376 topic_id: 22130 reply_id: 88022[/import]