I am developing a game where the player has to move a ball using a gyroscope. Until now I have done the following:
--gyroscope function local function onGyroscopeDataReceived( event ) local deltaRadiansX = event.xRotation \* event.deltaTime local deltaDegreesX = deltaRadiansX \* (180 / math.pi) local deltaRadiansY = event.yRotation \* event.deltaTime local deltaDegreesY = deltaRadiansY \* (180 / math.pi) ball:applyForce( deltaDegreesX\*4, -deltaDegreesY\*4, ball.x, ball.y ) end
I want instead of applying force to the ball, to change the gravity of the scene so the ball will fall in the appropriate direction, I supposed that I have to use the physics.setGravity( gx, gy ) . I am not sure which dimension of the device x,y,z represent and if deltaRadians or deltaDegrees can be used in gx,gy. Any idea how is it possible to achieve gravity change using gyroscope?