1
Graphics / Re: GetGlobalBounds not updating?
« on: January 27, 2013, 11:09:13 pm »
i want to move things around and it was simple with the Translate method
but after compiling the newest sfml the sprite is not moving
but after compiling the newest sfml the sprite is not moving
public void StartTest()
{
//set the window and event handlers
renWin = new RenderWindow(new VideoMode(800, 600), "DraggTest");
renWin.Closed += new EventHandler(OnClose);
renWin.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(OnClick);
renWin.MouseButtonReleased += new EventHandler<MouseButtonEventArgs>(OnClickRelease);
renWin.MouseMoved += new EventHandler<MouseMoveEventArgs>(OnMousMove);
renWin.KeyPressed += new EventHandler<KeyEventArgs>(OnKey);
renWin.MouseLeft += new EventHandler(OnMouseLeft);
//set the sprite
Texture tex = new Texture("imgs\\ace.gif");
sprite = new Sprite(tex);
//move the sprite from the start 0,0 position to 20,20
sprite.Position = new Vector2f(20,20); //works
//sprite.Transform.Translate(20,20); //doesn't work
//the loop
while (renWin.IsOpen())
{
//events
renWin.DispatchEvents();
//clear
renWin.Clear(Color.Black);
//move sprite
if (dragging)
{
sprite.Position = mPos-dPos;
}
//draw sprite
renWin.Draw(sprite);
//update window
renWin.Display();
}
}
{
//set the window and event handlers
renWin = new RenderWindow(new VideoMode(800, 600), "DraggTest");
renWin.Closed += new EventHandler(OnClose);
renWin.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(OnClick);
renWin.MouseButtonReleased += new EventHandler<MouseButtonEventArgs>(OnClickRelease);
renWin.MouseMoved += new EventHandler<MouseMoveEventArgs>(OnMousMove);
renWin.KeyPressed += new EventHandler<KeyEventArgs>(OnKey);
renWin.MouseLeft += new EventHandler(OnMouseLeft);
//set the sprite
Texture tex = new Texture("imgs\\ace.gif");
sprite = new Sprite(tex);
//move the sprite from the start 0,0 position to 20,20
sprite.Position = new Vector2f(20,20); //works
//sprite.Transform.Translate(20,20); //doesn't work
//the loop
while (renWin.IsOpen())
{
//events
renWin.DispatchEvents();
//clear
renWin.Clear(Color.Black);
//move sprite
if (dragging)
{
sprite.Position = mPos-dPos;
}
//draw sprite
renWin.Draw(sprite);
//update window
renWin.Display();
}
}