RotationZ

Introduction

RotationZ is the counterclockwise rotation value of the positioned object along the Z axis. For most games this value is used to rotate an object such as a car in a top-down game, or a spinning particle. RotationZ is represented in radians.

Although RotationZ is a property on all PositionedObjects, the Circle and AxisAlignedRectangle objects will not visually respond to rotation values.

Code Example - Manually Increasing Rotation

The following code shows how to apply RotationZ to a Sprite in code. This assumes that SpriteInstance is a valid Sprite with a valid Texture. Typically this would be set in Glue.

void CustomActivity(bool firstTimeCalled)
{
    if(InputManager.Keyboard.KeyPushed(Microsoft.Xna.Framework.Input.Keys.Space))
    {
        SpriteInstance.RotationZ += 1; // rotate by one radian counterclockwise
    }
}

Last updated