Moving Platforms

It's common to have moving platforms:

For this, it's easier if we use an application to create a single-object platform (NOT something using the combined middle tile and end sprites).

It also needs to be its own object, as once we add the moving behavior, it will apply to all the copies of that object...

We like the desktop app GIMP.

But you can use Piskel or PixilArt, which are web-based.

Rectangular Movement

Once we add this new Sprite to our project, we can add the two following Behaviors to it:

Once you add this object to your scene you can experiment with the motion properties:

NOTE: One major limitation of this and similar linear movement behaviors is that you cannot control the starting direction of objects. So, making platforms with same speed that criss-cross each other's paths regularly becomes impossible.

Using Hidden Stage Directions

Another way to control moving platforms is to add stage directions that can be reused with simple events.

We did something similar in the Action RPG tutorial with monsters.

Here is an example:

Create a PlatformObject with no movement behavior, and place it somehwere in the area where you want it to move.

Add an instance Speed variable to this object.

Instance Variables are like Object Variables - they belong to the object - but each instance on the scene can have its own value. In events, you still use the same Object Variable syntax.

Now add some meaningless sprite to your scene, and place it twice, at the two ends of where you wish your platforms to move back and forth between:

Finally, we will add the two simple events to control our moving platforms:

You can then have two platforms starting at the same position but with different instance speeds (say, 100 and -100) and they will move in opposite directions!

By the way, don't forget to HIDE the stage direction sprites.

Irregular Platforms

You may have some ideas about other types of platforms (see-saws, rotators, toggle passthrough on/off, etc)

For instance, we wanted to have platforms that that fall off-screen and you have to jump off of it before it's too late!

There are many ways to do it, but one way for this is to toggle Physics types on the object.

First, create a new version of the Moving Platform (new Sprite, not just anothe rinstance of Moving Platform).

Then add the Behaviors:

Place the object somewhere appropriate in your level.

Then add an event that changes the Physics type to Dynamic when your character collides with it:

You can change the Gravity scale to make it fall slower...

HINT: Make sure when you die to restart the scene or re-position and re-Static the object, so that it's reset when necessary.

Other Ideas