Have pushed a new sample 'examples/layerani' which demonstrates how to set up a 2-layer playfield and apply animaton to the top layer.
This example shows trees growing slowly and independently at random locations around the map. They are not location-specific - in other words, the tree graphics are independent of the other background graphics and are masked on top.
In fact both playfield layers can be animated independently if needed.
Map asset containing the tree shapes. As with any playfield map, this consists of a map file and a tile library.
Sample showing the background with the trees growing on top:
Dual-layer playfields are enbled with the PFA_DualLayer attribute in the playfield config.
Tile animation is enabled with PFA_TileAnimation.
Animating the base layer is useful for things like opening doors, animating water, damaging scenery etc. Many of these cases would be map location specific.
Animating the top (transparent overlay) layer is useful for things like animated shrubbery, switches and other reusable things which might be placed anywhere at multiple locations on the base layer.
Since this type of animation uses tilemaps and is part of the background, the cost is very low so long as the animation is infrequently updated. While you could achieve the same with sprites, you'd be paying the cost of those sprites every refresh.
Some primitives are provided to assist with copying rectangles, rows and colums from a loaded map asset to the active playfield - either base or top layer.
Maps (general purpose or active playfields) can also be created & filled at runtime, without loading them. In this sample, the 2nd playfield layer is created empty. The trees are placed at runtime.
Animation is achieved by creating invisible entities (again!
