本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.Sprite.Move方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.Move方法的具体用法?C# Sprite.Move怎么用?C# Sprite.Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.Sprite
的用法示例。
在下文中一共展示了Sprite.Move方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveForward
private void MoveForward(Sprite sprite)
{
var x = 0f;
var y = 0f;
switch (_currentDirection)
{
case Direction.Up:
y = -1*_speed;
break;
case Direction.Down:
y = _speed;
break;
case Direction.Left:
x = -1*_speed;
break;
case Direction.Right:
x = _speed;
break;
default:
return;
}
if (_currentState == BoomerangState.Forward)
{
var collision = GetComponent<Collision>(ComponentType.Collision);
if(collision != null && collision.CheckCollisionWithTiles(new Rectangle((int) (sprite.Position.X + x), (int) (sprite.Position.Y + y),sprite.Width,sprite.Height)))
{
_currentState = BoomerangState.Back;
_counter = 0;
}
else
{
sprite.Move(x,y);
}
}
}
示例2: MoveBack
private void MoveBack(Sprite sprite)
{
var ownerSprite = Owner.GetComponent<Sprite>(ComponentType.Sprite);
if(ownerSprite == null)
{
_currentState = BoomerangState.Stop;
Active = false;
}
if(ManagerFunction.Distance(sprite.Position,ownerSprite.Position) < 2)
{
_currentState = BoomerangState.Stop;
Active = false;
return;
}
if(ownerSprite.Position.X < sprite.Position.X)
sprite.Move(-1*_speed,0);
if (ownerSprite.Position.X > sprite.Position.X)
sprite.Move(_speed, 0);
if (ownerSprite.Position.Y < sprite.Position.Y)
sprite.Move(0, -1*_speed);
if (ownerSprite.Position.Y > sprite.Position.Y)
sprite.Move(0, _speed);
}