KeepSpriteInScreen
Introduction
The KeepSpriteInScreen method adjusts the absolute position of the argument Sprite so that it is fully in-view. This method makes a few assumptions:
The Camera is not rotated
The Sprite is in front of the Camera (has a smaller Z value than the Camera)
Syntax
Code Example
The following code creates a Sprite which is moved around the screen by the Keyboad with the arrow keys. Add the following using statement:
Add the following at class scope:
Add the following to Initialize after initializing FlatRedBall:
Add the following to Update:
KeepSpriteInScreen and Entities
As of the July 2010 release of FlatRedBall, the KeepSpriteInScreen method works properly even if the argument Sprite has a parent (a common setup when using Entities).
Last updated