mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-05-04 08:31:47 +00:00
fps meter
This commit is contained in:
parent
6f7b0b5c7b
commit
6993f18626
3 changed files with 38 additions and 0 deletions
|
|
@ -8,6 +8,8 @@ class ProfilerUI {
|
||||||
var fpsCounter:Text;
|
var fpsCounter:Text;
|
||||||
var debugProfiler:h3d.impl.Benchmark;
|
var debugProfiler:h3d.impl.Benchmark;
|
||||||
|
|
||||||
|
public var fps:Float;
|
||||||
|
|
||||||
public static var instance:ProfilerUI;
|
public static var instance:ProfilerUI;
|
||||||
|
|
||||||
public function new(s2d:h2d.Scene) {
|
public function new(s2d:h2d.Scene) {
|
||||||
|
|
@ -36,6 +38,7 @@ class ProfilerUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function update(fps:Float) {
|
public static function update(fps:Float) {
|
||||||
|
instance.fps = fps;
|
||||||
// instance.fpsCounter.text = "FPS: " + fps;
|
// instance.fpsCounter.text = "FPS: " + fps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,7 @@ class Settings {
|
||||||
Window.getInstance().displayMode = optionsSettings.isFullScreen ? FullscreenResize : Windowed;
|
Window.getInstance().displayMode = optionsSettings.isFullScreen ? FullscreenResize : Windowed;
|
||||||
#end
|
#end
|
||||||
AudioManager.updateVolumes();
|
AudioManager.updateVolumes();
|
||||||
|
Window.getInstance().vsync = optionsSettings.vsync;
|
||||||
|
|
||||||
MarbleGame.canvas.render(MarbleGame.canvas.scene2d);
|
MarbleGame.canvas.render(MarbleGame.canvas.scene2d);
|
||||||
save();
|
save();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package gui;
|
package gui;
|
||||||
|
|
||||||
|
import src.ProfilerUI;
|
||||||
|
import hxd.App;
|
||||||
import hxd.res.Image;
|
import hxd.res.Image;
|
||||||
import hxd.Window;
|
import hxd.Window;
|
||||||
import h3d.shader.AlphaMult;
|
import h3d.shader.AlphaMult;
|
||||||
|
|
@ -68,6 +70,8 @@ class PlayGui {
|
||||||
|
|
||||||
var _init:Bool;
|
var _init:Bool;
|
||||||
|
|
||||||
|
var fpsMeter:GuiText;
|
||||||
|
|
||||||
public function dispose() {
|
public function dispose() {
|
||||||
if (_init) {
|
if (_init) {
|
||||||
playGuiCtrl.dispose();
|
playGuiCtrl.dispose();
|
||||||
|
|
@ -138,6 +142,8 @@ class PlayGui {
|
||||||
initCenterText();
|
initCenterText();
|
||||||
initPowerupBox();
|
initPowerupBox();
|
||||||
initTexts();
|
initTexts();
|
||||||
|
if (Settings.optionsSettings.frameRateVis)
|
||||||
|
initFPSMeter();
|
||||||
|
|
||||||
if (Util.isTouchDevice()) {
|
if (Util.isTouchDevice()) {
|
||||||
MarbleGame.instance.touchInput.showControls(this.playGuiCtrl);
|
MarbleGame.instance.touchInput.showControls(this.playGuiCtrl);
|
||||||
|
|
@ -388,6 +394,30 @@ class PlayGui {
|
||||||
playGuiCtrl.addChild(alertTextCtrl);
|
playGuiCtrl.addChild(alertTextCtrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initFPSMeter() {
|
||||||
|
var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
|
||||||
|
var domcasual32b = new BitmapFont(domcasual32fontdata.entry);
|
||||||
|
@:privateAccess domcasual32b.loader = ResourceLoader.loader;
|
||||||
|
var bfont = domcasual32b.toSdfFont(cast 26 * Settings.uiScale, MultiChannel);
|
||||||
|
|
||||||
|
var fpsMeterCtrl = new GuiImage(ResourceLoader.getResource("data/ui/game/transparency-fps.png", ResourceLoader.getImage, this.imageResources)
|
||||||
|
.toTile());
|
||||||
|
fpsMeterCtrl.position = new Vector(544, 448);
|
||||||
|
fpsMeterCtrl.horizSizing = Left;
|
||||||
|
fpsMeterCtrl.vertSizing = Top;
|
||||||
|
fpsMeterCtrl.extent = new Vector(96, 32);
|
||||||
|
|
||||||
|
fpsMeter = new GuiText(bfont);
|
||||||
|
fpsMeter.horizSizing = Width;
|
||||||
|
fpsMeter.vertSizing = Height;
|
||||||
|
fpsMeter.position = new Vector(10, 3);
|
||||||
|
fpsMeter.text.textColor = 0;
|
||||||
|
fpsMeter.extent = new Vector(96, 32);
|
||||||
|
fpsMeterCtrl.addChild(fpsMeter);
|
||||||
|
|
||||||
|
playGuiCtrl.addChild(fpsMeterCtrl);
|
||||||
|
}
|
||||||
|
|
||||||
public function setHelpTextOpacity(value:Float) {
|
public function setHelpTextOpacity(value:Float) {
|
||||||
helpTextForeground.text.color.a = value;
|
helpTextForeground.text.color.a = value;
|
||||||
helpTextBackground.text.color.a = value;
|
helpTextBackground.text.color.a = value;
|
||||||
|
|
@ -537,5 +567,9 @@ class PlayGui {
|
||||||
if (this.powerupImageObject != null)
|
if (this.powerupImageObject != null)
|
||||||
this.powerupImageObject.update(timeState);
|
this.powerupImageObject.update(timeState);
|
||||||
this.powerupImageScene.setElapsedTime(timeState.dt);
|
this.powerupImageScene.setElapsedTime(timeState.dt);
|
||||||
|
|
||||||
|
if (this.fpsMeter != null) {
|
||||||
|
this.fpsMeter.text.text = '${cast (ProfilerUI.instance.fps, Int)} fps';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue