Since the iPhone versions are using the GUI buttons for the moving of the player, I was wondering how you could actually move the player by pressing it. Like is there a way to make the client think, that the player pressed a key (keydown()) even when the player just pressed a GUI? And how can it be made if the mouse slides over to the other GUI, that it won´t need to get reclicked?
The only way I was thinking of making it was this:
PHP Code:
//#CLIENTSIDE
function onCreated() {
const PLAYER_SPEED = 0.2;
const PLAYER_NORMAL = "block.png";
const PLAYER_PRESSED = "lightblock.png";
new GuiBitmapButtonCtrl("PadMovement_0") {
x = 64;
y = screenheight - 128;
width = height = 32;
text = " Up";
normalbitmap = mouseoverbitmap = PLAYER_NORMAL;
pressedbitmap = PLAYER_PRESSED;
}
new GuiBitmapButtonCtrl("PadMovement_1") {
x = 32;
y = screenheight - 96;
width = height = 32;
text = " Left";
normalbitmap = mouseoverbitmap = PLAYER_NORMAL;
pressedbitmap = PLAYER_PRESSED;
}
new GuiBitmapButtonCtrl("PadMovement_2") {
x = 64;
y = screenheight - 64;
width = height = 32;
text = "Down";
normalbitmap = mouseoverbitmap = PLAYER_NORMAL;
pressedbitmap = PLAYER_PRESSED;
}
new GuiBitmapButtonCtrl("PadMovement_3") {
x = 96;
y = screenheight - 96;
width = height = 32;
text = "Right";
normalbitmap = mouseoverbitmap = PLAYER_NORMAL;
pressedbitmap = PLAYER_PRESSED;
}
}
function PadMovement_0.onAction() {
player.dir = 0;
player.x += vecx(player.dir) * PLAYER_SPEED;
player.y += vecy(player.dir) * PLAYER_SPEED;
}
function PadMovement_1.onAction() {
player.dir = 1;
player.x += vecx(player.dir) * PLAYER_SPEED;
player.y += vecy(player.dir) * PLAYER_SPEED;
}
function PadMovement_2.onAction() {
player.dir = 2;
player.x += vecx(player.dir) * PLAYER_SPEED;
player.y += vecy(player.dir) * PLAYER_SPEED;
}
function PadMovement_3.onAction() {
player.dir = 3;
player.x += vecx(player.dir) * PLAYER_SPEED;
player.y += vecy(player.dir) * PLAYER_SPEED;
}