mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 14:21:04 +08:00
[Android] Updated example to handle screen rotation events (#531)
This commit is contained in:
parent
6302cc0762
commit
775277b8fb
@ -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" />
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user