A downloadable Stencyl Tutorial

Welcome to my second Stencyl tutorial!!! In this tutorial we're going to explain how to add custom blocks and use them. Note that there also are other uses of the custom block. This is an example.

First go to the events bar and click on + Add Event, Advanced.


As you see, we have two types of Custom Blocks; Custom Block and Global Custom Block

What's the difference?

Custom Block is only used for a current scene or Actor Type. If you use it to a different Actor Type or Scene, its code won't run.

Global Custom Block is used on every Actor Type/Scene.

l'll make an Global Custom Block at this part.

So when you do it, you see this:


Click on "Create Global Custom Block" button.

After that you see this:


So first, let's add a name: Set_Animation_For_ActorType for example.


Then, you can set description if you want.

After that, you need to create Block Fields by pressing the + button. (Note that if the block will have only text with no selection do not create block fields.) Then give a name, set the type of want you want to be and hit OK.


Next, you see this:


These numbers will be used to Block Spector (how the block will look)

So, write something like this:


At this case, with these block fields you have created, %0 means Animation and %1 means Actor Type.

Last, we have the Return Type.


If you want the block to be Action Block, select None.

Then hit create.

After that you see this:


Put inside the wrapper the code you want to apply when it's used.


After that, grab the block fields you had created, to each category.

To finish the tutorial, you need to find your custom block to the Custom category.


Last, put your global custom block on the event you want and write whatever you need to.


----------------------------------------------------------------------------------------------------------

FAQ

  • What if, l want to use a custom block, in a few actor/scenes only?

The answer is simple. Create an Actor/Scene behavior and create inside your custom blocks. Let's create the Distance Between Two Actors for example.

You create its code as l previously said.


Then, save the behavior and attach it to a scene/actor.


l think you see this, after you attached the behavior.


Then, just use the custom block.


----------------------------------------------------------------------------------------------------------

Tutorial by: Chris24XD

If you liked the tutorial rate it.

If you didn't understand anything click here.

Bye!

Leave a comment

Log in with itch.io to leave a comment.