Time for action – creating the Camera class
- Add a new class called "Camera" to the Robot Rampage project.
- Add the following
using
directive to the class:using Microsoft.Xna.Framework;
- Modify the declaration of the Camera class to make the class
public
andstatic
:public static class Camera
- Add declarations to the Camera class:
#region Declarations private static Vector2 position = Vector2.Zero; private static Vector2 viewPortSize = Vector2.Zero; private static Rectangle worldRectangle = new Rectangle(0, 0, 0, 0); #endregion
- Add properties to the Camera class to access and modify the underlying members:
#region Properties public static Vector2 Position { get { return position; } set { position = new Vector2( MathHelper.Clamp(value.X, worldRectangle.X, ...
Get XNA 4.0 Game Development by Example Beginner's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.