本文整理匯總了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);
}