Azioni – Move

Move image image image image image image image image image
Jump image image image image image image image
Paths image image image image
Steps image image

Il primo gruppo di azioni consiste di quelle relative al movimento degli oggetti.

Esistono le seguenti azioni:

image Move Fixed

Usa quest’azione per incominciare, ad esempio, a muoverti in una certa direzione.
Specifichi la direzione tramite i pulsanti con le frecce.
Usa il pulsante al centro per fermare il movimento.
Dovrai anche specificare la velocità del movimento.
Questa velocità è data in pixel per passo.
Se non la cambi, la velocità verrà messa a 8.
Non usare una velocità negativa.

Puoi anche specificare direzioni multiple.
In questo caso verrà fatta una scelta casuale.
Con questa tecnica puoi fare in modo che un mostro cominci a muoversi o a destra o a sinistra.

image Move Free

Questo è il secondo modo per specificare un movimento.
Con questa azione puoi indicare una direzione precisa.
Si tratta di un angolo tra i 0 e i 360 gradi, 0 significa a destra, la direzione è in senso antiorario, quindi per esempio 90indica la direzione verso l’alto.
Se vuoi una direzione arbitraria, puoi digitare random(360).
Come vedrai più avanti, la funzione random() dà un numero a caso più piccolo del valore indicato (360).
Come avrai notato c’ è una casella di scelta Relative.
Se la attivi, il nuovo movimento è aggiunto al precedente.
Per esempio, se la richiesta è il movimento in su e tu aggiungi qualche movimento a destra, il nuovo movimento sarà in sù a destra.

image Move Towards

This action gives a third way to specify a motion.
You indicate a position and a speed and the instance starts moving with the speed towards the position.
It won’t stop at the position!
For example, if you want a bullet to fly towards the position of the spaceship you can use as position spaceship.x, spaceship.y.
You will learn more about the use of variables like these below.
If you check the Relative box, you specify the position relative to the current position of the instance.
The speed is not taken relatively!

image Speed Horizontal

The speed of an instance consists of a horizontal part and a vertical part.
With this action you can change the horizontal speed.
A positive horizontal speed means a motion to the right.
A negative one means a motion to the left.
The vertical speed will remain the same.
Use relative to increase the horizontal speed (or decrease it by providing a negative number).

image Speed Vertical

In a similar way, with this action you can change the vertical speed of the instance.

image Set Gravity

With this action you can create gravity for this particular object.
You specify a direction (angle between 0 and 360 degrees) and a speed, and in each step this amount of speed in the given direction is added to the current motion of the object instance.
Normally you need a very small speed increment (like 0.01).
Typically you want a downward direction (270 degrees).
If you check the Relative box you increase the gravity speed and direction.
Note that, contrary to real life, different object can have different gravity directions.

image Reverse Horizontal

With this action you reverse the horizontal motion of the instance.
This can for example be used when the object collides with a vertical wall.

image Reverse Vertical

With this action you reverse the vertical motion of the instance.
This can for example be used when the object collides with a horizontal wall.

image Set Friction

Friction slows down the instances when they move. You specify the amount of friction.
In each step this amount is subtracted from the speed until the speed becomes 0.
Normally you want a very small number here (like 0.01).

 



image Jump to Position

Using this action you can place the instance in a particular position. You simply specify the x- and y-coordinate, and the instance is placed with its reference point on that position.
If you check the Relative box, the position is relative to the current position of the instance.
This action is often used to continuously move an instance.
In each step we increment the position a bit.

image Jump to Start

This action places the instance back at the position where it was created.

image Jump to Random

This action moves the instance to a random position in the room.
Only positions are chosen where the instance does not intersect any solid instance.
You can specify the snapping used.
If you specify positive values, the coordinates chosen with be integer multiples of the indicated values.
This could for example be used to keep the instance aligned with the cells in your game (if any).
You can specify a separate horizontal snapping and vertical snapping.

image Align to Grid

With this action you can round the position of the instance to a grid.
You can indicate both the horizontal and vertical snapping value (that is, the size of the cells of the grid).
This can be very useful to make sure that instances stay on a grid.

image Wrap Screen

With this action you can let an instance wrap around, that is, when it leaves on one side of the room it reappears at the other side.
This action is normally used in the Outside event.
Note that the instance must have a speed for wrapping to work, cause the direction of wrapping is based on the direction of the motion.
You can indicate whether to wrap only horizontal, only vertical, or in both directions.

image Move to Contact

With this action you can move the instance in a given direction until a contact position with an object is reached.
If there already is a collision at the current position the instance is not moved.
Otherwise, the instance is placed just before a collision occurs.
You can specify the direction but also a maximal distance to move.
For example, when the instance is falling you can move a maximal distance down until an object is encountered.
You can also indicate whether to consider solid object only or all objects.
You typically put this action in the collision event to make sure that the instance stops in contact with the other instance involved in the collision.

image Bounce

When you put this action in the collision event with some object, the instance bounces back from this object in a natural way.
If you set the parameter precise to false, only horizontal and vertical walls are treated correctly.
When you set precise to true also slanted (and even curved) walls are treated correctly.
This is though slower.
Also you can indicate whether to bounce only against solid objects or against all objects.
Please realize that the bounce is not completely accurate because this depends on many properties.
But in many situations the effect is good enough.

 



Some additional move actions are available in advanced mode.
The following actions are added:

image Set Path

With this action you can specify that the instance should follow a particular path. You indicate the path that must be followed and the speed in pixels per step. When the speed is positive the instance starts at the beginning of the path. If it is negative it starts at the end. Next you specify the end behavior, that is, what should happen when the end of the path is reached. You can choose to stop the motion, restart from the beginning, restart from the current position (which is the same when the path is closed), or reverse the motion. Finally you can indicate that the path must be seen as absolute, that is, the position will be as indicated in the path (this is useful when you have designed the path at a particular place in the room) or relative, in which case the start point of the path is placed at the current location of the instance (end point when speed is negative). See the chapter on paths for more information.

image End Path

Use this action to stop the path for the instance.

image Path Position

With this action you can change the current position of the instance in the path.
This must be a value between 0 and 1 (0=beginning, 1=end).

image Path Speed

With this action you can change the speed of the instance on the path.
A negative speed moves the instance backwards along the path.
Set it to 0 to temporarily stop the motion along the path.

 



image Step Towards

This action should be placed in the step event to let the instance take a step towards a particular position.
When the instance is already at the position it will not move any further.
You specify the position to move to, the speed with which to move, that is, the size of the step, and whether the motion should stop when hitting a solid instance or when hitting any instance.

image Step Avoiding

This is a very powerful motion action.
It should be placed in the step event.
Like the previous action it lets the instance take a step towards a particular position.
But in this case it tries to avoid obstacles.
When the instance would run into a solid instance (or any instance) it will change the direction of motion to try to avoid the instance and move around it.
The approach is not guaranteed to work but in most easy cases it will effectively move the instance towards the goal.
For more complicated cases, there are motion planning functions.
You specify the position to move to, the speed with which to move, that is, the size of the step, and whether the motion should avoid solid instances or any instance.

Lascia un commento