Catch up
This commit is contained in:
parent
521f440d16
commit
5929980e9b
@ -6,7 +6,6 @@
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height)
|
||||
{
|
||||
|
||||
JniInitApp<TMyApplication>(width, height, 320.f, 480.f);
|
||||
}
|
||||
|
||||
|
@ -17,18 +17,6 @@ using namespace SE;
|
||||
|
||||
extern "C" {
|
||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height);
|
||||
/*JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_StopSounds(JNIEnv * env, jobject obj);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Update(JNIEnv * env, jobject obj, long dt);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Destroy(JNIEnv * env, jobject obj);
|
||||
JNIEXPORT int JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_IsInited(JNIEnv * env, jobject obj);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapUpAfterMove(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time);
|
||||
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_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time);
|
||||
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_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode);
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
import fishrungames.engine.GLViewAncestor;
|
||||
import fishrungames.engine.FileWrapper;
|
||||
import fishrungames.engine.EngineWrapper;
|
||||
|
||||
|
||||
class GLView extends GLViewAncestor
|
||||
@ -18,8 +18,6 @@ class GLView extends GLViewAncestor
|
||||
static long lastTimeStamp;
|
||||
static boolean gameIsInited = false;
|
||||
|
||||
static boolean callDestroy = false;
|
||||
|
||||
public GLView(Context context)
|
||||
{
|
||||
//Change this method? Don't forget to change method below!
|
||||
@ -55,7 +53,7 @@ class GLView extends GLViewAncestor
|
||||
|
||||
long currentTimeStamp = c.getTimeInMillis();
|
||||
|
||||
FileWrapper.Update(currentTimeStamp - lastTimeStamp);
|
||||
EngineWrapper.Update(currentTimeStamp - lastTimeStamp);
|
||||
|
||||
lastTimeStamp = currentTimeStamp;
|
||||
}
|
||||
@ -63,9 +61,6 @@ class GLView extends GLViewAncestor
|
||||
|
||||
public void onSurfaceChanged(GL10 gl, int width, int height)
|
||||
{
|
||||
|
||||
//JniWrapper.Destroy();
|
||||
|
||||
JniWrapper.Init(width,height);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package fishrungames.salmonjnitemplate;
|
||||
|
||||
import fishrungames.engine.FileWrapper;
|
||||
import fishrungames.engine.EngineWrapper;
|
||||
|
||||
//Deprecated
|
||||
//import fishrungames.androidjnitemplate.R;
|
||||
@ -36,45 +36,17 @@ public class MainActivity extends Activity
|
||||
|
||||
GLView mView;
|
||||
|
||||
boolean IsScrolling = false;
|
||||
|
||||
float PrevMovePosX = 0;
|
||||
float PrevMovePosY = 0;
|
||||
|
||||
private GestureDetector gestureDetector;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle)
|
||||
{
|
||||
|
||||
super.onCreate(icicle);
|
||||
|
||||
gestureDetector = new GestureDetector(new MyGestureListener());
|
||||
EngineWrapper.LoadSalmonEngineLibrary();
|
||||
|
||||
FileWrapper.LoadSalmonEngineLibrary();
|
||||
EngineWrapper.SetActivityInstance(this);
|
||||
EngineWrapper.SetupEnviroment();
|
||||
|
||||
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();
|
||||
}*/
|
||||
|
||||
String apkFilePath = null;
|
||||
ApplicationInfo appInfo = null;
|
||||
@ -88,28 +60,23 @@ public class MainActivity extends Activity
|
||||
}
|
||||
apkFilePath = appInfo.sourceDir;
|
||||
|
||||
FileWrapper.SetupApkFilePath(apkFilePath);
|
||||
EngineWrapper.SetupApkFilePath(apkFilePath);
|
||||
|
||||
mView = new GLView(getApplication());
|
||||
|
||||
|
||||
setContentView(mView);
|
||||
|
||||
EngineWrapper.SetView(mView);
|
||||
|
||||
}
|
||||
|
||||
class JniDestroyRunnable implements Runnable
|
||||
{
|
||||
public void run ()
|
||||
{
|
||||
FileWrapper.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
|
||||
mView.queueEvent(new JniDestroyRunnable());
|
||||
EngineWrapper.CallDestroy();
|
||||
super.onPause();
|
||||
mView.onPause();
|
||||
}
|
||||
@ -131,130 +98,15 @@ public class MainActivity extends Activity
|
||||
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event)
|
||||
{
|
||||
int ascii_keycode = keyCode;
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_DEL)
|
||||
{
|
||||
ascii_keycode = 8; //Hack - getUnicodeChar does not recognize backspace
|
||||
}
|
||||
else
|
||||
{
|
||||
ascii_keycode = event.getUnicodeChar();
|
||||
}
|
||||
|
||||
FileWrapper.OnKeyPress(ascii_keycode);
|
||||
EngineWrapper.ProcessKeyDown(keyCode, event);
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(MotionEvent event)
|
||||
{
|
||||
/*
|
||||
if (event.getAction() == MotionEvent.ACTION_UP)
|
||||
{
|
||||
if (IsScrolling)
|
||||
{
|
||||
float x = event.getX();
|
||||
float y = (float) mView.getHeight() - event.getY();
|
||||
|
||||
JniWrapper.OnTapUpAfterShift(x, y, event.getEventTime());
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (event.getAction() == MotionEvent.ACTION_MOVE)
|
||||
{
|
||||
float x = event.getX();
|
||||
float y = (float) mView.getHeight() - event.getY();
|
||||
|
||||
float oldX = PrevMovePosX;
|
||||
float oldY = (float) mView.getHeight() - PrevMovePosY;
|
||||
|
||||
|
||||
float shiftX = x - oldX;
|
||||
float shiftY = y - oldY;
|
||||
|
||||
if (Math.abs(shiftX) > 0.001f || Math.abs(shiftY) > 0.001f)
|
||||
{
|
||||
FileWrapper.OnScroll(-shiftX, -shiftY, event.getEventTime());
|
||||
}
|
||||
|
||||
PrevMovePosX = event.getX();
|
||||
PrevMovePosY = event.getY();
|
||||
|
||||
IsScrolling = true;
|
||||
|
||||
}
|
||||
/*
|
||||
if (gestureDetector.onTouchEvent(event))
|
||||
{
|
||||
return true;
|
||||
}*/
|
||||
|
||||
if (event.getAction() == MotionEvent.ACTION_UP)
|
||||
{
|
||||
|
||||
|
||||
float x = event.getX();
|
||||
float y = (float) mView.getHeight() - event.getY();
|
||||
|
||||
if (IsScrolling)
|
||||
{
|
||||
IsScrolling = false;
|
||||
FileWrapper.OnTapUpAfterMove(x, y, event.getEventTime());
|
||||
}
|
||||
else
|
||||
{
|
||||
FileWrapper.OnTapUp(x, y, event.getEventTime());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN)
|
||||
{
|
||||
float x = event.getX();
|
||||
float y = (float) mView.getHeight() - event.getY();
|
||||
|
||||
PrevMovePosX = event.getX();
|
||||
PrevMovePosY = event.getY();
|
||||
|
||||
FileWrapper.OnTapDown(x, y, event.getEventTime());
|
||||
|
||||
}
|
||||
EngineWrapper.ProcessTouchEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
class MyGestureListener extends SimpleOnGestureListener
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
|
||||
float velocityY)
|
||||
{
|
||||
FileWrapper.OnFling(velocityX, velocityY, e2.getEventTime());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onScroll(MotionEvent e1, MotionEvent e2,
|
||||
float distanceX, float distanceY)
|
||||
{
|
||||
|
||||
FileWrapper.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();
|
||||
|
||||
FileWrapper.OnTapDown(x, y, event.getEventTime());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user