Skip to content

Commit

Permalink
[Android] Updated example to handle screen rotation events (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
intjelic committed Jun 21, 2014
1 parent 6302cc0 commit 775277b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/android/AndroidManifest.xml
Expand Up @@ -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" />
Expand Down
9 changes: 9 additions & 0 deletions examples/android/jni/main.cpp
Expand Up @@ -23,6 +23,8 @@ int main(int argc, char *argv[])

music.play();

sf::View view = window.getDefaultView();

while (window.isOpen())
{
sf::Event event;
Expand All @@ -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))
Expand Down

0 comments on commit 775277b

Please sign in to comment.