Class Actor¶
-
class Actor : public ISaveable¶
The Actor class represents an Actor in the game’s world.
See also
Direction
Public Functions
-
Actor() = default¶
Empty constructor.
-
Actor(const std::string &fileName)¶
Constructor that takes a path to the .ractor file.
-
Actor(std::unique_ptr<TileSet> tileSet, Vector2 atlasPos, std::string tileSetSource)¶
Constructor that takes a TileSet, the atlas position of the tile to use, and the path to the TileSet.
-
void unload() const¶
Unload routine. The UnloadTexture function will called here.
-
void update()¶
Update routine.
-
void draw() const¶
Draw routine.
-
Vector2 getPosition() const¶
Get this actor’s position in the world.
-
void setTilePosition(Vector2 newPosition, Vector2 tileSize)¶
Set Actor position relative to a tile in the world.
-
int getCurrentFrame() const¶
Get the current frame of this actor.
-
inline void resetAnimation()¶
Reset the animation back to frame 0.
-
Vector2 getCurrentAnimationAtlas() const¶
Get the current animation atlas of this actor.
-
Rectangle getCurrentAnimationRectangle() const¶
Get the current animation rectangle of this actor.
-
Vector2 getAnimationAtlasByIdx(int frameIndex) const¶
Get an atlas of this actor by frame index.
-
void setAnimationFrame(int frameIndex)¶
Set the current frame.
-
int getAnimationCount() const¶
Get the current size of the animation in the direction.
-
void setTileSet(const std::string &newTileSetSource)¶
-
Rectangle getCollisionRect(Vector2 velocity) const¶
Get the collision rectangle of this Actor if it was moved by the velocity vector
-
Vector2 getCollisionCenter() const¶
Get collision center point.
-
void addAnimationFrame(Direction id, Vector2 atlasPos)¶
Add a frame in the chosen animation. The frame represents an atlas tile from this Actor’s TileSet.
-
void removeAnimationFrame(Direction id, int frameIndex)¶
Remove a frame in the chosen animation, specified by an index.
-
void setAnimationFrame(Direction id, int frameIndex, Vector2 atlasTile)¶
Change a frame in the chosen animation to another atlas tile from the TileSet.
-
void addAnimationFrames(Direction id, const std::vector<std::vector<int>> &frames)¶
Add multiple frames to the chosen animation.
-
bool isTempAnimationPlaying()¶
Check whether a temporary animation is playing
-
std::array<std::vector<Vector2>, 8> getAnimationsRaw() const¶
Get an array of this Actor’s animations
-
bool hasInteractable()¶
Whether this Actor has an Interactable.
-
void setHasInteractable(bool value)¶
Set the ‘ownsInteractable’ flag.
-
Interactable *getInteractable()¶
Get a pointer to this Actor’s Interactable.
-
void setInteractableFromPath(const std::string &interPath)¶
Add an Interactable using an interactable file.
Public Members
-
std::function<void(int)> onFrameChanged¶
The callback when the current frame changes.
-
Actor() = default¶