View Single Post
  #4  
Old 07-15-2009, 06:58 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
I just tested my examples and they worked fine, also remember you're working with pixels not Graal x, y, coordinates. So try increasing your speed above 1.

Try.. this.speed = this.lvl * 1;

That assumes that you're setting this.lvl to 1 though.

Also just learned that you should use keydownglobal() function instead of keydown()

Here is my example..

PHP Code:
//#CLIENTSIDE
function onCreated() {
  new 
GuiWindowCtrl("GameGUI") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "320,240";

    
canmove true;
    
canresize false;
    
closequery false;
    
destroyonhide false;
    
text "Game - Use Arrow Keys to Move Button";
    
287;
    
241;

    new 
GuiButtonCtrl("GameGUI_Button") {
      
profile GuiBlueButtonProfile;
      
text "Exit";
      
width 80;
      
119;
      
108;
    }
  }
  
setTimer(0.05);
}

function 
GameGUI_Button.onAction() {
  
// Button "Fun Example" has been pressed
  
GameGUI.destroy();
}

function 
onTimeout() {
  if (
GameGUI.visible) {
    
this.speed 2;
    
// Loop through Arrow/Direction Keys
    
for (temp.0temp.4temp.i++) {
      
// Check if direction key is pressed
      
if (keydownglobal(temp.i)) {
        
// Record the direction pressed and exit the loop.
        
this.direction temp.i;
        
temp.pressed true;
        break;
      }
    }
    
// Check if a Direction key was pressed.
    
if (temp.pressed) {
      
// Move Button
      
GameGUI_Button.+= vecx(this.direction) * this.speed;
      
GameGUI_Button.+= vecy(this.direction) * this.speed;
    }
    
// Freezeplayer to prevent graal movement
    
freezeplayer(0.05);
    
// Continue game loop
    
setTimer(0.05);
  }

__________________
Quote:

Last edited by fowlplay4; 07-15-2009 at 07:09 AM..
Reply With Quote