Flatland

Tutorial

13 | Sprites

Sprites are special types of blocks that don’t really have a 3D model, but that offer particular behaviors to 2D images in 3D space. There are 4 types of sprites:

The sprite block “1″
The simplest sprite block is simply a single plane on which you can place a texture and which doesn’t really have any behavior at all.

The spriterevolve block “2″
The spriterevolve block is a single plane that spins around on its central axis.

The spriteface block “3″
The spriteface block is a single plane that always faces the viewer. No matter what direction you approach the spriteface block from, the image that is assigned to it will appear to be facing you.

The spritefacet block “4″
The spritefacet block will unwrap a gif animation and present each frame to be viewed from a different angle in the spot. For example, if you took photographs of your favorite comfy chair from 8 different vantage points, all in the same horizontal plane, then put those images together in a gif animation, the spritefacet block would unwrap that animation, making it appear as if the chair were in your spot, and you could walk all the way around it.

Sprite Parameters
There are 5 parameters that are associated with sprites. All sprites can take the align, solid, and size parameters. Align specifies at what height in the blockspace the sprite will appear. Sprites will appear at the bottom of the block space by default. They can also be assigned to the top or the center. solid determines whether or not you can walk through the sprite. If solid=”no”, then a visitor can walk right through the sprite. If solid=”yes”, then the sprite will be solid. Solid=”yes” by default. Size of course determines how large the sprite will be. Size is measured in pixels and cannot exceed “(256,256)”. If no size is specified, the sprite will be the same size as the image that is placed on it.

The sprite block can also take an angle parameter, specifying what angle the sprite is facing. The angle is expressed as whole number degrees from 0 to 359. The default value is “0″. The spriterevolve block can take a speed parameter, expressed as revolutions per second. The default value is “.5″.

Experiment with Sprites.
Put the following < create> tags in your firstspot.3dml:

< create symbol="1" block="sprite">
< part name="*" texture="images/animate.gif" />
< param angle="45" solid="no" />
< /create>

< create symbol="2" block="spriterevolve">
< part name="*" texture="images/animate.gif" />
< param speed="1" solid="no" />
< /create>

< create symbol="3" block="spriteface">
< part name="*" texture="images/animate.gif" />
< param align="top" />
< /create>

< create symbol="4" block="spritefacet">
< part name="*" texture="images/animate.gif" />
< param align="center" />
< /create>

And change the map to look like this:

< level number="1">
###.@.###
#…….#
#.1…..#
#…..2.#
#…….#
#.3…..#
#….4..#
#…….#
#########
< /level>

Save the file and open it in your browser. Walk around each of the different sprites to see how they behave. Try walking right through them.

show me the code next lesson

Welcome | Starting | Head Tag | Body Tag | Multilevels | Navigation | Textures | Orientation | Linking | Sound | Lighting | Popups | Sprites | Actions | Streaming 1 | Streaming 2 | More Blocks | Tips & Tricks | Orientation Guide | Texture Styles