Returns the tilt value for the z axis of the device. Imagine a line running perpendicular through the center of your device's screen.
Returns a value representing the tilt of the device.
TiltGetz() reveals whether the face of the device is pointed toward the sky (positive) or the ground (negative). The range of values is typically between -1000 and 1000. A value of zero is returned if the device is flat on this axis. Values greater than +/- 1000 indicate that the device is being shaken.
Available in DragonFireSDK 1.0 and later.
The example below will query the current location of a text object and increment it's X and Y coordinates in the OnTimer() event.
// Set up an image of a ball to move around the screen:
BallImage = ImageAdd("Images/Ball.png");
BallView = ViewAdd(BallImage, 0, 0);
int BallX, BallY;
int tx, ty, tz;
// Get tilt (accelerometer) data for each axis.
tx = TiltGetx();
ty = TiltGety();
tz = TiltGetz();
// Update the ball's next X and Y values based on G-Force and the strength of gravity:
BallX = ViewGetx(BallView) + (tx / 100);
BallY = ViewGety(BallView) + (ty / 100);
// Don't let the ball go off the screen:
if (BallX >= 283)
BallX = 283;
if (BallX <= 0)
BallX = 0;
if (BallY >= 443)
BallY = 443;
if (BallY <= 0)
BallY = 0;
// Update the ball's position:
ViewSetxy(BallView, BallX, BallY);