gar Registered User |
Quote
|
2016-10-30 22:40:51 |
|
Somebody know how to do that ?
|
niko Moderator |
Quote
|
2016-10-31 06:00:08 |
|
There is nothing for that available, but it would be easy to script a behavior which could print the current FPS on a 2D overlay. Maybe that would be a solution?
|
jaimezegpi Guest |
Quote
|
2016-11-02 16:25:30 |
|
I think this help.
https://www.isaacsukin.com/news/...
<script async src="//jsfiddle.net/IceCreamYou/rnqLfz14/9/embed/js,html,css,result/dark/"></script>
|
gar Registered User |
Quote
|
2016-11-04 00:20:58 |
|
Thank you jaimezegpi.
This is what I did . It it seems to work OK in Windows 10 and WebGL but I can't get it to work on my Android Phone or Androide Tablet.
Could someone take a look at the code to se if I have done something wrong ?
(Copy the code and save it as : behavior_fps.js in your behavior folder.)
// This Coppercube behavior must be attached to a 2D Overlay2, where it will show the FPS. // Converted to CopperCube by : Gar // Origional : Isaac Sukin // https://www.isaacsukin.com/news/2015/01/detailed-explanation-javascript-game-loops-and-timingfps-control // // The following embedded xml is for the editor and describes how the behavior can be edited: // Supported types are: int, float, string, bool, color, vect3d, scenenode, texture, action /* <behavior jsname="behavior_fps" description="FPS counter"> </behavior> */
behavior_fps = function() { /* var fps = 60, framesThisSecond = 0, lastFpsUpdate = 0; */ this.fps = 60; this.framesThisSecond = 0; this.lastFpsUpdate = 0; /* this.Speed = 1.0; this.TimeOfDay = -1; this.LastTime = -1; */ };
// called every frame. // 'node' is the scene node where this behavior is attached to. // 'timeMs' the current time in milliseconds of the scene. // Returns 'true' if something changed, and 'false' if not. behavior_fps.prototype.onAnimate = function(n, timeMs) { if (timeMs > this.lastFpsUpdate + 1000) { // update every second this.fps = 0.25 * this.framesThisSecond + (1 - 0.25) * this.fps; // compute the new FPS ccbSetSceneNodeProperty(n, "Text", this.fps); this.lastFpsUpdate = timeMs; this.framesThisSecond = 0; } this.framesThisSecond++; }
bold textbold text
|
niko Moderator |
Quote
|
2016-11-04 05:26:33 |
|
Seems ok for me, maybe replace the line with ccbSetSceneNodeProperty with this one, it could help:
ccbSetSceneNodeProperty(n, "Text", this.fps + ' ');
Which forces the value to be a string instead of a float.
|
gar Registered User |
Quote
|
2016-11-04 17:36:03 |
|
wrote:
Seems ok for me, maybe replace the line with ccbSetSceneNodeProperty with this one, it could help:
ccbSetSceneNodeProperty(n, "Text", this.fps + ' ');
Which forces the value to be a string instead of a float.
Thank you Niko
Here is the new version :
// This Coppercube behavior must be attached to a 2D Overlay2, where it will show the FPS. // Converted to CopperCube by : Gar // Origional : Isaac Sukin // https://www.isaacsukin.com/news/2015/01/detailed-explanation-javascript-game-loops-and-timingfps-control // // The following embedded xml is for the editor and describes how the behavior can be edited: // Supported types are: int, float, string, bool, color, vect3d, scenenode, texture, action /* <behavior jsname="behavior_fps" description="FPS counter"> </behavior> */
behavior_fps = function() { /* var fps = 60, framesThisSecond = 0, lastFpsUpdate = 0; */ this.fps = 60; this.framesThisSecond = 0; this.lastFpsUpdate = 0; /* this.Speed = 1.0; this.TimeOfDay = -1; this.LastTime = -1; */ };
// called every frame. // 'node' is the scene node where this behavior is attached to. // 'timeMs' the current time in milliseconds of the scene. // Returns 'true' if something changed, and 'false' if not. behavior_fps.prototype.onAnimate = function(n, timeMs) { if (timeMs > this.lastFpsUpdate + 1000) { // update every second this.fps = 0.25 * this.framesThisSecond + (1 - 0.25) * this.fps; // compute the new FPS ccbSetSceneNodeProperty(n, "Text", Math.round(this.fps) + ' '); this.lastFpsUpdate = timeMs; this.framesThisSecond = 0; } this.framesThisSecond++; }
|