I have a small problem where when I touch my buttons to make my character move. If you touch them really quickly, the sprite slides to in the button’s direction without animating. 
[lua]function createPiggyBank()
local piggyBankSheet = sprite.newSpriteSheet(“images/game_piggybank.png”, 96, 96)
local piggyBankSet = sprite.newSpriteSet(piggyBankSheet, 1, 6)
sprite.add (piggyBankSet, “pigmleft”, 1, 3, 250, 0)
sprite.add (piggyBankSet, “pigmright”, 4, 3, 250, 0)
piggyBank = sprite.newSprite(piggyBankSet)
physics.addBody(piggyBank, “static”)
piggyBank.x = display.contentWidth / 2
piggyBank.y = 397
function piggyBank:collision(event)
if(event.other.type == “coinbronze”) then
scorePlaceThree = scorePlaceThree + 1
audio.play(coinSound)
elseif(event.other.type == “coinsilver”) then
scorePlaceThree = scorePlaceThree + 5
audio.play(coinSound)
elseif(event.other.type == “coingold”) then
scorePlaceTwo = scorePlaceTwo + 1
audio.play(coinSound)
elseif(event.other.type == “rock”) then
end
event.other:removeSelf()
end
piggyBank:addEventListener(“collision”, piggyBank)
end
function createButtons()
local motionX = 0
local speed = 8
local buttonSheet = sprite.newSpriteSheet(“images/game_buttons.png”, 72, 72)
local buttonSet = sprite.newSpriteSet(buttonSheet, 1, 4)
sprite.add (buttonSet, “leftn”, 1, 1, 60000, 0)
sprite.add (buttonSet, “leftp”, 2, 1, 60000, 0)
sprite.add (buttonSet, “rightn”, 3, 1, 60000, 0)
sprite.add (buttonSet, “rightp”, 4, 1, 60000, 0)
leftButton = sprite.newSprite(buttonSet)
leftButton.x = 51
leftButton.y = 429
leftButton:prepare(“leftn”)
leftButton:play(“leftn”)
function touchLeft (event)
motionX = -speed
leftButton:prepare(“leftp”)
leftButton:play(“leftp”)
piggyBank:prepare(“pigmleft”)
piggyBank:play(“pigmleft”)
end
rightButton = sprite.newSprite(buttonSet)
rightButton.x = 749
rightButton.y = 429
rightButton:prepare(“rightn”)
rightButton:play(“rightn”)
function touchRight (event)
motionX = speed
rightButton:prepare(“rightp”)
rightButton:play(“rightp”)
piggyBank:prepare(“pigmright”)
piggyBank:play(“pigmright”)
end
local function movePiggyBank(event)
piggyBank.x = piggyBank.x + motionX
if(piggyBank.x < -33) then piggyBank.x = 833
elseif(piggyBank.x > 833) then piggyBank.x = -33 end
end
local function stopPiggyBank (event)
if event.phase ==“ended” then
motionX = 0
leftButton:prepare(“leftn”)
leftButton:play(“leftn”)
rightButton:prepare(“rightn”)
rightButton:play(“rightn”)
piggyBank:pause()
end
end
leftButton:addEventListener(“touch”, touchLeft)
rightButton:addEventListener(“touch”, touchRight)
Runtime:addEventListener(“enterFrame”, movePiggyBank)
Runtime:addEventListener(“touch”, stopPiggyBank)
end[/lua] [import]uid: 103624 topic_id: 18229 reply_id: 318229[/import]