当前位置: 首页>>代码示例>>C#>>正文


C# Sprite.AddFrame方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.Sprite.AddFrame方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.AddFrame方法的具体用法?C# Sprite.AddFrame怎么用?C# Sprite.AddFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Graphics.Sprite的用法示例。


在下文中一共展示了Sprite.AddFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FireShot

        public void FireShot(Vector2 location, Vector2 velocity, bool playerFired)
        {
            Sprite thisShot = new Sprite(texture, location, initialFrame, velocity);

            thisShot.Velocity *= shotSpeed;

            for (int x = 1; x < frameCount; x++)
            {
                thisShot.AddFrame(new Rectangle(initialFrame.X + (initialFrame.Width * x), initialFrame.Y,
                    initialFrame.Width, initialFrame.Height));
            }

            thisShot.collisionRadius = collisionRadius;
            shots.Add(thisShot);

            if (playerFired)
            {
                // TODO: Add player shot sound FX
            }
        }
开发者ID:BlueLampGames,项目名称:OrangeBanana_Temp,代码行数:20,代码来源:ShotManager.cs

示例2: generateReward

        public void generateReward()
        {
            int checkLocation = rand.Next(0, hills.pixelCount);

            if (hills.HillsPixels[checkLocation].Location.X > 790.0f)
            {
                rewardType = rand.Next(0, 4);
                //rewardType = 2;//bd test
                switch (rewardType)
                {
                    case 0:
                        //generate a gold bar pile
                        goldSprite = new Sprite(
                        new Vector2(500, 400),
                        texture,
                        new Rectangle(0, goldBarSpriteOffset, goldBarFrameWidth, goldBarFrameHeight),
                        Vector2.Zero);

                        for (int x = 1; x < goldBarFrameCount; x++)
                        {
                            goldSprite.AddFrame(
                                new Rectangle(
                                    goldBarFrameIndex + (goldBarFrameWidth * x),
                                    goldBarSpriteOffset,
                                    goldBarFrameWidth,
                                    goldBarFrameHeight));
                        }

                        goldSprite.Scale = 0.5f;

                        goldSprite.HillIndex = checkLocation;

                        goldSprite.Location.X = hills.HillsPixels[goldSprite.HillIndex].Location.X - (goldBarFrameWidth / 2);

                        goldSprite.Location.Y = hills.HillsPixels[goldSprite.HillIndex].Location.Y - (goldBarFrameHeight / 2) - 20.0f;

                        goldSprite.Rotation = (float)Math.Atan(hills.getSlope((int)goldSprite.Location.X));

                        goldSprite.CollisionRadius = goldBarRadius;

                        rewardsList.Add(goldSprite);

                        break;

                    case 1:

                        //generate a battery power pod
                        batterySprite = new Sprite(
                        new Vector2(500, 400),
                        texture,
                        new Rectangle(0, batterySpriteOffset, batteryFrameWidth, batteryFrameHeight),
                        Vector2.Zero);

                        for (int x = 1; x < batteryFrameCount; x++)
                        {
                            batterySprite.AddFrame(
                            new Rectangle(
                            batteryFrameIndex + (batteryFrameWidth * x),
                            batterySpriteOffset,
                            batteryFrameWidth,
                            batteryFrameHeight));
                        }

                        batterySprite.Scale = 0.5f;

                        batterySprite.HillIndex = checkLocation;

                        batterySprite.Location.X = hills.HillsPixels[batterySprite.HillIndex].Location.X - (batteryFrameWidth / 2);

                        batterySprite.Location.Y = hills.HillsPixels[batterySprite.HillIndex].Location.Y - (batteryFrameHeight / 2) - 20.0f;

                        batterySprite.Rotation = (float)Math.Atan(hills.getSlope((int)batterySprite.Location.X));

                        batterySprite.CollisionRadius = batteryRadius;

                        rewardsList.Add(batterySprite);
                        break;

                    case 2:

                        //generate a saw
                        sawSprite = new Sprite(
                        new Vector2(0, 0),
                        texture,
                        new Rectangle(0, sawSpriteOffset, sawFrameWidth, sawFrameHeight),
                        Vector2.Zero);

                        for (int x = 1; x < sawFrameCount; x++)
                        {
                            sawSprite.AddFrame(
                            new Rectangle(
                            sawFrameIndex + (sawFrameWidth * x),
                            sawSpriteOffset,
                            sawFrameWidth,
                            sawFrameHeight));
                        }

                        sawSprite.Scale = 0.4f;

                        sawSprite.HillIndex = checkLocation;
//.........这里部分代码省略.........
开发者ID:Gillium,项目名称:spyrun,代码行数:101,代码来源:Rewards.cs


注:本文中的Microsoft.Xna.Framework.Graphics.Sprite.AddFrame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。