Beispiel #1
0
        public void LoadContent(IContentManager<DemoGameContent> contentManager)
        {
            this.sprite = new Sprite(contentManager.Load<SpriteSheet>(DemoGameContent.Ship));
            this.sprite.Frame = 1;
            this.sprite.Origin = new Vector2(40, 40);

            this.sprite.AddChild(new Sprite(contentManager.Load<SpriteSheet>(DemoGameContent.ShipFlame)));
            this.sprite.Children[0].Frame = 0;
            this.sprite.Children[0].Origin = new Vector2(8, 8);
            this.sprite.Children[0].Position = new Vector2(40, 88);

            this.blasterSoundEffect = contentManager.Load<SoundEffect>(DemoGameContent.Blaster);
        }
        protected override void Initialize()
        {
            this.graphicsDevice.CreateDevice(800, 600);

            // GraphicsBatch must be created after the graphics device is created.
            this.graphics = new GraphicsBatch(this.graphicsDevice);

            this.animationOffset = 1;

            // Load a texture and wrap it in a SpriteSheet. The sheet contains frames which are 32x32.
            SpriteSheet spriteSheet = this.content.Load<SpriteSheet>(new LoadSpriteSheetArgs()
            {
                FileName = "wizard.png",
                FrameWidth = 32,
                FrameHeight = 32
            });

            this.sprite = new Sprite(spriteSheet);
            this.sprite.Position = new Vector2(this.Window.DisplayWidth / 2, this.Window.DisplayHeight / 2);
            this.sprite.Origin = new Vector2(16, 16);
        }
Beispiel #3
0
        public void AddChild(Sprite sprite)
        {
            if (sprite == null)
                throw new ArgumentNullException("sprite");

            this.children.Add(sprite);
        }