ProtoRPG:Sprite

Jump to: navigation, search

In ProtoRPG all visual elements are stored in graphic files, in any format that the browser is capable of displaying. PNG is recommended as it has high and lossless compression, as well as alpha transparency support, however GIF and JPEG are also an option. You can even use animated GIF if you want to get some visual element to be animated.

Basic form

Most of the time the appearance of an element is specified by the following property :

file: "tulip.png"

This tells the game engine that the graphic to use is located in the picturename.png file (always within the graphics subdirectory).

Subdirectories

You can organize your files in subdirectory if you want to, in this case you'll need to pass the name :

file: "flowers/tulip.png"

Sprites

Since using a file for every element is very inefficient and slow (and therefor not recommended), pictures can be grouped in a single graphic file: this will be a very wide image with all the elements aligned one after the other. In this case you need to tell the engine which part of the picture needs to be drawn :

file: ["flowers/tulips.png",5]

This tells the game engine that the picture to use is the #5 (the 6th one, as count starts from 0). If your game uses 32 pixels tiles, then it's the graphic starting at coordinate 160x0 and of size 32x32 pixels.

Note that ["file.png",0] is the same as "file.png".