catch up
This commit is contained in:
parent
9da15411a1
commit
46015b9dc8
@ -2,176 +2,9 @@
|
||||
|
||||
#include "main_code.h"
|
||||
|
||||
boost::shared_ptr<TAndroidApplication> App(new TAndroidApplication);
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height)
|
||||
{
|
||||
try
|
||||
{
|
||||
App->OuterInit(width, height, 480.f, 320.f);
|
||||
}
|
||||
catch (ErrorCommon e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
JniInitApp<TAndroidApplication>(width, height, 480.f, 320.f);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_StopSounds(JNIEnv * env, jobject obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
App->OuterDeinit(); //Clean up what is left at previous launch (if applicable)
|
||||
}
|
||||
catch (ErrorCommon e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_Update(JNIEnv * env, jobject obj, long dt)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (!App->IsInited())
|
||||
{
|
||||
return;
|
||||
}
|
||||
App->OuterDraw();
|
||||
App->OuterUpdate(dt);
|
||||
|
||||
}
|
||||
catch (ErrorCommon e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT int JNICALL Java_fishrungames_doublehitballs_JniWrapper_IsInited(JNIEnv * env, jobject obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (App->IsInited())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
catch (ErrorCommon e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_Destroy(JNIEnv * env, jobject obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
*Console<<"Destroy!!!\n";
|
||||
}
|
||||
catch (ErrorCommon e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, float x, float y, long time)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!App->IsInited())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
x = x * 480.f / Renderer->GetScreenWidth();
|
||||
y = y * 320.f / Renderer->GetScreenHeight();
|
||||
|
||||
//*Console<<"Tap down "<<tostr(Renderer->GetScreenHeight())<<" "<<tostr(y)<<endl;
|
||||
OnTapDownSignal(vec2(x, y));
|
||||
|
||||
}
|
||||
catch (ErrorCommon e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, float x, float y, long time)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if (!App->IsInited())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
x = x * 480.f / Renderer->GetScreenWidth();
|
||||
y = y * 320.f / Renderer->GetScreenHeight();
|
||||
|
||||
OnTapUpSignal(vec2(x, y));
|
||||
|
||||
}
|
||||
catch (ErrorCommon e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, float x, float y, long time)
|
||||
{
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if (!App->IsInited())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
velocityX = velocityX * 480.f / Renderer->GetScreenWidth();
|
||||
velocityY = velocityY * 320.f / Renderer->GetScreenHeight();
|
||||
|
||||
OnFlingSignal(vec2(velocityX, velocityY));
|
||||
|
||||
}
|
||||
catch (ErrorCommon e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!App->IsInited())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
distanceX = distanceX * 480.f / Renderer->GetScreenWidth();
|
||||
distanceY = distanceY * 320.f / Renderer->GetScreenHeight();
|
||||
OnScrollSignal(vec2(distanceX, distanceY));
|
||||
|
||||
}
|
||||
catch (ErrorCommon e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -10,24 +10,15 @@
|
||||
|
||||
#include "boost/shared_ptr.hpp"
|
||||
|
||||
#include "main_code.h"
|
||||
|
||||
#include "include/Engine.h"
|
||||
|
||||
using namespace SE;
|
||||
|
||||
|
||||
class TAndroidApplication;
|
||||
extern boost::shared_ptr<TAndroidApplication> App;
|
||||
|
||||
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_StopSounds(JNIEnv * env, jobject obj);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_Update(JNIEnv * env, jobject obj, long dt);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_Destroy(JNIEnv * env, jobject obj);
|
||||
JNIEXPORT int JNICALL Java_fishrungames_doublehitballs_JniWrapper_IsInited(JNIEnv * env, jobject obj);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time);
|
||||
};
|
||||
|
||||
|
||||
|
@ -127,8 +127,6 @@ void TAndroidApplication::InnerDeinit()
|
||||
|
||||
}
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
|
||||
void TAndroidApplication::InnerOnTapDown(vec2 p)
|
||||
{
|
||||
OnTapDownSignal(vec2(p.v[0], p.v[1]));
|
||||
@ -148,30 +146,6 @@ void TAndroidApplication::OnFling(vec2 v)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_IOS
|
||||
|
||||
void TAndroidApplication::InnerOnTapDown(vec2 p)
|
||||
{
|
||||
OnTapDownSignal(vec2(p.v[0], p.v[1]));
|
||||
}
|
||||
|
||||
void TAndroidApplication::InnerOnTapUp(vec2 p)
|
||||
{
|
||||
OnTapUpSignal(vec2(p.v[0], p.v[1]));
|
||||
}
|
||||
|
||||
void TAndroidApplication::InnerOnMove(vec2 shift)
|
||||
{
|
||||
OnScrollSignal(shift);
|
||||
}
|
||||
|
||||
void TAndroidApplication::OnFling(vec2 v)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void TAndroidApplication::ApplySignalsToMenu()
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef GL_CODE_H_INCLUDED
|
||||
#define GL_CODE_H_INCLUDED
|
||||
#ifndef MAIN_CODE_H_INCLUDED
|
||||
#define MAIN_CODE_H_INCLUDED
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
#include "android_api.h"
|
||||
@ -32,10 +32,6 @@
|
||||
using namespace SE;
|
||||
|
||||
|
||||
class TAndroidApplication;
|
||||
extern TAndroidApplication* Application;
|
||||
|
||||
|
||||
extern boost::signal<void (vec2)> OnTapUpSignal;
|
||||
extern boost::signal<void (vec2)> OnTapDownSignal;
|
||||
extern boost::signal<void (vec2)> OnFlingSignal;
|
||||
@ -150,5 +146,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
extern TAndroidApplication* Application;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
package fishrungames.doublehitballs;
|
||||
|
||||
import fishrungames.engine.FileWrapper;
|
||||
import fishrungames.engine.EngineWrapper;
|
||||
|
||||
//Deprecated
|
||||
//import fishrungames.doublehitballs.R;
|
||||
@ -11,6 +11,7 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Bundle;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
@ -23,40 +24,15 @@ public class GL2JNIActivity extends Activity
|
||||
|
||||
GLView mView;
|
||||
|
||||
boolean IsScrolling = false;
|
||||
|
||||
private GestureDetector gestureDetector;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle)
|
||||
{
|
||||
|
||||
super.onCreate(icicle);
|
||||
|
||||
gestureDetector = new GestureDetector(new MyGestureListener());
|
||||
|
||||
FileWrapper.LoadHalibutEngineLibrary();
|
||||
FileWrapper.SetActivityInstance(this);
|
||||
FileWrapper.SetupEnviroment();
|
||||
/*
|
||||
* Deprecated
|
||||
try
|
||||
|
||||
{
|
||||
for (Field f : R.raw.class.getFields())
|
||||
{
|
||||
FileWrapper.AddToFileMap(f.getName(), f.getInt(null));
|
||||
}
|
||||
|
||||
} catch (IllegalArgumentException e)
|
||||
{
|
||||
FileWrapper.ConsoleOut("IllegalArgumentException\n");
|
||||
onStop();
|
||||
} catch (IllegalAccessException e)
|
||||
{
|
||||
FileWrapper.ConsoleOut("IllegalAccessException\n");
|
||||
onStop();
|
||||
}*/
|
||||
EngineWrapper.LoadSalmonEngineLibrary();
|
||||
EngineWrapper.SetActivityInstance(this);
|
||||
EngineWrapper.SetupEnviroment();
|
||||
|
||||
String apkFilePath = null;
|
||||
ApplicationInfo appInfo = null;
|
||||
@ -66,23 +42,25 @@ public class GL2JNIActivity extends Activity
|
||||
} catch (NameNotFoundException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
throw new RuntimeException("Unable to locate assets, aborting...");
|
||||
}
|
||||
apkFilePath = appInfo.sourceDir;
|
||||
|
||||
FileWrapper.SetupApkFilePath(apkFilePath);
|
||||
EngineWrapper.SetupApkFilePath(apkFilePath);
|
||||
|
||||
mView = new GLView(getApplication());
|
||||
|
||||
setContentView(mView);
|
||||
|
||||
EngineWrapper.SetView(mView);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
FileWrapper.ConsoleOut("OnPause\n");
|
||||
JniWrapper.StopSounds();
|
||||
EngineWrapper.CallDestroy();
|
||||
super.onPause();
|
||||
mView.onPause();
|
||||
}
|
||||
@ -97,82 +75,18 @@ public class GL2JNIActivity extends Activity
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
|
||||
//FileWrapper.ConsoleOut("OnStop\n");
|
||||
//StopSounds();
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
public boolean onTouchEvent (MotionEvent event)
|
||||
{
|
||||
if (gestureDetector.onTouchEvent(event))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
if (event.getAction() == MotionEvent.ACTION_MOVE)
|
||||
{
|
||||
float x = event.getX();
|
||||
float y = (float)mView.getHeight()-event.getY();
|
||||
|
||||
|
||||
|
||||
float shiftX = x - event.getHistoricalX(0, event.getHistorySize()-2);
|
||||
|
||||
if(IsScrolling)
|
||||
{
|
||||
IsScrolling = false;
|
||||
}
|
||||
|
||||
JniWrapper.OnScroll(x, y, event.getEventTime());
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
if (event.getAction() == MotionEvent.ACTION_UP)
|
||||
{
|
||||
float x = event.getX();
|
||||
float y = (float)mView.getHeight()-event.getY();
|
||||
|
||||
if(IsScrolling)
|
||||
{
|
||||
IsScrolling = false;
|
||||
}
|
||||
|
||||
JniWrapper.OnTapUp(x, y, event.getEventTime());
|
||||
|
||||
}
|
||||
EngineWrapper.ProcessTouchEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
class MyGestureListener extends SimpleOnGestureListener
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event)
|
||||
{
|
||||
@Override
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
|
||||
{
|
||||
JniWrapper.OnFling(velocityX, velocityY, e2.getEventTime());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
|
||||
{
|
||||
JniWrapper.OnScroll(distanceX, distanceY, e2.getEventTime());
|
||||
IsScrolling = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onDown(MotionEvent event)
|
||||
{
|
||||
|
||||
float x = event.getX();
|
||||
float y = (float)mView.getHeight()-event.getY();
|
||||
|
||||
JniWrapper.OnTapDown(x, y, event.getEventTime());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
EngineWrapper.ProcessKeyDown(keyCode, event);
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
}
|
@ -11,6 +11,8 @@ import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
import fishrungames.engine.GLViewAncestor;
|
||||
|
||||
import fishrungames.engine.EngineWrapper;
|
||||
|
||||
class GLView extends GLViewAncestor
|
||||
{
|
||||
static long lastTimeStamp;
|
||||
@ -49,7 +51,7 @@ class GLView extends GLViewAncestor
|
||||
|
||||
long currentTimeStamp = c.getTimeInMillis();
|
||||
|
||||
JniWrapper.Update(currentTimeStamp - lastTimeStamp);
|
||||
EngineWrapper.Update(currentTimeStamp - lastTimeStamp);
|
||||
|
||||
lastTimeStamp = currentTimeStamp;
|
||||
}
|
||||
@ -57,13 +59,9 @@ class GLView extends GLViewAncestor
|
||||
|
||||
public void onSurfaceChanged(GL10 gl, int width, int height)
|
||||
{
|
||||
if (JniWrapper.IsInited() == 1)
|
||||
{
|
||||
JniWrapper.Destroy();
|
||||
}
|
||||
JniWrapper.Init(width,height);
|
||||
}
|
||||
|
||||
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config)
|
||||
{
|
||||
//Do nothing.
|
||||
|
@ -8,14 +8,5 @@ public class JniWrapper
|
||||
|
||||
|
||||
public static native void Init(int width, int height);
|
||||
public static native void Update(long dt);
|
||||
public static native void StopSounds();
|
||||
public static native void Destroy();
|
||||
public static native int IsInited();
|
||||
public static native void OnTapDown(float x, float y, long time);
|
||||
public static native void OnTapUp(float x, float y, long time);
|
||||
public static native void OnTapMove(float x, float y, long time);
|
||||
|
||||
public static native void OnFling(float velocityX, float velocityY, long time);
|
||||
public static native void OnScroll(float distanceX, float distanceY, long time);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user