Finish mobile support
This commit is contained in:
6 files changed
+40
-26
No files matched your search
+8
-4
@@ -13,6 +13,8 @@ public partial class Player : Node2D {
|
||||
var WindowScale = WindowSize / ScreenSize;
|
||||
|
||||
Position = new Vector2(x: DisplayServer.WindowGetSize().X / 2, y: (WindowSize.Y / WindowScale.Y) - 100);
|
||||
|
||||
if (Utils.IsMobile()) GetNode<Node2D>("/root/Game/CanvasLayer/MobileButtons").Visible = true;
|
||||
}
|
||||
|
||||
public override void _Process(double delta) {
|
||||
@@ -23,18 +25,18 @@ public partial class Player : Node2D {
|
||||
Vector2 Pos = Position;
|
||||
|
||||
if (!Globals.IsPaused) {
|
||||
if ((Input.IsKeyPressed(Key.Left) || Input.IsKeyPressed(Key.A) || doLeft) && Pos.X > ScreenBorders) {
|
||||
if ((Utils.IsMobile() ? doLeft : Input.IsKeyPressed(Key.Left) || Input.IsKeyPressed(Key.A)) && Pos.X > ScreenBorders) {
|
||||
GetNode<Sprite2D>("Texture").FlipH = false;
|
||||
Pos.X -= Globals.MovementSpeed * (float)delta;
|
||||
}
|
||||
|
||||
float ScreenWidth = (WindowSize.X / WindowScale.X) - ScreenBorders;
|
||||
if ((Input.IsKeyPressed(Key.Right) || Input.IsKeyPressed(Key.D) || doRight) && Pos.X < ScreenWidth) {
|
||||
if ((Utils.IsMobile() ? doRight : Input.IsKeyPressed(Key.Right) || Input.IsKeyPressed(Key.D)) && Pos.X < ScreenWidth) {
|
||||
GetNode<Sprite2D>("Texture").FlipH = true;
|
||||
Pos.X += Globals.MovementSpeed * (float)delta;
|
||||
}
|
||||
|
||||
if ((Input.IsKeyPressed(Key.Space) || doJump) && Pos.Y >= 976) {
|
||||
if ((Utils.IsMobile() ? doJump : Input.IsKeyPressed(Key.Space)) && Pos.Y >= 976) {
|
||||
VelocityY = Globals.JumpHeight;
|
||||
GetNode<AudioStreamPlayer>("JumpSoundPlayer").Play();
|
||||
}
|
||||
@@ -79,7 +81,7 @@ public partial class Player : Node2D {
|
||||
Globals.BerrySpeed = Globals.DefaultBerrySpeed * 2f;
|
||||
}
|
||||
|
||||
if (Input.IsActionJustPressed("EscapeKey")) {
|
||||
if (!Utils.IsMobile() && Input.IsActionJustPressed("EscapeKey")) {
|
||||
if (!Globals.IsPaused) {
|
||||
PackedScene PauseMenu = GD.Load<PackedScene>("res://Prefabs/PauseMenu.tscn");
|
||||
|
||||
@@ -112,6 +114,8 @@ public partial class Player : Node2D {
|
||||
private void MobileJumpMoveDown() => doJump = true;
|
||||
private void MobileJumpMoveUp() => doJump = false;
|
||||
private void MobilePausePressed() {
|
||||
if (Utils.IsMobile()) GetNode<Node2D>("/root/Game/CanvasLayer/MobileButtons").Visible = false;
|
||||
|
||||
PackedScene PauseMenu = GD.Load<PackedScene>("res://Prefabs/PauseMenu.tscn");
|
||||
|
||||
Control PauseMenuInstance = PauseMenu.Instantiate<Control>();
|
||||
|
||||
Reference in new issue
Block a user