Im pretty new to this
I can now rotate the “car” fine, yay for me, hehe
Lets say my left side of this car is th front.
If I make this a physics body, and set gravity to 0. (so I can crash into other stuff)
How can I control that it goes in the direction of “front” and speed to have.
tried lots of stuff but it pretty much files out
this will be a top side view game…
--this is my car local car = display.newRect(150, 150, 5, 10) car:setFillColor(255, 100, 255) --local circle = display.newImageRect("ball.png", 60, 60) local circle = display.newCircle(450, 230, 30) circle.x = 450 circle.y = 230 local function stear (event) local t = event.target local phase = event.phase --print("Phase: " .. phase) if (phase == "began") then --print("began") display.getCurrentStage():setFocus( t ) t.isFocus = true -- Store initial position of finger t.x1 = event.x t.y1 = event.y elseif t.isFocus then if (phase == "moved") then t.x2 = event.x t.y2 = event.y local angle1 = 180/math.pi \* math.atan2(t.y1 - t.y , t.x1 - t.x) local angle2 = 180/math.pi \* math.atan2(t.y2 - t.y , t.x2 - t.x) local rotationAmt = angle1 - angle2 t.rotation = t.rotation - rotationAmt t.x1 = t.x2 t.y1 = t.y2 -- print(angle1) car:rotate(-rotationAmt) elseif (phase == "ended") or (phase == "cancelled") then print("ended") display.getCurrentStage():setFocus( nil ) t.isFocus = false --car:setLinearVelocity( 0, 0 , 1, 1) end end -- Stop further propagation of touch event return true end circle:addEventListener("touch",stear);