Time for action – using the grow instruction block

The game file to import and load for this session is 5961_05_07.stencyl.

  1. Ensure that the Manage Player Collisions behavior is displaying the Collides with Collectibles event; click on the Dashboard tab, select Actor Behaviors, and double-click on the Manage Player Collisions icon in the main panel.
  2. Holding the Shift key on the keyboard, drag the fade out of group over 0.25 sec using None block and drop it onto the icon of the trashcan at the upper-right of the center panel. Only the blue block should move during this process. If the other blocks are dragged with the blue block, place the blocks into their original position, release the Shift key, and try again!
  3. In the Actor | Tweening category of the instruction-block palette, locate the grow self to (w: 0%, h: 0% ) over 0 sec using None block and drag it, so that it snaps into place above the orange do after 0.25 seconds block.
  4. Drag the blue … of group block from the when Self hits a … of Collectibles block, and drop it onto the word Self in the new grow block.
  5. In the new blue block enter 0 into the w: textbox and 0 into the h: textbox.
  6. Enter 0.5 in the textbox that appears after the word over.
  7. In the orange do after 0.25 seconds block, change the timing to 0.5 seconds.
    Time for action – using the grow instruction block
  8. Ensure that the Collides with Collectibles event now looks like the previous screenshot and then test the game; move the monkey so that it collides with some collectibles.

What just happened?

We have modified the Collides with Collectibles event in the Manage Player Collisions behavior so that the collectible items shrink away to nothing when the monkey collides with it.

Originally, when a collision occurred between the monkey and a collectible, the collectible would fade away, but we dragged the original fade out… block into the trashcan to remove it from the event. Holding down the Shift key when dragging a block ensures that only a single block is dragged.

We then located the grow… instruction block in the palette, dragged it into the event, and changed the timing of the grow effect to 0.5 seconds. The w: and h: textboxes in the grow... instruction specify the final width and height of the actor when the effect has completed. In our case, we set both the w: and h: settings to 0, because we want the actor to shrink so that it is no longer visible. If we needed an actor to grow, we could specify the final w: and h: sizes to be greater than 100 percent; for example, setting the size to 200 percent would make the actor grow to twice its original size.

The final step was to modify the timing in the kill… of group block, so that the actor will not be removed from the scene until the grow effect has completed.

Have a go hero

We have now used both a fade… block (which we have now removed) and a grow… block in our game.

Experiment with the grow effect option (currently set to None) and the timings of the grow... block in the Collides with Collectibles event, remembering also to change the timing of the do after… block.

Also, take this opportunity to review the available Tweening blocks in the palette, and consider how they may be used to make interesting special effects in our game. We've only touched on how to use the effects that are available to us, so go ahead and try various combinations of effects; some will look great, and some may be a little over-the-top, but have some fun while learning!

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

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