@Override
  public 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();

    /*
    // fps controlling
    if (interval < Cocos2dxRenderer.sAnimationInterval) {
    	try {
    		// because we render it before, so we should sleep twice time interval
    		Thread.sleep((Cocos2dxRenderer.sAnimationInterval - interval) / Cocos2dxRenderer.NANOSECONDSPERMICROSECOND);
    	} catch (final Exception e) {
    	}
    }

    this.mLastTickInNanoSeconds = nowInNanoSeconds;
    */
  }
예제 #2
0
 /*
  * This function is called before Cocos2dxRenderer.nativeInit(), so the
  * width and height is correct.
  */
 @Override
 protected void onSizeChanged(
     final int pNewSurfaceWidth,
     final int pNewSurfaceHeight,
     final int pOldSurfaceWidth,
     final int pOldSurfaceHeight) {
   if (!isInEditMode()) {
     mCocosRenderer.setScreenWidthAndHeight(pNewSurfaceWidth, pNewSurfaceHeight);
   }
 }
예제 #3
0
 private String getContentText() {
   return mCocosRenderer.getContentText();
 }
 @Override
 public void onSurfaceCreated(final GL10 pGL10, final EGLConfig pEGLConfig) {
   Cocos2dxRenderer.nativeInit(this.mScreenWidth, this.mScreenHeight);
   this.mLastTickInNanoSeconds = System.nanoTime();
 }
 public void handleDeleteBackward() {
   Cocos2dxRenderer.nativeDeleteBackward();
 }
 public String getContentText() {
   return Cocos2dxRenderer.nativeGetContentText();
 }
 public void handleOnResume() {
   Cocos2dxRenderer.nativeOnResume();
 }
 public void handleInsertText(final String pText) {
   Cocos2dxRenderer.nativeInsertText(pText);
 }
 public void handleOnPause() {
   Cocos2dxRenderer.nativeOnPause();
 }
 public void handleKeyDown(final int pKeyCode) {
   Cocos2dxRenderer.nativeKeyDown(pKeyCode);
 }
 public void handleActionMove(final int[] pIDs, final float[] pXs, final float[] pYs) {
   Cocos2dxRenderer.nativeTouchesMove(pIDs, pXs, pYs);
 }
 public void handleActionUp(final int pID, final float pX, final float pY) {
   Cocos2dxRenderer.nativeTouchesEnd(pID, pX, pY);
 }
 public void handleActionDown(final int pID, final float pX, final float pY) {
   Cocos2dxRenderer.nativeTouchesBegin(pID, pX, pY);
 }