Hi everyone. Thanks for all your help.
I have one function that makes one image move from point A to point B.
– when I press a button, the image “falls” or moves, and when it reaches point B it removes it self. Good!
– everytime I press the button, point B remove…
–But If I press the button in the middle of the transition… before it gets to point B,
a new image start to fall, and the first image will not remove it self in point B
but the second image yes…
And the first image there is no way to remove it when I go to another scene.
Please I need help
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 buttonThis local buttonBack local funny local fallLeaf ------------------------------------------------------------------------------------------ -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[FUNCTIONS]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- ------------------------------------------------------------------------------------------ local function homeWorldHandler() storyboard.gotoScene( "mainMenu", "fromRight", 200 ) return true end local function buttonBackHandler() storyboard.gotoScene( "simple", "fromLeft", 200 ) return true end local function greenTrash() display.remove (fallLeaf) end local function fallOne(event) fallLeaf = display.newImage("leaf.png") fallLeaf.x = math.random ( 0, 1000); fallLeaf.y = math.random ( -100, 50) fallLeaf:rotate(math.random(0, 360)) local smaller = 1 + math.random(-1, 1) / 2 fallLeaf:scale (smaller, smaller) transition.to(fallLeaf, {time=6000, x = 500, y = 500, onComplete=greenTrash}) end ------------------------------------------------------------------------------------------ -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[CREATE SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- ------------------------------------------------------------------------------------------ function scene:createScene( event ) local group = self.view local background = display.newImage( "backgroundFunny.png" ) group:insert ( background ) funny = display.newImage( "funnyG1.png" ) group:insert ( funny ) funny.x = 500 funny.y = 400 funny.name = "FunnyG" funny:addEventListener ("tap", fallOne ) buttonThis = widget.newButton{ defaultFile="buttonHowToDoThis.png", onRelease = buttonThisHandler } group:insert ( buttonThis ) buttonThis.x = 900 buttonThis.y = 650 buttonThis:scale (.6, .6) buttonBack = widget.newButton{ defaultFile="buttonBack.png", onRelease = buttonBackHandler } group:insert ( buttonBack ) buttonBack.x = 80 buttonBack.y = 710 local newText10 = display.newText("Just tap on my face, to see the falling leaves.", 230, 500, native.systemFont, 26) group:insert ( newText10 ) newText10:setTextColor(255, 255, 255) end ------------------------------------------------------------------------------------------ -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[ENTER SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- ------------------------------------------------------------------------------------------ function scene:enterScene( event ) local group = self.view end ------------------------------------------------------------------------------------------ -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[EXIT SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- ------------------------------------------------------------------------------------------ function scene:exitScene() display.remove (funnyG) end ------------------------------------------------------------------------------------------ -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[DESTROY SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- ------------------------------------------------------------------------------------------ function scene:destroyScene( event ) local group = self.view if buttonThis then buttonThis:removeSelf() buttonThis = nil end if buttonBack then buttonBack:removeSelf() buttonBack = nil end end ---------------------------------------------------------------------------------- scene:addEventListener( "createScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene
thanks
victor