I want to control a ship with the accelmeter. CAn some help me with this [import]uid: 55737 topic_id: 10028 reply_id: 310028[/import]
I’ve seen many ways of doing it but here’s a basic way of doing it in portrait.
[code]
– Get the center of the screen
local centerX = display.contentWidth/2;
local centerY = display.contentHeight/2;
– Set the sensitivity of the accelerometer 100=max.
system.setAccelerometerInterval( 100 )
– Create a 64x64px rectangle, position it at the center of the screen, fill it with a froggy green color.
local ship = display.newRect(centerX, centerY, 64, 64);
ship:setFillColor(123,234, 0);
local function ship:accelerometer(event)
– For portrait
ship.x = centerX + (centerX * event.xGravity);
ship.y = centerY - (centerY * event.yGravity);
end
Runtime:addEventListener(“accelerometer”, ship);
[/code] [import]uid: 13560 topic_id: 10028 reply_id: 36595[/import]