![]() Our title screen has three buttons, Start, Load and End, corresponding to the values 0, 1, 2. We initiate two variables, cursor and max_cursor. The code lines in a Create Event will be only called one time, during the instance creation of the corresponding object. Double-click on this object, we want to add some code lines! First step: add a Create Event using the Add Event button. Well, let’s return to our only object, obj_titlemenu. We write this code for the other three directions and we have some very useful code lines, which may be called everytime using scr_input() Translated: if the right arrow key is pressed ( vk_right), the value true will be stored in the variable right_key. We want to store this value in a variable, in case of our script it’s the variable **right_key for the true/false check of our right arrow key. keyboard_check(argument0) will return a true or a false* as value (boolean data type). argument0 is the key to check the down state of. Keyboard_check(argument0) is an already implemented script in GMS2. Name the script scr_input and include the following code: Go to the ressources tree and right-click on Scripts, than left-click on Create. Nice!Įnough theory, let’s write our own script. Therefore, we just need to write for example addition(3, 5) and we value 8 will be returned. The sum of both variables is stored in the variable c and variable c is returned by the script. Let’s look at the code:Īrgument0 and argument1 are saved in the variables a and b. The script adds both numbers and returns the sum. I will explain this possibility using a script named addition(argument0, argument1) Both arguments are numbers, which are passed to the script. ![]() We want to put our keyboard checks into one script and call it every time we need it using script() Another possibility to use scripts is with the involvement of arguments. We will use this method to create an input script during this part. We don’t want to insert the whole code segment each time when we need it, so the transfer of these segments into scripts is very useful. Scripts contain code segments, which are used frequently in our projects. We will return to scripts and how to use them. Today, we will continue with the implementation of some keyboard inputs and the corresponding cursor movement!įeel free to join this course and make your first steps as a game developer! Welcome to the second part of our Game Maker Studio 2 (GMS2) tutorial! In the last part, we finished the title screen draw and create a script for some font shadow. Your first game with Game Maker Studio 2 Part 2:Keyboard input and cursor movement! Schotti December 18, 2016
0 Comments
Leave a Reply. |