mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-02-18 20:21:17 +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 debugProfiler:h3d.impl.Benchmark;
|
||||
|
||||
public var fps:Float;
|
||||
|
||||
public static var instance:ProfilerUI;
|
||||
|
||||
public function new(s2d:h2d.Scene) {
|
||||
|
|
@ -36,6 +38,7 @@ class ProfilerUI {
|
|||
}
|
||||
|
||||
public static function update(fps:Float) {
|
||||
instance.fps = fps;
|
||||
// instance.fpsCounter.text = "FPS: " + fps;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ class Settings {
|
|||
Window.getInstance().displayMode = optionsSettings.isFullScreen ? FullscreenResize : Windowed;
|
||||
#end
|
||||
AudioManager.updateVolumes();
|
||||
Window.getInstance().vsync = optionsSettings.vsync;
|
||||
|
||||
MarbleGame.canvas.render(MarbleGame.canvas.scene2d);
|
||||
save();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package gui;
|
||||
|
||||
import src.ProfilerUI;
|
||||
import hxd.App;
|
||||
import hxd.res.Image;
|
||||
import hxd.Window;
|
||||
import h3d.shader.AlphaMult;
|
||||
|
|
@ -68,6 +70,8 @@ class PlayGui {
|
|||
|
||||
var _init:Bool;
|
||||
|
||||
var fpsMeter:GuiText;
|
||||
|
||||
public function dispose() {
|
||||
if (_init) {
|
||||
playGuiCtrl.dispose();
|
||||
|
|
@ -138,6 +142,8 @@ class PlayGui {
|
|||
initCenterText();
|
||||
initPowerupBox();
|
||||
initTexts();
|
||||
if (Settings.optionsSettings.frameRateVis)
|
||||
initFPSMeter();
|
||||
|
||||
if (Util.isTouchDevice()) {
|
||||
MarbleGame.instance.touchInput.showControls(this.playGuiCtrl);
|
||||
|
|
@ -388,6 +394,30 @@ class PlayGui {
|
|||
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) {
|
||||
helpTextForeground.text.color.a = value;
|
||||
helpTextBackground.text.color.a = value;
|
||||
|
|
@ -537,5 +567,9 @@ class PlayGui {
|
|||
if (this.powerupImageObject != null)
|
||||
this.powerupImageObject.update(timeState);
|
||||
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