Oxygine  1
2g game engine
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
oxygine::Actor Class Reference
Inheritance diagram for oxygine::Actor:
oxygine::EventDispatcher oxygine::intrusive_list_item< spActor > oxygine::Serializable oxygine::Object oxygine::ref_counter oxygine::ObjectBase oxygine::PoolObject oxygine::ClipRectActor oxygine::DebugActor oxygine::SlidingActor oxygine::Stage oxygine::VStyleActor oxygine::WebImage oxygine::Sprite oxygine::TextField oxygine::Box9Sprite oxygine::Button oxygine::ColorRectSprite oxygine::MaskedSprite oxygine::Polygon oxygine::ProgressBar

Public Types

typedef Property2Args< float, Vector2, const Vector2 &, Actor, &Actor::getPosition, &Actor::setPosition > TweenPosition
 
typedef Property< float, float, Actor, &Actor::getX, &Actor::setX > TweenX
 
typedef Property< float, float, Actor, &Actor::getY, &Actor::setY > TweenY
 
typedef Property< float, float, Actor, &Actor::getWidth, &Actor::setWidth > TweenWidth
 
typedef Property< float, float, Actor, &Actor::getHeight, &Actor::setHeight > TweenHeight
 
typedef Property2Args2< float, Vector2, Vector2, const Vector2 &, Actor, &Actor::getSize, &Actor::setSizeTweenSize
 
typedef Property< float, float, Actor, &Actor::getRotation, &Actor::setRotationTweenRotation
 
typedef Property< float, float, Actor, &Actor::getRotationDegrees, &Actor::setRotationDegreesTweenRotationDegrees
 
typedef Property2Args1Arg< float, Vector2, const Vector2 &, Actor, &Actor::getScale, &Actor::setScale > TweenScale
 
typedef Property2Args1Arg< float, Vector2, const Vector2 &, Actor, &Actor::getAnchor, &Actor::setAnchorTweenAnchor
 
typedef Property< float, float, Actor, &Actor::getScaleX, &Actor::setScaleX > TweenScaleX
 
typedef Property< float, float, Actor, &Actor::getScaleY, &Actor::setScaleY > TweenScaleY
 
typedef Property< unsigned char, unsigned char, Actor, &Actor::getAlpha, &Actor::setAlphaTweenAlpha
 
- Public Types inherited from oxygine::ObjectBase
typedef std::vector< ObjectBase * > __createdObjects
 

Public Member Functions

 Actor (const Actor &src, cloneOptions opt=0)
 
virtual Actorclone (cloneOptions opt=0) const
 
void copyFrom (const Actor &src, cloneOptions opt=0)
 
spActor getFirstChild () const
 
spActor getLastChild () const
 
spActor getNextSibling () const
 
spActor getPrevSibling () const
 
ActorgetDescendant (const std::string &name, error_policy ep=ep_show_error)
 
template<class T >
T * getDescendantT (const std::string &name, error_policy ep=ep_show_error)
 
spActor getChild (const std::string &name, error_policy ep=ep_show_error) const
 
template<class T >
T * getChildT (const std::string &name, error_policy ep=ep_show_error) const
 
spTween getTween (const std::string &name, error_policy ep=ep_show_error)
 
spTween getFirstTween () const
 
spTween getLastTween () const
 
const Vector2getAnchor () const
 
float getAnchorX () const
 
float getAnchorY () const
 
bool getIsAnchorInPixels ()
 
const Vector2getPosition () const
 
float getX () const
 
float getY () const
 
const Vector2getScale () const
 
float getScaleX () const
 
float getScaleY () const
 
float getRotation () const
 
float getRotationDegrees () const
 
int getPriority () const
 
bool getVisible () const
 
ActorgetParent ()
 
const ActorgetParent () const
 
Vector2 getSize () const
 
Vector2 getScaledSize () const
 
float getWidth () const
 
float getScaledWidth () const
 
float getHeight () const
 
float getScaledHeight () const
 
unsigned char getAlpha () const
 
const spClock & getClock () const
 
virtual RectF getDestRect () const
 
pointer_index getPressed (MouseButton b=MouseButton_Touch) const
 
pointer_index getOvered () const
 
bool getTouchEnabled () const
 
bool getTouchChildrenEnabled () const
 
UpdateCallback getCallbackDoUpdate () const
 
MaterialgetMaterial ()
 
const Transform & getTransform () const
 
const Transform & getTransformInvert () const
 
Transform computeGlobalTransform (Actor *parent=0) const
 
RectF computeBounds (const Transform &transform=Transform::getIdentity()) const
 
void setAnchor (const Vector2 &anchor)
 
void setAnchor (float ax, float ay)
 
void setAnchorInPixels (const Vector2 &anchor)
 
void setAnchorInPixels (float x, float y)
 
void setAnchorX (float x)
 
void setAnchorY (float y)
 
void setPosition (const Vector2 &pos)
 
void setPosition (float x, float y)
 
void setX (float x)
 
void setY (float y)
 
void setTransform (const AffineTransform &tr)
 
void setPriority (short zorder)
 
void setScale (float scale)
 
void setScale (const Vector2 &scale)
 
void setScale (float scaleX, float scaleY)
 
void setScaleX (float sx)
 
void setScaleY (float sy)
 
void setRotation (float angle)
 
void setRotationDegrees (float angle)
 
void setSize (const Vector2 &)
 
void setSize (float w, float h)
 
void setWidth (float w)
 
void setHeight (float h)
 
void setExtendedClickArea (char add)
 
void setClock (spClock clock)
 
void setMaterial (Material *mat)
 
void setVisible (bool vis)
 
void setCull (bool enable)
 
void setAlpha (unsigned char alpha)
 
void setTouchEnabled (bool enabled)
 
void setTouchChildrenEnabled (bool enabled)
 
void setTouchEnabled (bool enabled, bool childrenEnabled)
 
void setCallbackDoUpdate (UpdateCallback cb)
 
virtual bool isOn (const Vector2 &localPosition, float localScale=1.0f)
 
bool isDescendant (const spActor &actor) const
 
void insertSiblingBefore (spActor)
 
void insertSiblingAfter (spActor)
 
void prependChild (spActor actor)
 
void prependChild (Actor *actor)
 
void addChild (spActor actor)
 
void addChild (Actor *actor)
 
void attachTo (spActor parent)
 
void attachTo (Actor *parent)
 
void removeChild (spActor actor)
 
void removeChildren ()
 
Actordetach ()
 
void dispatchEvent (Event *event) override
 
virtual void updateStateOvered ()
 
virtual void updateStatePressed ()
 
spTween addTween (spTween)
 
spTween addTween2 (spTween, const TweenOptions &opt)
 
template<class Prop >
spTween addTween (const Prop &prop, timeMS duration, int loops=1, bool twoSides=false, timeMS delay=0, Tween::EASE ease=Tween::ease_linear)
 
template<class Prop >
spTween addTween (const Prop &prop, const TweenOptions &opt)
 
int addClickListener (const EventCallback &cb)
 
int addTouchDownListener (const EventCallback &cb)
 
int addTouchUpListener (const EventCallback &cb)
 
void removeTween (spTween)
 
void removeTweensByName (const std::string &name)
 
void removeTweens (bool callComplete=false)
 
virtual void update (const UpdateState &us)
 
virtual void render (const RenderState &rs)
 
virtual void handleEvent (Event *event)
 
virtual void doRender (const RenderState &rs)
 
Vector2 parent2local (const Vector2 &pos) const
 
Vector2 local2parent (const Vector2 &pos=Vector2(0, 0)) const
 
Vector2 local2stage (const Vector2 &pos=Vector2(0, 0), Actor *stage=0) const
 
Vector2 stage2local (const Vector2 &pos, Actor *stage=0) const
 
void serialize (serializedata *) override
 
void deserialize (const deserializedata *) override
 
virtual std::string dump (const dumpOptions &opt) const
 
Stage_getStage ()
 
void setNotPressed (MouseButton b)
 
bool internalRender (RenderState &rs, const RenderState &parentRS)
 
void clean ()
 
virtual bool getBounds (RectF &) const
 
- Public Member Functions inherited from oxygine::EventDispatcher
 EventDispatcher (const EventDispatcher &ed)
 
int addEventListener (eventType, const EventCallback &)
 
void removeEventListener (eventType, const EventCallback &)
 
void removeEventListener (int id)
 
bool hasEventListeners (void *CallbackThis)
 
bool hasEventListeners (eventType, const EventCallback &)
 
void removeEventListeners (void *CallbackThis)
 
void removeAllEventListeners ()
 
int getListenersCount () const
 
int getLastListenerID () const
 
const EventCallback & getListenerByIndex (int index) const
 
- Public Member Functions inherited from oxygine::Object
 Object (const Object &src)
 
 Object (bool assignUniqueID=true)
 
- Public Member Functions inherited from oxygine::ref_counter
void addRef ()
 
void releaseRef ()
 
