Adding sprites
Sprites are images. LDK supports all images that HTML supports. The game object defines the addSprite(id,src,pos,col) method for adding them. Id works as always, src is the place on the web server where the image might be located, pos specifies both the position and scale of the image, and col is the background-color. Like addRect, the object is returned.

Some images allow transparency. If you want your image to have transparency information, set col to ldk_transparentBackground.

Properties of sprites
id, animating, depth, color and position work as always. Functions for movement, animation, deletion and events are exactly the same as they are for the rectangle. The sprite object has only one additional attribute, the source attribute.

Behind the scenes, sprites are handled quite differently from text and rectangles, but you don't need to worry about that!

Last edited Dec 13, 2009 at 11:41 PM by larztheloser, version 1


No comments yet.