ImageRenderer

RareEngine2 Renderer for Tiled Bitmap Rendering

Overview

ImageRenderer is a Renderer subclass that renders a portion (tile) of a Bitmap onto a GameObject. It supports loading from resources or path and allows dynamic tile selection for animations or sprite sheets.

Field Summary

Bitmap image
The bitmap image to be rendered.
Vector2 tilescale
Size of an individual tile in the image.
Vector2 tileid
Current tile ID (x, y) to render from the bitmap.
static final float MATCH_IMAGE = -1
Special constant to auto-match tile size to the full image.

Method Summary

ImageRenderer()
Constructor that initializes tileid and tilescale.
void start(GameObject o, GameView gv)
Called when the component is initialized. Inherits from Renderer.
void update(GameObject o, GameView gv)
Called every frame. Inherits from Renderer.
void destroy(GameObject o, GameView gv)
Releases the image resource and performs cleanup.
void render(Canvas canvas, GameObject object, Paint p, GameView gv)
Draws the current tile of the bitmap on the screen.
Vector2 getTileIdWithNumber(int number)
Returns the tile ID (x, y) based on the tile number in a sprite sheet.
void setImage(Bitmap map)
Sets the bitmap image to render.
Bitmap getFromResource(Resources resource, int resid)
Loads a bitmap from app resources.
Bitmap getFromPath(String path)
Loads a bitmap from a file path.