2014-07-16
Environment: COCOS2DX 2.2.4
AppDelegate.cpp in FPS set to 60
Pdirector->setanimationinterval (1.0/60);
Problem: Run on two Android devices. Two FPS is not the same
i9100:4.0 system, fps approx. 60, (change FPS to 30, also changes)
s5700:2.3 system, fps approx. 80, (change FPS to 30, still 80)
This results in the game brush frame, the two machines run at a different speed.
Workaround such as the following (should only have Android have this problem)
Change the Cocos2dxrenderer.java code of COCOS2DX in Android
(PS: Assuming that the official gaze changes, also cannot achieve FPS consistent)
@Overridepublic void Ondrawframe (Final GL10 GL) {/* * FPS controlling algorithm is not accurate, and it'll slow down fps * On some devices. So comment FPS controlling code. *////*final Long nowinnanoseconds = System.nanotime ();//final long interval = nowinnanoseconds- this.mlasttickinnanoseconds;//*///should render a frame when ondrawframe () are called or there is a//"ghost" Cocos2dxrende Rer.nativerender (); final long afterinnanoseconds = System.nanotime (); final long interval = afterinnanoseconds- nowinnanoseconds;///*//fps controllingif (interval < Cocos2dxrenderer.sanimationinterval) {try {//because we render It before, so we should sleep twice time Intervalthread.sleep ((cocos2dxrenderer.sanimationinterval-interval)/Cocos2dxR Enderer. Nanosecondspermicrosecond);} catch (Final Exception e) {}}//this.mlasttickinnanoseconds = nowinnanoseconds;//*/}
Above, thank you
This address: http://blog.csdn.net/you_and_me12/article/details/37885461
Cocos2d-x learning--android different device fps problems