ios stuff

This commit is contained in:
Vladislav Khorev 2013-02-05 20:44:27 +00:00
parent 46b17db96e
commit 19ee54778c
2 changed files with 19 additions and 44 deletions

View File

@ -23,7 +23,7 @@
<application <application
android:icon="@drawable/ic_menu_template" android:label="Salmon Jni Template"> android:icon="@drawable/ic_menu_template" android:label="Salmon Jni Template">
<activity android:name="fishrungames.salmonjnitemplate.MainActivity" <activity android:name="fishrungames.salmonjnitemplate.MainActivity"
android:screenOrientation="landscape" android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask" android:launchMode="singleTask"
android:configChanges="orientation|keyboardHidden" android:configChanges="orientation|keyboardHidden"

View File

@ -3,7 +3,7 @@
#include "main_code.h" #include "main_code.h"
#include "boost\thread.hpp" #include "boost\thread.hpp"
boost::shared_ptr<TMyApplication> App(new TMyApplication); boost::shared_ptr<TMyApplication> App;
boost::mutex m; boost::mutex m;
@ -13,14 +13,13 @@ JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Init(JNIEn
m.lock(); m.lock();
try try
{ {
if (App->IsInited())
{
App->OuterDeinit(); //Clean up what is left at previous launch (if applicable)
}
App->OuterInit(width, height, 480.f, 320.f); CreateEngine();
App = boost::shared_ptr<TMyApplication>(new TMyApplication);
App->OuterInit(width, height, 320.f, 480.f);
App->Inited = true;
} }
catch (...) catch (...)
{ {
@ -40,11 +39,10 @@ JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Update(JNI
m.lock(); m.lock();
try try
{ {
if (App->IsInited())
{
App->OuterDraw(); App->OuterDraw();
App->OuterUpdate(dt); App->OuterUpdate(dt);
}
} }
catch (...) catch (...)
@ -58,14 +56,7 @@ m.lock();
JNIEXPORT int JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_IsInited(JNIEnv * env, jobject obj) JNIEXPORT int JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_IsInited(JNIEnv * env, jobject obj)
{ {
if (App->IsInited())
{
return 1;
}
else
{
return 0; return 0;
}
} }
@ -74,11 +65,14 @@ JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Destroy(JN
m.lock(); m.lock();
try try
{ {
if (App->IsInited())
{
App->OuterDeinit(); App->OuterDeinit();
App->Inited = false;
} delete App;
App = NULL;
DestroyEngine();
} }
catch (...) catch (...)
@ -91,66 +85,51 @@ m.lock();
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, float x, float y, long time) JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, float x, float y, long time)
{ {
*Console<<"OuterOnTapDown";
m.lock();
try try
{ {
*Console<<"OuterOnTapDown2";
App->OuterOnTapDown(vec2(x,y)); App->OuterOnTapDown(vec2(x,y));
} }
catch (...) catch (...)
{ {
throw; throw;
} }
m.unlock();
} }
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, float x, float y, long time) JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, float x, float y, long time)
{ {
*Console<<"OuterOnTapUp";
m.lock();
try try
{ {
*Console<<"OuterOnTapUp2";
App->OuterOnTapUp(vec2(x,y)); App->OuterOnTapUp(vec2(x,y));
} }
catch (...) catch (...)
{ {
throw; throw;
} }
m.unlock();
} }
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapUpAfterShift(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time) JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapUpAfterShift(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time)
{ {
m.lock();
try try
{ {
*Console<<"OuterOnTapUp2";
App->OuterOnTapUpAfterShift(vec2(x,y)); App->OuterOnTapUpAfterShift(vec2(x,y));
} }
catch (...) catch (...)
{ {
throw; throw;
} }
m.unlock();
} }
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, float x, float y, long time) JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, float x, float y, long time)
{ {
*Console<<"OuterOnMove";
m.lock();
try try
{ {
*Console<<"OuterOnMove2";
App->OuterOnMove(vec2(x,y)); App->OuterOnMove(vec2(x,y));
} }
catch (...) catch (...)
{ {
throw; throw;
} }
m.unlock();
} }
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time) JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time)
@ -161,18 +140,14 @@ JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnFling(JN
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time) JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time)
{ {
*Console<<"OuterOnScroll";
m.lock();
try try
{ {
*Console<<"OuterOnScroll2";
App->OuterOnMove(vec2(distanceX,distanceY)); App->OuterOnMove(vec2(distanceX,distanceY));
} }
catch (...) catch (...)
{ {
throw; throw;
} }
m.unlock();
} }
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode) JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode)