Meteor 2 Scripting Functions
Input
vector2 getMousePos()
Get the mouse screen position in pixels
print("Mouse is at " + getMousePos());
bool mouseWithin(float x1, float y1, float x2, float y2)
Determine if a mouse cursor is within a rectangle.
if(mouseWithin(0, 0, SCREEN_W -1, SCREEN_H * 0.5))
print("Mouse is in top half of screen");
bool mouseButtonDown(int buttonIndex)
Determine if a mouse button is held down.
if(mouseButtonDown(1))
print("Left mouse button is down");
buttonIndex can be either: 1 (LEFT), 2 (RIGHT), 3 (MIDDLE)
bool mouseButtonClicked(int buttonIndex)
Determine if a mouse button was clicked (pressed and released).
if(mouseButtonClicked(1))
print("Left mouse button is clicked");
buttonIndex can be either: 1 (LEFT), 2 (RIGHT), 3 (MIDDLE)
bool keyDown(int key)
Determine if a keyboard key is being held down.
void onUpdate(float deltaTime)
{
if(gameHasFocus())
{
if(keyDown(KEY_Z))
print("Z key is down");
}
}
Keys values List:
KEY_NONE
KEY_A to KEY_Z
KEY_0 to KEY_9
KEY_PAD_0 to KEY_PAD_9
KEY_F1 to KEY_F12
KEY_ESCAPE or KEY_ESC
KEY_TILDE
KEY_PLUS
KEY_MINUS
KEY_EQUALS
KEY_BACKSPACE
KEY_TAB
KEY_ENTER
KEY_SEMICOLON
KEY_QUOTE
KEY_BACKSLASH
KEY_BACKSLASH2
KEY_COMMA
KEY_FULLSTOP or KEY_PERIOD
KEY_SLASH
KEY_SPACE
KEY_INSERT
KEY_DELETE
KEY_HOME
KEY_END
KEY_PGUP
KEY_PGDN
KEY_LEFT
KEY_RIGHT
KEY_UP
KEY_DOWN
KEY_PAD_MINUS
KEY_PAD_PLUS
KEY_PAD_DELETE
KEY_PAD_ENTER
KEY_PAUSE
KEY_LSHIFT
KEY_RSHIFT
KEY_LCTRL
KEY_RCTRL
KEY_ALT
KEY_ALTGR
KEY_MENU
bool keyPressed(int key)
Determine if a keyboard key was pressed.
void onUpdate(float deltaTime)
{
if(gameHasFocus())
{
if(keyPressed(KEY_Z))
print("Z key was pressed");
}
}
void clearPressedKeys()
Clears the pressed keys buffer.
clearPressedKeys();
void waitForKeyRelease(int key)
Waits a short time for key to be released.
waitForKeyRelease(KEY_Z);
The delay is minimal so the game is not held up.
Do not call every frame.
Index
Generated on the 23 November 2024 at 08:20:41 (UK Time)