Beispiel #1
0
        protected override void Draw(GameTime gameTime)
        {
            PerfMon.DrawStarted();

            this.GraphicsDevice.Clear(Color.CornflowerBlue);

            this.spriteBatch.Begin(SpriteSortMode.FrontToBack);

            var sprites   = new Span <SpriteComponent>(Scene.SpriteComponents);
            var positions = new Span <PositionComponent>(Scene.PositionComponents);

            for (int i = 0; i < Scene.EntityCount; i++)
            {
                var texture2D = this.texture2Ds[sprites[i].Index];
                var color     = new Color(sprites[i].ColorR, sprites[i].ColorG, sprites[i].ColorB, sprites[i].Alpha);
                var origin    = new Vector2(texture2D.Width / 2, texture2D.Height / 2);
                this.spriteBatch.Draw(texture2D, positions[i].Value, null, color, 0.0f, origin, Vector2.One, SpriteEffects.None, sprites[i].Index);
            }

            this.spriteBatch.End();

            base.Draw(gameTime);

            PerfMon.DrawFinished();
        }
        protected override void Draw(GameTime gameTime)
        {
            PerfMon.DrawStarted();
            GraphicsDevice.Clear(Color.CornflowerBlue);

            this.spriteBatch.Begin();

            for (var i = 0; i < s_GameObjects.Count; i++)
            {
                var gameObject = s_GameObjects[i];
                var texture2D  = this.texture2Ds[gameObject.SpriteIndex];
                var origin     = new Vector2(texture2D.Width / 2, texture2D.Height / 2);
                this.spriteBatch.Draw(texture2D, gameObject.Position, null, gameObject.SpriteColor, 0.0f, origin, Vector2.One,
                                      SpriteEffects.None, gameObject.SpriteIndex);
            }

            this.spriteBatch.End();

            base.Draw(gameTime);
            PerfMon.DrawFinished();
        }
        protected override void Draw(GameTime gameTime)
        {
            PerfMon.DrawStarted();
            GraphicsDevice.Clear(Color.CornflowerBlue);

            this.spriteBatch.Begin(SpriteSortMode.FrontToBack);
            foreach (var gameObject in s_GameObjects)
            {
                var position = gameObject.GetComponent <PositionComponent>();
                var sprite   = gameObject.GetComponent <SpriteComponent>();

                if (position != null && sprite != null)
                {
                    var texture2D = this.texture2Ds[sprite.Index];
                    var color     = new Color(sprite.ColorR, sprite.ColorG, sprite.ColorB, sprite.Alpha);
                    var origin    = new Vector2(texture2D.Width / 2, texture2D.Height / 2);
                    this.spriteBatch.Draw(texture2D, position.Value, null, color, 0.0f, origin, Vector2.One, SpriteEffects.None, sprite.Index);
                }
            }
            this.spriteBatch.End();
            base.Draw(gameTime);
            PerfMon.DrawFinished();
        }