- Public Member Functions inherited from oxygine::ObjectBase
 ObjectBase (const ObjectBase &src)
 
 ObjectBase (bool assignID=true)
 
const std::string & getName () const
 
const void * getUserData () const
 
int getObjectID () const
 
bool isName (const std::string &name) const
 
bool isName (const char *name) const
 
void setName (const std::string &name)
 
void setUserData (const void *data)
 
void dumpObject () const
 
void __removeFromDebugList ()
 
- Public Member Functions inherited from oxygine::intrusive_list_item< spActor >
intrusive_list< spActor > * getParentList ()
 
- Public Member Functions inherited from oxygine::Serializable
virtual void deserializeLink (const deserializeLinkData *)
 

Protected Types

enum  flags {
  flag_anchorInPixels = 1, flag_visible = 1 << 1, flag_touchEnabled = 1 << 2, flag_transformDirty = 1 << 3,
  flag_transformInvertDirty = 1 << 4, flag_touchChildrenEnabled = 1 << 5, flag_cull = 1 << 6, flag_fastTransform = 1 << 7,
  flag_reserved = 1 << 8, flag_last = flag_reserved
}
 
typedef intrusive_list< spActor > children
 
typedef intrusive_list< spTween > tweens
 
- Protected Types inherited from oxygine::EventDispatcher
typedef std::vector< listenerlisteners
 

Protected Member Functions

void added2stage (Stage *)
 
void removedFromStage ()
 
virtual void onAdded2Stage ()
 
virtual void onRemovedFromStage ()
 
virtual void transformUpdated ()
 
virtual void calcBounds2 (RectF &bounds, const Transform &transform) const
 
void _onGlobalTouchUpEvent (Event *)
 
void _onGlobalTouchUpEvent1 (Event *)
 
void _onGlobalTouchUpEvent2 (Event *)
 
void _onGlobalTouchMoveEvent (Event *)
 
const Vector2_getSize () const
 
void _setSize (const Vector2 &)
 
virtual void sizeChanged (const Vector2 &size)
 
Actor_getDescendant (const std::string &name)
 
spTween _addTween (spTween tween, bool rel)
 
bool prepareRender (RenderState &rs, const RenderState &parentRS)
 
void completeRender (const RenderState &rs)
 
void updateTransform () const
 
void internalUpdate (const UpdateState &us)
 
virtual void doUpdate (const UpdateState &us)
 
- Protected Member Functions inherited from oxygine::Object
void __doCheck ()
 
- Protected Member Functions inherited from oxygine::ObjectBase
void __generateID ()
 
std::string * __getName () const
 
void __freeName () const
 
- Protected Member Functions inherited from oxygine::intrusive_list_item< spActor >
spActor & getNextSibling ()
 
spActor & getPrevSibling ()
 

Static Protected Member Functions

static void setParent (Actor *actor, Actor *parent)
 
static childrengetChildren (spActor &actor)
 
static unsigned short & _getFlags (Actor *actor)
 
- Static Protected Member Functions inherited from oxygine::ObjectBase
static void __addToDebugList (ObjectBase *base)
 
static void __removeFromDebugList (ObjectBase *base)
 

Protected Attributes

Material_material
 
Stage_stage
 
UpdateCallback _cbDoUpdate
 
Transform _transform
 
Transform _transformInvert
 
unsigned short _flags
 
unsigned char _alpha
 
char _extendedIsOn
 
spClock _clock
 
Actor_parent
 
tweens _tweens
 
children _children
 
union {
   struct {
      pointer_index   _overred
 
      pointer_index   _pressedButton [MouseButton_Num]
 
   } 
 
   int32_t   _pressedOvered
 
}; 
 
- Protected Attributes inherited from oxygine::EventDispatcher
int _lastID
 
listeners * _listeners
 
- Protected Attributes inherited from oxygine::ObjectBase
std::string __name
 
int __id
 
const void * __userData
 
- Protected Attributes inherited from oxygine::intrusive_list_item< spActor >
spActor _prev
 
spActor _next
 
intrusive_list< spActor > * _list
 

Additional Inherited Members

- Static Public Member Functions inherited from oxygine::ObjectBase
static void dumpCreatedObjects ()
 
static void showAssertInCtor (int id)
 
static void showAssertInDtor (int id)
 
static __createdObjects & __getCreatedObjects ()
 
static void __startTracingLeaks ()
 
static void __stopTracingLeaks ()
 
- Public Attributes inherited from oxygine::ref_counter
int _ref_counter
 
- Static Protected Attributes inherited from oxygine::ObjectBase
static int _lastID
 
static int _assertCtorID
 
static int _assertDtorID
 

Member Function Documentation

◆ _getStage()

Stage* oxygine::Actor::_getStage ( )

Returns Stage where Actor attached to. Used for multi stage (window) mode

◆ addClickListener()

int oxygine::Actor::addClickListener ( const EventCallback &  cb)
inline

short syntax version of actor->addEventListener(TouchEvent::CLICK, ...);

◆ addTouchDownListener()

int oxygine::Actor::addTouchDownListener ( const EventCallback &  cb)
inline

short syntax version of actor->addEventListener(TouchEvent::TOUCH_DOWN, ...);

◆ addTouchUpListener()

int oxygine::Actor::addTouchUpListener ( const EventCallback &  cb)
inline

short syntax version of actor->addEventListener(TouchEvent::TOUCH_UP, ...);

◆ clean()

void oxygine::Actor::clean ( )

recursively removes all event listeners and added tweens

◆ computeBounds()

RectF oxygine::Actor::computeBounds ( const Transform &  transform = Transform::getIdentity()) const

computes actor Bounds rectangle. Iterates children

◆ computeGlobalTransform()

Transform oxygine::Actor::computeGlobalTransform ( Actor parent = 0) const

computes global actor transformation

◆ detach()

Actor* oxygine::Actor::detach ( )

detaches actor from parent and returns parent. return NULL If actor doesn't have parent

◆ dispatchEvent()

void oxygine::Actor::dispatchEvent ( Event event)
overridevirtual

Dispatches an event into the event flow. The event target is the EventDispatcher object upon which the dispatchEvent() method is called.

Reimplemented from oxygine::EventDispatcher.

◆ doUpdate()

virtual void oxygine::Actor::doUpdate ( const UpdateState us)
protectedvirtual

doUpdate is virtual method for overloading in inherited classes. UpdateState struct has local time of Actor (relative to Clock) and delta time.

Reimplemented in oxygine::SlidingActor, and oxygine::DebugActor.

◆ dump()

virtual std::string oxygine::Actor::dump ( const dumpOptions &  opt) const
virtual

Returns detailed actor information. Used for debug purposes.

Reimplemented in oxygine::TextField, oxygine::Sprite, oxygine::Stage, oxygine::ProgressBar, oxygine::Box9Sprite, and oxygine::Polygon.

◆ getChild()

spActor oxygine::Actor::getChild ( const std::string &  name,
error_policy  ep = ep_show_error 
) const

search child by name

◆ getChildT()

template<class T >
T* oxygine::Actor::getChildT ( const std::string &  name,
error_policy  ep = ep_show_error 
) const
inline

search child by name and cast it to other class

◆ getDescendant()

Actor* oxygine::Actor::getDescendant ( const std::string &  name,
error_policy  ep = ep_show_error 
)

search child by name recursively, could return self

◆ getDescendantT()

template<class T >
T* oxygine::Actor::getDescendantT ( const std::string &  name,
error_policy  ep = ep_show_error 
)
inline

search child by name recursively and cast it to other class

◆ getFirstChild()

spActor oxygine::Actor::getFirstChild ( ) const
inline

returns first child

◆ getFirstTween()

spTween oxygine::Actor::getFirstTween ( ) const
inline

returns first tween in actor

◆ getLastChild()

spActor oxygine::Actor::getLastChild ( ) const
inline

returns last child

◆ getLastTween()

spTween oxygine::Actor::getLastTween ( ) const
inline

returns last tween in actor

◆ getNextSibling()

spActor oxygine::Actor::getNextSibling ( ) const
inline

returns next sibling

◆ getOvered()

pointer_index oxygine::Actor::getOvered ( ) const

returns touch id if actor is moused overred

◆ getPressed()

pointer_index oxygine::Actor::getPressed ( MouseButton  b = MouseButton_Touch) const

returns touch id if actor is pressed down

◆ getPrevSibling()

spActor oxygine::Actor::getPrevSibling ( ) const
inline

returns previous sibling

◆ getRotation()

float oxygine::Actor::getRotation ( ) const
inline

Returns rotation angle in radians

◆ getRotationDegrees()

float oxygine::Actor::getRotationDegrees ( ) const
inline

Returns rotation angle in degrees

◆ getScaledSize()

Vector2 oxygine::Actor::getScaledSize ( ) const
inline

Returns Size*Scale

◆ getTransform()

const Transform& oxygine::Actor::getTransform ( ) const

return local actor transformation

◆ getTween()

spTween oxygine::Actor::getTween ( const std::string &  name,
error_policy  ep = ep_show_error 
)

search tween by name

◆ insertSiblingAfter()

void oxygine::Actor::insertSiblingAfter ( spActor  )

inserts sibling after 'this' actor

◆ insertSiblingBefore()

void oxygine::Actor::insertSiblingBefore ( spActor  )

inserts sibling before 'this' actor

◆ isDescendant()

bool oxygine::Actor::isDescendant ( const spActor &  actor) const

Returns true if actor is child or located deeper in current subtree

◆ isOn()

virtual bool oxygine::Actor::isOn ( const Vector2 localPosition,
float  localScale = 1.0f 
)
virtual

Sets callback which would be called each Actor::render cycle before doRender. Use it if you don't want inherit from Actor and overload Actor::doRender.

Reimplemented in oxygine::TextField, oxygine::Stage, oxygine::Sprite, and oxygine::Box9Sprite.

◆ prependChild() [1/2]

void oxygine::Actor::prependChild ( spActor  actor)

adds child first in list

◆ prependChild() [2/2]

void oxygine::Actor::prependChild ( Actor actor)

adds child first in list

◆ removeChild()

void oxygine::Actor::removeChild ( spActor  actor)

Remove one child

◆ removeChildren()

void oxygine::Actor::removeChildren ( )

Removes all children from Actor

◆ removeTweens()

void oxygine::Actor::removeTweens ( bool  callComplete = false)

remove all tweens and call Tween::complete to them if callComplete == true

◆ render()

virtual void oxygine::Actor::render ( const RenderState rs)
virtual

Renders this actor and children.

Reimplemented in oxygine::DebugActor, oxygine::MaskedSprite, and oxygine::ClipRectActor.

◆ setAlpha()

void oxygine::Actor::setAlpha ( unsigned char  alpha)

Sets transparency. if alpha is 0 actor and children are completely invisible. Invisible Actor doesn't receive Touch events.

◆ setAnchor()

void oxygine::Actor::setAnchor ( const Vector2 anchor)

Sets Anchor. Anchor also called Pivot point. It is "center" for rotation/scale/position. Anchor could be set in Pixels or in Percents (/100). Default value is (0,0) - top left corner of Actor

◆ setCallbackDoUpdate()

void oxygine::Actor::setCallbackDoUpdate ( UpdateCallback  cb)
inline

Sets callback which would be called each Actor::update cycle before doUpdate. Use it if you don't want inherit from Actor and overload Actor::doUpdate.

◆ setCull()

void oxygine::Actor::setCull ( bool  enable)
inline

Enable/Disable culling this actor outside of clip area (use it in pair with ClipRectActor)

◆ setExtendedClickArea()

void oxygine::Actor::setExtendedClickArea ( char  add)
inline

Extends actor's clickable area from each side. Affects only to Actor::isOn. Max value is 127, Min Value is -128

◆ setPriority()

void oxygine::Actor::setPriority ( short  zorder)

set z order draw priority, from back (low value) to front (high value). Max value is 32000, Min value -32000

◆ setRotation()

void oxygine::Actor::setRotation ( float  angle)

Sets rotation angle in radians

◆ setRotationDegrees()

void oxygine::Actor::setRotationDegrees ( float  angle)

Sets rotation angle in degrees. Converts internally to radians. (use setRotation!)

◆ setSize()

void oxygine::Actor::setSize ( const Vector2 )

Sets Size of Actor. Size doesn't scale contents of Actor. Size only affects event handling and rendering if you change Anchor

◆ setTouchChildrenEnabled()

void oxygine::Actor::setTouchChildrenEnabled ( bool  enabled)
inline

Enables/Disables Touch events for children of Actor.

◆ setTouchEnabled() [1/2]

void oxygine::Actor::setTouchEnabled ( bool  enabled)
inline

Enables/Disables Touch events for Actor.

◆ setTouchEnabled() [2/2]

void oxygine::Actor::setTouchEnabled ( bool  enabled,
bool  childrenEnabled 
)
inline

setTouchEnabled + setTouchChildrenEnabled

◆ setTransform()

void oxygine::Actor::setTransform ( const AffineTransform &  tr)

Overwrites transformation matrix. position/scale/rotation would be ignored until you change them

◆ setVisible()

void oxygine::Actor::setVisible ( bool  vis)
inline

Show/Hide actor and children. Invisible Actor doesn't receive Touch events.

◆ update()

virtual void oxygine::Actor::update ( const UpdateState us)
virtual

Updates this actor, children and all tweens.


The documentation for this class was generated from the following file: