46
DotNet / Re: Set sprite origin.
« on: November 20, 2014, 04:24:44 pm »
^^ Works fine.
(click to show/hide)
public class Player
{
private Sprite sprite = new Sprite();
//Transform
public Vector2f Position { get { return this.sprite.Position; } set { this.sprite.Position = value; } }
public Vector2f Scale { get { return this.sprite.Scale; } set { this.sprite.Scale = value; } }
public float Rotation { get { return this.sprite.Rotation; } set { this.sprite.Rotation = value; } }
public Texture Texture { get { return this.sprite.Texture; } set { this.sprite.Texture = value; } }
public Vector2f Origin { get { return this.sprite.Origin; } set { this.sprite.Origin = value; } }
public void Draw(RenderWindow rWindow)
{
rWindow.Draw(this.sprite);
}
}
public static class Program
{
private static Player p = new Player();
private static readonly Color CornflowerBlue = new Color(100, 149, 237);
public static void Main(string[] args)
{
RenderWindow window = new RenderWindow(new VideoMode(1280, 720), "SFML Window");
window.Closed += (sender, eventArgs) => window.Close();
LoadContent();
while (window.IsOpen())
{
window.DispatchEvents();
window.Clear(CornflowerBlue);
p.Draw(window);
window.Display();
}
}
public static void LoadContent()
{
p.Texture = new Texture("marsu.jpg");
p.Origin = new Vector2f(-100, -100);
}
}
{
private Sprite sprite = new Sprite();
//Transform
public Vector2f Position { get { return this.sprite.Position; } set { this.sprite.Position = value; } }
public Vector2f Scale { get { return this.sprite.Scale; } set { this.sprite.Scale = value; } }
public float Rotation { get { return this.sprite.Rotation; } set { this.sprite.Rotation = value; } }
public Texture Texture { get { return this.sprite.Texture; } set { this.sprite.Texture = value; } }
public Vector2f Origin { get { return this.sprite.Origin; } set { this.sprite.Origin = value; } }
public void Draw(RenderWindow rWindow)
{
rWindow.Draw(this.sprite);
}
}
public static class Program
{
private static Player p = new Player();
private static readonly Color CornflowerBlue = new Color(100, 149, 237);
public static void Main(string[] args)
{
RenderWindow window = new RenderWindow(new VideoMode(1280, 720), "SFML Window");
window.Closed += (sender, eventArgs) => window.Close();
LoadContent();
while (window.IsOpen())
{
window.DispatchEvents();
window.Clear(CornflowerBlue);
p.Draw(window);
window.Display();
}
}
public static void LoadContent()
{
p.Texture = new Texture("marsu.jpg");
p.Origin = new Vector2f(-100, -100);
}
}