TestWorkingVersionOfAnimator
This commit is contained in:
parent
2d33e13283
commit
cb9b3664a4
3 changed files with 26 additions and 1 deletions
|
@ -40,6 +40,7 @@ namespace AnimationsFileCreator
|
|||
string id = Console.ReadLine();
|
||||
Console.WriteLine("Введите 1 если анимация зациклена, и 0 если нет");
|
||||
AnimationContainer container = new AnimationContainer();
|
||||
|
||||
int a = int.Parse(Console.ReadLine());
|
||||
if (a==1)
|
||||
{
|
||||
|
@ -49,6 +50,10 @@ namespace AnimationsFileCreator
|
|||
{
|
||||
container.IsCycle = false;
|
||||
}
|
||||
Console.WriteLine("Введите отклонение анимации от стандартной (сначала X, потом enter, потом Y): ");
|
||||
int otklx = int.Parse(Console.ReadLine());
|
||||
int otkly = int.Parse(Console.ReadLine());
|
||||
container.Offset =new Vector2(otklx,otkly);
|
||||
container.FramesCount = framesCount;
|
||||
container.FrameTime = new System.Collections.Generic.List<Tuple<int, int>>();
|
||||
container.FrameTime.Add(new Tuple<int, int>(0, interval));
|
||||
|
|
|
@ -23,6 +23,10 @@ namespace DangerousD.GameCore.Graphics
|
|||
public int FramesCount { get; set; }
|
||||
[JsonProperty("isCycle")]
|
||||
public bool IsCycle { get; set; }
|
||||
[JsonProperty("offset")]
|
||||
public Vector2 Offset { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,8 +129,24 @@ namespace DangerousD.GameCore.Graphics
|
|||
|
||||
public void DrawAnimation(Rectangle destinationRectangle, SpriteBatch _spriteBatch)
|
||||
{
|
||||
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);
|
||||
|
||||
_spriteBatch.Draw(textures[texturesNames.FindIndex(x => x == currentAnimation.TextureName)],
|
||||
}
|
||||
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