|
Rhythm
Game Engines Final Project
|
A component that handles texture rendering for a GameObject. More...
Public Member Functions | |
| this (GameObject *owner) | |
| Constructor for ComponentTexture. | |
| ~this () | |
| Destructor for ComponentTexture. | |
| override void | Render (SDL_Renderer *renderer) |
| Renders the texture using the given renderer. | |
| override void | Update () |
| Updates the animation frame if the texture is animated. | |
| SDL_Rect * | GetRectangle () |
| Gets the rectangle defining the texture's position and size. | |
| typeof (this) SetRectangle(SDL_Rect rectangle) | |
| Sets the rectangle defining the texture's position and size. | |
| typeof (this) SetImage(string path | |
| Sets the image for the texture from a file. | |
| typeof (this) SetRotation(double rotation) | |
| Sets the rotation angle for the texture. | |
| double | GetRotation () |
| Gets the rotation angle of the texture. | |
| void | SetPosition (int x, int y) |
| Sets the position of the texture. | |
| typeof (this) LoadAnimations(string filename) | |
| Loads animations from a JSON file. | |
| typeof (this) LoadPlayerAnimations(string filename) | |
| Loads player animations from a JSON file. | |
| typeof (this) LoadBlockAnimation(string filename | |
| Loads block animation from a JSON file. | |
| assert (json.type==JSONType.OBJECT) | |
| assert (sprites.type==JSONType.OBJECT) | |
| if ("tileWidth" in sprites.object) | |
| if ("tileHeight" in sprites.object) | |
| for (int y=0;y< numFramesY;y++) | |
| assert (animations.type==JSONType.OBJECT) | |
| foreach (string key, JSONValue frameInfo;animations.object) | |
| typeof (this) PlayAnimation(string name) | |
| Plays the specified animation. | |
| typeof (this) SetFrameDuration(long duration) | |
| Sets the duration of each frame in the animation. | |
Public Attributes | |
| SDL_Renderer * | renderer |
| int | index |
| JSONValue | json = parseJSON(fileContent) |
| JSONValue | sprites = json.object["sprites"][index] |
| int | width = sprites.object["width"].integer.to!int |
| int | height = sprites.object["height"].integer.to!int |
| int | tileWidth = width |
| int | tileHeight = height |
| int | numFramesX = width / tileWidth |
| int | numFramesY = height / tileHeight |
| JSONValue | animations = json.object["sprites"][index]["animations"] |
| mIsAnimated = true | |
A component that handles texture rendering for a GameObject.
|
inline |
Constructor for ComponentTexture.
| owner | Pointer to the GameObject that owns this component. |
|
inline |
Gets the rectangle defining the texture's position and size.
|
inline |
Gets the rotation angle of the texture.
|
inline |
Renders the texture using the given renderer.
| renderer | The SDL_Renderer to use for rendering. |
|
inline |
Sets the position of the texture.
| x | The x-coordinate of the position. |
| y | The y-coordinate of the position. |
|
inline |
Loads animations from a JSON file.
| filename | The path to the JSON file. |
| components::texture::ComponentTexture::typeof | ( | this | ) |
Loads block animation from a JSON file.
| filename | The path to the JSON file. |
| index | The index of the block animation in the JSON file. |
|
inline |
Loads player animations from a JSON file.
| filename | The path to the JSON file. |
|
inline |
Plays the specified animation.
| name | The name of the animation to play. |
|
inline |
Sets the duration of each frame in the animation.
| duration | The duration of each frame in frames. |
| components::texture::ComponentTexture::typeof | ( | this | ) |
Sets the image for the texture from a file.
| path | The path to the image file. |
| renderer | The SDL_Renderer to use for rendering. |
|
inline |
Sets the rectangle defining the texture's position and size.
| rectangle | The new rectangle to set. |
|
inline |
Sets the rotation angle for the texture.
| rotation | The rotation angle in degrees. |
| int components::texture::ComponentTexture::index |
| SDL_Renderer* components::texture::ComponentTexture::renderer |