[Android] Updated example to handle screen rotation events (#531)

This commit is contained in:
Jonathan De Wachter 2014-06-21 20:10:46 +02:00
parent 6302cc0762
commit 775277b8fb
2 changed files with 10 additions and 1 deletions

View File

@ -16,7 +16,7 @@
<activity android:name="android.app.NativeActivity"
android:label="@string/app_name"
android:icon="@drawable/sfml_logo"
android:configChanges="keyboardHidden|screenSize">
android:configChanges="keyboardHidden|orientation|screenSize">
<meta-data android:name="android.app.lib_name" android:value="sfml-activity" />
<meta-data android:name="sfml.app.lib_name" android:value="sfml-example" />

View File

@ -23,6 +23,8 @@ int main(int argc, char *argv[])
music.play();
sf::View view = window.getDefaultView();
while (window.isOpen())
{
sf::Event event;
@ -33,6 +35,13 @@ int main(int argc, char *argv[])
{
window.close();
}
if (event.type == sf::Event::Resized)
{
view.setSize(event.size.width, event.size.height);
view.setCenter(event.size.width/2, event.size.height/2);
window.setView(view);
}
}
if (sf::Touch::isDown(0))