Esempio n. 1
0
        /// <summary>
        /// Initialize the SpriteBatch for this canvas and prepare for drawing.
        /// </summary>
        /// <remarks>
        /// This method is called by the Initialize method of the game engine,
        /// after all of the game has finished all necessary off-screen
        /// initialization.
        /// </remarks>
        /// <param name="game">The root game engine for this canvas</param>
        public void Initialize(Game game)
        {
            // Override window position at start-up
            window = game.Window;
            if (!fullscreen)
            {
                graphics.PreferredBackBufferWidth  = bounds.Width;
                graphics.PreferredBackBufferHeight = bounds.Height;
                graphics.ApplyChanges();
            }

            // Set up Sprite Batch properites
            spriteBatch = new SpriteBatch(game.GraphicsDevice);

            // Set up polygon properties
            effect                 = new BasicEffect(game.GraphicsDevice);
            effect.View            = Matrix.Identity;
            effect.Projection      = Matrix.CreateOrthographicOffCenter(0, bounds.Width, bounds.Height, 0, 0, 1);
            effect.TextureEnabled  = true;
            effect.LightingEnabled = false;

            // We are not actively drawing
            state = DrawState.Inactive;

            tiny = new Texture2D(game.GraphicsDevice, 1, 1);
            Color[] data = new Color[1];
            data[0] = Color.White;
            tiny.SetData <Color>(data);

            textureManager = new Texture2DManager();
        }
Esempio n. 2
0
        /// <summary>
        /// Initialize the SpriteBatch for this canvas and prepare for drawing.
        /// </summary>
        /// <remarks>
        /// This method is called by the Initialize method of the game engine,
        /// after all of the game has finished all necessary off-screen
        /// initialization.
        /// </remarks>
        /// <param name="game">The root game engine for this canvas</param>
        public void Initialize(Game game)
        {
            // Override window position at start-up
            window = game.Window;
            if (!fullscreen)
            {
                graphics.PreferredBackBufferWidth = bounds.Width;
                graphics.PreferredBackBufferHeight = bounds.Height;
                graphics.ApplyChanges();
            }

            // Set up Sprite Batch properites
            spriteBatch = new SpriteBatch(game.GraphicsDevice);

            // Set up polygon properties
            effect = new BasicEffect(game.GraphicsDevice);
            effect.View = Matrix.Identity;
            effect.Projection = Matrix.CreateOrthographicOffCenter(0, bounds.Width, bounds.Height, 0, 0, 1);
            effect.TextureEnabled = true;
            effect.LightingEnabled = false;

            // We are not actively drawing
            state = DrawState.Inactive;

            tiny = new Texture2D(game.GraphicsDevice, 1, 1);
            Color[] data = new Color[1];
            data[0] = Color.White;
            tiny.SetData<Color>(data);

            textureManager = new Texture2DManager();
        }