NewPeregruzkaDlyDraw
This commit is contained in:
parent
9f8e7bcbd4
commit
469050e4cd
1 changed files with 22 additions and 0 deletions
|
@ -146,6 +146,28 @@ namespace DangerousD.GameCore.Graphics
|
|||
}
|
||||
|
||||
|
||||
_spriteBatch.Draw(texture,
|
||||
destinationRectangle, sourceRectangle, Color.White);
|
||||
}
|
||||
public void DrawAnimation(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
||||
{
|
||||
Texture2D texture = textures[texturesNames.FindIndex(x => x == currentAnimation.TextureName)];
|
||||
float scale;
|
||||
if (currentAnimation.Offset.X != 0)
|
||||
{
|
||||
destinationRectangle.X -= (int)currentAnimation.Offset.X;
|
||||
scale = destinationRectangle.Height / sourceRectangle.Height;
|
||||
destinationRectangle.Width = (int)(sourceRectangle.Width * scale);
|
||||
|
||||
}
|
||||
else if (currentAnimation.Offset.Y != 0)
|
||||
{
|
||||
destinationRectangle.Y -= (int)currentAnimation.Offset.Y;
|
||||
scale = destinationRectangle.Width / sourceRectangle.Width;
|
||||
destinationRectangle.Height = (int)(sourceRectangle.Height * scale);
|
||||
}
|
||||
|
||||
|
||||
_spriteBatch.Draw(texture,
|
||||
destinationRectangle, sourceRectangle, Color.White);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue