轉載自:https://blog.csdn.net/justforthedream/article/details/36902249
貌似cocos2d-x沒有接口直接做這個功能
而各個平臺又不一樣,所以只能對于不同的平臺做不同的設置
首先android,在自己的activity的onCreate方法里添加一句getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);即可保持屏幕常亮
其次ios,[ [ UIApplication sharedApplication ] setIdleTimerDisabled:YES ] ;這句加到AppController.mm文件的
didFinishLaunchingWithOptions方法里面,添加到
[[UIApplication sharedApplication] setStatusBarHidden: YES];這句后面就好。經測試,這個方法ok~