Merge pull request #68 from progtime-net/texture-flipping
Add flipping and rotation around left-top edge
This commit is contained in:
commit
7244981e86
4 changed files with 19 additions and 26 deletions
|
@ -163,6 +163,7 @@ namespace ZoFo.GameCore.Graphics
|
||||||
}
|
}
|
||||||
|
|
||||||
interval--;
|
interval--;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch)
|
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch)
|
||||||
|
@ -187,8 +188,9 @@ namespace ZoFo.GameCore.Graphics
|
||||||
destinationRectangle.Y -= CameraPosition.Y;
|
destinationRectangle.Y -= CameraPosition.Y;
|
||||||
|
|
||||||
destinationRectangle = Scaling(destinationRectangle);
|
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)
|
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
||||||
{
|
{
|
||||||
|
@ -213,7 +215,8 @@ namespace ZoFo.GameCore.Graphics
|
||||||
|
|
||||||
destinationRectangle = Scaling(destinationRectangle);
|
destinationRectangle = Scaling(destinationRectangle);
|
||||||
_spriteBatch.Draw(texture,
|
_spriteBatch.Draw(texture,
|
||||||
destinationRectangle, sourceRectangle, Color.White);
|
destinationRectangle, sourceRectangle, Color.White, 0,
|
||||||
|
Vector2.Zero, Flip, 0);
|
||||||
}
|
}
|
||||||
private void buildSourceRectangle()
|
private void buildSourceRectangle()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,9 @@ public abstract class GraphicsComponent
|
||||||
public static int scaling = 1;
|
public static int scaling = 1;
|
||||||
public string mainTextureName;//TODO костыль - пофиксить
|
public string mainTextureName;//TODO костыль - пофиксить
|
||||||
|
|
||||||
|
public SpriteEffects Flip = SpriteEffects.None;
|
||||||
|
public float Rotation;
|
||||||
|
|
||||||
public abstract void LoadContent();
|
public abstract void LoadContent();
|
||||||
public abstract void Update();
|
public abstract void Update();
|
||||||
public abstract void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch);
|
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
|
namespace ZoFo.GameCore.Graphics
|
||||||
{
|
{
|
||||||
|
|
||||||
public class StaticGraphicsComponent : GraphicsComponent
|
public class StaticGraphicsComponent : GraphicsComponent
|
||||||
{
|
{
|
||||||
private Texture2D texture;
|
private Texture2D texture;
|
||||||
|
@ -18,7 +17,7 @@ namespace ZoFo.GameCore.Graphics
|
||||||
{
|
{
|
||||||
LoadContent();
|
LoadContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StaticGraphicsComponent(string textureName)
|
public StaticGraphicsComponent(string textureName)
|
||||||
{
|
{
|
||||||
BuildComponent(textureName);
|
BuildComponent(textureName);
|
||||||
|
@ -29,7 +28,7 @@ namespace ZoFo.GameCore.Graphics
|
||||||
{
|
{
|
||||||
_textureName = textureName;
|
_textureName = textureName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void LoadContent()
|
public override void LoadContent()
|
||||||
{
|
{
|
||||||
|
@ -37,7 +36,7 @@ namespace ZoFo.GameCore.Graphics
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
texture = AppManager.Instance.Content.Load<Texture2D>(_textureName);
|
texture = AppManager.Instance.Content.Load<Texture2D>(_textureName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,11 +52,14 @@ namespace ZoFo.GameCore.Graphics
|
||||||
destinationRectangle.X -= CameraPosition.X;
|
destinationRectangle.X -= CameraPosition.X;
|
||||||
destinationRectangle.Y -= CameraPosition.Y;
|
destinationRectangle.Y -= CameraPosition.Y;
|
||||||
destinationRectangle = Scaling(destinationRectangle);
|
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)
|
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
||||||
{
|
{
|
||||||
|
// Uncomment to go brrrr
|
||||||
|
//Rotation = new Random().Next(1, 365);
|
||||||
DebugHUD.Instance.Log("draw ");
|
DebugHUD.Instance.Log("draw ");
|
||||||
|
|
||||||
destinationRectangle.X -= CameraPosition.X;
|
destinationRectangle.X -= CameraPosition.X;
|
||||||
|
@ -65,7 +67,8 @@ namespace ZoFo.GameCore.Graphics
|
||||||
|
|
||||||
destinationRectangle = Scaling(destinationRectangle);
|
destinationRectangle = Scaling(destinationRectangle);
|
||||||
_spriteBatch.Draw(texture,
|
_spriteBatch.Draw(texture,
|
||||||
destinationRectangle, sourceRectangle, Color.White);
|
destinationRectangle, sourceRectangle, Color.White, Rotation,
|
||||||
|
Vector2.Zero, Flip, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue