Cuts the sprite into a custom number of rows
and columns
. Useful if you have animated sprites.
void onSceneLoaded() { // load a 256x256 sprite LoadSprite("animations/animated_sprite_256x256.png"); // divides the sprite into a 4x4 rect (4 columns and 2 rows) SetupSpriteRects("animations/animated_sprite_256x256.png", 4, 2); // will look like this: // +-------------------+ // | | | | | // | 0 | 1 | 2 | 3 | // | | | | | // |____|____|____|____| // | | | | | // | 4 | 5 | 6 | 7 | // | | | | | // |____|____|____|____| // should return vector2(64,128) vector2 size = GetSpriteFrameSize("animations/animated_sprite_256x256.png"); // select the third frame SetSpriteRect("animations/animated_sprite_256x256.png", 2); } void onSceneUpdate() { // Draw the third frame // +----+ // | | // | 2 | // | | // |____| DrawSprite("animations/animated_sprite_256x256.png", vector2(0,0), 0xFFFFFFFF); }