FGF: Oriented Drawing

After you’ve read about the Display Orientation features of FGF, a natural question to ask is “How do I draw and take input with a rotated display?” Fortunately FGF has some methods to help in this department that sit alongside the rotation methods and properties in the Application class.

Application.OrientedDisplaySize

If you need to draw something relative to the size of the screen, use the OrientedDisplaySize property of the Application class. This property differs from DisplaySize, which is used to change the actual size of the display, in that OrientatedDisplaySize reacts to the selected rotation of the display, set with the DisplayOrientation property.

DisplaySize = new Vector2(272, 480);
DisplayOrientation = DisplayOrientation.Rotated;

Console.WriteLine(OrientedDisplaySize.ToString());

Because the display is set to be rotated (landscape on the Zune HD), the above code will actually print out a display size of (480, 272) rather than the standard (272, 480) size.

Application.DisplayOrientation

Get or set the orientation of the display. Setting this value to standard will set landscape mode on the PC and portrait mode on the Zune HD. At the time of writing this article, the PC/Xbox360 version of FGF does not support rotating the display but setting the orientation to Rotated on the Zune HD will enable landscape mode.

Application.DisplayRotation

You can view the rotation value being used to render the global render target through this property. Note that this property is used in conjunction with the DisplaySpriteEffects and DisplayOrientation properties and cannot be set manually.

DisplaySpriteEffects

You can view the sprite effectsbeing used to render the global render target through this property. Note that this property is used in conjunction with the DisplayRotation and DisplayOrientation properties and cannot be set manually.

Application.DisplaySize

The standard size of the display is given by the DisplaySize property. Set this property to change the size of the display at any time.

Application.ScreenToObject(Vector2)

The ScreenToObject method is used to translate screen space coordinates into object space coordinates. The major use of this method is to translate touch panel positions into object space where they can be used for object selection.

Application.ObjectToScreen(Vector2)

Opposite of the ScreenToObject method, ObjectToScreen converts object space coordinates to screen space coordinates. Note that the resulting coordinates are not to be used for drawing in an oriented application; objects will automatically be rotated and positioned correctly via the global render target.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>