int TiltGety();

 

Returns the tilt value for the y axis of the device.  Imagine a line running from the bottom to the top of your device's screen.

 

Return Value

 

Returns a value representing the tilt of the device.

 

Remarks

 

TiltGety() will return a negative value if the device is tilted up or a positive value if tilted down.  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.

 

Availability

 

Available in DragonFireSDK 1.0 and later.

 

Example

 

The example below will query the current location of a text object and increment it's X and Y coordinates in the OnTimer() event.

 

#include "DragonFireSDK.h"

 

int BallImage;

int BallView;

 

void AppMain()

{

  // Set up an image of a ball to move around the screen:

  BallImage = ImageAdd("Images/Ball.png");

  BallView = ViewAdd(BallImage, 0, 0);

}

 

void AppExit()

{

 

}

 

void OnTimer()

{

  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);

}