|  | 
 
 
 楼主|
发表于 2012-8-4 21:36:11
|
显示全部楼层 
| 接上 首先,我们绘制的天空。然后我们绘制以水平不同的速度运动的云 ,然后我们画的大海,然后船。最后,我们得出的动态元素:炮弹,大炮,比分。复制代码public override void Draw(GameTime gameTime)
        {
            ScreenManager.SpriteBatch.Begin(0, null, null, null, null, null, Camera.View);
            if (gameStateMachine.CurrentSate != GameState.None)
            {
                var skyRect = GamePredefinitions.SkyTextureRectangle;
                var seaRect = GamePredefinitions.SeaTextureRectangle;
                ScreenManager.SpriteBatch.Draw(skyTexture, skyRect, Color.White);
                ScreenManager.SpriteBatch.Draw(cloud1Texture, new Rectangle(skyRect.X + cloudStep1, skyRect.Y, skyRect.Width, skyRect.Height), Color.White);
                ScreenManager.SpriteBatch.Draw(cloud2Texture, new Rectangle(skyRect.X + cloudStep2 * 2, skyRect.Y, skyRect.Width, skyRect.Height), Color.White);
                ScreenManager.SpriteBatch.Draw(cloud3Texture, new Rectangle(skyRect.X + cloudStep3 * 3, skyRect.Y, skyRect.Width, skyRect.Height), Color.White);
                ScreenManager.SpriteBatch.Draw(seaTexture, seaRect, Color.White);
                ScreenManager.SpriteBatch.Draw(pirateShipTexture, GamePredefinitions.PirateShipTextureRectangle, Color.White);
                ScreenManager.SpriteBatch.Draw(royalShipTexture, GamePredefinitions.RoyalShipTextureRectangle, Color.White);
            }
            smokeTracePositions.ForEach(e =>
                ScreenManager.SpriteBatch.Draw(smokeTraceTexture, ConvertUnits.ToDisplayUnits(e) + GamePredefinitions.CannonCenter - new Vector2(10, 10),
                    null, Color.White, 0f, Vector2.Zero, _scale, SpriteEffects.None, 0f));
            foreach (var textureBody in textureBodies)
            {
                ScreenManager.SpriteBatch.Draw(textureBody.DisplayTexture, ConvertUnits.ToDisplayUnits(textureBody.Body.Position),
                                               null, Color.White, textureBody.Body.Rotation, textureBody.Origin, _scale, SpriteEffects.None, 0f);
            }
            ScreenManager.SpriteBatch.Draw(cannonTexture, GamePredefinitions.CannonCenter,
                                null, Color.White, cannonAngle, new Vector2(40f, 29f), 1f, SpriteEffects.None,
                                0f);
            var hiScoreText = string.Format("hi score: {0}", scoreManager.GetHiScore());
            var scoreText = string.Format("score: {0}", scoreManager.GetScore());
            DrawScoreText(0, 0, hiScoreText);
            DrawScoreText(0, 30, scoreText);
            ScreenManager.SpriteBatch.End();
            _border.Draw();
            base.Draw(gameTime);
        }
 最后的思考
 
 我希望你喜欢!如果你有话要说,请到卤面网(codewp7.com)问答区联系我,我会很高兴知道你在想什么。同时wp7交流QQ群172765887中,也能找到我的身影,感谢大家
 
 | 
 |