本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.Sprite.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.Create方法的具体用法?C# Sprite.Create怎么用?C# Sprite.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.Sprite
的用法示例。
在下文中一共展示了Sprite.Create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UfoFiresBullet
private void UfoFiresBullet()
{
Sprite newBullet = new Sprite(_ufobullet.Texture);
Vector2 velocity = _ship.Position - _ufo.Position;
velocity.Normalize();
newBullet.Rotation = (float) Math.Atan2(velocity.Y, velocity.X) + MathHelper.PiOver2;
velocity *= 6.0f;
newBullet.Velocity = velocity;
newBullet.Position = _ufo.Position;
newBullet.Damage = 1;
newBullet.Create();
_ufobullets.Add(newBullet);
}
示例2: ShipSpecialAttack
private void ShipSpecialAttack()
{
//_ship.Velocity += new Vector2(
// (float) (Math.Cos(_ship.Rotation - MathHelper.PiOver2)*0.5f),
// (float) ((Math.Sin(_ship.Rotation - MathHelper.PiOver2)*0.5f)));
float chunk = MathHelper.TwoPi/BulletsInSpecialAttack;
for (int i = 0; i < BulletsInSpecialAttack; i++)
{
Sprite newBullet = new Sprite(_specialBulletTexture);
newBullet.Position = _ship.Position;
newBullet.Damage = 2;
newBullet.Velocity = new Vector2((float)Math.Cos(-MathHelper.Pi + chunk * i), (float)Math.Sin(-MathHelper.Pi + chunk * i))*10;
newBullet.Create();
_bullets.Add(newBullet);
}
}
示例3: NewAsteroid
private void NewAsteroid(Sprite a, int index)
{
Sprite tempSprite = new Sprite(_asteroidTextures[index])
{
Index = index,
Position = a.Position,
Velocity = RandomVelocity(),
Rotation = (float) _random.NextDouble()*
MathHelper.Pi*4 - MathHelper.Pi*2
};
if (a.Index < 3)
{
tempSprite.Life = 3;
}
else if (a.Index < 6)
{
tempSprite.Life = 1;
}
tempSprite.Create();
_asteroids.Add(tempSprite);
}
示例4: ShipFiresBullet
private void ShipFiresBullet()
{
Sprite newBullet = new Sprite(_bullet.Texture);
Vector2 velocity = new Vector2(
(float)Math.Cos(_ship.Rotation - MathHelper.PiOver2) ,
(float)Math.Sin(_ship.Rotation - MathHelper.PiOver2) );
velocity.Normalize();
velocity *= 10.0f;
newBullet.Velocity = velocity;
newBullet.Position = _ship.Position + newBullet.Velocity*2;
newBullet.Damage = 1;
newBullet.Rotation = _ship.Rotation;
newBullet.Create();
_bullets.Add(newBullet);
}
示例5: GenerateAidkits
/*
*
* UPDATE LOGIC BLOC
*
*
*/
private void GenerateAidkits(TimeSpan totalTime)
{
if (_random.Next(0, 700) == 301)
{
Sprite aidkit = new Sprite(_aidkitTexture);
double xPos = 0;
double yPos = 0;
int value = _random.Next(0, 4);
switch (value)
{
case 0:
case 1:
xPos = aidkit.Width + _random.NextDouble() * 40;
yPos = _random.NextDouble() * _screenHeight;
break;
case 2:
case 3:
xPos = _screenWidth - _random.NextDouble() * 40;
yPos = _random.NextDouble() * _screenHeight;
break;
case 4:
case 5:
xPos = _random.NextDouble() * _screenWidth;
yPos = aidkit.Height + _random.NextDouble() * 40;
break;
default:
xPos = _random.NextDouble() * _screenWidth;
yPos = _screenHeight - _random.NextDouble() * 40;
break;
}
aidkit.Position = new Vector2((float)xPos, (float)yPos);
aidkit.Rotation = (float)_random.NextDouble() *
MathHelper.Pi * 4 - MathHelper.Pi * 2;
aidkit.Life = _random.Next(3, 6);
aidkit.LastUpdate = totalTime.TotalMilliseconds;
aidkit.Create();
_aidkits.Add(aidkit);
}
}