|
JNGL
Easy to use cross-platform 2D game library
|
Base class for drawable objects with a position and a rectangle size. More...
#include <jngl/Drawable.hpp>
Public Member Functions | |
| Drawable (const Drawable &)=default | |
| Drawable & | operator= (const Drawable &)=default |
| Drawable (Drawable &&)=default | |
| Drawable & | operator= (Drawable &&)=default |
| virtual void | step ()=0 |
| Advance object's state. | |
| virtual void | draw () const =0 |
| Called when drawing a frame. | |
| Vec2 | getPos () const |
| Returns position (not center) | |
| virtual void | setPos (double x, double y) |
| Sets the position of the top-left of the Drawable. | |
| template<class Vect > | |
| void | setPos (Vect p) |
| Sets the position of the top-left of the Drawable. | |
| jngl::Vec2 | getCenter () const |
| Returns the position of the center of the Drawable. | |
| virtual void | setCenter (double x, double y) |
| Centers the Sprite at (x, y) | |
| template<class Vect > | |
| void | setCenter (Vect c) |
| Centers the Sprite at c (e.g. jngl::Vec2) | |
| double | getLeft () const |
| Returns the distance from the left side of the screen. | |
| void | setLeft (double x) |
| double | getTop () const |
| Returns the distance from the top of the screen. | |
| void | setTop (double y) |
| double | getRight () const |
| Returns the distance from the right side of the screen. | |
| void | setRight (double x) |
| double | getBottom () const |
| Returns the distance from the bottom of the screen. | |
| void | setBottom (double y) |
| double | getX () const |
| void | setX (double) |
| double | getY () const |
| void | setY (double) |
| Vec2 | getSize () const |
| Returns {width, height} in screen coordinates. | |
| float | getWidth () const |
| Returns the width in screen coordinates. | |
| float | getHeight () const |
| Returns the height in screen coordinates. | |
| void | drawBoundingBox () const |
| Draws a red box around the Drawable. | |
| bool | contains (jngl::Vec2 point) const |
| Returns whether point is inside the bounding box. | |
Protected Member Functions | |
| void | setWidth (float) |
| Override width (in screen coordinates) | |
| void | setHeight (float) |
| Override height (in screen coordinates) | |
Friends | |
| class | Sprite |
| class | Text |
Base class for drawable objects with a position and a rectangle size.
Definition at line 15 of file Drawable.hpp.
|
pure virtual |
Advance object's state.
Implemented in Text.
|
pure virtual |
Called when drawing a frame.
Implemented in Text.
|
inline |
Sets the position of the top-left of the Drawable.
Definition at line 40 of file Drawable.hpp.
|
inline |
Centers the Sprite at c (e.g. jngl::Vec2)
Definition at line 51 of file Drawable.hpp.
|
friend |
Definition at line 17 of file Drawable.hpp.
|
friend |
Definition at line 18 of file Drawable.hpp.