View Single Post
  #1  
Old 11-21-2011, 11:58 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Controlling something using GUI buttons

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") {
    
64;
    
screenheight 128;
    
width height 32;
    
text "  Up";
    
normalbitmap mouseoverbitmap PLAYER_NORMAL;
    
pressedbitmap PLAYER_PRESSED;
  }

  new 
GuiBitmapButtonCtrl("PadMovement_1") {
    
32;
    
screenheight 96;
    
width height 32;
    
text " Left";
    
normalbitmap mouseoverbitmap PLAYER_NORMAL;
    
pressedbitmap PLAYER_PRESSED;
  }

  new 
GuiBitmapButtonCtrl("PadMovement_2") {
    
64;
    
screenheight 64;
    
width height 32;
    
text "Down";
    
normalbitmap mouseoverbitmap PLAYER_NORMAL;
    
pressedbitmap PLAYER_PRESSED;
  }

  new 
GuiBitmapButtonCtrl("PadMovement_3") {
    
96;
    
screenheight 96;
    
width height 32;
    
text "Right";
    
normalbitmap mouseoverbitmap PLAYER_NORMAL;
    
pressedbitmap PLAYER_PRESSED;
  }
}

function 
PadMovement_0.onAction() {
  
player.dir 0;
  
player.+= vecx(player.dir) * PLAYER_SPEED;
  
player.+= vecy(player.dir) * PLAYER_SPEED;
}

function 
PadMovement_1.onAction() {
  
player.dir 1;
  
player.+= vecx(player.dir) * PLAYER_SPEED;
  
player.+= vecy(player.dir) * PLAYER_SPEED;
}

function 
PadMovement_2.onAction() {
  
player.dir 2;
  
player.+= vecx(player.dir) * PLAYER_SPEED;
  
player.+= vecy(player.dir) * PLAYER_SPEED;
}

function 
PadMovement_3.onAction() {
  
player.dir 3;
  
player.+= vecx(player.dir) * PLAYER_SPEED;
  
player.+= vecy(player.dir) * PLAYER_SPEED;

__________________
MEEP!

Last edited by callimuc; 11-21-2011 at 11:59 PM.. Reason: typo
Reply With Quote