How to make an Object travel at an Angle.

No problem :slight_smile:

C [import]uid: 147322 topic_id: 35556 reply_id: 143022[/import]

Hi Brent… With that my rocket just falls and the dot touch just randomly flashes… I can’t seem to have the rocket follow that touch… [import]uid: 20272 topic_id: 35556 reply_id: 142970[/import]

@mkjt88: I think that was meant to be translated into a touch function:
[lua]
local rocket = display.newRect(100,100,60,30) ; rocket:setFillColor(255)
rocket.x = display.contentWidth/2 ; rocket.y = display.contentHeight/2
physics.addBody( rocket, “dynamic” )
rocket.isFixedRotation = true

rocket.tJoint = physics.newJoint( “touch”, rocket, rocket.x, rocket.y )
–these properties determine the joint properties (pull force, damping)
rocket.tJoint.maxForce = 1000
rocket.tJoint.dampingRatio = 0.5

local function clearDot( thisDot )
display.remove(thisDot) ; thisDot = nil
end

local dot

local function moveTouch(event)
clearDot(dot)

dot = display.newCircle(event.x, event.y, 10)
dot:setFillColor(255,0,0)

rocket.tJoint:setTarget(event.x, event.y)
end

Runtime:addEventListener(“touch”, moveTouch)
[/lua] [import]uid: 147322 topic_id: 35556 reply_id: 142991[/import]

Ah… Sorry guys it was getting late when I tried to get it working… This makes perfect sense now that I see it Caleb. I appreciate all the help guys and sorry for the seemingly obvious questions… This is my first real program besides basic calculators or command line code in C++ and I struggle a lot while I’m trying to learn. Thanks again. [import]uid: 20272 topic_id: 35556 reply_id: 143019[/import]

No problem :slight_smile:

C [import]uid: 147322 topic_id: 35556 reply_id: 143022[/import]

Hi Brent… With that my rocket just falls and the dot touch just randomly flashes… I can’t seem to have the rocket follow that touch… [import]uid: 20272 topic_id: 35556 reply_id: 142970[/import]

@mkjt88: I think that was meant to be translated into a touch function:
[lua]
local rocket = display.newRect(100,100,60,30) ; rocket:setFillColor(255)
rocket.x = display.contentWidth/2 ; rocket.y = display.contentHeight/2
physics.addBody( rocket, “dynamic” )
rocket.isFixedRotation = true

rocket.tJoint = physics.newJoint( “touch”, rocket, rocket.x, rocket.y )
–these properties determine the joint properties (pull force, damping)
rocket.tJoint.maxForce = 1000
rocket.tJoint.dampingRatio = 0.5

local function clearDot( thisDot )
display.remove(thisDot) ; thisDot = nil
end

local dot

local function moveTouch(event)
clearDot(dot)

dot = display.newCircle(event.x, event.y, 10)
dot:setFillColor(255,0,0)

rocket.tJoint:setTarget(event.x, event.y)
end

Runtime:addEventListener(“touch”, moveTouch)
[/lua] [import]uid: 147322 topic_id: 35556 reply_id: 142991[/import]

Ah… Sorry guys it was getting late when I tried to get it working… This makes perfect sense now that I see it Caleb. I appreciate all the help guys and sorry for the seemingly obvious questions… This is my first real program besides basic calculators or command line code in C++ and I struggle a lot while I’m trying to learn. Thanks again. [import]uid: 20272 topic_id: 35556 reply_id: 143019[/import]

No problem :slight_smile:

C [import]uid: 147322 topic_id: 35556 reply_id: 143022[/import]