summaryrefslogtreecommitdiff
path: root/samples/wxwidgets/Main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'samples/wxwidgets/Main.cpp')
-rwxr-xr-x[-rw-r--r--]samples/wxwidgets/Main.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/samples/wxwidgets/Main.cpp b/samples/wxwidgets/Main.cpp
index b5a13c0..c06a793 100644..100755
--- a/samples/wxwidgets/Main.cpp
+++ b/samples/wxwidgets/Main.cpp
@@ -26,6 +26,7 @@ public :
// Load an image and assign it to our sprite
myImage.LoadFromFile("datas/wxwidgets/sfml.png");
mySprite.SetImage(myImage);
+ mySprite.SetCenter(mySprite.GetSize() / 2.f);
// Catch the mouse move event
Connect(wxEVT_MOTION, wxMouseEventHandler(MyCanvas::OnMouseMove));
@@ -39,6 +40,10 @@ private :
////////////////////////////////////////////////////////////
virtual void OnUpdate()
{
+ // Rotate the sprite
+ if (GetInput().IsMouseButtonDown(sf::Mouse::Left)) mySprite.Rotate( GetFrameTime() * 50);
+ if (GetInput().IsMouseButtonDown(sf::Mouse::Right)) mySprite.Rotate(-GetFrameTime() * 50);
+
// Display the sprite in the view
Draw(mySprite);
}
@@ -50,8 +55,8 @@ private :
void OnMouseMove(wxMouseEvent& Event)
{
// Make the sprite follow the mouse cursor
- mySprite.SetLeft(Event.GetX() - mySprite.GetWidth() / 2);
- mySprite.SetTop(Event.GetY() - mySprite.GetHeight() / 2);
+ mySprite.SetX(Event.GetX());
+ mySprite.SetY(Event.GetY());
}
////////////////////////////////////////////////////////////