Hello everyone,
I’m pretty new to Corona and as of lately I’ve been experiencing an error and where ever I looked I was unable to find a solution for it.
So the error is related to the function I used to be able to move objects around and here is the function that I’m talking about:
local function movePlatform(event) platformTouched = event.target if (event.phase == "began") then display.getCurrentStage():setFocus( platformTouched ) audio.play (selectionSound) display.remove( rotationalert ) rotationalert = nil platformTouched.startMoveX = platformTouched.x platformTouched.startMoveY = platformTouched.y elseif (event.phase == "moved") then -- The line below is the 392th line: platformTouched.x = (event.x - event.xStart) + platformTouched.startMoveX platformTouched.y = (event.y - event.yStart) + platformTouched.startMoveY elseif event.phase == "ended" or event.phase == "cancelled" then display.getCurrentStage():setFocus( nil ) end return true end
I have also attached a picture of the error as well as a video of when I get the error as I’m not really sure why I get the error.
Another question that I had is about a retry button that I tried to create. Basically, I want the retry button to restart the level, but, I want it to return the images moved to the location that the user set it to. So basically the person playing the game moves the object to a certain location and then starts the game (which applies physics) and then when the person presses the retry button I want the objects to return to the location that the person moved them to.
Here is the code I used for the retry button and I’ve also attached a video of it. I’m not sure how to return the objects to the location set by the player.
local function retryTapped(obj) ball.y = 164 ball.x = 164 ball.rotation = 0 --woodenPlank1.rotation = 0 --woodenBox.rotation = 0 -- woodenBox1.rotation = 0 physics:stop() woodenPlank1:addEventListener( "touch", movePlatform ) woodenPlank1:addEventListener( "tap", platformTapped ) woodenBox:addEventListener( "touch", movePlatform2 ) woodenBox1:addEventListener( "touch", movePlatform2 ) weight:addEventListener( "touch", movePlatform2 ) display.remove( backgroundOverlay ) display.remove( overlay ) display.remove( levelBtn ) display.remove( playBtn ) display.remove( reloadBtn ) return true end
Every help would be greatly appreciated.