How to stop an animation

I have this function

local function buttonBackHandler() -- A per-frame event to move the elements local tPrevious = system.getTimer() local function move(event) &nbsp;&nbsp; &nbsp;local tDelta = event.time - tPrevious &nbsp;&nbsp; &nbsp;tPrevious = event.time &nbsp;&nbsp; &nbsp;local xOffset = ( 0.1 \* tDelta ) &nbsp;&nbsp; &nbsp;funny1.x = funny1.x - xOffset &nbsp;&nbsp; &nbsp;funny2.x = funny2.x - xOffset &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;if (funny1.x + funny1.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny1:translate( 1500, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;if (funny2.x + funny2.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny2:translate( 1500, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;-- Start everything moving Runtime:addEventListener( "enterFrame", move );&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end

It’s moving two images just fine…

but I need another button with a function inside to “Stop” the movement

I put this and it did not work

local function buttonHomeHandler() &nbsp;&nbsp; &nbsp;move.stop()&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end

Please help me out with this, I have a problem with sprites and with stop animation

this is the complete code

local storyboard = require( "storyboard" ) local widget = require "widget" local scene = storyboard.newScene() local buttonHome local buttonBack local funny1 local funny2 local function buttonHomeHandler() &nbsp;&nbsp; &nbsp;move.stop()&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end local function buttonBackHandler() -- A per-frame event to move the elements local tPrevious = system.getTimer() local function move(event) &nbsp;&nbsp; &nbsp;local tDelta = event.time - tPrevious &nbsp;&nbsp; &nbsp;tPrevious = event.time &nbsp;&nbsp; &nbsp;local xOffset = ( 0.1 \* tDelta ) &nbsp;&nbsp; &nbsp;funny1.x = funny1.x - xOffset &nbsp;&nbsp; &nbsp;funny2.x = funny2.x - xOffset &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;if (funny1.x + funny1.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny1:translate( 1500, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;if (funny2.x + funny2.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny2:translate( 1500, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;-- Start everything moving Runtime:addEventListener( "enterFrame", move );&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[CREATE SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:createScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;local background = display.newImage( "backgroundFunny.png" ) &nbsp;&nbsp; &nbsp;group:insert ( background ) &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonHome = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonHome.png", &nbsp;&nbsp; &nbsp;onRelease = buttonHomeHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonHome ) &nbsp;&nbsp; &nbsp;buttonHome.x = 910 &nbsp;&nbsp; &nbsp;buttonHome.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonBack = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonBack.png", &nbsp;&nbsp; &nbsp;onRelease = buttonBackHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonBack ) &nbsp;&nbsp; &nbsp;buttonBack.x = 100 &nbsp;&nbsp; &nbsp;buttonBack.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;funny1 = display.newImage( "funnyG1.png" ) &nbsp;&nbsp; &nbsp;funny1:setReferencePoint( display.CenterLeftReferencePoint ) &nbsp;&nbsp; &nbsp;funny1.x = 100; funny1.y = 200 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;funny2 = display.newImage( "carTireFront.png" ) &nbsp;&nbsp; &nbsp;funny2:setReferencePoint( display.CenterLeftReferencePoint ) &nbsp;&nbsp; &nbsp;funny2.x = 250; funny2.y = 200 end --------------------------------------------------------------ENTER SCENE---------- function scene:enterScene( event ) &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- --------------------------------------------------------------EXIT SCENE---------- function scene:exitScene() &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[DESTROY SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:destroyScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonHome then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonBack then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; end ---------------------------------------------------------------------------------- scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene

–Also, is there any function to move the images from left to right?

– And I found another problem. I have a button that will take me to another scene.

– I press that button and works fine.

– But if I have the images moving, when I use the button to go to another scene, I have an error.

File: …tormbarba/Desktop/How to make an app/speedSample.lua
Line: 31

Attempt to perform arithmetic on field ‘x’ (a nil value)

– Please I need help.

Thanks

Victor

local animateOn = true local function buttonBackHandler() -- A per-frame event to move the elements local tPrevious = system.getTimer() if animateOn == true then local function move(event) local tDelta = event.time - tPrevious tPrevious = event.time local xOffset = ( 0.1 \* tDelta ) funny1.x = funny1.x - xOffset funny2.x = funny2.x - xOffset if (funny1.x + funny1.contentWidth) \< 0 then funny1:translate( 1500, 0) end if (funny2.x + funny2.contentWidth) \< 0 then funny2:translate( 1500, 0) end end end local function buttonHomeHandler() animateOn = false end -- Start everything moving Runtime:addEventListener( "enterFrame", move ); return true end

Not tested, but you get the idea.

I wish I had the idea. but no. I tried the code like this:

complete code

-- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- -- How to make an app -- By Victor M. Barba -- Copyright 2013 -- All Rights Reserved -- -- Version 1.0 -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- local storyboard = require( "storyboard" ) local widget = require "widget" local scene = storyboard.newScene() local buttonHome local buttonBack local funny1 local funny2 local function buttonHomeHandler() &nbsp;&nbsp; &nbsp;storyboard.gotoScene( "mainMenu", "zoomInOutFade", 200 )&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end local animateOn = true local function buttonBackHandler() -- A per-frame event to move the elements local tPrevious = system.getTimer() if animateOn == true then local function move(event) &nbsp;&nbsp; &nbsp;local tDelta = event.time - tPrevious &nbsp;&nbsp; &nbsp;tPrevious = event.time &nbsp;&nbsp; &nbsp;local xOffset = ( 0.1 \* tDelta ) &nbsp;&nbsp; &nbsp;funny1.x = funny1.x - xOffset &nbsp;&nbsp; &nbsp;funny2.x = funny2.x - xOffset &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;if (funny1.x + funny1.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny1:translate( 1300, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;if (funny2.x + funny2.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny2:translate( 1200, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; end local function buttonHomeHandler() &nbsp; animateOn = false end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;-- Start everything moving Runtime:addEventListener( "enterFrame", move );&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[CREATE SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:createScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;local background = display.newImage( "backgroundFunny.png" ) &nbsp;&nbsp; &nbsp;group:insert ( background ) &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonHome = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonHome.png", &nbsp;&nbsp; &nbsp;onRelease = buttonHomeHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonHome ) &nbsp;&nbsp; &nbsp;buttonHome.x = 910 &nbsp;&nbsp; &nbsp;buttonHome.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonBack = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonBack.png", &nbsp;&nbsp; &nbsp;onRelease = buttonBackHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonBack ) &nbsp;&nbsp; &nbsp;buttonBack.x = 100 &nbsp;&nbsp; &nbsp;buttonBack.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;funny1 = display.newImage( "funnyG1.png" ) &nbsp;&nbsp; &nbsp;group:insert ( funny1 ) &nbsp;&nbsp; &nbsp;funny1:setReferencePoint( display.CenterLeftReferencePoint ) &nbsp;&nbsp; &nbsp;funny1.x = 100; funny1.y = 200 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;funny2 = display.newImage( "carTireFront.png" ) &nbsp;&nbsp; &nbsp;group:insert ( funny2 ) &nbsp;&nbsp; &nbsp;funny2:setReferencePoint( display.CenterLeftReferencePoint ) &nbsp;&nbsp; &nbsp;funny2.x = 250; funny2.y = 200 end --------------------------------------------------------------ENTER SCENE---------- function scene:enterScene( event ) &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- --------------------------------------------------------------EXIT SCENE---------- function scene:exitScene() Runtime:removeEventListener( "enterFrame", move ); &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[DESTROY SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:destroyScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonHome then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonBack then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; end ---------------------------------------------------------------------------------- scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene

But I got this

File: assertion failed!

Assertion failed!

I never heard that word before in my life “Assertion”

Please help.

Victor

You have 2 functions called “buttonHomeHandler”.   You have to change the name of one of them.

I changed the name, still is not working

complete code

-- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- -- How to make an app -- By Victor M. Barba -- Copyright 2013 -- All Rights Reserved -- -- Version 1.0 -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- local storyboard = require( "storyboard" ) local widget = require "widget" local scene = storyboard.newScene() local buttonHome local buttonBack local funny1 local funny2 local playMove local function buttonHomeHandler() &nbsp;&nbsp; &nbsp;storyboard.gotoScene( "mainMenu", "zoomInOutFade", 200 )&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end local function buttonBackHandler() &nbsp;&nbsp; &nbsp;storyboard.gotoScene( "animation", "zoomInOutFade", 200 )&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end local animateOn = true local function playMoveHandler() -- A per-frame event to move the elements local tPrevious = system.getTimer() if animateOn == true then local function move(event) &nbsp;&nbsp; &nbsp;local tDelta = event.time - tPrevious &nbsp;&nbsp; &nbsp;tPrevious = event.time &nbsp;&nbsp; &nbsp;local xOffset = ( 0.1 \* tDelta ) &nbsp;&nbsp; &nbsp;funny1.x = funny1.x - xOffset &nbsp;&nbsp; &nbsp;funny2.x = funny2.x - xOffset &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;if (funny1.x + funny1.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny1:translate( 1300, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;if (funny2.x + funny2.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny2:translate( 1200, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; end local function animationGood() &nbsp; animateOn = false end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;-- Start everything moving Runtime:addEventListener( "enterFrame", move );&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[CREATE SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:createScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;local background = display.newImage( "backgroundFunny.png" ) &nbsp;&nbsp; &nbsp;group:insert ( background ) &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonHome = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonHome.png", &nbsp;&nbsp; &nbsp;onRelease = buttonHomeHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonHome ) &nbsp;&nbsp; &nbsp;buttonHome.x = 910 &nbsp;&nbsp; &nbsp;buttonHome.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonBack = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonBack.png", &nbsp;&nbsp; &nbsp;onRelease = buttonBackHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonBack ) &nbsp;&nbsp; &nbsp;buttonBack.x = 100 &nbsp;&nbsp; &nbsp;buttonBack.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;funny1 = display.newImage( "funnyG1.png" ) &nbsp;&nbsp; &nbsp;group:insert ( funny1 ) &nbsp;&nbsp; &nbsp;funny1:setReferencePoint( display.CenterLeftReferencePoint ) &nbsp;&nbsp; &nbsp;funny1.x = 100; funny1.y = 200 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;funny2 = display.newImage( "carTireFront.png" ) &nbsp;&nbsp; &nbsp;group:insert ( funny2 ) &nbsp;&nbsp; &nbsp;funny2:setReferencePoint( display.CenterLeftReferencePoint ) &nbsp;&nbsp; &nbsp;funny2.x = 250; funny2.y = 200 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;playMove = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonPlay.png", &nbsp;&nbsp; &nbsp;onRelease = playMoveHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( playMove ) &nbsp;&nbsp; &nbsp;playMove.x = 512 &nbsp;&nbsp; &nbsp;playMove.y = 400 &nbsp;&nbsp; &nbsp; end --------------------------------------------------------------ENTER SCENE---------- function scene:enterScene( event ) &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- --------------------------------------------------------------EXIT SCENE---------- function scene:exitScene() Runtime:removeEventListener( "enterFrame", move ); &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[DESTROY SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:destroyScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonHome then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonBack then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if playMove then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;playMove:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;playMove = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; end ---------------------------------------------------------------------------------- scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene

Thank you for taking the time to help me out

Victor

Rob, Brent, I know you must be busy, but please have a moment of your time to help me with this speed problem

The image I have they start to move as soon as I onRelease the button, is good…

But what function do I need to make the images “Stop”

I need a button, that onRelease make the images “Stop moving”

here is the complete code

-- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- -- How to make an app -- By Victor M. Barba -- Copyright 2013 -- All Rights Reserved -- -- Version 1.0 -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- local storyboard = require( "storyboard" ) local widget = require "widget" local scene = storyboard.newScene() local buttonHome local buttonBack local funny1 local funny2 local playMove local function buttonHomeHandler() &nbsp;&nbsp; &nbsp;storyboard.gotoScene( "mainMenu", "zoomInOutFade", 200 )&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end local function buttonBackHandler() &nbsp;&nbsp; &nbsp;storyboard.gotoScene( "animation", "zoomInOutFade", 200 )&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end local animateOn = true local function playMoveHandler() -- A per-frame event to move the elements local tPrevious = system.getTimer() if animateOn == true then local function move(event) &nbsp;&nbsp; &nbsp;local tDelta = event.time - tPrevious &nbsp;&nbsp; &nbsp;tPrevious = event.time &nbsp;&nbsp; &nbsp;local xOffset = ( 0.1 \* tDelta ) &nbsp;&nbsp; &nbsp;funny1.x = funny1.x - xOffset &nbsp;&nbsp; &nbsp;funny2.x = funny2.x - xOffset &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;if (funny1.x + funny1.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny1:translate( 1300, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;if (funny2.x + funny2.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny2:translate( 1200, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; end local function animationGood() &nbsp; animateOn = false end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;-- Start everything moving Runtime:addEventListener( "enterFrame", move );&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[CREATE SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:createScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;local background = display.newImage( "backgroundFunny.png" ) &nbsp;&nbsp; &nbsp;group:insert ( background ) &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonHome = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonHome.png", &nbsp;&nbsp; &nbsp;onRelease = buttonHomeHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonHome ) &nbsp;&nbsp; &nbsp;buttonHome.x = 910 &nbsp;&nbsp; &nbsp;buttonHome.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonBack = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonBack.png", &nbsp;&nbsp; &nbsp;onRelease = buttonBackHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonBack ) &nbsp;&nbsp; &nbsp;buttonBack.x = 100 &nbsp;&nbsp; &nbsp;buttonBack.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;funny1 = display.newImage( "funnyG1.png" ) &nbsp;&nbsp; &nbsp;group:insert ( funny1 ) &nbsp;&nbsp; &nbsp;funny1:setReferencePoint( display.CenterLeftReferencePoint ) &nbsp;&nbsp; &nbsp;funny1.x = 100; funny1.y = 200 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;funny2 = display.newImage( "carTireFront.png" ) &nbsp;&nbsp; &nbsp;group:insert ( funny2 ) &nbsp;&nbsp; &nbsp;funny2:setReferencePoint( display.CenterLeftReferencePoint ) &nbsp;&nbsp; &nbsp;funny2.x = 250; funny2.y = 200 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;playMove = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonPlay.png", &nbsp;&nbsp; &nbsp;onRelease = playMoveHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( playMove ) &nbsp;&nbsp; &nbsp;playMove.x = 512 &nbsp;&nbsp; &nbsp;playMove.y = 400 &nbsp;&nbsp; &nbsp; end --------------------------------------------------------------ENTER SCENE---------- function scene:enterScene( event ) &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- --------------------------------------------------------------EXIT SCENE---------- function scene:exitScene() Runtime:removeEventListener( "enterFrame", move ); &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[DESTROY SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:destroyScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonHome then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonBack then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if playMove then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;playMove:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;playMove = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; end ---------------------------------------------------------------------------------- scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene

Thanks

local animateOn = true local function buttonBackHandler() -- A per-frame event to move the elements local tPrevious = system.getTimer() if animateOn == true then local function move(event) local tDelta = event.time - tPrevious tPrevious = event.time local xOffset = ( 0.1 \* tDelta ) funny1.x = funny1.x - xOffset funny2.x = funny2.x - xOffset if (funny1.x + funny1.contentWidth) \< 0 then funny1:translate( 1500, 0) end if (funny2.x + funny2.contentWidth) \< 0 then funny2:translate( 1500, 0) end end end local function buttonHomeHandler() animateOn = false end -- Start everything moving Runtime:addEventListener( "enterFrame", move ); return true end

Not tested, but you get the idea.

I wish I had the idea. but no. I tried the code like this:

complete code

-- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- -- How to make an app -- By Victor M. Barba -- Copyright 2013 -- All Rights Reserved -- -- Version 1.0 -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- local storyboard = require( "storyboard" ) local widget = require "widget" local scene = storyboard.newScene() local buttonHome local buttonBack local funny1 local funny2 local function buttonHomeHandler() &nbsp;&nbsp; &nbsp;storyboard.gotoScene( "mainMenu", "zoomInOutFade", 200 )&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end local animateOn = true local function buttonBackHandler() -- A per-frame event to move the elements local tPrevious = system.getTimer() if animateOn == true then local function move(event) &nbsp;&nbsp; &nbsp;local tDelta = event.time - tPrevious &nbsp;&nbsp; &nbsp;tPrevious = event.time &nbsp;&nbsp; &nbsp;local xOffset = ( 0.1 \* tDelta ) &nbsp;&nbsp; &nbsp;funny1.x = funny1.x - xOffset &nbsp;&nbsp; &nbsp;funny2.x = funny2.x - xOffset &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;if (funny1.x + funny1.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny1:translate( 1300, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;if (funny2.x + funny2.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny2:translate( 1200, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; end local function buttonHomeHandler() &nbsp; animateOn = false end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;-- Start everything moving Runtime:addEventListener( "enterFrame", move );&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[CREATE SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:createScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;local background = display.newImage( "backgroundFunny.png" ) &nbsp;&nbsp; &nbsp;group:insert ( background ) &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonHome = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonHome.png", &nbsp;&nbsp; &nbsp;onRelease = buttonHomeHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonHome ) &nbsp;&nbsp; &nbsp;buttonHome.x = 910 &nbsp;&nbsp; &nbsp;buttonHome.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonBack = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonBack.png", &nbsp;&nbsp; &nbsp;onRelease = buttonBackHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonBack ) &nbsp;&nbsp; &nbsp;buttonBack.x = 100 &nbsp;&nbsp; &nbsp;buttonBack.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;funny1 = display.newImage( "funnyG1.png" ) &nbsp;&nbsp; &nbsp;group:insert ( funny1 ) &nbsp;&nbsp; &nbsp;funny1:setReferencePoint( display.CenterLeftReferencePoint ) &nbsp;&nbsp; &nbsp;funny1.x = 100; funny1.y = 200 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;funny2 = display.newImage( "carTireFront.png" ) &nbsp;&nbsp; &nbsp;group:insert ( funny2 ) &nbsp;&nbsp; &nbsp;funny2:setReferencePoint( display.CenterLeftReferencePoint ) &nbsp;&nbsp; &nbsp;funny2.x = 250; funny2.y = 200 end --------------------------------------------------------------ENTER SCENE---------- function scene:enterScene( event ) &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- --------------------------------------------------------------EXIT SCENE---------- function scene:exitScene() Runtime:removeEventListener( "enterFrame", move ); &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[DESTROY SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:destroyScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonHome then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonBack then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; end ---------------------------------------------------------------------------------- scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene

But I got this

File: assertion failed!

Assertion failed!

I never heard that word before in my life “Assertion”

Please help.

Victor

You have 2 functions called “buttonHomeHandler”.   You have to change the name of one of them.

I changed the name, still is not working

complete code

-- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- -- How to make an app -- By Victor M. Barba -- Copyright 2013 -- All Rights Reserved -- -- Version 1.0 -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- local storyboard = require( "storyboard" ) local widget = require "widget" local scene = storyboard.newScene() local buttonHome local buttonBack local funny1 local funny2 local playMove local function buttonHomeHandler() &nbsp;&nbsp; &nbsp;storyboard.gotoScene( "mainMenu", "zoomInOutFade", 200 )&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end local function buttonBackHandler() &nbsp;&nbsp; &nbsp;storyboard.gotoScene( "animation", "zoomInOutFade", 200 )&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end local animateOn = true local function playMoveHandler() -- A per-frame event to move the elements local tPrevious = system.getTimer() if animateOn == true then local function move(event) &nbsp;&nbsp; &nbsp;local tDelta = event.time - tPrevious &nbsp;&nbsp; &nbsp;tPrevious = event.time &nbsp;&nbsp; &nbsp;local xOffset = ( 0.1 \* tDelta ) &nbsp;&nbsp; &nbsp;funny1.x = funny1.x - xOffset &nbsp;&nbsp; &nbsp;funny2.x = funny2.x - xOffset &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;if (funny1.x + funny1.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny1:translate( 1300, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;if (funny2.x + funny2.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny2:translate( 1200, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; end local function animationGood() &nbsp; animateOn = false end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;-- Start everything moving Runtime:addEventListener( "enterFrame", move );&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[CREATE SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:createScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;local background = display.newImage( "backgroundFunny.png" ) &nbsp;&nbsp; &nbsp;group:insert ( background ) &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonHome = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonHome.png", &nbsp;&nbsp; &nbsp;onRelease = buttonHomeHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonHome ) &nbsp;&nbsp; &nbsp;buttonHome.x = 910 &nbsp;&nbsp; &nbsp;buttonHome.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonBack = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonBack.png", &nbsp;&nbsp; &nbsp;onRelease = buttonBackHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonBack ) &nbsp;&nbsp; &nbsp;buttonBack.x = 100 &nbsp;&nbsp; &nbsp;buttonBack.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;funny1 = display.newImage( "funnyG1.png" ) &nbsp;&nbsp; &nbsp;group:insert ( funny1 ) &nbsp;&nbsp; &nbsp;funny1:setReferencePoint( display.CenterLeftReferencePoint ) &nbsp;&nbsp; &nbsp;funny1.x = 100; funny1.y = 200 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;funny2 = display.newImage( "carTireFront.png" ) &nbsp;&nbsp; &nbsp;group:insert ( funny2 ) &nbsp;&nbsp; &nbsp;funny2:setReferencePoint( display.CenterLeftReferencePoint ) &nbsp;&nbsp; &nbsp;funny2.x = 250; funny2.y = 200 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;playMove = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonPlay.png", &nbsp;&nbsp; &nbsp;onRelease = playMoveHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( playMove ) &nbsp;&nbsp; &nbsp;playMove.x = 512 &nbsp;&nbsp; &nbsp;playMove.y = 400 &nbsp;&nbsp; &nbsp; end --------------------------------------------------------------ENTER SCENE---------- function scene:enterScene( event ) &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- --------------------------------------------------------------EXIT SCENE---------- function scene:exitScene() Runtime:removeEventListener( "enterFrame", move ); &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[DESTROY SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:destroyScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonHome then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonBack then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if playMove then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;playMove:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;playMove = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; end ---------------------------------------------------------------------------------- scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene

Thank you for taking the time to help me out

Victor

Rob, Brent, I know you must be busy, but please have a moment of your time to help me with this speed problem

The image I have they start to move as soon as I onRelease the button, is good…

But what function do I need to make the images “Stop”

I need a button, that onRelease make the images “Stop moving”

here is the complete code

-- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- -- How to make an app -- By Victor M. Barba -- Copyright 2013 -- All Rights Reserved -- -- Version 1.0 -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- local storyboard = require( "storyboard" ) local widget = require "widget" local scene = storyboard.newScene() local buttonHome local buttonBack local funny1 local funny2 local playMove local function buttonHomeHandler() &nbsp;&nbsp; &nbsp;storyboard.gotoScene( "mainMenu", "zoomInOutFade", 200 )&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end local function buttonBackHandler() &nbsp;&nbsp; &nbsp;storyboard.gotoScene( "animation", "zoomInOutFade", 200 )&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end local animateOn = true local function playMoveHandler() -- A per-frame event to move the elements local tPrevious = system.getTimer() if animateOn == true then local function move(event) &nbsp;&nbsp; &nbsp;local tDelta = event.time - tPrevious &nbsp;&nbsp; &nbsp;tPrevious = event.time &nbsp;&nbsp; &nbsp;local xOffset = ( 0.1 \* tDelta ) &nbsp;&nbsp; &nbsp;funny1.x = funny1.x - xOffset &nbsp;&nbsp; &nbsp;funny2.x = funny2.x - xOffset &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;if (funny1.x + funny1.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny1:translate( 1300, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;if (funny2.x + funny2.contentWidth) \< 0 then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;funny2:translate( 1200, 0) &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; end local function animationGood() &nbsp; animateOn = false end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;-- Start everything moving Runtime:addEventListener( "enterFrame", move );&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[CREATE SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:createScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;local background = display.newImage( "backgroundFunny.png" ) &nbsp;&nbsp; &nbsp;group:insert ( background ) &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonHome = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonHome.png", &nbsp;&nbsp; &nbsp;onRelease = buttonHomeHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonHome ) &nbsp;&nbsp; &nbsp;buttonHome.x = 910 &nbsp;&nbsp; &nbsp;buttonHome.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonBack = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonBack.png", &nbsp;&nbsp; &nbsp;onRelease = buttonBackHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonBack ) &nbsp;&nbsp; &nbsp;buttonBack.x = 100 &nbsp;&nbsp; &nbsp;buttonBack.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;funny1 = display.newImage( "funnyG1.png" ) &nbsp;&nbsp; &nbsp;group:insert ( funny1 ) &nbsp;&nbsp; &nbsp;funny1:setReferencePoint( display.CenterLeftReferencePoint ) &nbsp;&nbsp; &nbsp;funny1.x = 100; funny1.y = 200 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;funny2 = display.newImage( "carTireFront.png" ) &nbsp;&nbsp; &nbsp;group:insert ( funny2 ) &nbsp;&nbsp; &nbsp;funny2:setReferencePoint( display.CenterLeftReferencePoint ) &nbsp;&nbsp; &nbsp;funny2.x = 250; funny2.y = 200 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;playMove = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonPlay.png", &nbsp;&nbsp; &nbsp;onRelease = playMoveHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( playMove ) &nbsp;&nbsp; &nbsp;playMove.x = 512 &nbsp;&nbsp; &nbsp;playMove.y = 400 &nbsp;&nbsp; &nbsp; end --------------------------------------------------------------ENTER SCENE---------- function scene:enterScene( event ) &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- --------------------------------------------------------------EXIT SCENE---------- function scene:exitScene() Runtime:removeEventListener( "enterFrame", move ); &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[DESTROY SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:destroyScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonHome then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonBack then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if playMove then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;playMove:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;playMove = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; end ---------------------------------------------------------------------------------- scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene

Thanks