KeyDown in Global Script Editor

Game Editor comments and discussion.

KeyDown in Global Script Editor

Postby QbiWan » Thu Dec 29, 2011 8:05 pm

Hi, i have made few events for VIEW moving with keys and mouse+screen edge. All is fine but i saw that some events can by found when clicking on SCRIPT button on top screen, and some CANT be found. its just ViewMoving, so i afraid that one day i just wont find some events in created mess.
So to the MAIN TOPIC: can i write all events available in ADD menu in the global script (f.e. KeyDown cant be found in script editor's variables/functions menu)?? If yes, how should it look like??
ScreenShot001.jpg

KeyDown>Down> y = y + 10
QbiWan
 
Posts: 4
Joined: Fri Dec 16, 2011 12:21 pm
Score: 0 Give a positive score

Re: KeyDown in Global Script Editor

Postby skydereign » Thu Dec 29, 2011 8:08 pm

You mean is there a way to determine what key(s) are pressed in script? You can use the function GetKeyState to see if keys are pressed in script.
Code: Select all
char* key = GetKeyState();
if(key[KEY_RIGHT]==1)
{
    x+=10;
}

You can find all the keys here. http://game-editor.com/docs/script_reference.htm

If you want to use just the last key, and have a keydown any key event, you can use getLastKey() function.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: KeyDown in Global Script Editor

Postby QbiWan » Fri Dec 30, 2011 11:03 pm

But can i do it ALL in Global code? To assign actor with moving action when key is pressed, becouse i want to call it a name to have f.e. all move scripts in one place.
QbiWan
 
Posts: 4
Joined: Fri Dec 16, 2011 12:21 pm
Score: 0 Give a positive score

Re: KeyDown in Global Script Editor

Postby phyzix5761 » Fri Dec 30, 2011 11:12 pm

Yes, you can have it all in global code.

Make it a function

Code: Select all
void functionName()
{
   //your code here
}

and then in the draw actor event put the function. If you ever need to edit the code just go into global code and edit the function.
phyzix5761
 
Posts: 261
Joined: Sun Feb 27, 2011 4:28 am
Score: 18 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest