cocos2dx 怎样实现游戏时候保持屏幕常亮?大神们指点!
安卓的话,是需要jni调用
能具体点吗哥
PowerManager powerManager = null;
WakeLock wakeLock = null;
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
this.powerManager = (PowerManager)this.getSystemService(Context.POWER_SERVICE);
this.wakeLock = this.powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Lock");
}
public Cocos2dxGLSurfaceView onCreateView() {
Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
// sg should create stencil buffer
glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
return glSurfaceView;
}
static {
System.loadLibrary("cocos2dcpp");
}
@Override
public void onResume() {
super.onResume();
this.wakeLock.acquire();
}
@Override
public void onPause() {
super.onPause();
this.wakeLock.release();
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
this.wakeLock.release(); //解除保持唤醒
}
如果只需要使用屏幕常亮的话,可以修改java代码,需要调用其他相机之类的就需要jni调了
谢谢,非常感谢
ios如何实现呢?