If your new to Game Editor, this post will help you get started.
Repeated Questions Answered
Here is a list of questions that people ask all the time and they get answered over and over again.
- How can I make the character move?
How can I jump?
How do I use collision?
What you will learn
Here is what you will learn in this post.
- Character movement
Screen movement
collision
paths
canvas
text control
activation regions
variable controle
Character Movement
You can move the character using these methods.
Add an event - Key Down - Right - Script Editor
- Code: Select all
Insde the script editor
x = x + 4;
For moving right, use that method. Then use the same thing again, but like this.
Add an event - Key Down - Left - Script Editor
- Code: Select all
Inside the script editor
x = x - 4;
The + means the character moves 4 pixels to the right, this is because it's adding the original x to the number you assigned. The larger the number, the more the character moves.
The - is just like the + except it minuses the x.
Yo9u can make gravity by doing this.
Add an event - Draw Actor - Script Editor
- Code: Select all
Inside the script editor
yvelocity = yvelocity + .9;
You have gravity now.
To make the character jump, use this method.
Add an event - Key Down - Space - Repeat no - Script Editor
- Code: Select all
yvelocity = yvelocity - 9;
Screen movement
You can make the screen move using these methods.
Make the screen parent the main player.
Make a new actor, call him screenmovement, make him a wire framed actor. Center him in the middle of the character, and make him a little bit bigger then he actor.
Add an event - Collision - Right Side of Player - Repeat yes - Script Editor
- Code: Select all
Inside the script editor
view.x = view.x + 4;
This makes the view's X move when the actor walks right.
Do the same thing with left, only use this.
- Code: Select all
Inside the script editor
view.x = view.x - 4;
Now make the same thing again, but collision with the Top side of the player.
- Code: Select all
Inside the script editor
view.y = view.y - 4;
Same thing with the bottom of the player.
- Code: Select all
Inside of the script editor
view.y = view.y + 4;
Your screen should now move when the character moves.
Collisions
If you have the player falling with gravity, you might wan't to stop your character if he hits the ground. This can be done using this. Click your player.
Add an event - Collision - Any side of level - Repeat yes - Physical Response.
You should see a menu, there should be 4 spots where you can input numbers. On the 3rd one down, make it 0. Now the character will stop when he hits the ground.
Paths
Paths can come in handy if your making a game with a target that moves, or a moving platform. To use a path, create a path, then after you've designed it, click the actor you wan't to have the path, click paths, then click the path you created.
Canvas
Canvas' can be used for many things, such as drawing functions, and many more. You can fill a canvas with color using this method.
Add an event - Draw Actor - Script Editor
- Code: Select all
erase(0. 0. 0. 0);
The first 0 is the red value, The second 0 is the green value, the third 0 is the blue value, and the 4th 0 is the transparency value.
If you wan't to make a drawing funtion, use this method. Create a variable called "draw". You can do this by clicking Variables inside of the script editor.
Add an event Create Actor - Script Editor
- Code: Select all
setpen(0, 0, 0, 0, 1);
draw = 0;
Like in the function above, red green blue transparency, This sets the color of the pen, but the 1 is the size of the line that you wan't to draw with. Now to draw with the mouse.
Add an event - Mouse button down - left click - Script Editor
- Code: Select all
screen_to_actor(&xmouse, &ymouse);
moveto(xmouse, ymouse);
draw = 1;
Now add another method.
Add an event - Draw Actor - Script Editor
- Code: Select all
if (draw == 1)
{
screen_to_actor(&xmouse, &ymouse);
lineto(xmouse, ymouse);
}
Now add another function.
Add an event - Mouse button up - Left click - Script Editor
- Code: Select all
draw = 0;
Click Game Mode and start drawing.
You can scale items using canvas' using this method.
Create an actor, then create a canvas. Click on canvas, then do this method.
Add an event - Draw Actor - Script Editor
- Code: Select all
erase(0, 0, 0, .99);
draw_from("player", width / 2, height / 2, 1);
The 1 is the scale.
Text Control
You can set the text of an actor by clicking text. With text, you can make a score using this method. First, make the text of the actor 0.
Add an event - Draw Actor - Script Editor
- Code: Select all
Make a variable called score
textactor.textNumber = score';
textactor is the name of the text actor you made. Now add this function when you run into an object that gives you points.
Add an event - Collision - any side of player - Repeat no - Script Editor
- Code: Select all
score = score + 80;
DestroyActor("Event Actor");
Click Game Mode and run into the object that gives you the points, you will see that you obtained 80 points.
Activation Regions
Activation regions are used to do different things, what they do is they only allow an event to be activated once it reaches a certain set. You can have it be activated when the mouse is hovered over it. You can do that using this method.
Right click the actor, click on add activation event, click the activation you want, such as mouseenter, now you will see a line, click the actor you want the activation region to effect. Now use this method. Click the actor you drew the line to.
Add an event - Activation Event - Script Editor
- Code: Select all
transp= .8;
transp is the transparency of the actor. Now click game mode and hover over the actor you drew the line to. You can get used to this function and use it to do other things, too.