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_10.stencyl.

Ensure that the Manage Statues behavior is displayed on screen.

Towards the end of this Time for action section, there is a screenshot displaying the completed behavior, and this can be referred to while completing the following steps:

  1. Drag the kill Self block out of the orange do after 5 seconds block, and drop it onto the gray background below the orange block.
  2. Ensure that the Actor section button is selected at the top of the instruction block palette, and click on the gray Tweening category button.
  3. Drag the fade in Self over 0 sec using None block into the do after 5 seconds block.
  4. In the fade in Self over ... sec using None block, click on the in option and change it to out.
  5. Enter the number 1 into the over textbox.
  6. Display the flow instruction blocks by clicking on the Flow section button at the top of the instruction block palette, and click on the Time category button.
  7. Drag the do after 0 seconds block from the instruction block palette and place it underneath the blue fade out … block.
  8. In the new do after … seconds block, change the textbox to 1.
  9. Drag the blue kill Self block into the new do after 1 seconds block:
    Time for action – making the statues disappear after a delay
  10. Test the game. Watch what happens to each statue after five seconds.

What just happened?

We have modified the behavior so that, instead of just killing the statue instantly, it will gently fade the statue out of view and then kill the actor.

It's important to note that when the statue has completely faded out of view, it still exists (it's just invisible!), which is why we need the kill Self block. We also need to understand that while the fade out Self over 1 sec using None block is doing its job, it does not wait for the fading to complete before the behavior moves on to the next instruction. That's why we have had to put the kill Self block inside an additional do after 1 seconds block. If we fail to delay the kill Self instruction, then the fade out Self over 1 sec using None block will start to fade the statue, but the kill Self block will instantly remove the statue after the fade process has started and before the fade out Self over 1 sec using None block has completed its work.

By introducing this new behavior, we have fixed two problems—the gameplay problem, whereby statues could block the monkey's path, and also the technical problem, which caused the game to lag when too many statues were on the screen. Lateral thinking such as this, will often help us to resolve gameplay and technical problems. So, bear this in mind in the cases when a difficult technical or gameplay issue occurs during the development process. Consider that there might be a straightforward solution that can also make the game more interesting and fun to play.

Experimenting with the timings

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

In the Kill statues event, we have three different timings to consider:

  1. The main do after 5 seconds event block, which determines how long the event should wait after the creation of the statue and before triggering the enclosed instruction blocks.
  2. The fade out Self over 1 sec using None block, which determines over how long the fade will occur.
  3. The additional do after 1 seconds block, which specifies how long to wait before the statue is removed from the scene. In practice, for this effect, the delay should always be the same as the delay for the fade out Self over 1 sec using None block.

Experiment with the timings of the blocks to get a feel of how it affects the gameplay, and decide upon a set of timings that works well in the game.

Another interesting experiment would be to edit the Drop Actors Randomly scene behavior, so the statues appear more quickly. Reducing the do every … seconds delay in the Drop statues event will make the statues appear more frequently, and, if the fade and kill delays are sped up, the game becomes far more manic. Consider how changes to these arguments (the numbers and textual information that affect the way that some instruction blocks work) can change the gameplay. Often, an increase in difficulty in later levels can easily be achieved, simply by changing the timings in a behavior.

It might be a good idea to ask someone else to test the game in its current state, and listen to what they have to say about their first impressions of the game. Make a note of these comments and keep them. There will always be an opportunity to come back to this behavior at a later stage of the development to make further adjustments.

Ensure that, after experimenting, the game is tested thoroughly and is working correctly.

Have a go hero – making the fruit fade when collected

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

Earlier in this chapter, we created an actor behavior called Manage Player Collisions, in which the Collides with Collectibles event removes the fruit from the scene when the monkey collides with it.

Try modifying the Collides with Collectibles event so that it fades out the fruit rather than killing it instantly. Refer to the previous Time for action – making the statues disappear after a delay section, in which we changed the Manage Statues behavior to fade out the statues. The code is very similar.

Tip

Right-clicking on an existing instruction block in a behavior, and selecting Copy from the drop-down menu, places the block into the Stencyl clipboard. The copied blocks can then be pasted (right-click, Paste) into the gray background area of a different behavior, and then dragged and dropped into the required location.

Try different timings for the fading of the fruit and note that timings do not have to be whole numbers. It is acceptable to specify fractions of a second, for example, do after 0.5 seconds.

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

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