-
Notifications
You must be signed in to change notification settings - Fork 1
Drawables
There are a few types of Drawables as of now:
- Tile (lowest processing cost but mostly integrated with Tilemaps)
- Image(low processing cost but not able to be animated)
- Sprite(highest processing cost but still quite low - can have multiple animations)
If you are unsure how the 'assetName' works below, refer to the Asset Manager write-up on the Cheatsheet.
Tiles should be handled by Tilemaps at this time.
Images are something static on your screen. They are Positionals so they can be placed and moved, tweened, or even player controlled but they lack the ability to be animated.
To create a Image is pretty simple. Below creates an Image with the preloaded Image Texture with the name "alienShip", adds it to the renderer's second lowest Draw Layer: 0 (Tilemaps have their own lowest Draw Layer) at position x = 100, y = 200.
// assetName position size layer
Image* alienShip = new Image("alienShip", Vec2(100, 200), Vec2Int(16, 16), 0);
Sprites are what you want to use for any graphic that needs animations. They are about as simple as Images.
To create a Sprite, the syntax is mostly the same as an Image:
// assetName position size layer
Sprite* alienShipWithAnimations = new Sprite("alienShip", Vec2(100, 200), Vec2Int(16, 16), 0);
// Add an animation named "bombStuff" which starts on frame 0 and has 4 total frames
// that have 1 second between them and the animation loops with no onComplete function.
// total loop
// name start interval onCompleteFunc
alienShipWithAnimations->AddAnimation("bombStuff", 0, 4, 1000, true, nullptr);
An Important Note about Animations They are built automatically from the size you specify the frames of the animation must be (as of now) in a horizontal strip.
Sprites have lots of functions and abilities so check out the Doxygen Sprite Docs for more info.