LevelObject - JayhawkZombie/EECS581Project GitHub Wiki
--
class LevelObject : public BaseEngineInterface
in SFEngine > Source > Headers > Level > LevelObject.h
This class derives from Engine::BaseEngineInterface
and forms the base for objects which appear in a level.
While working on documentation, the most significant methods will be documented first, and only those methods whose interface is never changing or very unlikely to change will be documented. Others are internal and not intended for use outside of experimental features or internal operations
Methods
virtual void TickUpdate(const double &delta) override
- The usual TickUpdate function, called every frame your object is alive (or visible if rendered).
- Use this method to do any time-based updating you need to do.
virtual void PhysicsUpdate()
- This function will be called after the physics has been updated (i.e. your collider has been moved)
- Use this method to properly update yourself after a physics update (physics updates do not occur at the same rate a rendering updates)
virtual void Render(std::shared_ptr<sf::RenderTarget> Target) override
- This function is called every frame you are to be rendered
- Use this method to render any primitives necessary onto the render target
virtual void OnShutDown() override
- overridden from BaseEngineInterface
virtual void SerializeOut(std::ofstream &out) override
- overridden from BaseEngineInterface
virtual void SerializeIn(std::ifstream &in) override
- overridden from BaseEngineInterface
virtual void SetPosition(const sf::Vector2f &pos)
- Set the position of your object (typically with respect to the upper-left corner)
virtual void SetSize(const sf::Vector2f &size)
- Set the size of your object
virtual void SetTexture(std::shared_ptr<sf::Texture> mytexture)
- Set the texture used by your object's Sprite member
virtual void SetTextureRect(sf::IntRect myRect)
- Set the texture rect rendered using your object's Sprite member
virtual void HandleInputEvent(const UserEvent &evnt)
- Called to inform the object of an input event
virtual void SetID(const std::string &ID) override
- Called to force the object to set its ID
virtual void OnGameStart()
- Called when the "game"/level is initially started
virtual void OnGameEnd()
- Called when the "game"/level is done
virtual void OnKilled()
- Called when your object has been killed/destroyed
virtual void OnSpawn()
- Called when your object is spawned (also called on a respawn)
sf::FloatRect GetGlobalBounds() const
- Get the global bounds enclosed within the object as (left, top, width, height)
virtual void Move(const sf::Vector2f &delta)
- Called to inform the object to move itself
virtual void Move(float x, float y)
- Called to inform the object to move itself
virtual void Move(int x, int y)
- Called to inform the object to move itself
void MoveObject(const sf::Vector2f &delta)
- Called to inform the object to move itself
std::vector<std::shared_ptr<Collider2D>> GetColliders()
- Get the collection of
Collider2D
instances associated with this object
void AddCollider(std::shared_ptr<Collider2D> Collider)
- Add a
Collider2D
instance to the object's collection
Member variables
thor::AnimationMap<sf::Sprite, std::string> m_AnimationMap
-
Thor
animation map used for animating sprites. See Thor
thor::Animator<sf::Sprite, std::string> m_Animator
-
Thor
animator used for animating sprites. See Thor
std::unordered_map<std::string, thor::FrameAnimation> m_FrameAnimations
-
Thor
frame animations used for animating sprites. See Thor
std::vector<std::shared_ptr<Collider2D>> m_Colliders
- Collection of
Collider2D
instances associated the object. Used for collision.
sf::Sprite Sprite
-
sf::Sprite
used to render the object (derived classes do not have to use this, it is just included for simplicity)
sf::IntRect TextureRect
- The texture rect used to render the object's Sprite member
sf::Vector2f Velocity
- The object's velocity
sf::Vector2f Acceleration
- The object's acceleration
sf::Vector2f Position
- The object's position
sf::Vector2f Size
- The object's size