mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
[Android] Added the example
This commit is contained in:
parent
860c232507
commit
6e57380e4f
32
examples/android/AndroidManifest.xml
Normal file
32
examples/android/AndroidManifest.xml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.example.sfml"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0" >
|
||||||
|
|
||||||
|
<uses-feature android:glEsVersion="0x00010001" />
|
||||||
|
|
||||||
|
<application android:label="@string/app_name"
|
||||||
|
android:icon="@drawable/sfml_logo"
|
||||||
|
android:hasCode="false"
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:debuggable="true">
|
||||||
|
|
||||||
|
<activity android:name="android.app.NativeActivity"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:icon="@drawable/sfml_logo"
|
||||||
|
android:configChanges="keyboardHidden|screenSize">
|
||||||
|
|
||||||
|
<meta-data android:name="android.app.lib_name" android:value="sfml-activity" />
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="9"
|
||||||
|
android:targetSdkVersion="17" />
|
||||||
|
</manifest>
|
BIN
examples/android/assets/canary.wav
Normal file
BIN
examples/android/assets/canary.wav
Normal file
Binary file not shown.
BIN
examples/android/assets/image.png
Normal file
BIN
examples/android/assets/image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
BIN
examples/android/assets/orchestral.ogg
Normal file
BIN
examples/android/assets/orchestral.ogg
Normal file
Binary file not shown.
BIN
examples/android/assets/sansation.ttf
Normal file
BIN
examples/android/assets/sansation.ttf
Normal file
Binary file not shown.
18
examples/android/jni/Android.mk
Normal file
18
examples/android/jni/Android.mk
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_MODULE := sfml-example
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := main.cpp
|
||||||
|
|
||||||
|
LOCAL_SHARED_LIBRARIES := sfml-system
|
||||||
|
LOCAL_SHARED_LIBRARIES += sfml-window
|
||||||
|
LOCAL_SHARED_LIBRARIES += sfml-graphics
|
||||||
|
LOCAL_SHARED_LIBRARIES += sfml-audio
|
||||||
|
LOCAL_SHARED_LIBRARIES += sfml-network
|
||||||
|
LOCAL_WHOLE_STATIC_LIBRARIES := sfml-main
|
||||||
|
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|
||||||
|
$(call import-module,sfml)
|
4
examples/android/jni/Application.mk
Normal file
4
examples/android/jni/Application.mk
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
APP_PLATFORM := android-17
|
||||||
|
APP_STL := stlport_shared
|
||||||
|
APP_ABI := armeabi-v7a
|
||||||
|
APP_MODULES := sfml-activity sfml-example
|
48
examples/android/jni/main.cpp
Normal file
48
examples/android/jni/main.cpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#include <SFML/System.hpp>
|
||||||
|
#include <SFML/Window.hpp>
|
||||||
|
#include <SFML/Graphics.hpp>
|
||||||
|
#include <SFML/Audio.hpp>
|
||||||
|
#include <SFML/Network.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "");
|
||||||
|
|
||||||
|
sf::Texture texture;
|
||||||
|
if(!texture.loadFromFile("image.png"))
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
sf::Sprite image(texture);
|
||||||
|
image.setPosition(0, 0);
|
||||||
|
image.setOrigin(texture.getSize().x/2, texture.getSize().y/2);
|
||||||
|
|
||||||
|
sf::Music music;
|
||||||
|
if(!music.openFromFile("canary.wav"))
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
music.play();
|
||||||
|
|
||||||
|
while (window.isOpen())
|
||||||
|
{
|
||||||
|
sf::Event event;
|
||||||
|
|
||||||
|
while (window.pollEvent(event))
|
||||||
|
{
|
||||||
|
if (event.type == sf::Event::Closed)
|
||||||
|
{
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sf::Touch::isDown(0))
|
||||||
|
{
|
||||||
|
sf::Vector2i position = sf::Touch::getPosition(0);
|
||||||
|
image.setPosition(position.x, position.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.clear(sf::Color::White);
|
||||||
|
window.draw(image);
|
||||||
|
window.display();
|
||||||
|
}
|
||||||
|
}
|
1
examples/android/project.properties
Normal file
1
examples/android/project.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
target=android-18
|
BIN
examples/android/res/drawable-hdpi/sfml_logo.png
Normal file
BIN
examples/android/res/drawable-hdpi/sfml_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
BIN
examples/android/res/drawable-ldpi/sfml_logo.png
Normal file
BIN
examples/android/res/drawable-ldpi/sfml_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
examples/android/res/drawable-mdpi/sfml_logo.png
Normal file
BIN
examples/android/res/drawable-mdpi/sfml_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
BIN
examples/android/res/drawable-xhdpi/sfml_logo.png
Normal file
BIN
examples/android/res/drawable-xhdpi/sfml_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
BIN
examples/android/res/drawable-xxhdpi/sfml_logo.png
Normal file
BIN
examples/android/res/drawable-xxhdpi/sfml_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.3 KiB |
4
examples/android/res/values/strings.xml
Normal file
4
examples/android/res/values/strings.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">SFML</string>
|
||||||
|
</resources>
|
Loading…
Reference in New Issue
Block a user