mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-03-13 23:36:16 +00:00
work on rewind touch controls
This commit is contained in:
parent
cee4731766
commit
b5a1d5af6b
6 changed files with 46 additions and 2 deletions
BIN
data/ui/touch/rewind.png
Normal file
BIN
data/ui/touch/rewind.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
|
|
@ -915,12 +915,15 @@ class MarbleWorld extends Scheduler {
|
|||
|
||||
var realDt = dt;
|
||||
|
||||
if ((Key.isDown(Settings.controlsSettings.rewind) || Gamepad.isDown(Settings.gamepadSettings.rewind))
|
||||
if ((Key.isDown(Settings.controlsSettings.rewind)
|
||||
|| MarbleGame.instance.touchInput.rewindButton.pressed
|
||||
|| Gamepad.isDown(Settings.gamepadSettings.rewind))
|
||||
&& Settings.optionsSettings.rewindEnabled
|
||||
&& !this.isWatching) {
|
||||
this.rewinding = true;
|
||||
} else {
|
||||
if ((Key.isReleased(Settings.controlsSettings.rewind) || Gamepad.isReleased(Settings.gamepadSettings.rewind))
|
||||
if (((Key.isReleased(Settings.controlsSettings.rewind) || Gamepad.isReleased(Settings.gamepadSettings.rewind))
|
||||
|| !MarbleGame.instance.touchInput.rewindButton.pressed)
|
||||
&& this.rewinding) {
|
||||
if (this.isRecording) {
|
||||
this.replay.spliceReplay(timeState.currentAttemptTime);
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ typedef TouchSettings = {
|
|||
var jumpButtonSize:Float;
|
||||
var powerupButtonPos:Array<Float>;
|
||||
var powerupButtonSize:Float;
|
||||
var rewindButtonPos:Array<Float>;
|
||||
var rewindButtonSize:Float;
|
||||
var buttonJoystickMultiplier:Float;
|
||||
}
|
||||
|
||||
|
|
@ -123,6 +125,8 @@ class Settings {
|
|||
jumpButtonSize: 60,
|
||||
powerupButtonPos: [440, 180],
|
||||
powerupButtonSize: 60,
|
||||
rewindButtonPos: [380, 240],
|
||||
rewindButtonSize: 60,
|
||||
buttonJoystickMultiplier: 2.5
|
||||
}
|
||||
|
||||
|
|
@ -262,6 +266,10 @@ class Settings {
|
|||
if (controlsSettings.rewind == 0) {
|
||||
controlsSettings.rewind = Key.R;
|
||||
}
|
||||
if (touchSettings.rewindButtonPos == null) {
|
||||
touchSettings.rewindButtonPos = [380, 240];
|
||||
touchSettings.rewindButtonSize = 60;
|
||||
}
|
||||
if (json.gamepad != null) {
|
||||
gamepadSettings = json.gamepad;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,10 +55,14 @@ class TouchCtrlsEditGui extends GuiImage {
|
|||
var powerupBtn = new TouchEditButton(ResourceLoader.getImage("data/ui/touch/energy.png").resource,
|
||||
new Vector(Settings.touchSettings.powerupButtonPos[0], Settings.touchSettings.powerupButtonPos[1]), Settings.touchSettings.powerupButtonSize);
|
||||
|
||||
var rewindBtn = new TouchEditButton(ResourceLoader.getImage("data/ui/touch/rewind.png").resource,
|
||||
new Vector(Settings.touchSettings.rewindButtonPos[0], Settings.touchSettings.rewindButtonPos[1]), Settings.touchSettings.rewindButtonSize);
|
||||
|
||||
jumpBtn.onClick = (sender, mousePos) -> {
|
||||
sender.setSelected(true);
|
||||
powerupBtn.setSelected(false);
|
||||
joystick.setSelected(false);
|
||||
rewindBtn.setSelected(false);
|
||||
}
|
||||
|
||||
jumpBtn.onChangeCb = (sender, value, rvalue) -> {
|
||||
|
|
@ -70,6 +74,7 @@ class TouchCtrlsEditGui extends GuiImage {
|
|||
sender.setSelected(true);
|
||||
jumpBtn.setSelected(false);
|
||||
joystick.setSelected(false);
|
||||
rewindBtn.setSelected(false);
|
||||
}
|
||||
|
||||
powerupBtn.onChangeCb = (sender, value, rvalue) -> {
|
||||
|
|
@ -81,6 +86,7 @@ class TouchCtrlsEditGui extends GuiImage {
|
|||
joystick.setSelected(true);
|
||||
jumpBtn.setSelected(false);
|
||||
powerupBtn.setSelected(false);
|
||||
rewindBtn.setSelected(false);
|
||||
}
|
||||
|
||||
joystick.onChangeCb = (value, rvalue) -> {
|
||||
|
|
@ -93,5 +99,6 @@ class TouchCtrlsEditGui extends GuiImage {
|
|||
this.addChild(joystick);
|
||||
this.addChild(jumpBtn);
|
||||
this.addChild(powerupBtn);
|
||||
this.addChild(rewindBtn);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
14
src/touch/RewindButton.hx
Normal file
14
src/touch/RewindButton.hx
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package touch;
|
||||
|
||||
import touch.TouchInput.Touch;
|
||||
import h3d.Vector;
|
||||
import hxd.Window;
|
||||
import src.ResourceLoader;
|
||||
import src.Settings;
|
||||
|
||||
class RewindButton extends TouchButton {
|
||||
public function new() {
|
||||
super(ResourceLoader.getImage("data/ui/touch/rewind.png").resource,
|
||||
new Vector(Settings.touchSettings.rewindButtonPos[0], Settings.touchSettings.rewindButtonPos[1]), Settings.touchSettings.rewindButtonSize);
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,7 @@ class TouchInput {
|
|||
public var powerupButton:PowerupButton;
|
||||
|
||||
public var pauseButton:PauseButton;
|
||||
public var rewindButton:RewindButton;
|
||||
|
||||
public var currentTouchState:TouchEventState;
|
||||
|
||||
|
|
@ -56,6 +57,7 @@ class TouchInput {
|
|||
this.jumpButton = new JumpButton();
|
||||
this.powerupButton = new PowerupButton();
|
||||
this.pauseButton = new PauseButton();
|
||||
this.rewindButton = new RewindButton();
|
||||
this.currentTouchState = new TouchEventState();
|
||||
this.previousTouchState = new TouchEventState();
|
||||
}
|
||||
|
|
@ -111,10 +113,14 @@ class TouchInput {
|
|||
this.movementInput = new MovementInput();
|
||||
this.jumpButton = new JumpButton();
|
||||
this.powerupButton = new PowerupButton();
|
||||
if (Settings.optionsSettings.rewindEnabled)
|
||||
this.rewindButton = new RewindButton();
|
||||
this.pauseButton = new PauseButton();
|
||||
pauseButton.add(parentGui);
|
||||
jumpButton.add(parentGui);
|
||||
powerupButton.add(parentGui);
|
||||
if (Settings.optionsSettings.rewindEnabled)
|
||||
rewindButton.add(parentGui);
|
||||
movementInput.add(parentGui);
|
||||
cameraInput.add(parentGui);
|
||||
cameraInput.enabled = true;
|
||||
|
|
@ -125,6 +131,8 @@ class TouchInput {
|
|||
this.powerupButton.setVisible(enabled);
|
||||
this.movementInput.setVisible(enabled);
|
||||
this.pauseButton.setVisible(enabled);
|
||||
if (this.rewindButton != null)
|
||||
this.rewindButton.setVisible(enabled);
|
||||
this.cameraInput.enabled = enabled;
|
||||
}
|
||||
|
||||
|
|
@ -134,10 +142,14 @@ class TouchInput {
|
|||
movementInput.remove(parentGui);
|
||||
pauseButton.remove(parentGui);
|
||||
cameraInput.remove(parentGui);
|
||||
if (this.rewindButton != null)
|
||||
rewindButton.remove(parentGui);
|
||||
jumpButton.dispose();
|
||||
powerupButton.dispose();
|
||||
movementInput.dispose();
|
||||
pauseButton.dispose();
|
||||
cameraInput.dispose();
|
||||
if (this.rewindButton != null)
|
||||
rewindButton.dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue