|
| RuntimeObject (RuntimeScene &scene, const gd::Object &object) |
| Construct a RuntimeObject from an object. More...
|
|
| RuntimeObject (const RuntimeObject &object) |
| Copy constructor. Calls Init().
|
|
RuntimeObject & | operator= (const RuntimeObject &object) |
| Assignment operator. Calls Init().
|
|
virtual | ~RuntimeObject () |
| Default destructor.
|
|
virtual std::unique_ptr< RuntimeObject > | Clone () const |
| Must return a pointer to a copy of the object. A such method is needed to do polymorphic copies. More...
|
|
virtual bool | ExtraInitializationFromInitialInstance (const gd::InitialInstance &position) |
| Called by RuntimeScene when creating the RuntimeObject from an initial instance. More...
|
|
virtual bool | Draw (sf::RenderTarget &renderTarget) |
| Draw the object. More...
|
|
const gd::String & | GetName () const |
| Get the name of the object.
|
|
const gd::String & | GetType () const |
| Get the type of the object.
|
|
int | GetZOrder () const |
| Query the Z order of the object.
|
|
void | SetZOrder (int zOrder_) |
| Change the Z order of the object.
|
|
bool | IsHidden () const |
| Return if the object is hidden or not.
|
|
bool | IsVisible () const |
| Return if the object is visible ( not hidden )
|
|
void | SetHidden (bool hide=true) |
| Hide/Show the object.
|
|
void | SetLayer (const gd::String &layer_) |
| Change the layer of the object.
|
|
const gd::String & | GetLayer () const |
| Get the layer of the object.
|
|
bool | IsOnLayer (const gd::String &layer_) const |
| Check if the object is on a layer.
|
|
sf::FloatRect | GetAABB () const |
| Get the object AABB.
|
|
virtual std::vector< Polygon2d > | GetHitBoxes () const |
| Get the object hitbox(es) More...
|
|
virtual std::vector< Polygon2d > | GetHitBoxes (sf::FloatRect hint) const |
| Get the object hitbox(es) preferably intersecting with hint. More...
|
|
bool | IsCollidingWith (RuntimeObject *other, bool ignoreTouchingEdges=false) |
| Check collision between two objects using their hitboxes. More...
|
|
bool | IsCollidingWithPoint (float pointX, float pointY) |
| Check if a point is inside the object collision hitboxes. More...
|
|
RaycastResult | RaycastTest (float x, float y, float angle, float dist, bool closest) |
| Check if a ray intersect any object hitbox. More...
|
|
bool | SeparateFromObjects (const std::vector< RuntimeObject *> &objects, bool ignoreTouchingEdges=false) |
| Check collision with each object of the list using their hitboxes, and move the object according to the sum of the move vector returned by each collision test. More...
|
|
virtual bool | CursorOnObject (RuntimeScene &scene, bool accurate) |
| Return true if the cursor is on the object. More...
|
|
virtual void | Update (const RuntimeScene &scene) |
| Called at each frame, before events and rendering. More...
|
|
signed long long | GetElapsedTime (const RuntimeScene &scene) const |
| Return the time elapsed since the last frame, in microseconds, for the object. More...
|
|
virtual float | GetWidth () const |
| Get the width of the object, in pixels.
|
|
virtual float | GetHeight () const |
| Get the height of the object, in pixels.
|
|
virtual void | SetWidth (float) |
| Set the new width of the object. More...
|
|
virtual void | SetHeight (float) |
| Set the new height of the object. More...
|
|
virtual bool | SetAngle (float) |
| Get the angle of the object, in degrees. More...
|
|
virtual float | GetAngle () const |
| Get the angle of the object, in degrees.
|
|
float | GetX () const |
| Get the X coordinate of the object in the layout.
|
|
float | GetY () const |
| Get the Y coordinate of the object in the layout.
|
|
void | SetX (float x_) |
| Change X position of the object. More...
|
|
void | SetY (float y_) |
| Change Y position of the object. More...
|
|
virtual void | OnPositionChanged () |
|
virtual float | GetDrawableX () const |
| Get the real X position where is renderer the object. More...
|
|
virtual float | GetDrawableY () const |
| Get the real Y position where is renderer the object. More...
|
|
virtual float | GetCenterX () const |
| Get the X position of the center, relative to the position returned by GetDrawableX().
|
|
virtual float | GetCenterY () const |
| Get the Y position of the center, relative to the position returned by GetDrawableY().
|
|
double | GetSqDistanceTo (double x, double y) |
| Get squared distance, in pixel, between the object and the specified position. More...
|
|
bool | ClearForce () |
| Delete all forces applied to the object.
|
|
|
Members functions providing access to the object's variables.
|
const RuntimeVariablesContainer & | GetVariables () const |
| Provide access to variables of the object.
|
|
RuntimeVariablesContainer & | GetVariables () |
| Provide access to variables of the object.
|
|
|
Functions related to behaviors management.
|
void | DoBehaviorsPreEvents (RuntimeScene &scene) |
| Call each behavior so that they do their work before events.
|
|
void | DoBehaviorsPostEvents (RuntimeScene &scene) |
| Call each behavior so that they do their work after the events were runn.
|
|
RuntimeBehavior * | GetBehaviorRawPointer (const gd::String &name) |
|
RuntimeBehavior * | GetBehaviorRawPointer (const gd::String &name) const |
|
bool | HasBehaviorNamed (const gd::String &name) const |
| Return true if the object has the behavior with the specified name.
|
|
void | AddBehavior (const gd::String &name, std::unique_ptr< RuntimeBehavior > behavior) |
| Add the specified behavior to the object.
|
|
|
Members functions used by the IDE
|
virtual void | GetPropertyForDebugger (std::size_t propertyNb, gd::String &name, gd::String &value) const |
| Called by the debugger so as to get a property value and name. More...
|
|
virtual bool | ChangeProperty (std::size_t propertyNb, gd::String newValue) |
| Called by the debugger so as to update a property. More...
|
|
virtual std::size_t | GetNumberOfProperties () const |
| Must return the number of available properties for the debugger.
|
|
|
void | DeleteFromScene (RuntimeScene &scene) |
|
void | PutAroundAPosition (float positionX, float positionY, float distance, float angleInDegrees) |
|
void | AddForce (float x, float y, float clearing) |
|
void | AddForceUsingPolarCoordinates (float angle, float length, float clearing) |
|
void | AddForceTowardPosition (float positionX, float positionY, float length, float clearing) |
|
void | AddForceToMoveAround (float positionX, float positionY, float angularVelocity, float distance, float clearing) |
|
void | AddForceTowardObject (RuntimeObject *object, float length, float clearing) |
|
void | AddForceToMoveAroundObject (RuntimeObject *object, float velocity, float length, float clearing) |
|
void | PutAroundObject (RuntimeObject *object, float length, float angleInDegrees) |
|
void | RotateTowardPosition (float Xposition, float Yposition, float speed, RuntimeScene &scene) |
|
void | RotateTowardAngle (float angleInDegrees, float speed, RuntimeScene &scene) |
|
void | Rotate (float speed, RuntimeScene &scene) |
|
bool | VariableExists (const gd::String &variable) |
|
void | SetXY (const char *xOperator, float xValue, const char *yOperator, float yValue) |
|
void | Duplicate (RuntimeScene &scene, std::map< gd::String, std::vector< RuntimeObject *> *> pickedObjectLists) |
|
void | ActivateBehavior (const gd::String &behaviorName, bool activate=true) |
|
bool | BehaviorActivated (const gd::String &behaviorName) |
|
bool | IsStopped () |
|
bool | TestAngleOfDisplacement (float angle, float tolerance) |
|
double | GetSqDistanceWithObject (RuntimeObject *other) |
|
double | GetDistanceWithObject (RuntimeObject *other) |
|
bool | SeparateFromObjects (std::map< gd::String, std::vector< RuntimeObject *> *> pickedObjectLists, bool ignoreTouchingEdges=false) |
|
void | SeparateObjectsWithoutForces (std::map< gd::String, std::vector< RuntimeObject *> *> pickedObjectLists) |
|
void | SeparateObjectsWithForces (std::map< gd::String, std::vector< RuntimeObject *> *> pickedObjectLists) |
|
static gd::Variable & | ReturnVariable (gd::Variable &variable) |
|
static double | GetVariableValue (const gd::Variable &variable) |
|
static const gd::String & | GetVariableString (const gd::Variable &variable) |
|
static bool | VariableChildExists (const gd::Variable &variable, const gd::String &childName) |
|
static void | VariableRemoveChild (gd::Variable &variable, const gd::String &childName) |
|
static void | VariableClearChildren (gd::Variable &variable) |
|
static unsigned int | GetVariableChildCount (gd::Variable &variable) |
|
A RuntimeObject is something displayed on the scene.
Games don't directly use this class: Extensions can provide object by deriving from this class, and redefining functions:
- The constructor must have this signature : MyRuntimeObject(RuntimeScene & scene, const MyObject & object) with MyObject the class inheriting from gd::Object.
- An important function is RuntimeObject::Draw. It is called to render the object on the scene. This function take in parameter a reference to the target where render the object.
- RuntimeObject must be able to return their size, by redefining RuntimeObject::GetWidth and RuntimeObject::GetHeight
- RuntimeObject must be able to return the position where they have precisely drawn ( for example, Sprite can draw its image not exactly at the position of the object, if the origin point was moved ). It must also be able to return the position of their center. See RuntimeObject::GetDrawableX, RuntimeObject::GetDrawableY and RuntimeObject::GetCenterX, RuntimeObject::GetCenterY.
- If objects need to load resources ( for example textures at the loading ), it must be done inside the constructor creating the object from a gd::Object.
- When objects are placed at the start of the scene, scenes call RuntimeObject::ExtraInitializationFromInitialInstance, passing a gd::InitialInstance object in parameter ( containing information like the position where place the object ). Note that common information were already changed ( Position, angle, layer... ). You just need to setup the object with the information related to your object.
- Finally, objects can expose debugging features: RuntimeObject::GetPropertyForDebugger, RuntimeObject::ChangeProperty and RuntimeObject::GetNumberOfProperties
See also gd::Object which is used to store the initial objects before they are put on the scene.
- See also
- gd::Object