コード例 #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            backgroundLayer.Draw(spriteBatch, cam.position);


            foreach (TileObject c in objList)
            {
                c.Draw(spriteBatch);
            }

            foreach (Enemy e in enemyList)
            {
                e.Draw(spriteBatch);
            }

            foreach (AnimatedSprite a in animList)
            {
                a.Draw(spriteBatch, a.pos, 0.0f);
            }

            player.Draw(spriteBatch);

            int hx = 10;
            int hy = 50;


            spriteBatch.Begin();

            for (int i = 0; i < player._lives; i++)
            {
                spriteBatch.Draw(heart, new Rectangle(hx, hy, heart.Width / 2, heart.Height / 2), Color.White);
                hx += heart.Width / 2 + 10;
            }

            spriteBatch.DrawString(spriteFont, "Score : " + player.score, new Vector2(10, 90), Color.White);
            spriteBatch.End();

            if (TransitionPosition > 0 || pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2);

                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }