// the constructor creates a new PrimitiveBatch and sets up all of the internals // that PrimitiveBatch will need. public PrimitiveBatch(XNA2DCamera camera, GraphicsDevice graphicsDevice) { mCamera = camera; if (graphicsDevice == null) { throw new ArgumentNullException("graphicsDevice"); } device = graphicsDevice; // create a vertex declaration, which tells the graphics card what kind of // data to expect during a draw call. We're drawing using // VertexPositionColors, so we'll use those vertex elements. vertexDeclaration = new VertexDeclaration(graphicsDevice, VertexPositionColor.VertexElements); // set up a new basic effect, and enable vertex colors. basicEffect = new BasicEffect(graphicsDevice, null); basicEffect.VertexColorEnabled = true; // projection uses CreateOrthographicOffCenter to create 2d projection // matrix with 0,0 in the upper left. basicEffect.Projection = Matrix.CreateOrthographicOffCenter (0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height, 0, 0, 1); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here base.Initialize(); mCamera = new XNA2DCamera(graphics.GraphicsDevice); mGameWorld = new GameWorldCore(graphics, mContent, this); mGameMouse = new GameMouse(graphics, mContent); }