Cocos2d-X學習——Android不同裝置FPS不同問題

來源:互聯網
上載者:User

標籤:

2014-07-16

環境:Cocos2dx 2.2.4

AppDelegate.cpp中FPS設定為 60

pDirector->setAnimationInterval(1.0 / 60);


問題:在兩台Android機器上跑。 兩台的FPS不一樣

I9100: 4.0系統,FPS 約60,(改動FPS為30,也會改變)

S5700: 2.3系統,FPS 約80,(改動FPS為30,照樣80)


這樣就導致了在遊戲刷幀的時候,兩台機器跑的速度不一樣了。


解決方案例如以下(應該僅僅有Android有這個問題)

改動Android中cocos2dx的 Cocos2dxRenderer.java代碼

(PS:假設依照官方的凝視改動,也不能達到FPS一致)

@Overridepublic void onDrawFrame(final GL10 gl) {/* * FPS controlling algorithm is not accurate, and it will 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() is called or there is a// "ghost"Cocos2dxRenderer.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) / Cocos2dxRenderer.NANOSECONDSPERMICROSECOND);} catch (final Exception e) {}}//this.mLastTickInNanoSeconds = nowInNanoSeconds;//*/}

以上,謝謝


本文地址:http://blog.csdn.net/you_and_me12/article/details/37885461

Cocos2d-X學習——Android不同裝置FPS不同問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.