本文整理汇总了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
}
}
示例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;
//.........这里部分代码省略.........