Cocos2d-x learning--android different device fps problems

Source: Internet
Author: User

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, (modified FPS is 30, will also change)

s5700:2.3 system, fps approx. 80, (modified FPS is 30, still 80)


This results in the game brush frame, the two machines run at a different speed.


The workaround is as follows (only Android should have this problem)

Modify the Cocos2dxrenderer.java code of COCOS2DX in Android

(PS: If the official comments are modified, it will not be consistent with FPS)

@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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.