Understanding active actors

Stencyl does its best to assist us in optimizing our games. For example, if we have a moving actor in our scene, but it leaves our screen, Stencyl will make the actor inactive, so that it isn't wasting our computer's processing resources on unnecessary physics calculations. The actor will be made active again when it reappears in our scene.

Although this optimization feature is very useful, it can cause problems with certain forms of gameplay. For example, we may want our offscreen actors to remain active, even though they have left the screen. In our game, we may occasionally see that this built-in optimization becomes a problem if a statue falls at an angle, or on its side, at the very edge of the screen. The statue can freeze in midair.

In the following screenshot, the dotted rectangle represents the screen that we can see during gameplay. The statue is falling such that it is far enough away from the edge of the screen to make the actor inactive, but close enough that we can still see the corner of the statue, frozen onscreen.

Understanding active actors

This phenomenon is difficult to see when testing our game. Our monkey has to be exactly in the right place on the screen, and running in the right direction, when the statue falls. While this might happen very infrequently, the chances are that it will happen eventually, and players of our game will not be impressed to see the game's actors freezing unexpectedly.

Experiencing a freezing statue

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

Rather than playing our game for an extended period, and hoping to see a statue freeze at the edge of the screen, we can see the problem by loading the demonstration file that has been provided.

The demonstration version of the game has been configured so that a frozen statue can be seen at the right-hand edge of the screen, as shown in the previous screenshot. Test the demonstration game, but do not press any keys. The corner of a statue will be seen hanging in midair.

If the monkey is then made to run to the right of the screen, so that the camera moves, the statue will become active again, and fall as expected.

Note

After completing the previous experiment, do not use the demo game to continue development. The demo game has been configured specifically for the purpose of demonstrating how inactive actors can freeze and still be visible onscreen, and several other elements of the game have been deleted or modified in order to simplify the demonstration.

It is recommended that, once the experiment is complete, the demo game be closed and deleted.

The origin of the actors

Stencyl determines which actors are to become inactive based on the location of the origin of the actor. By default, the origin of an actor will be at its exact center; it's the central point around which the actor will rotate. Stencyl tries to take into account the size of the actor, so it can ensure that the actor is completely offscreen before making it inactive. However, if an actor is not in its original orientation, it may still be seen to freeze.

Our next task is to prevent the statue actors from becoming inactive.

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

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