Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:18 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.