I am having difficulty being able to access the constant x and (especially) y coordinates of the jet image I created. I added a force to this image that makes the jet go higher anytime i touch the screen. I want to know the immediate y values at any time so i can make another object follow it constantly but any time i try to set the new object to the jet coordinate variables, I only get the original x and y value (80,100). For example if i say
newYValue = jet.y, all i get is the original Y value no matter where the jet is in reality. PLEASE help me with this, Ive been working on it for hours upon hours. Here’s my code, thanks a lot.
local physics = require "physics" physics.start() physics.setGravity(0,8) jet= display.newImage ("redJet.png") jet.x = 80 jet.y =100 physics.addBody (jet, "dynamic", {density = .1, bounce=.1, friction=.2,radius=10}) function activateJets (self, event) self:applyForce (0, -1.5, self.x, self.y) end function touchScreen (event) if event.phase == "began" then jet.enterFrame = activateJets Runtime:addEventListener("enterFrame", jet) end if event.phase == "ended" then Runtime:removeEventListener("enterFrame", jet) end end Runtime:addEventListener("touch", touchScreen)