Time for action – making the statues disappear after a delay

The game file that needs to be imported and loaded for this session is 5961_04_09.stencyl.

Let's create a timer that will remove each statue from the scene after a specified delay, Now perform the following instructions:

  1. If the Drop Actors Randomly tab is open, then close the tab.
  2. On the Dashboard, click on Actor Behaviors.
  3. Create a new actor behavior called Manage Statues.
  4. Click on +Add Event and select Time from the menu.
  5. Click on the After N seconds icon.
  6. Change the name of the After N Seconds event to Kill statues.
  7. In the do after … seconds block, enter the number 5 into the textbox.
  8. The Actor section button in the instruction block palette should already be selected, so click on the gray Properties category button in the palette.
  9. Drag the blue kill Self block onto the orange do after 5 seconds block, as shown in the following screenshot:
    Time for action – making the statues disappear after a delay
  10. Click on the green Attach to Actor Type button above the instruction blockpalette, and double-click on the Stencyl Book Statue in the Choose an Actor Type dialog box.
  11. Test the game. Watch several statues fall and wait for at least five seconds.

What just happened?

We created a new actor behavior, which automatically kills the actor five seconds after it is created, and we attached the new behavior to the statue actor.

It was an easy behavior to create and it does a very straightforward job, however, the result is not very elegant—the statues just vanish! As with other aspects of the game, this may be the desired effect, but instantly vanishing actors might be rather confusing for players of a game. Perhaps we can implement a more elegant solution.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.86.134