mirror of https://github.com/axmolengine/axmol.git
Merge remote branch 'origin/master'
This commit is contained in:
commit
6c8efba1e2
|
@ -29,6 +29,28 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
|
|||
setRenderer(mRenderer);
|
||||
}
|
||||
|
||||
public void onPause(){
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleOnPause();
|
||||
}
|
||||
});
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
public void onResume(){
|
||||
super.onResume();
|
||||
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleOnResume();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(final MotionEvent event) {
|
||||
// these data are used in ACTION_MOVE and ACTION_CANCEL
|
||||
final int pointerNumber = event.getPointerCount();
|
||||
|
|
|
@ -64,6 +64,14 @@ public class Cocos2dxRenderer implements GLSurfaceView.Renderer {
|
|||
nativeKeyDown(keyCode);
|
||||
}
|
||||
|
||||
public void handleOnPause(){
|
||||
nativeOnPause();
|
||||
}
|
||||
|
||||
public void handleOnResume(){
|
||||
nativeOnResume();
|
||||
}
|
||||
|
||||
public static void setAnimationInterval(double interval){
|
||||
animationInterval = (long)(interval * NANOSECONDSPERSECOND);
|
||||
}
|
||||
|
@ -75,4 +83,6 @@ public class Cocos2dxRenderer implements GLSurfaceView.Renderer {
|
|||
private static native boolean nativeKeyDown(int keyCode);
|
||||
private static native void nativeRender();
|
||||
private static native void nativeInit(int w, int h);
|
||||
private static native void nativeOnPause();
|
||||
private static native void nativeOnResume();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ THE SOFTWARE.
|
|||
#include "CCTouchDispatcher.h"
|
||||
#include "CCFileUtils.h"
|
||||
#include "CCGeometry.h"
|
||||
#include "platform/android/CCAccelerometer_android.h"
|
||||
#include "CCAccelerometer.h"
|
||||
#include "CCApplication.h"
|
||||
#include <android/log.h>
|
||||
|
||||
#if 0
|
||||
|
@ -173,6 +174,20 @@ extern "C"
|
|||
cocos2d::CCDirector::sharedDirector()->getOpenGLView()->getDelegate()->touchesCancelled(&set, NULL);
|
||||
}
|
||||
|
||||
// handle onPause and onResume
|
||||
|
||||
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause()
|
||||
{
|
||||
CCApplication::sharedApplication().applicationDidEnterBackground();
|
||||
}
|
||||
|
||||
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume()
|
||||
{
|
||||
// Shared OpenGL View instance doesn't exist yet when Activity.onResume is first called
|
||||
if (CCDirector::sharedDirector()->getOpenGLView())
|
||||
CCApplication::sharedApplication().applicationWillEnterForeground();
|
||||
}
|
||||
|
||||
#define KEYCODE_BACK 0x04
|
||||
#define KEYCODE_MENU 0x52
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
|
||||
#if CC_ENABLE_PROFILERS
|
||||
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "CCObject.h"
|
||||
#include "platform/platform.h"
|
||||
|
|
|
@ -29,6 +29,28 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
|
|||
setRenderer(mRenderer);
|
||||
}
|
||||
|
||||
public void onPause(){
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleOnPause();
|
||||
}
|
||||
});
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
public void onResume(){
|
||||
super.onResume();
|
||||
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleOnResume();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(final MotionEvent event) {
|
||||
// these data are used in ACTION_MOVE and ACTION_CANCEL
|
||||
final int pointerNumber = event.getPointerCount();
|
||||
|
|
|
@ -64,6 +64,14 @@ public class Cocos2dxRenderer implements GLSurfaceView.Renderer {
|
|||
nativeKeyDown(keyCode);
|
||||
}
|
||||
|
||||
public void handleOnPause(){
|
||||
nativeOnPause();
|
||||
}
|
||||
|
||||
public void handleOnResume(){
|
||||
nativeOnResume();
|
||||
}
|
||||
|
||||
public static void setAnimationInterval(double interval){
|
||||
animationInterval = (long)(interval * NANOSECONDSPERSECOND);
|
||||
}
|
||||
|
@ -75,4 +83,6 @@ public class Cocos2dxRenderer implements GLSurfaceView.Renderer {
|
|||
private static native boolean nativeKeyDown(int keyCode);
|
||||
private static native void nativeRender();
|
||||
private static native void nativeInit(int w, int h);
|
||||
private static native void nativeOnPause();
|
||||
private static native void nativeOnResume();
|
||||
}
|
||||
|
|
|
@ -32,11 +32,15 @@ public class TestsDemo extends Cocos2dxActivity{
|
|||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
mGLView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
mGLView.onResume();
|
||||
}
|
||||
|
||||
protected void onDestroy()
|
||||
|
|
Loading…
Reference in New Issue