Cocos2d-x  v4
Follow Class Reference

Follow is an action that "follows" a node. Eg: More...

Inherits Action.

Public Member Functions

bool isBoundarySet () const
 Return boundarySet. More...
 
void setBoundarySet (bool value)
 Alter behavior - turn on/off boundary. More...
 
virtual Followclone () const override
 Returns a clone of action. More...
 
virtual Followreverse () const override
 Returns a new action that performs the exact reverse of the action. More...
 
virtual void step (float dt) override
 
virtual bool isDone () const override
 Return true if the action has finished. More...
 
virtual void stop () override
 Called after the action has finished. More...
 
- Public Member Functions inherited from Action
virtual std::string description () const
 @js NA @lua NA
 
virtual void startWithTarget (Node *target)
 Called before the action start. More...
 
virtual void update (float time)
 Called once per frame. More...
 
NodegetTarget () const
 Return certain target. More...
 
void setTarget (Node *target)
 The action will modify the target properties. More...
 
NodegetOriginalTarget () const
 Return a original Target. More...
 
void setOriginalTarget (Node *originalTarget)
 Set the original target, since target can be nil. More...
 
int getTag () const
 Returns a tag that is used to identify the action easily. More...
 
void setTag (int tag)
 Changes the tag that is used to identify the action easily. More...
 
unsigned int getFlags () const
 Returns a flag field that is used to group the actions easily. More...
 
void setFlags (unsigned int flags)
 Changes the flag field that is used to group the actions easily. More...
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 Destructor. More...
 
- Public Member Functions inherited from Clonable
virtual ~Clonable ()
 @js NA @lua NA
 

Static Public Member Functions

static Followcreate (Node *followedNode, const Rect &rect=Rect::ZERO)
 Creates the action with a set boundary or with no boundary. More...
 
static FollowcreateWithOffset (Node *followedNode, float xOffset, float yOffset, const Rect &rect=Rect::ZERO)
 Creates the action with a set boundary or with no boundary with offsets. More...
 

Protected Member Functions

 Follow ()
 @js ctor
 
virtual ~Follow ()
 @js NA @lua NA
 
bool initWithTarget (Node *followedNode, const Rect &rect=Rect::ZERO)
 Initializes the action with a set boundary or with no boundary. More...
 
bool initWithTargetAndOffset (Node *followedNode, float xOffset, float yOffset, const Rect &rect=Rect::ZERO)
 Initializes the action with a set boundary or with no boundary with offsets. More...
 

Additional Inherited Members

- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 
- Static Public Attributes inherited from Action
static const int INVALID_TAG = -1
 Default tag used for all the actions.
 

Detailed Description

Follow is an action that "follows" a node. Eg:

layer->runAction(Follow::create(hero));

Instead of using Camera as a "follower", use this action instead.

Since
v0.99.2

Member Function Documentation

◆ create()

static Follow* create ( Node followedNode,
const Rect rect = Rect::ZERO 
)
static

Creates the action with a set boundary or with no boundary.

Parameters
followedNodeThe node to be followed.
rectThe boundary. If rect is equal to Rect::ZERO, it'll work with no boundary.

◆ createWithOffset()

static Follow* createWithOffset ( Node followedNode,
float  xOffset,
float  yOffset,
const Rect rect = Rect::ZERO 
)
static

Creates the action with a set boundary or with no boundary with offsets.

Parameters
followedNodeThe node to be followed.
rectThe boundary. If rect is equal to Rect::ZERO, it'll work with no boundary.
xOffsetThe horizontal offset from the center of the screen from which the node is to be followed.It can be positive,negative or zero.If set to zero the node will be horizontally centered followed.
yOffsetThe vertical offset from the center of the screen from which the node is to be followed.It can be positive,negative or zero. If set to zero the node will be vertically centered followed. If both xOffset and yOffset are set to zero,then the node will be horizontally and vertically centered followed.

◆ isBoundarySet()

bool isBoundarySet ( ) const
inline

Return boundarySet.

Returns
Return boundarySet.

◆ setBoundarySet()

void setBoundarySet ( bool  value)
inline

Alter behavior - turn on/off boundary.

Parameters
valueTurn on/off boundary.

◆ clone()

virtual Follow* clone ( ) const
overridevirtual

Returns a clone of action.

Returns
A clone action.

Reimplemented from Action.

◆ reverse()

virtual Follow* reverse ( ) const
overridevirtual

Returns a new action that performs the exact reverse of the action.

Returns
A new action that performs the exact reverse of the action. @js NA

Reimplemented from Action.

◆ step()

virtual void step ( float  dt)
overridevirtual
Parameters
dtin seconds. @js NA

Reimplemented from Action.

◆ isDone()

virtual bool isDone ( ) const
overridevirtual

Return true if the action has finished.

Returns
Is true if the action has finished.

Reimplemented from Action.

◆ stop()

virtual void stop ( )
overridevirtual

Called after the action has finished.

It will set the 'target' to nil. IMPORTANT: You should never call "Action::stop()" manually. Instead, use: "target->stopAction(action);".

Reimplemented from Action.

◆ initWithTarget()

bool initWithTarget ( Node followedNode,
const Rect rect = Rect::ZERO 
)
protected

Initializes the action with a set boundary or with no boundary.

Parameters
followedNodeThe node to be followed.
rectThe boundary. If rect is equal to Rect::ZERO, it'll work with no boundary.

◆ initWithTargetAndOffset()

bool initWithTargetAndOffset ( Node followedNode,
float  xOffset,
float  yOffset,
const Rect rect = Rect::ZERO 
)
protected

Initializes the action with a set boundary or with no boundary with offsets.

Parameters
followedNodeThe node to be followed.
rectThe boundary. If rect is equal to Rect::ZERO, it'll work with no boundary.
xOffsetThe horizontal offset from the center of the screen from which the node is to be followed.It can be positive,negative or zero.If set to zero the node will be horizontally centered followed.
yOffsetThe vertical offset from the center of the screen from which the node is to be followed.It can be positive,negative or zero. If set to zero the node will be vertically centered followed. If both xOffset and yOffset are set to zero,then the node will be horizontally and vertically centered followed.

The documentation for this class was generated from the following file:
cocos2d::Follow::create
static Follow * create(Node *followedNode, const Rect &rect=Rect::ZERO)
Creates the action with a set boundary or with no boundary.