Add flipping and rotation around left-top edge
This commit is contained in:
parent
97cd62759c
commit
22c595878d
4 changed files with 19 additions and 26 deletions
|
@ -163,6 +163,7 @@ namespace ZoFo.GameCore.Graphics
|
|||
}
|
||||
|
||||
interval--;
|
||||
|
||||
}
|
||||
|
||||
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch)
|
||||
|
@ -187,8 +188,9 @@ namespace ZoFo.GameCore.Graphics
|
|||
destinationRectangle.Y -= CameraPosition.Y;
|
||||
|
||||
destinationRectangle = Scaling(destinationRectangle);
|
||||
_spriteBatch.Draw(texture,
|
||||
destinationRectangle, sourceRectangle, Color.White);
|
||||
|
||||
_spriteBatch.Draw(texture, destinationRectangle, sourceRectangle, Color.White, Rotation,
|
||||
Vector2.Zero, Flip, 0);
|
||||
}
|
||||
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
||||
{
|
||||
|
@ -213,7 +215,8 @@ namespace ZoFo.GameCore.Graphics
|
|||
|
||||
destinationRectangle = Scaling(destinationRectangle);
|
||||
_spriteBatch.Draw(texture,
|
||||
destinationRectangle, sourceRectangle, Color.White);
|
||||
destinationRectangle, sourceRectangle, Color.White, 0,
|
||||
Vector2.Zero, Flip, 0);
|
||||
}
|
||||
private void buildSourceRectangle()
|
||||
{
|
||||
|
|
|
@ -9,6 +9,9 @@ public abstract class GraphicsComponent
|
|||
public static int scaling = 1;
|
||||
public string mainTextureName;//TODO костыль - пофиксить
|
||||
|
||||
public SpriteEffects Flip = SpriteEffects.None;
|
||||
public float Rotation;
|
||||
|
||||
public abstract void LoadContent();
|
||||
public abstract void Update();
|
||||
public abstract void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch);
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace ZoFo.GameCore.Graphics;
|
||||
|
||||
public interface IGraphicsComponent
|
||||
{
|
||||
public Rectangle ObjectDrawRectangle { get; set; }
|
||||
public static int scaling = 1;
|
||||
public string mainTextureName { get; set; }//TODO костыль - пофиксить
|
||||
|
||||
public abstract void LoadContent();
|
||||
public abstract void Update();
|
||||
public abstract void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch);
|
||||
public abstract void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle);
|
||||
}
|
|
@ -8,7 +8,6 @@ using ZoFo.GameCore.GUI;
|
|||
|
||||
namespace ZoFo.GameCore.Graphics
|
||||
{
|
||||
|
||||
public class StaticGraphicsComponent : GraphicsComponent
|
||||
{
|
||||
private Texture2D texture;
|
||||
|
@ -53,11 +52,14 @@ namespace ZoFo.GameCore.Graphics
|
|||
destinationRectangle.X -= CameraPosition.X;
|
||||
destinationRectangle.Y -= CameraPosition.Y;
|
||||
destinationRectangle = Scaling(destinationRectangle);
|
||||
_spriteBatch.Draw(texture, destinationRectangle, Color.White);
|
||||
_spriteBatch.Draw(texture, destinationRectangle, texture.Bounds, Color.White, Rotation,
|
||||
Vector2.Zero, Flip, 0);
|
||||
}
|
||||
|
||||
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
||||
{
|
||||
// Uncomment to go brrrr
|
||||
//Rotation = new Random().Next(1, 365);
|
||||
DebugHUD.Instance.Log("draw ");
|
||||
|
||||
destinationRectangle.X -= CameraPosition.X;
|
||||
|
@ -65,7 +67,8 @@ namespace ZoFo.GameCore.Graphics
|
|||
|
||||
destinationRectangle = Scaling(destinationRectangle);
|
||||
_spriteBatch.Draw(texture,
|
||||
destinationRectangle, sourceRectangle, Color.White);
|
||||
destinationRectangle, sourceRectangle, Color.White, Rotation,
|
||||
Vector2.Zero, Flip, 0);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue