mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
gui render crap
This commit is contained in:
parent
cbc0257509
commit
e8cd086e80
7 changed files with 385 additions and 98 deletions
|
|
@ -701,12 +701,7 @@ class MarbleWorld extends Scheduler {
|
|||
var spherebounds = new Bounds();
|
||||
var center = marble.collider.transform.getPosition();
|
||||
var radius = marble._radius;
|
||||
spherebounds.xMin = center.x - radius;
|
||||
spherebounds.yMin = center.y - radius;
|
||||
spherebounds.zMin = center.z - radius;
|
||||
spherebounds.xMax = center.x + radius;
|
||||
spherebounds.yMax = center.y + radius;
|
||||
spherebounds.zMax = center.z + radius;
|
||||
spherebounds.addSpherePos(center.x, center.y, center.z, radius);
|
||||
|
||||
var gjkSphere = new collision.gjk.Sphere();
|
||||
gjkSphere.position = center;
|
||||
|
|
|
|||
26
src/gui/GuiAnim.hx
Normal file
26
src/gui/GuiAnim.hx
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package gui;
|
||||
|
||||
import h2d.Anim;
|
||||
import h2d.Scene;
|
||||
import h2d.Tile;
|
||||
import h2d.Bitmap;
|
||||
|
||||
@:publicFields
|
||||
class GuiAnim extends GuiControl {
|
||||
var anim:Anim;
|
||||
|
||||
public function new(textures:Array<Tile>) {
|
||||
super();
|
||||
this.anim = new Anim(textures, 0);
|
||||
}
|
||||
|
||||
public override function render(scene2d:Scene) {
|
||||
super.render(scene2d);
|
||||
var renderRect = this.getRenderRectangle();
|
||||
anim.setPosition(renderRect.position.x, renderRect.position.y);
|
||||
anim.scaleX = renderRect.extent.x / anim.getFrame().width;
|
||||
anim.scaleY = renderRect.extent.y / anim.getFrame().height;
|
||||
if (!scene2d.contains(anim))
|
||||
scene2d.addChild(anim);
|
||||
}
|
||||
}
|
||||
101
src/gui/GuiControl.hx
Normal file
101
src/gui/GuiControl.hx
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
package gui;
|
||||
|
||||
import h2d.Scene;
|
||||
import h2d.col.Bounds;
|
||||
import hxd.Window;
|
||||
import h3d.Vector;
|
||||
|
||||
enum HorizSizing {
|
||||
Right;
|
||||
Width;
|
||||
Left;
|
||||
Center;
|
||||
Relative;
|
||||
}
|
||||
|
||||
enum VertSizing {
|
||||
Bottom;
|
||||
Height;
|
||||
Top;
|
||||
Center;
|
||||
Relative;
|
||||
}
|
||||
|
||||
@:publicFields
|
||||
class GuiControl {
|
||||
var horizSizing:HorizSizing = Right;
|
||||
var vertSizing:VertSizing = Bottom;
|
||||
|
||||
var position:Vector;
|
||||
var extent:Vector;
|
||||
|
||||
var children:Array<GuiControl> = [];
|
||||
|
||||
var parent:GuiControl;
|
||||
|
||||
public function new() {}
|
||||
|
||||
public function render(scene2d:Scene) {
|
||||
for (c in children) {
|
||||
c.render(scene2d);
|
||||
}
|
||||
}
|
||||
|
||||
public function getRenderRectangle() {
|
||||
var rect = new Rect(this.position, this.extent);
|
||||
var parentRect:Rect = null;
|
||||
if (this.parent != null) {
|
||||
parentRect = this.parent.getRenderRectangle();
|
||||
rect.position = parentRect.position.add(this.position);
|
||||
}
|
||||
if (this.horizSizing == HorizSizing.Width) {
|
||||
if (this.parent != null)
|
||||
rect.extent.x = parentRect.extent.x;
|
||||
else
|
||||
rect.extent.x = Window.getInstance().width;
|
||||
}
|
||||
if (this.vertSizing == VertSizing.Height) {
|
||||
if (this.parent != null)
|
||||
rect.extent.y = parentRect.extent.y;
|
||||
else
|
||||
rect.extent.y = Window.getInstance().height;
|
||||
}
|
||||
|
||||
if (this.horizSizing == HorizSizing.Center) {
|
||||
if (this.parent != null) {
|
||||
rect.position.x = parentRect.position.x + parentRect.extent.x / 2 - rect.extent.x / 2;
|
||||
}
|
||||
}
|
||||
if (this.vertSizing == VertSizing.Center) {
|
||||
if (this.parent != null) {
|
||||
rect.position.y = parentRect.position.y + parentRect.extent.y / 2 - rect.extent.y / 2;
|
||||
}
|
||||
}
|
||||
if (this.horizSizing == HorizSizing.Right) {
|
||||
if (this.parent != null) {
|
||||
rect.position.x = parentRect.position.x + this.position.x;
|
||||
}
|
||||
}
|
||||
if (this.vertSizing == VertSizing.Bottom) {
|
||||
if (this.parent != null) {
|
||||
rect.position.y = parentRect.position.y + this.position.y;
|
||||
}
|
||||
}
|
||||
if (this.horizSizing == HorizSizing.Left) {
|
||||
if (this.parent != null) {
|
||||
rect.position.x = parentRect.extent.x - (parent.extent.x - this.position.x);
|
||||
}
|
||||
}
|
||||
if (this.vertSizing == VertSizing.Top) {
|
||||
if (this.parent != null) {
|
||||
rect.position.y = parentRect.extent.y - (parent.extent.y - this.position.y);
|
||||
}
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
public function addChild(ctrl:GuiControl) {
|
||||
this.children.push(ctrl);
|
||||
ctrl.parent = this;
|
||||
}
|
||||
}
|
||||
25
src/gui/GuiImage.hx
Normal file
25
src/gui/GuiImage.hx
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package gui;
|
||||
|
||||
import h2d.Scene;
|
||||
import h2d.Tile;
|
||||
import h2d.Bitmap;
|
||||
|
||||
@:publicFields
|
||||
class GuiImage extends GuiControl {
|
||||
var bmp:Bitmap;
|
||||
|
||||
public function new(texture:Tile) {
|
||||
super();
|
||||
this.bmp = new Bitmap(texture);
|
||||
}
|
||||
|
||||
public override function render(scene2d:Scene) {
|
||||
super.render(scene2d);
|
||||
var renderRect = this.getRenderRectangle();
|
||||
bmp.setPosition(renderRect.position.x, renderRect.position.y);
|
||||
bmp.scaleX = renderRect.extent.x / bmp.tile.width;
|
||||
bmp.scaleY = renderRect.extent.y / bmp.tile.height;
|
||||
if (!scene2d.contains(bmp))
|
||||
scene2d.addChild(bmp);
|
||||
}
|
||||
}
|
||||
41
src/gui/GuiText.hx
Normal file
41
src/gui/GuiText.hx
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package gui;
|
||||
|
||||
import h2d.Scene;
|
||||
import hxd.res.BitmapFont;
|
||||
import h2d.Text;
|
||||
|
||||
enum Justification {
|
||||
Left;
|
||||
Right;
|
||||
Center;
|
||||
}
|
||||
|
||||
@:publicFields
|
||||
class GuiText extends GuiControl {
|
||||
var text:Text;
|
||||
var justify:Justification = Left;
|
||||
|
||||
public function new(font:BitmapFont) {
|
||||
super();
|
||||
this.text = new Text(font.toFont());
|
||||
}
|
||||
|
||||
public override function render(scene2d:Scene) {
|
||||
super.render(scene2d);
|
||||
var renderRect = this.getRenderRectangle();
|
||||
if (justify == Left) {
|
||||
text.setPosition(renderRect.position.x, renderRect.position.y);
|
||||
text.textAlign = Left;
|
||||
}
|
||||
if (justify == Right) {
|
||||
text.setPosition(renderRect.position.x + renderRect.extent.x, renderRect.position.y);
|
||||
text.textAlign = Right;
|
||||
}
|
||||
if (justify == Center) {
|
||||
text.setPosition(renderRect.position.x + renderRect.extent.x / 2, renderRect.position.y);
|
||||
text.textAlign = Center;
|
||||
}
|
||||
if (!scene2d.contains(text))
|
||||
scene2d.addChild(text);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package gui;
|
||||
|
||||
import hxd.snd.WavData;
|
||||
import gui.GuiControl.HorizSizing;
|
||||
import src.TimeState;
|
||||
import format.gif.Data.Block;
|
||||
import hxd.res.BitmapFont;
|
||||
|
|
@ -23,32 +25,40 @@ class PlayGui {
|
|||
|
||||
public function new() {}
|
||||
|
||||
var timerNumbers:Array<Anim> = [];
|
||||
var timerPoint:Bitmap;
|
||||
var timerColon:Bitmap;
|
||||
var timerNumbers:Array<GuiAnim> = [];
|
||||
var timerPoint:GuiImage;
|
||||
var timerColon:GuiImage;
|
||||
|
||||
var gemCountNumbers:Array<Anim> = [];
|
||||
var gemCountSlash:Bitmap;
|
||||
var gemCountNumbers:Array<GuiAnim> = [];
|
||||
var gemCountSlash:GuiImage;
|
||||
var gemImageScene:h3d.scene.Scene;
|
||||
var gemImageSceneTarget:Texture;
|
||||
var gemImageObject:DtsObject;
|
||||
var gemImageSceneTargetBitmap:Bitmap;
|
||||
|
||||
var powerupBox:Bitmap;
|
||||
var powerupBox:GuiImage;
|
||||
var powerupImageScene:h3d.scene.Scene;
|
||||
var powerupImageSceneTarget:Texture;
|
||||
var powerupImageObject:DtsObject;
|
||||
|
||||
var RSGOCenterText:Anim;
|
||||
|
||||
var helpTextForeground:Text;
|
||||
var helpTextBackground:Text;
|
||||
var alertTextForeground:Text;
|
||||
var alertTextBackground:Text;
|
||||
var helpTextForeground:GuiText;
|
||||
var helpTextBackground:GuiText;
|
||||
var alertTextForeground:GuiText;
|
||||
var alertTextBackground:GuiText;
|
||||
|
||||
var playGuiCtrl:GuiControl;
|
||||
|
||||
public function init(scene2d:h2d.Scene) {
|
||||
this.scene2d = scene2d;
|
||||
|
||||
playGuiCtrl = new GuiControl();
|
||||
playGuiCtrl.position = new Vector();
|
||||
playGuiCtrl.extent = new Vector(640, 480);
|
||||
playGuiCtrl.horizSizing = Width;
|
||||
playGuiCtrl.vertSizing = Height;
|
||||
|
||||
var numberTiles = [];
|
||||
for (i in 0...10) {
|
||||
var tile = ResourceLoader.getImage('data/ui/game/numbers/${i}.png').toTile();
|
||||
|
|
@ -56,11 +66,11 @@ class PlayGui {
|
|||
}
|
||||
|
||||
for (i in 0...7) {
|
||||
timerNumbers.push(new Anim(numberTiles, 0, scene2d));
|
||||
timerNumbers.push(new GuiAnim(numberTiles));
|
||||
}
|
||||
|
||||
for (i in 0...4) {
|
||||
gemCountNumbers.push(new Anim(numberTiles, 0, scene2d));
|
||||
gemCountNumbers.push(new GuiAnim(numberTiles));
|
||||
}
|
||||
|
||||
var rsgo = [];
|
||||
|
|
@ -70,38 +80,62 @@ class PlayGui {
|
|||
rsgo.push(ResourceLoader.getImage("data/ui/game/outofbounds.png").toTile());
|
||||
RSGOCenterText = new Anim(rsgo, 0, scene2d);
|
||||
|
||||
timerPoint = new Bitmap(ResourceLoader.getImage('data/ui/game/numbers/point.png').toTile(), scene2d);
|
||||
timerColon = new Bitmap(ResourceLoader.getImage('data/ui/game/numbers/colon.png').toTile(), scene2d);
|
||||
gemCountSlash = new Bitmap(ResourceLoader.getImage('data/ui/game/numbers/slash.png').toTile(), scene2d);
|
||||
|
||||
powerupBox = new Bitmap(ResourceLoader.getImage('data/ui/game/powerup.png').toTile(), scene2d);
|
||||
powerupBox = new GuiImage(ResourceLoader.getImage('data/ui/game/powerup.png').toTile());
|
||||
initTimer();
|
||||
initGemCounter();
|
||||
initCenterText();
|
||||
initPowerupBox();
|
||||
initTexts();
|
||||
|
||||
playGuiCtrl.render(scene2d);
|
||||
}
|
||||
|
||||
public function initTimer() {
|
||||
var screenWidth = scene2d.width;
|
||||
var screenHeight = scene2d.height;
|
||||
var timerCtrl = new GuiControl();
|
||||
timerCtrl.horizSizing = HorizSizing.Center;
|
||||
timerCtrl.position = new Vector(215, 1);
|
||||
timerCtrl.extent = new Vector(234, 58);
|
||||
|
||||
function toScreenSpaceX(x:Float) {
|
||||
return screenWidth / 2 - (234 / 2) + x;
|
||||
}
|
||||
function toScreenSpaceY(y:Float) {
|
||||
return (y / 480) * screenHeight;
|
||||
}
|
||||
timerNumbers[0].position = new Vector(23, 0);
|
||||
timerNumbers[0].extent = new Vector(43, 55);
|
||||
|
||||
timerNumbers[0].x = toScreenSpaceX(23);
|
||||
timerNumbers[1].x = toScreenSpaceX(47);
|
||||
timerColon.x = toScreenSpaceX(67);
|
||||
timerNumbers[2].x = toScreenSpaceX(83);
|
||||
timerNumbers[3].x = toScreenSpaceX(107);
|
||||
timerPoint.x = toScreenSpaceX(127);
|
||||
timerNumbers[4].x = toScreenSpaceX(143);
|
||||
timerNumbers[5].x = toScreenSpaceX(167);
|
||||
timerNumbers[6].x = toScreenSpaceX(191);
|
||||
timerNumbers[1].position = new Vector(47, 0);
|
||||
timerNumbers[1].extent = new Vector(43, 55);
|
||||
|
||||
timerColon = new GuiImage(ResourceLoader.getImage('data/ui/game/numbers/colon.png').toTile());
|
||||
timerColon.position = new Vector(67, 0);
|
||||
timerColon.extent = new Vector(43, 55);
|
||||
|
||||
timerNumbers[2].position = new Vector(83, 0);
|
||||
timerNumbers[2].extent = new Vector(43, 55);
|
||||
|
||||
timerNumbers[3].position = new Vector(107, 0);
|
||||
timerNumbers[3].extent = new Vector(43, 55);
|
||||
|
||||
timerPoint = new GuiImage(ResourceLoader.getImage('data/ui/game/numbers/point.png').toTile());
|
||||
timerPoint.position = new Vector(127, 0);
|
||||
timerPoint.extent = new Vector(43, 55);
|
||||
|
||||
timerNumbers[4].position = new Vector(143, 0);
|
||||
timerNumbers[4].extent = new Vector(43, 55);
|
||||
|
||||
timerNumbers[5].position = new Vector(167, 0);
|
||||
timerNumbers[5].extent = new Vector(43, 55);
|
||||
|
||||
timerNumbers[6].position = new Vector(191, 0);
|
||||
timerNumbers[6].extent = new Vector(43, 55);
|
||||
|
||||
timerCtrl.addChild(timerNumbers[0]);
|
||||
timerCtrl.addChild(timerNumbers[1]);
|
||||
timerCtrl.addChild(timerColon);
|
||||
timerCtrl.addChild(timerNumbers[2]);
|
||||
timerCtrl.addChild(timerNumbers[3]);
|
||||
timerCtrl.addChild(timerPoint);
|
||||
timerCtrl.addChild(timerNumbers[4]);
|
||||
timerCtrl.addChild(timerNumbers[5]);
|
||||
timerCtrl.addChild(timerNumbers[6]);
|
||||
|
||||
playGuiCtrl.addChild(timerCtrl);
|
||||
}
|
||||
|
||||
public function initCenterText() {
|
||||
|
|
@ -132,11 +166,27 @@ class PlayGui {
|
|||
}
|
||||
|
||||
public function initGemCounter() {
|
||||
gemCountNumbers[0].x = 30;
|
||||
gemCountNumbers[1].x = 54;
|
||||
gemCountSlash.x = 75;
|
||||
gemCountNumbers[2].x = 96;
|
||||
gemCountNumbers[3].x = 120;
|
||||
gemCountNumbers[0].position = new Vector(30, 0);
|
||||
gemCountNumbers[0].extent = new Vector(43, 55);
|
||||
|
||||
gemCountNumbers[1].position = new Vector(54, 0);
|
||||
gemCountNumbers[1].extent = new Vector(43, 55);
|
||||
|
||||
gemCountSlash = new GuiImage(ResourceLoader.getImage('data/ui/game/numbers/slash.png').toTile());
|
||||
gemCountSlash.position = new Vector(75, 0);
|
||||
gemCountSlash.extent = new Vector(43, 55);
|
||||
|
||||
gemCountNumbers[2].position = new Vector(96, 0);
|
||||
gemCountNumbers[2].extent = new Vector(43, 55);
|
||||
|
||||
gemCountNumbers[3].position = new Vector(120, 0);
|
||||
gemCountNumbers[3].extent = new Vector(43, 55);
|
||||
|
||||
playGuiCtrl.addChild(gemCountNumbers[0]);
|
||||
playGuiCtrl.addChild(gemCountNumbers[1]);
|
||||
playGuiCtrl.addChild(gemCountSlash);
|
||||
playGuiCtrl.addChild(gemCountNumbers[2]);
|
||||
playGuiCtrl.addChild(gemCountNumbers[3]);
|
||||
|
||||
this.gemImageScene = new h3d.scene.Scene();
|
||||
var gemImageRenderer = cast(this.gemImageScene.renderer, h3d.scene.pbr.Renderer);
|
||||
|
|
@ -168,8 +218,11 @@ class PlayGui {
|
|||
}
|
||||
|
||||
function initPowerupBox() {
|
||||
powerupBox.x = scene2d.width - 102;
|
||||
powerupBox.y = 6;
|
||||
powerupBox.position = new Vector(538, 6);
|
||||
powerupBox.extent = new Vector(97, 96);
|
||||
powerupBox.horizSizing = Left;
|
||||
|
||||
playGuiCtrl.addChild(powerupBox);
|
||||
|
||||
this.powerupImageScene = new h3d.scene.Scene();
|
||||
var powerupImageRenderer = cast(this.powerupImageScene.renderer, h3d.scene.pbr.Renderer);
|
||||
|
|
@ -187,57 +240,89 @@ class PlayGui {
|
|||
var fontdata = ResourceLoader.loader.load("data/font/DomCasual32px.fnt");
|
||||
var bfont = new BitmapFont(fontdata.entry);
|
||||
@:privateAccess bfont.loader = ResourceLoader.loader;
|
||||
helpTextBackground = new Text(bfont.toFont(), scene2d);
|
||||
helpTextBackground.text = "Bruh";
|
||||
helpTextBackground.x = scene2d.width / 2 - helpTextBackground.textWidth / 2 + 1;
|
||||
helpTextBackground.y = scene2d.height * 0.45 + 1;
|
||||
helpTextBackground.textColor = 0x000000;
|
||||
|
||||
helpTextForeground = new Text(bfont.toFont(), scene2d);
|
||||
helpTextForeground.text = "Bruh";
|
||||
helpTextForeground.x = scene2d.width / 2 - helpTextForeground.textWidth / 2;
|
||||
helpTextForeground.y = scene2d.height * 0.45;
|
||||
helpTextForeground.textColor = 0xFFFFFF;
|
||||
var helpTextCtrl = new GuiControl();
|
||||
helpTextCtrl.position = new Vector(0, 210);
|
||||
helpTextCtrl.extent = new Vector(640, 60);
|
||||
helpTextCtrl.vertSizing = Center;
|
||||
helpTextCtrl.horizSizing = Width;
|
||||
|
||||
alertTextBackground = new Text(bfont.toFont(), scene2d);
|
||||
alertTextBackground.text = "Bruh";
|
||||
alertTextBackground.x = scene2d.width / 2 - alertTextBackground.textWidth / 2 + 1;
|
||||
alertTextBackground.y = scene2d.height - 102 + 1;
|
||||
alertTextBackground.textColor = 0x000000;
|
||||
helpTextBackground = new GuiText(bfont);
|
||||
helpTextBackground.text.textColor = 0x000000;
|
||||
helpTextBackground.position = new Vector(1, 1);
|
||||
helpTextBackground.extent = new Vector(640, 14);
|
||||
helpTextBackground.vertSizing = Height;
|
||||
helpTextBackground.horizSizing = Width;
|
||||
helpTextBackground.justify = Center;
|
||||
|
||||
alertTextForeground = new Text(bfont.toFont(), scene2d);
|
||||
alertTextForeground.text = "Bruh";
|
||||
alertTextForeground.x = scene2d.width / 2 - alertTextForeground.textWidth / 2;
|
||||
alertTextForeground.y = scene2d.height - 102;
|
||||
alertTextForeground.textColor = 0xFFE240;
|
||||
helpTextForeground = new GuiText(bfont);
|
||||
helpTextForeground.text.textColor = 0xFFFFFF;
|
||||
helpTextForeground.position = new Vector(0, 0);
|
||||
helpTextForeground.extent = new Vector(640, 16);
|
||||
helpTextForeground.vertSizing = Height;
|
||||
helpTextForeground.horizSizing = Width;
|
||||
helpTextForeground.justify = Center;
|
||||
|
||||
helpTextCtrl.addChild(helpTextBackground);
|
||||
helpTextCtrl.addChild(helpTextForeground);
|
||||
|
||||
var alertTextCtrl = new GuiControl();
|
||||
alertTextCtrl.position = new Vector(0, 378);
|
||||
alertTextCtrl.extent = new Vector(640, 98);
|
||||
alertTextCtrl.vertSizing = Top;
|
||||
alertTextCtrl.horizSizing = Width;
|
||||
|
||||
alertTextBackground = new GuiText(bfont);
|
||||
alertTextBackground.text.textColor = 0x000000;
|
||||
alertTextBackground.position = new Vector(1, 1);
|
||||
alertTextBackground.extent = new Vector(640, 32);
|
||||
alertTextBackground.vertSizing = Height;
|
||||
alertTextBackground.horizSizing = Width;
|
||||
alertTextBackground.justify = Center;
|
||||
|
||||
alertTextForeground = new GuiText(bfont);
|
||||
alertTextForeground.text.textColor = 0xFFE240;
|
||||
alertTextForeground.position = new Vector(0, 0);
|
||||
alertTextForeground.extent = new Vector(640, 32);
|
||||
alertTextForeground.vertSizing = Height;
|
||||
alertTextForeground.horizSizing = Width;
|
||||
alertTextForeground.justify = Center;
|
||||
|
||||
alertTextCtrl.addChild(alertTextBackground);
|
||||
alertTextCtrl.addChild(alertTextForeground);
|
||||
|
||||
playGuiCtrl.addChild(helpTextCtrl);
|
||||
playGuiCtrl.addChild(alertTextCtrl);
|
||||
}
|
||||
|
||||
public function setHelpTextOpacity(value:Float) {
|
||||
helpTextForeground.color.a = value;
|
||||
helpTextBackground.color.a = value;
|
||||
helpTextForeground.text.color.a = value;
|
||||
helpTextBackground.text.color.a = value;
|
||||
}
|
||||
|
||||
public function setAlertTextOpacity(value:Float) {
|
||||
alertTextForeground.color.a = value;
|
||||
alertTextBackground.color.a = value;
|
||||
alertTextForeground.text.color.a = value;
|
||||
alertTextBackground.text.color.a = value;
|
||||
}
|
||||
|
||||
public function setAlertText(text:String) {
|
||||
this.alertTextForeground.text = text;
|
||||
this.alertTextBackground.text = text;
|
||||
alertTextForeground.x = scene2d.width / 2 - alertTextForeground.textWidth / 2;
|
||||
alertTextForeground.y = scene2d.height - 102;
|
||||
alertTextBackground.x = scene2d.width / 2 - alertTextBackground.textWidth / 2 + 1;
|
||||
alertTextBackground.y = scene2d.height - 102 + 1;
|
||||
this.alertTextForeground.text.text = text;
|
||||
this.alertTextBackground.text.text = text;
|
||||
alertTextBackground.render(scene2d);
|
||||
// alertTextForeground.x = scene2d.width / 2 - alertTextForeground.textWidth / 2;
|
||||
// alertTextForeground.y = scene2d.height - 102;
|
||||
// alertTextBackground.x = scene2d.width / 2 - alertTextBackground.textWidth / 2 + 1;
|
||||
// alertTextBackground.y = scene2d.height - 102 + 1;
|
||||
}
|
||||
|
||||
public function setHelpText(text:String) {
|
||||
this.helpTextForeground.text = text;
|
||||
this.helpTextBackground.text = text;
|
||||
helpTextForeground.x = scene2d.width / 2 - helpTextForeground.textWidth / 2;
|
||||
helpTextForeground.y = scene2d.height * 0.45;
|
||||
helpTextBackground.x = scene2d.width / 2 - helpTextBackground.textWidth / 2 + 1;
|
||||
helpTextBackground.y = scene2d.height * 0.45 + 1;
|
||||
this.helpTextForeground.text.text = text;
|
||||
this.helpTextBackground.text.text = text;
|
||||
helpTextBackground.render(scene2d);
|
||||
// helpTextForeground.x = scene2d.width / 2 - helpTextForeground.textWidth / 2;
|
||||
// helpTextForeground.y = scene2d.height * 0.45;
|
||||
// helpTextBackground.x = scene2d.width / 2 - helpTextBackground.textWidth / 2 + 1;
|
||||
// helpTextBackground.y = scene2d.height * 0.45 + 1;
|
||||
}
|
||||
|
||||
public function setPowerupImage(powerupIdentifier:String) {
|
||||
|
|
@ -281,15 +366,15 @@ class PlayGui {
|
|||
public function formatGemCounter(collected:Int, total:Int) {
|
||||
if (total == 0) {
|
||||
for (number in gemCountNumbers) {
|
||||
number.visible = false;
|
||||
number.anim.visible = false;
|
||||
}
|
||||
gemCountSlash.visible = false;
|
||||
gemCountSlash.bmp.visible = false;
|
||||
gemImageSceneTargetBitmap.visible = false;
|
||||
} else {
|
||||
for (number in gemCountNumbers) {
|
||||
number.visible = true;
|
||||
number.anim.visible = true;
|
||||
}
|
||||
gemCountSlash.visible = true;
|
||||
gemCountSlash.bmp.visible = true;
|
||||
gemImageSceneTargetBitmap.visible = true;
|
||||
}
|
||||
|
||||
|
|
@ -299,10 +384,10 @@ class PlayGui {
|
|||
var collectedTenths = Math.floor(collected / 10);
|
||||
var collectedOnes = collected % 10;
|
||||
|
||||
gemCountNumbers[0].currentFrame = collectedTenths;
|
||||
gemCountNumbers[1].currentFrame = collectedOnes;
|
||||
gemCountNumbers[2].currentFrame = totalTenths;
|
||||
gemCountNumbers[3].currentFrame = totalOnes;
|
||||
gemCountNumbers[0].anim.currentFrame = collectedTenths;
|
||||
gemCountNumbers[1].anim.currentFrame = collectedOnes;
|
||||
gemCountNumbers[2].anim.currentFrame = totalTenths;
|
||||
gemCountNumbers[3].anim.currentFrame = totalOnes;
|
||||
}
|
||||
|
||||
public function formatTimer(time:Float) {
|
||||
|
|
@ -320,13 +405,13 @@ class PlayGui {
|
|||
var hundredthOne = hundredth % 10;
|
||||
var hundredthTen = (hundredth - hundredthOne) / 10;
|
||||
|
||||
timerNumbers[0].currentFrame = minutesTen;
|
||||
timerNumbers[1].currentFrame = minutesOne;
|
||||
timerNumbers[2].currentFrame = secondsTen;
|
||||
timerNumbers[3].currentFrame = secondsOne;
|
||||
timerNumbers[4].currentFrame = hundredthTen;
|
||||
timerNumbers[5].currentFrame = hundredthOne;
|
||||
timerNumbers[6].currentFrame = thousandth;
|
||||
timerNumbers[0].anim.currentFrame = minutesTen;
|
||||
timerNumbers[1].anim.currentFrame = minutesOne;
|
||||
timerNumbers[2].anim.currentFrame = secondsTen;
|
||||
timerNumbers[3].anim.currentFrame = secondsOne;
|
||||
timerNumbers[4].anim.currentFrame = hundredthTen;
|
||||
timerNumbers[5].anim.currentFrame = hundredthOne;
|
||||
timerNumbers[6].anim.currentFrame = thousandth;
|
||||
}
|
||||
|
||||
public function render(engine:h3d.Engine) {
|
||||
|
|
|
|||
14
src/gui/Rect.hx
Normal file
14
src/gui/Rect.hx
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package gui;
|
||||
|
||||
import h3d.Vector;
|
||||
|
||||
@:publicFields
|
||||
class Rect {
|
||||
var position:Vector;
|
||||
var extent:Vector;
|
||||
|
||||
public function new(position:Vector, extent:Vector) {
|
||||
this.position = position.clone();
|
||||
this.extent = extent.clone();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue