1 decade ago by Joncom
I noticed there's a FPS displaying in the debug panel...
I was just curious if there was a function to bring this into my game?
I was just curious if there was a function to bring this into my game?
This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact
Quote from empika
Thanks Graphikos, glad my plugin can still be of some use :)
Instructions of how to use the plugin are here Joncom https://github.com/empika/ImpactJS-Plugins/blob/master/Readme.markdown
var x = ig.system.width/2, y = ig.system.height/2;
var x = ig.system.width/2, y = ig.system.height/2;
Quote from empika
var x = ig.system.width/2, y = ig.system.height/2;
This gets the mid-point of the game screen, looks like it has no actual affect on the debug plugin though ;)
// this.debugDisplay.draw(info, display_fps, display_average, average_time, interval_count)
// info, array: this will display each array element on a new line
// display_fps, bool: pass in true or false to either show the FPS or not. defaults to true
// display_average, bool: pass in true or false to either show the average FPS over a period of time or not.
// defaults to false
// average_time, integer: amount of of time between samples. defaults to 10000 (10 seconds)
// interval_count, integer: amount of samples to take over time. defaults to 500
this.debugDisplay.draw(["my", "info", "here"], true, true, 10000, 100);
this.debugDisplay.draw(["my", "info", "here"], true, true, 10000, 100);
ig.module(
'game.states.free'
)
.requires(
'impact.game',
'game.plugins.debugdisplay'
)
.defines(function(){
Free = ig.Game.extend({
font: new ig.Font( 'media/04b03.font.png' ),
Backgroundimg: new ig.Image( 'media/game_backdrop_1.png' ),
gravity: 300, // All entities are affected by this
clearColor:null, //'rgba(200,200,200,1)',
init: function() {
//debug display
this.DebugDisplay = new DebugDisplay( this.font )
//end debug display
ig.game.maintimer = new ig.Timer(5);
//console.log("height",ig.system.height,"width",ig.system.width);
},
update: function(){
if(ig.game.maintimer.delta() >= 0){ //when timer hits zero
ig.system.setGame(GameOver); //change the game state
console.log ("end",ig.game.maintimer.delta()); //show the end time
alerted(); //provs that timers in setgames are avialbel elsewere.
}
this.parent();
},
draw: function() {
this.Backgroundimg.draw( 0, 0 );
this.parent();
//debug display
var x = ig.system.width/2, y = ig.system.height/2;
//this.debugDisplay.draw( info, display_fps, display_average, average_time, interval_count);
// info, array: this will display each array element on a new line
// display_fps, bool: pass in true or false to either show the FPS or not. defaults to true
// display_average, bool: pass in true or false to either show the average FPS over a period of time or not.
// defaults to false
// average_time, integer: amount of of time between samples. defaults to 10000 (10 seconds)
// interval_count, integer: amount of samples to take over time. defaults to 500
this.debugDisplay.draw(["my", "info", "here"], true, true, 10000, 100);
//
},
});
});