Skip to content
Rodrigo Braz Monteiro edited this page Apr 2, 2018 · 11 revisions

Overview

Sprites are the main way in which images are drawn in Halley. Each sprite represents a quad (drawn as two triangles), which can be positioned, rotated, scaled, coloured and texture mapped. A sprite also contains a reference to a Material that will be used to draw it, and it might contain clipping and slicing information.

Animation and Text Rendering generate sprites for rendering.

Sprites are can be drawn directly to a Painter (see draw, below), or they can be queued in a Sprite Painter for drawing with sorting.

Initialising sprites

Sprites are typically constructed empty, then modified with accessors. The most typical way to initialise one is by providing an image name, and, optionally, a Material name (Halley/Sprite will be used by default).

auto s1 = Sprite().setImage(resources, "mySprite.png");
auto s2 = Sprite().setImage(resources, "light.png", "Halley/SpriteAdd");

You can also pass explicit textures and material definitions, like so:

auto s3 = Sprite().setImage(resources.get<Texture>("mySprite.png"), resources.get<MaterialDefinition>("Halley/SpriteAdd"));

If the sprite is being loaded from a spritesheet, it's also possible to load them with the setSprite method:

auto s4 = Sprite().setSprite(resources, "lights", "myCoolLight", "Halley/SpriteAdd");
auto s5 = Sprite().setSprite(resources.get<SpriteSheet>("lights"), "myCoolLight");
auto s6 = Sprite().setSprite(resources.get<SpriteSheet>("lights")->getSprite("myCoolLight"));

Transforming sprites

todo

Drawing sprites

todo

Clone this wiki locally