15.2 Animation techniques

When it comes to animation, you have to choose between three techniques: Sprites, double buffering, and layers. This section is designed to give you an overview of the three techniques so that the decision is easier for you.

  1. Sprites: Sprites are especially useful when there are not much graphics to be drawn. For example, if you only need to move some blocks or player and enemy sprites around. In this case, it is better to use sprites because Hollywood can refresh the display pretty fast because not much changes. See Sprite introduction for details.

  2. Double buffering: Using a double buffer Hollywood always needs to refresh the whole display. Although hardware acceleration is used here when possible this can still be quite expensive when you have a 640x480 display which needs to be refreshed 25 times a second. Thus, a double buffer is only recommended when a lot of custom graphics have to be drawn. For instance, the Hollywood examples that draw a real sine scroller use a double buffer because they need to draw a lot of different tiles. Such things would not be possible with sprites because the drawing operations are heavily customized and change every frame. See BeginDoubleBuffer() for details.

  3. Layers: Hollywood comes with a powerful layers system which allows you to access every graphics item on the display as its own layer and modify its position, size, and looks on the fly. The layer system is extremely flexible and powerful at the cost of speed so if you need to draw a lot of graphics it might be faster to use double buffering instead.

Here is a recommendation of animation techniques that are suitable for common types of applications:

Board/card games:
Sprites or layers because fast graphics aren't required.

Sprites or layers because there's not much action and screen updates do not have to be very fast.

Sprites or layers. The only thing that moves are the enemies and the player.

2D shooter:
Double buffering because the background is scrolling. Hence, the whole screen has to be updated every frame.

Double buffer if there is a scrolling background. If the game doesn't scroll then sprites or layers.

Scene demo:
Double buffer by any means. A lot of custom graphics have to be drawn. This is a classical double buffer case.

If you use sprites or layers you should also encapsulate all commands required to draw a single frame of your project within a BeginRefresh() and EndRefresh() section. This will allow Hollywood to use optimized drawing on systems that do not support partial screen refresh like Android. As a welcome side effect using BeginRefresh() and EndRefresh() will also improve drawing speed when autoscaling is active. See BeginRefresh for details.

Show TOC