COCOS2DX New development of the game, the hand is very hot, the need for friends can refer to.
COCOS2DX new research and development of the game, mobile phone running on the phone is very hot, and later listen to other project groups to share that can be resolved by reducing the frame of the problem, the original is cocos2dx default of 60, later modified to 30, the test found that mobile phone fever problem solved.
To modify the code:
AppDelegate.cpp
Set FPS. The default value is 1.0/60 if you don ' t call this
Pdirector->setanimationinterval (1.0/30);
And there is: Cocos2dxrenderer.java
//private static long Sanimationinterval = (long) (1.0/60 * cocos2dxrenderer.nanosecondspersecond);Private Static LongSanimationinterval = (Long) (1.0/ -*cocos2dxrenderer.nanosecondspersecond); @Override Public voidondrawframe (Final GL10 gl) {/** FPS controlling algorithm is not accurate, and it would slow down fps* on some devices. So comment FPS controlling code.*/FinalLongNowinnanoseconds =system.nanotime ();//should render a frame when ondrawframe () are called or there is a//"Ghost"Cocos2dxrenderer.nativerender (); finalLongAfterrendernano =system.nanotime ();//final long interval = afterrendernano-mlasttickinnanoseconds-cocos2dxrenderer.sanimationinterval;//afterrendernano-nowinnanoseconds;//nowinnanoseconds-this.mlasttickinnanoseconds;FinalLongInterval = Afterrendernano-nowinnanoseconds;//fps controllingif(Interval <cocos2dxrenderer.sanimationinterval) {//log.d ("Ondrawframe", "Cancel Frame" + interval + "/" +cocos2dxrenderer.sanimationinterval);Try {//because we render it before, so we should sleep twice time intervalThread.Sleep ((Cocos2dxrenderer.sanimationinterval-Interval)/cocos2dxrenderer.nanosecondspermicrosecond);} Catch(Final Exception e) {}}//this.mlasttickinnanoseconds = nowinnanoseconds;}
COCOS2DX new game, very hot solution when the hand is running