Beispiel #1
0
        protected override void Initialize()
        {
            // must be initialized. required by Content loading and rendering (will add itself to the Services)
            // note that MonoGame requires this to be initialized in the constructor, while WpfInterop requires it to
            // be called inside Initialize (before base.Initialize())
            graphicsDeviceManager = new WpfGraphicsDeviceService(this);

            // must be called after the WpfGraphicsDeviceService instance was created
            base.Initialize();

            // Create a spritebatch for drawing sprites
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //graphicsDeviceManager.PreferMultiSampling = false;
            //graphicsDeviceManager.ApplyChanges();

            // wpf and keyboard need reference to the host control in order to receive input
            // this means every WpfGame control will have it's own keyboard & mouse manager which will only react if the mouse is in the control
            keyboard = new WpfKeyboard(this);
            mouse    = new WpfMouse(this);

            spriteFrames = new List <Texture2D>();

            Texture2D tex = new Texture2D(GraphicsDevice, 1, 1);

            tex.SetData(new Color[] { Color.Red });
            texRectangle = new TextureSprite(tex);

            tex = new Texture2D(GraphicsDevice, 1, 1);
            tex.SetData(new Color[] { Color.LightBlue });
            texPixel = new TextureSprite(tex);

            // content loading now possible
        }
Beispiel #2
0
        public void SetSprite(List <System.Drawing.Bitmap> bitmaps)
        {
            if (bitmaps.Count > 0)
            {
                // Clear current list of frames
                foreach (Texture2D texture in spriteFrames)
                {
                    // Delete texture
                }
                spriteFrames.Clear();

                // Add all frames
                foreach (System.Drawing.Bitmap bitmap in bitmaps)
                {
                    Texture2D tex = TextureSprite.GetTexture(GraphicsDevice, bitmap);
                    spriteFrames.Add(tex);
                }
            }
        }
Beispiel #3
0
 public TextureSprite(GraphicsDevice graphics, Bitmap bitmap)
 {
     Texture = TextureSprite.GetTexture(graphics, bitmap);
     CalculateCenter();
 }
Beispiel #4
0
 public void SetAnchorSprites(System.Drawing.Bitmap bitmap1, System.Drawing.Bitmap bitmap2)
 {
     texAnchor1 = new TextureSprite(GraphicsDevice, bitmap1);
     texAnchor2 = new TextureSprite(GraphicsDevice, bitmap2);
 }
Beispiel #5
0
 public void SetOriginSprite(System.Drawing.Bitmap bitmap)
 {
     texOrigin = new TextureSprite(GraphicsDevice, bitmap);
 }
Beispiel #6
0
 public void SetCursor(System.Drawing.Bitmap bitmap)
 {
     texCursor = new TextureSprite(GraphicsDevice, bitmap);
 }