thanks for all the newbie tips Rob!
I want the ship to move only on the y-axis (so up and down) while the background moves behind it (which I already set up), and I want it to be controlled by a touch on the screen.
when you touch the screen, I want the ship to fly up, but then fall back down when you’re no longer touching the screen. I also do not want the ship to be able to fly out visibility.
on the second image where my code is:
local jet = display.newImage("Starship.png") jet.x = 100 jet.y = 100 jet.width = 50 jet.height = 30 physics.addBody(jet, "dynamic", {density=.1, bounce=0.1, friction=.2, radius=25}) function activateJets(self, event) self:applyForce(0, -2, self.x, self.y) end function touchScreen(event) -- print("touch") if event.phase == "began" then jet.enterFrame = activateJets Runtime:addEventListener("enterFrame", jet) end if event.phase == "ended" then Runtime:removeEventListener("enterFrame", jet) end end
my ship doesn’t fly when I touch the screen at all. when I start the simulation in Corona and tap on the screen, it will only drop out of view.
then, when I take out “Runtime:removeEventListener(“enterFrame”, jet)” from my code and relaunch the simulator, my ship will fly up when I touch the screen, but it flys out of view and doesn’t come back down into view.
am I making sense yet? I sure hope so. if not, I’ll try harder with my next response.