Has anybody used the Joystick code sample provided by Matthew Pringle to control the rotation of an object as well as direction. Just one Joystick on the screen, you move it and the player faces and moves in that direction. I can get it to work, kinda, but something is wrong with my code. The player spins around it’s own center point, is this to do with my logic? or maybe the set:ReferencePoint? Here is my code, any help would be appreciated.
Cheers
This
[lua]function drawPlayer()
player = display.newImage( “STAR.png” , 27, 27 )
player.xOrigin = 0; player.yOrigin = 600
physics.addBody(player, “dynamic”, {bounce = 0.5, friction = 0.5, density = 2.0 })
player:setReferencePoint( display.CenterReferencePoint )
camera:insert(player)
camera.x = -player.x
camera.y = -player.y + 280
end[/lua]
And this
[lua]local function rotatePlayer( joyAngle )
if joyAngle ~= false then
player.rotation = joyAngle
end
end
function playerControl( event )
local joyX = event.joyX
local joyY = event.joyY
local joyAngle = event.joyAngle
movePlayer( joyX , joyY )
rotatePlayer( joyAngle )
end
[/lua] [import]uid: 26289 topic_id: 12838 reply_id: 312838[/import]