Hi everyone. I bought the videos from Jay, mastering Corona, they are good, I was hoping to get some answers to make my second app, but I still have the same 5 questions. this is one of them.
– Timer
– I have an image that is there on the screen.
– When I press a button, it moves from right to left. That’s good!
What function do I need to make that image stop?
This is the complete code
-- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- -- How to make an app -- By Victor M. Barba -- Copyright 2013 -- All Rights Reserved -- -- Version 1.0 -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- ------------------------------------------------------------------------------------------ -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[STORYBOARD REQUIRE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- ------------------------------------------------------------------------------------------ local storyboard = require( "storyboard" ) local widget = require "widget" local scene = storyboard.newScene() ------------------------------------------------------------------------------------------ -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[VARIABLES]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- ------------------------------------------------------------------------------------------ local buttonHome local buttonBack local funny1 local funny2 ------------------------------------------------------------------------------------------ -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[FUNCTIONS]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- ------------------------------------------------------------------------------------------ local function buttonHomeHandler() Runtime:removeEventListener( "enterFrame", move ); return true end local tPrevious = system.getTimer() local function move(event) local tDelta = event.time - tPrevious tPrevious = event.time local xOffset = ( 0.6 \* tDelta ) funny1.x = funny1.x - xOffset funny2.x = funny2.x - xOffset if (funny1.x + funny1.contentWidth) \< 0 then funny1:translate( 600 \* 2, 0) end if (funny2.x + funny2.contentWidth) \< 0 then funny2:translate( 600 \* 2, 0) end end -------------------------------------------------------------------------------------------------------- Start everything moving local function buttonBackHandler() Runtime:addEventListener( "enterFrame", move ); return true end ------------------------------------------------------------------------------------------ -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[CREATE SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- ------------------------------------------------------------------------------------------ function scene:createScene( event ) local group = self.view local background = display.newImage( "backgroundFunny.png" ) group:insert ( background ) buttonHome = widget.newButton{ defaultFile="buttonHome.png", onRelease = buttonHomeHandler } group:insert ( buttonHome ) buttonHome.x = 910 buttonHome.y = 710 buttonBack = widget.newButton{ defaultFile="buttonBack.png", onRelease = buttonBackHandler } group:insert ( buttonBack ) buttonBack.x = 100 buttonBack.y = 710 funny1 = display.newImage( "funnyG1.png" ) group:insert ( funny1 ) funny1:setReferencePoint( display.CenterLeftReferencePoint ) funny1.x = 100; funny1.y = 200 funny2 = display.newImage( "carTireFront.png" ) group:insert ( funny2 ) funny2:setReferencePoint( display.CenterLeftReferencePoint ) funny2.x = 250; funny2.y = 200 end ------------------------------------------------------------------------------------------ -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[ENTER SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- ------------------------------------------------------------------------------------------ function scene:enterScene( event ) end ------------------------------------------------------------------------------------------ -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[EXIT SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- ------------------------------------------------------------------------------------------ function scene:exitScene() end ------------------------------------------------------------------------------------------ -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[DESTROY SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- ------------------------------------------------------------------------------------------ function scene:destroyScene( event ) local group = self.view if buttonHome then buttonHome:removeSelf() buttonHome = nil end if buttonBack then buttonBack:removeSelf() buttonBack = nil end end ------------------------------------------------------------------------------------------ scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene
Thanks
Victor