FPS Display

  ... the case you feel the need for a new feature or want to submit one.

FPS Display

Postby anoopch » Wed Feb 09, 2011 1:33 pm

An option to see the frames per second count...
It would help to decide to add or remove certain objects when they take too much load...

Like in Cocos2d
anoopch
 
Posts: 2
Joined: Wed Feb 09, 2011 12:42 pm
Location: India

Re: FPS Display

Postby Duiker101 » Wed Feb 09, 2011 2:17 pm

it's at the beginning of the onLoadScene() method in evry example...

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 this.mEngine.registerUpdateHandler(new FPSLogger());
Parsed in 0.010 seconds, using GeSHi 1.0.8.4

Just look at your logcat


The changeabletext example will show you a better implementation
http://code.google.com/p/andengineexamp ... ample.java
"I do not agree with what you have to say, but I'll defend to the death your right to say it." Voltaire
Duiker101
 
Posts: 264
Joined: Tue Feb 01, 2011 11:28 am
Location: Italy

Re: FPS Display

Postby codejoy » Tue Feb 15, 2011 11:11 pm

Is there anyway to do this to the HUD? SO I can see my fps on my device in real time without having it wired?
codejoy
 
Posts: 69
Joined: Fri Nov 19, 2010 12:15 am

Re: FPS Display

Postby Duiker101 » Tue Feb 15, 2011 11:42 pm

of curse use always the same code to create the hud (Remember if you declare text in a method set it as final ) and then update the text with an handler:

Code that should work but is untested:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. final FPSCounter fpsCounter = new FPSCounter();
  2.                 this.mEngine.registerUpdateHandler(fpsCounter);
  3.  
  4. public HUD hud=new HUD();
  5. final ChangeableText text = new ChangeableText(10, 10, this.mFont, "FPS:", "FPS: XXXXX".length());
  6. hud.getLastChild().attachChild(text);
  7. camera.setHUD(this.hud);
  8.  
  9. scene.registerUpdateHandler(new TimerHandler(1 / 20.0f, true, new ITimerCallback() {
  10.                         @Override
  11.                         public void onTimePassed(final TimerHandler pTimerHandler) {
  12.                                  text.setText("FPS: " + fpsCounter.getFPS());
  13.                         }
  14.                 }));
  15.  
  16.  
Parsed in 0.011 seconds, using GeSHi 1.0.8.4



P.S.
even if a bit out of date the ChangeableTextExample does exactly this, the only difference is that the instead of attaching the Text to the scene it is attached to the HUD witch is attached to the scene.
"I do not agree with what you have to say, but I'll defend to the death your right to say it." Voltaire
Duiker101
 
Posts: 264
Joined: Tue Feb 01, 2011 11:28 am
Location: Italy


Return to Features

Who is online

Users browsing this forum: No registered users and 4 guests