mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-12-24 17:02:50 +00:00
middle messages for time travel bonus
This commit is contained in:
parent
808e35a4af
commit
81bf76bfb2
3 changed files with 59 additions and 1 deletions
|
|
@ -1625,6 +1625,17 @@ class MarbleWorld extends Scheduler {
|
|||
MarbleGame.instance.touchInput.powerupButton.setEnabled(false);
|
||||
}
|
||||
|
||||
public function addBonusTime(t:Float) {
|
||||
this.bonusTime += t;
|
||||
if (t > 0) {
|
||||
this.playGui.addMiddleMessage('+${t}s', 0x99ff99);
|
||||
} else if (t < 0) {
|
||||
this.playGui.addMiddleMessage('${t}s', 0xff9999);
|
||||
} else {
|
||||
this.playGui.addMiddleMessage('+0s', 0xcccccc);
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the current interpolated orientation quaternion. */
|
||||
public function getOrientationQuat(time:Float) {
|
||||
var completion = Util.clamp((time - this.orientationChangeTime) / 0.3, 0, 1);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ import h3d.mat.Texture;
|
|||
import src.Settings;
|
||||
import src.Util;
|
||||
|
||||
typedef MiddleMessage = {
|
||||
ctrl:GuiText,
|
||||
age:Float,
|
||||
}
|
||||
|
||||
class PlayGui {
|
||||
var scene2d:h2d.Scene;
|
||||
|
||||
|
|
@ -76,6 +81,8 @@ class PlayGui {
|
|||
|
||||
var fpsMeter:GuiText;
|
||||
|
||||
var middleMessages:Array<MiddleMessage> = [];
|
||||
|
||||
public function dispose() {
|
||||
if (_init) {
|
||||
playGuiCtrl.dispose();
|
||||
|
|
@ -630,5 +637,45 @@ class PlayGui {
|
|||
if (this.fpsMeter != null) {
|
||||
this.fpsMeter.text.text = '${Math.floor(ProfilerUI.instance.fps)} fps';
|
||||
}
|
||||
this.updateMiddleMessages(timeState.dt);
|
||||
}
|
||||
|
||||
function updateMiddleMessages(dt:Float) {
|
||||
var itermessages = this.middleMessages.copy();
|
||||
if (itermessages.length > 0) {
|
||||
var thismsg = itermessages.shift();
|
||||
thismsg.age += dt;
|
||||
if (thismsg.age > 0.6) {
|
||||
this.middleMessages.remove(thismsg);
|
||||
thismsg.ctrl.parent.removeChild(thismsg.ctrl); // Delete it
|
||||
} else {
|
||||
if (thismsg.age >= 0.3) {
|
||||
thismsg.ctrl.text.alpha = 1 - (thismsg.age - 0.3) / 0.3;
|
||||
}
|
||||
thismsg.ctrl.text.y -= (0.1 / playGuiCtrl.extent.y) * scene2d.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addMiddleMessage(text:String, color:Int) {
|
||||
var markerFelt32fontdata = ResourceLoader.getFileEntry("data/font/MarkerFelt.fnt");
|
||||
var markerFelt32b = new BitmapFont(markerFelt32fontdata.entry);
|
||||
@:privateAccess markerFelt32b.loader = ResourceLoader.loader;
|
||||
var markerFelt32 = markerFelt32b.toSdfFont(cast 44 * Settings.uiScale, MultiChannel);
|
||||
|
||||
var middleMsg = new GuiText(markerFelt32);
|
||||
middleMsg.position = new Vector(200, 50);
|
||||
middleMsg.extent = new Vector(400, 100);
|
||||
middleMsg.horizSizing = Center;
|
||||
middleMsg.vertSizing = Center;
|
||||
middleMsg.text.text = text;
|
||||
middleMsg.justify = Center;
|
||||
middleMsg.text.textColor = color;
|
||||
middleMsg.text.filter = new h2d.filter.DropShadow(1.414, 0.785, 0x000000F, 1, 0, 0.4, 1, true);
|
||||
this.playGuiCtrl.addChild(middleMsg);
|
||||
middleMsg.render(scene2d);
|
||||
middleMsg.text.y -= (25 / playGuiCtrl.extent.y) * scene2d.height;
|
||||
|
||||
this.middleMessages.push({ctrl: middleMsg, age: 0});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,6 @@ class TimeTravel extends PowerUp {
|
|||
}
|
||||
|
||||
public function use(time:TimeState) {
|
||||
level.bonusTime += this.timeBonus;
|
||||
level.addBonusTime(this.timeBonus);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue