mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
restart button in touch controls and fix sound sliders
This commit is contained in:
parent
57134b9a85
commit
50ae6803dc
5 changed files with 32 additions and 3 deletions
|
|
@ -1131,7 +1131,8 @@ class MarbleWorld extends Scheduler {
|
||||||
ProfilerUI.measure("updateTimer");
|
ProfilerUI.measure("updateTimer");
|
||||||
this.updateTimer(dt);
|
this.updateTimer(dt);
|
||||||
|
|
||||||
if (Key.isPressed(Settings.controlsSettings.respawn) && this.finishTime == null) {
|
if ((Key.isPressed(Settings.controlsSettings.respawn) || MarbleGame.instance.touchInput.restartButton.pressed)
|
||||||
|
&& this.finishTime == null) {
|
||||||
this.respawnPressedTime = timeState.timeSinceLoad;
|
this.respawnPressedTime = timeState.timeSinceLoad;
|
||||||
this.restart();
|
this.restart();
|
||||||
if (!this.isWatching) {
|
if (!this.isWatching) {
|
||||||
|
|
@ -1150,7 +1151,9 @@ class MarbleWorld extends Scheduler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Key.isDown(Settings.controlsSettings.respawn) && !this.isWatching && this.finishTime == null) {
|
if ((Key.isDown(Settings.controlsSettings.respawn) || MarbleGame.instance.touchInput.restartButton.pressed)
|
||||||
|
&& !this.isWatching
|
||||||
|
&& this.finishTime == null) {
|
||||||
if (timeState.timeSinceLoad - this.respawnPressedTime > 1.5) {
|
if (timeState.timeSinceLoad - this.respawnPressedTime > 1.5) {
|
||||||
this.restart(true);
|
this.restart(true);
|
||||||
this.respawnPressedTime = Math.POSITIVE_INFINITY;
|
this.respawnPressedTime = Math.POSITIVE_INFINITY;
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,11 @@ class GuiSlider extends GuiImage {
|
||||||
public var sliderValue:Float = 0;
|
public var sliderValue:Float = 0;
|
||||||
|
|
||||||
public var slidingSound:Channel;
|
public var slidingSound:Channel;
|
||||||
|
public var enabled:Bool = true;
|
||||||
|
|
||||||
public override function update(dt:Float, mouseState:MouseState) {
|
public override function update(dt:Float, mouseState:MouseState) {
|
||||||
var renderRect = getRenderRectangle();
|
var renderRect = getRenderRectangle();
|
||||||
if (renderRect.inRect(mouseState.position)) {
|
if (renderRect.inRect(mouseState.position) && enabled) {
|
||||||
if (Key.isDown(Key.MOUSE_LEFT)) {
|
if (Key.isDown(Key.MOUSE_LEFT)) {
|
||||||
sliderValue = (mouseState.position.x - renderRect.position.x - bmp.width / 2) / renderRect.extent.x;
|
sliderValue = (mouseState.position.x - renderRect.position.x - bmp.width / 2) / renderRect.extent.x;
|
||||||
sliderValue = Util.clamp(sliderValue, 0, 1);
|
sliderValue = Util.clamp(sliderValue, 0, 1);
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,9 @@ class OptionsDlg extends GuiImage {
|
||||||
for (b in optBtns) {
|
for (b in optBtns) {
|
||||||
b.disabled = !enabled;
|
b.disabled = !enabled;
|
||||||
}
|
}
|
||||||
|
for (s in optSliders) {
|
||||||
|
s.enabled = enabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.pressedAction = (sender) -> {
|
window.pressedAction = (sender) -> {
|
||||||
|
|
|
||||||
14
src/touch/RestartButton.hx
Normal file
14
src/touch/RestartButton.hx
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
package touch;
|
||||||
|
|
||||||
|
import src.MarbleGame;
|
||||||
|
import h3d.Vector;
|
||||||
|
import src.ResourceLoader;
|
||||||
|
|
||||||
|
class RestartButton extends TouchButton {
|
||||||
|
public function new() {
|
||||||
|
var offset = MarbleGame.instance.world != null ? (MarbleGame.instance.world.totalGems > 0 ? 30 : 0) : 0;
|
||||||
|
super(ResourceLoader.getImage("data/ui/touch/refresh.png").resource, new Vector(135, 55 + offset), 35);
|
||||||
|
this.guiElement.horizSizing = Right;
|
||||||
|
this.guiElement.vertSizing = Bottom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -42,6 +42,7 @@ class TouchInput {
|
||||||
public var powerupButton:PowerupButton;
|
public var powerupButton:PowerupButton;
|
||||||
public var blastbutton:BlastButton;
|
public var blastbutton:BlastButton;
|
||||||
public var pauseButton:PauseButton;
|
public var pauseButton:PauseButton;
|
||||||
|
public var restartButton:RestartButton;
|
||||||
|
|
||||||
public var currentTouchState:TouchEventState;
|
public var currentTouchState:TouchEventState;
|
||||||
|
|
||||||
|
|
@ -56,6 +57,7 @@ class TouchInput {
|
||||||
this.powerupButton = new PowerupButton();
|
this.powerupButton = new PowerupButton();
|
||||||
this.blastbutton = new BlastButton();
|
this.blastbutton = new BlastButton();
|
||||||
this.pauseButton = new PauseButton();
|
this.pauseButton = new PauseButton();
|
||||||
|
this.restartButton = new RestartButton();
|
||||||
this.currentTouchState = new TouchEventState();
|
this.currentTouchState = new TouchEventState();
|
||||||
this.previousTouchState = new TouchEventState();
|
this.previousTouchState = new TouchEventState();
|
||||||
}
|
}
|
||||||
|
|
@ -108,6 +110,7 @@ class TouchInput {
|
||||||
blastbutton.dispose();
|
blastbutton.dispose();
|
||||||
movementInput.dispose();
|
movementInput.dispose();
|
||||||
pauseButton.dispose();
|
pauseButton.dispose();
|
||||||
|
restartButton.dispose();
|
||||||
cameraInput.dispose();
|
cameraInput.dispose();
|
||||||
this.cameraInput = new CameraInput();
|
this.cameraInput = new CameraInput();
|
||||||
this.movementInput = new MovementInput();
|
this.movementInput = new MovementInput();
|
||||||
|
|
@ -116,7 +119,9 @@ class TouchInput {
|
||||||
if (ultra)
|
if (ultra)
|
||||||
this.blastbutton = new BlastButton();
|
this.blastbutton = new BlastButton();
|
||||||
this.pauseButton = new PauseButton();
|
this.pauseButton = new PauseButton();
|
||||||
|
this.restartButton = new RestartButton();
|
||||||
pauseButton.add(parentGui);
|
pauseButton.add(parentGui);
|
||||||
|
restartButton.add(parentGui);
|
||||||
jumpButton.add(parentGui);
|
jumpButton.add(parentGui);
|
||||||
powerupButton.add(parentGui);
|
powerupButton.add(parentGui);
|
||||||
if (ultra)
|
if (ultra)
|
||||||
|
|
@ -133,6 +138,7 @@ class TouchInput {
|
||||||
this.blastbutton.setVisible(enabled);
|
this.blastbutton.setVisible(enabled);
|
||||||
this.movementInput.setVisible(enabled);
|
this.movementInput.setVisible(enabled);
|
||||||
this.pauseButton.setVisible(enabled);
|
this.pauseButton.setVisible(enabled);
|
||||||
|
this.restartButton.setVisible(enabled);
|
||||||
this.cameraInput.enabled = enabled;
|
this.cameraInput.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,11 +149,13 @@ class TouchInput {
|
||||||
blastbutton.remove(parentGui);
|
blastbutton.remove(parentGui);
|
||||||
movementInput.remove(parentGui);
|
movementInput.remove(parentGui);
|
||||||
pauseButton.remove(parentGui);
|
pauseButton.remove(parentGui);
|
||||||
|
restartButton.remove(parentGui);
|
||||||
cameraInput.remove(parentGui);
|
cameraInput.remove(parentGui);
|
||||||
jumpButton.dispose();
|
jumpButton.dispose();
|
||||||
powerupButton.dispose();
|
powerupButton.dispose();
|
||||||
movementInput.dispose();
|
movementInput.dispose();
|
||||||
pauseButton.dispose();
|
pauseButton.dispose();
|
||||||
|
restartButton.dispose();
|
||||||
cameraInput.dispose();
|
cameraInput.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue