local composer = require( "composer" ) local scene = composer.newScene() local function buttonHit(event) composer.gotoScene( event.target.destination ) return true end local physics = require "physics" physics.start(); physics.pause() local screenW, screenH, halfW = display.contentWidth, display.contentHeight, display.contentWidth\*0.5 function scene:create( event ) local sceneGroup = self.view local background = display.newImage( "Campo1F.tif", true ) background.x = display.contentWidth / 2 background.y = display.contentHeight / 2 sceneGroup:insert( background ) end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then local backBtn = display.newImageRect("botaoV.tif",50,25) backBtn.x= 500 backBtn.y= 296 backBtn.destination = "menu" backBtn:addEventListener("tap", buttonHit) composer.removeScene(true) sceneGroup:insert(backBtn) local camisola1 = display.newImageRect("Camisola-F1.tif",35,60) camisola1.x = 45 camisola1.y = 50 sceneGroup:insert(camisola1) local camisola2 = display.newImageRect("Camisola-F2.tif",35,60) camisola2.x=45 camisola2.y=110 sceneGroup:insert(camisola2) local camisola3 = display.newImageRect("Camisola-F3.tif",35,60) camisola3.x=45 camisola3.y=160 sceneGroup:insert(camisola3) local camisola4 = display.newImageRect("Camisola-F4.tif",35,60) camisola4.x=45 camisola4.y=210 sceneGroup:insert(camisola4) local camisola5 = display.newImageRect("Camisola-F5.tif",35,60) camisola5.x=45 camisola5.y=260 sceneGroup:insert(camisola5) local function camisolaTouch(event) local touchedObject = event.target if event.phase == "began" then touchedObject.previousX = touchedObject.x touchedObject.previousY = touchedObject.y elseif event.phase == "moved" then touchedObject.x = (event.x - event.xStart) + touchedObject.previousX touchedObject.y = (event.y - event.yStart) + touchedObject.previousY end return true end camisola3:addEventListener( "touch" , camisolaTouch) camisola4:addEventListener( "touch" , camisolaTouch) camisola5:addEventListener( "touch" , camisolaTouch) camisola2:addEventListener( "touch" , camisolaTouch) camisola1:addEventListener( "touch" , camisolaTouch) elseif phase == "did" then physics.start() end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if event.phase == "will" then physics.stop() elseif phase == "did" then end end function scene:destroy( event ) local sceneGroup = self.view end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene
I want to move the images to where I want, moving up one another , freely …
But when they approach or give error then they change positions alone …