Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3-docs

Conflicts:
	cocos/base/CCAutoreleasePool.h
	cocos/base/CCData.h
This commit is contained in:
VisualSJ 2015-03-18 21:38:56 +08:00
commit 785214ae12
44 changed files with 1923 additions and 655 deletions

View File

@ -40,12 +40,12 @@ class Node;
*/
/**
@brief Base class for Action objects.
* @brief Base class for Action objects.
*/
class CC_DLL Action : public Ref, public Clonable
{
public:
/// Default tag used for all the actions
/** Default tag used for all the actions. */
static const int INVALID_TAG = -1;
/**
* @js NA
@ -53,58 +53,94 @@ public:
*/
virtual std::string description() const;
/** returns a clone of action */
/** Returns a clone of action.
*
* @return A clone action.
*/
virtual Action* clone() const
{
CC_ASSERT(0);
return nullptr;
}
/** returns a new action that performs the exactly the reverse action */
/** Returns a new action that performs the exactly the reverse action.
*
* @return A new action that performs the exactly the reverse action.
*/
virtual Action* reverse() const
{
CC_ASSERT(0);
return nullptr;
}
//! return true if the action has finished
/** Return true if the action has finished.
*
* @return Is true if the action has finished.
*/
virtual bool isDone() const;
//! called before the action start. It will also set the target.
/** Called before the action start. It will also set the target.
*
* @param target A certain target.
*/
virtual void startWithTarget(Node *target);
/**
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);"
*/
* 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);".
*/
virtual void stop();
//! called every frame with it's delta time, dt in seconds. DON'T override unless you know what you are doing.
/** Called every frame with it's delta time, dt in seconds. DON'T override unless you know what you are doing.
*
* @param dt In seconds.
*/
virtual void step(float dt);
/**
called once per frame. time a value between 0 and 1
* Called once per frame. time a value between 0 and 1.
For example:
- 0 means that the action just started
- 0.5 means that the action is in the middle
- 1 means that the action is over
*/
* For example:
* - 0 Means that the action just started.
* - 0.5 Means that the action is in the middle.
* - 1 Means that the action is over.
*
* @param time A value between 0 and 1.
*/
virtual void update(float time);
/** Return certain target..
*
* @return A certain target.
*/
inline Node* getTarget() const { return _target; }
/** The action will modify the target properties. */
/** The action will modify the target properties.
*
* @param target A certain target.
*/
inline void setTarget(Node *target) { _target = target; }
/** Return a original Target.
*
* @return A original Target.
*/
inline Node* getOriginalTarget() const { return _originalTarget; }
/** Set the original target, since target can be nil.
Is the target that were used to run the action. Unless you are doing something complex, like ActionManager, you should NOT call this method.
The target is 'assigned', it is not 'retained'.
@since v0.8.2
*/
/**
* Set the original target, since target can be nil.
* Is the target that were used to run the action. Unless you are doing something complex, like ActionManager, you should NOT call this method.
* The target is 'assigned', it is not 'retained'.
* @since v0.8.2
*
* @param originalTarget Is 'assigned', it is not 'retained'.
*/
inline void setOriginalTarget(Node *originalTarget) { _originalTarget = originalTarget; }
/** Returns a tag that is used to identify the action easily.
*
* @return A tag.
*/
inline int getTag() const { return _tag; }
/** Changes the tag that is used to identify the action easily.
*
* @param tag Used to identify the action easily.
*/
inline void setTag(int tag) { _tag = tag; }
CC_CONSTRUCTOR_ACCESS:
@ -113,34 +149,40 @@ CC_CONSTRUCTOR_ACCESS:
protected:
Node *_originalTarget;
/** The "target".
The target will be set with the 'startWithTarget' method.
When the 'stop' method is called, target will be set to nil.
The target is 'assigned', it is not 'retained'.
*/
/**
* The "target".
* The target will be set with the 'startWithTarget' method.
* When the 'stop' method is called, target will be set to nil.
* The target is 'assigned', it is not 'retained'.
*/
Node *_target;
/** The action tag. An identifier of the action */
/** The action tag. An identifier of the action. */
int _tag;
private:
CC_DISALLOW_COPY_AND_ASSIGN(Action);
};
/**
@brief
Base class actions that do have a finite time duration.
Possible actions:
- An action with a duration of 0 seconds
- An action with a duration of 35.5 seconds
Infinite time actions are valid
/** @class FiniteTimeAction
* @brief
* Base class actions that do have a finite time duration.
* Possible actions:
* - An action with a duration of 0 seconds.
* - An action with a duration of 35.5 seconds.
* Infinite time actions are valid.
*/
class CC_DLL FiniteTimeAction : public Action
{
public:
//! get duration in seconds of the action
/** Get duration in seconds of the action.
*
* @return The duration in seconds of the action.
*/
inline float getDuration() const { return _duration; }
//! set duration in seconds of the action
/** Set duration in seconds of the action.
*
* @param duration In seconds of the action.
*/
inline void setDuration(float duration) { _duration = duration; }
//
@ -164,7 +206,7 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~FiniteTimeAction(){}
protected:
//! duration in seconds
//! Duration in seconds.
float _duration;
private:
@ -174,25 +216,41 @@ private:
class ActionInterval;
class RepeatForever;
/**
@brief Changes the speed of an action, making it take longer (speed>1)
or less (speed<1) time.
Useful to simulate 'slow motion' or 'fast forward' effect.
@warning This action can't be Sequenceable because it is not an IntervalAction
/** @class Speed
* @brief Changes the speed of an action, making it take longer (speed>1)
* or less (speed<1) time.
* Useful to simulate 'slow motion' or 'fast forward' effect.
* @warning This action can't be Sequenceable because it is not an IntervalAction.
*/
class CC_DLL Speed : public Action
{
public:
/** create the action */
/** Create the action and set the speed.
*
* @param action An action.
* @param speed The action speed.
*/
static Speed* create(ActionInterval* action, float speed);
/** Return the speed.
*
* @return The action speed.
*/
inline float getSpeed(void) const { return _speed; }
/** alter the speed of the inner function in runtime */
/** Alter the speed of the inner function in runtime.
*
* @param speed Alter the speed of the inner function in runtime.
*/
inline void setSpeed(float speed) { _speed = speed; }
/** Replace the interior action.
*
* @param action The new action, it will replace the running action.
*/
void setInnerAction(ActionInterval *action);
/** Return the interior action.
*
* @return The interior action.
*/
inline ActionInterval* getInnerAction() const { return _innerAction; }
//
@ -206,12 +264,16 @@ public:
* @param dt in seconds.
*/
virtual void step(float dt) override;
/** Return true if the action has finished.
*
* @return Is true if the action has finished.
*/
virtual bool isDone() const override;
CC_CONSTRUCTOR_ACCESS:
Speed();
virtual ~Speed(void);
/** initializes the action */
/** Initializes the action. */
bool initWithAction(ActionInterval *action, float speed);
protected:
@ -244,9 +306,9 @@ public:
* with no boundary.
*/
static Follow* create(Node *followedNode, const Rect& rect = Rect::ZERO);
/** Return boundarySet.*/
inline bool isBoundarySet() const { return _boundarySet; }
/** alter behavior - turn on/off boundary */
/** Alter behavior - turn on/off boundary. */
inline void setBoundarySet(bool value) { _boundarySet = value; }
CC_DEPRECATED_ATTRIBUTE inline void setBoudarySet(bool value) { setBoundarySet(value); }
@ -292,20 +354,20 @@ CC_CONSTRUCTOR_ACCESS:
bool initWithTarget(Node *followedNode, const Rect& rect = Rect::ZERO);
protected:
// node to follow
/** Node to follow. */
Node *_followedNode;
// whether camera should be limited to certain area
/** Whether camera should be limited to certain area. */
bool _boundarySet;
// if screen size is bigger than the boundary - update not needed
/** If screen size is bigger than the boundary - update not needed. */
bool _boundaryFullyCovered;
// fast access to the screen dimensions
/** Fast access to the screen dimensions. */
Vec2 _halfScreenSize;
Vec2 _fullScreenSize;
// world boundaries
/** World boundaries. */
float _leftBoundary;
float _rightBoundary;
float _topBoundary;

View File

@ -40,10 +40,10 @@ class Camera;
* @{
*/
/**
@brief Base class for Camera actions
@ingroup Actions
*/
/**
*@brief Base class for Camera actions.
*@ingroup Actions
*/
class CC_DLL ActionCamera : public ActionInterval //<NSCopying>
{
public:
@ -62,18 +62,36 @@ public:
virtual ActionCamera * reverse() const override;
virtual ActionCamera *clone() const override;
/* sets the Eye value of the Camera */
/* Sets the Eye value of the Camera.
*
* @param eye The Eye value of the Camera.
*/
void setEye(const Vec3 &eye);
void setEye(float x, float y, float z);
/* returns the Eye value of the Camera */
/* Returns the Eye value of the Camera.
*
* @return The Eye value of the Camera.
*/
const Vec3& getEye() const { return _eye; }
/* sets the Center value of the Camera */
/* Sets the Center value of the Camera.
*
* @param center The Center value of the Camera.
*/
void setCenter(const Vec3 &center);
/* returns the Center value of the Camera */
/* Returns the Center value of the Camera.
*
* @return The Center value of the Camera.
*/
const Vec3& getCenter() const { return _center; }
/* sets the Up value of the Camera */
/* Sets the Up value of the Camera.
*
* @param up The Up value of the Camera.
*/
void setUp(const Vec3 &up);
/* Returns the Up value of the Camera */
/* Returns the Up value of the Camera.
*
* @return The Up value of the Camera.
*/
const Vec3& getUp() const { return _up; }
protected:
@ -86,18 +104,34 @@ protected:
Vec3 _up;
};
/**
@brief OrbitCamera action
Orbits the camera around the center of the screen using spherical coordinates
@ingroup Actions
*/
/** @class OrbitCamera
*
* @brief OrbitCamera action.
* Orbits the camera around the center of the screen using spherical coordinates.
* @ingroup Actions
*/
class CC_DLL OrbitCamera : public ActionCamera //<NSCopying>
{
public:
/** creates a OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */
/** Creates a OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX.
*
* @param t Duration in seconds.
* @param radius The start radius.
* @param deltaRadius The delta radius.
* @param angelZ The start Angel in Z.
* @param deltaAngleZ The delta angle in Z.
* @param angelX The start Angel in X.
* @param deltaAngleX The delta angle in X.
* @return An OrbitCamera.
*/
static OrbitCamera* create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX);
/** positions the camera according to spherical coordinates */
/** Positions the camera according to spherical coordinates.
*
* @param r The spherical radius.
* @param zenith The spherical zenith.
* @param azimuth The spherical azimuth.
*/
void sphericalRadius(float *r, float *zenith, float *azimuth);
// Overrides
@ -116,7 +150,7 @@ CC_CONSTRUCTOR_ACCESS:
*/
virtual ~OrbitCamera();
/** initializes a OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */
/** Initializes a OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX. */
bool initWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX);
protected:

View File

@ -50,15 +50,16 @@ class Node;
*/
/** An Array that contain control points.
Used by CardinalSplineTo and (By) and CatmullRomTo (and By) actions.
@ingroup Actions
* Used by CardinalSplineTo and (By) and CatmullRomTo (and By) actions.
* @ingroup Actions
*/
class CC_DLL PointArray : public Ref, public Clonable
{
public:
/** creates and initializes a Points array with capacity
/** Creates and initializes a Points array with capacity.
* @js NA
* @param capacity The size of the array.
*/
static PointArray* create(ssize_t capacity);
@ -73,47 +74,67 @@ public:
*/
PointArray();
/** initializes a Catmull Rom config with a capacity hint
/** Initializes a Catmull Rom config with a capacity hint.
*
* @js NA
* @param capacity The size of the array.
* @return True.
*/
bool initWithCapacity(ssize_t capacity);
/** appends a control point
/** Appends a control point.
*
* @js NA
* @param controlPoint A control point.
*/
void addControlPoint(Vec2 controlPoint);
/** inserts a controlPoint at index
/** Inserts a controlPoint at index.
*
* @js NA
* @param controlPoint A control point.
* @param index Insert the point to array in index.
*/
void insertControlPoint(Vec2 &controlPoint, ssize_t index);
/** replaces an existing controlPoint at index
/** Replaces an existing controlPoint at index.
*
* @js NA
* @param controlPoint A control point.
* @param index Replace the point to array in index.
*/
void replaceControlPoint(Vec2 &controlPoint, ssize_t index);
/** get the value of a controlPoint at a given index
/** Get the value of a controlPoint at a given index.
*
* @js NA
* @param index Get the point in index.
* @return A Vec2.
*/
Vec2 getControlPointAtIndex(ssize_t index);
/** deletes a control point at a given index
/** Deletes a control point at a given index
*
* @js NA
* @param index Remove the point in index.
*/
void removeControlPointAtIndex(ssize_t index);
/** returns the number of objects of the control point array
/** Returns the number of objects of the control point array.
*
* @js NA
* @return The number of objects of the control point array.
*/
ssize_t count() const;
/** returns a new copy of the array reversed. User is responsible for releasing this copy
/** Returns a new copy of the array reversed. User is responsible for releasing this copy.
*
* @js NA
* @return A new copy of the array reversed.
*/
PointArray* reverse() const;
/** reverse the current control point array inline, without generating a new one
/** Reverse the current control point array inline, without generating a new one.
* @js NA
*/
void reverseInline();
@ -131,24 +152,27 @@ public:
*/
void setControlPoints(std::vector<Vec2*> *controlPoints);
private:
/** Array that contains the control points */
/** Array that contains the control points. */
std::vector<Vec2*> *_controlPoints;
};
/** Cardinal Spline path.
http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline
@ingroup Actions
/** @class CardinalSplineTo
* Cardinal Spline path.
* http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline
* @ingroup Actions
*/
class CC_DLL CardinalSplineTo : public ActionInterval
{
public:
/** creates an action with a Cardinal Spline array of points and tension
* @param duration in seconds
/** Creates an action with a Cardinal Spline array of points and tension.
* @param duration In seconds.
* @param point An PointArray.
* @param tension Goodness of fit.
* @code
* when this function bound to js or lua,the input params are changed
* in js: var create(var t,var table)
* in lua: lcaol create(local t, local table)
* When this function bound to js or lua,the input params are changed.
* In js: var create(var t,var table)
* In lua: lcaol create(local t, local table)
* @endcode
*/
static CardinalSplineTo* create(float duration, PointArray* points, float tension);
@ -164,13 +188,22 @@ public:
CardinalSplineTo();
/**
* initializes the action with a duration and an array of points
* @param duration in seconds
* Initializes the action with a duration and an array of points.
*
* @param duration In seconds.
* @param point An PointArray.
* @param tension Goodness of fit.
*/
bool initWithDuration(float duration, PointArray* points, float tension);
/** It will update the target position and change the _previousPosition to newPos
*
* @param newPos The new position.
*/
virtual void updatePosition(Vec2 &newPos);
/** Return a PointArray.
*
* @return A PointArray.
*/
inline PointArray* getPoints() { return _points; }
/**
* @js NA
@ -189,7 +222,7 @@ public:
virtual void startWithTarget(Node *target) override;
/**
* @param time in seconds.
* @param time In seconds.
*/
virtual void update(float time) override;
@ -202,19 +235,23 @@ protected:
Vec2 _accumulatedDiff;
};
/** Cardinal Spline path.
http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline
@ingroup Actions
/** @class CardinalSplineBy
* Cardinal Spline path.
* http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline
* @ingroup Actions
*/
class CC_DLL CardinalSplineBy : public CardinalSplineTo
{
public:
/** creates an action with a Cardinal Spline array of points and tension
/** Creates an action with a Cardinal Spline array of points and tension.
* @code
* when this function bound to js or lua,the input params are changed
* in js: var create(var t,var table)
* in lua: lcaol create(local t, local table)
* When this function bound to js or lua,the input params are changed.
* In js: var create(var t,var table).
* In lua: lcaol create(local t, local table).
* @param duration In seconds.
* @param point An PointArray.
* @param tension Goodness of fit.
* @endcode
*/
static CardinalSplineBy* create(float duration, PointArray* points, float tension);
@ -231,28 +268,32 @@ protected:
Vec2 _startPosition;
};
/** An action that moves the target with a CatmullRom curve to a destination point.
A Catmull Rom is a Cardinal Spline with a tension of 0.5.
http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline
@ingroup Actions
/** @class CatmullRomTo
* An action that moves the target with a CatmullRom curve to a destination point.
* A Catmull Rom is a Cardinal Spline with a tension of 0.5.
* http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline
* @ingroup Actions
*/
class CC_DLL CatmullRomTo : public CardinalSplineTo
{
public:
/** creates an action with a Cardinal Spline array of points and tension
* @param dt in seconds
/** Creates an action with a Cardinal Spline array of points and tension.
* @param dt In seconds.
* @param points An PointArray.
* @code
* when this function bound to js or lua,the input params are changed
* in js: var create(var dt,var table)
* in lua: lcaol create(local dt, local table)
* When this function bound to js or lua,the input params are changed.
* In js: var create(var dt,var table).
* In lua: lcaol create(local dt, local table).
* @endcode
*/
static CatmullRomTo* create(float dt, PointArray* points);
/**
* initializes the action with a duration and an array of points
* @param dt in seconds
* Initializes the action with a duration and an array of points.
*
* @param dt In seconds.
* @param points An PointArray.
*/
bool initWithDuration(float dt, PointArray* points);
@ -261,25 +302,31 @@ public:
virtual CatmullRomTo *reverse() const override;
};
/** An action that moves the target with a CatmullRom curve by a certain distance.
A Catmull Rom is a Cardinal Spline with a tension of 0.5.
http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline
@ingroup Actions
/** @class CatmullRomBy
* An action that moves the target with a CatmullRom curve by a certain distance.
* A Catmull Rom is a Cardinal Spline with a tension of 0.5.
* http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline
* @ingroup Actions
*/
class CC_DLL CatmullRomBy : public CardinalSplineBy
{
public:
/** creates an action with a Cardinal Spline array of points and tension
* @param dt in seconds
/** Creates an action with a Cardinal Spline array of points and tension.
* @param dt In seconds.
* @param points An PointArray.
* @code
* when this function bound to js or lua,the input params are changed
* in js: var create(var dt,var table)
* in lua: lcaol create(local dt, local table)
* When this function bound to js or lua,the input params are changed.
* In js: var create(var dt,var table).
* In lua: lcaol create(local dt, local table).
* @endcode
*/
static CatmullRomBy* create(float dt, PointArray* points);
/** initializes the action with a duration and an array of points */
/** Initializes the action with a duration and an array of points.
*
* @param dt In seconds.
* @param points An PointArray.
*/
bool initWithDuration(float dt, PointArray* points);
// Override

File diff suppressed because it is too large Load Diff

View File

@ -39,12 +39,19 @@ class NodeGrid;
* @{
*/
/** @brief Base class for Grid actions */
/**
@class GridAction
@brief Base class for Grid actions.
@detail Grid actions are the actions take effect on GridBase.
*/
class CC_DLL GridAction : public ActionInterval
{
public:
/** returns the grid */
/**
@brief Get the pointer of GridBase.
@return The pointer of GridBase.
*/
virtual GridBase* getGrid();
// overrides
@ -60,8 +67,10 @@ CC_CONSTRUCTOR_ACCESS:
GridAction() {}
virtual ~GridAction() {}
/**
* initializes the action with size and duration
* @param duration in seconds
* @brief Initializes the action with size and duration.
* @param duration The duration of the GridAction. It's a value in seconds.
* @param gridSize The size of the GridAction should be.
* @return Return true when the initialization success, otherwise return false.
*/
bool initWithDuration(float duration, const Size& gridSize);
@ -78,15 +87,18 @@ private:
/**
@brief Base class for Grid3D actions.
Grid3D actions can modify a non-tiled grid.
@detail Grid3D actions can modify a non-tiled grid.
*/
class CC_DLL Grid3DAction : public GridAction
{
public:
/** returns the grid */
virtual GridBase* getGrid() override;
/** returns the vertex than belongs to certain position in the grid
/**
* @brief Get the vertex that belongs to certain position in the grid.
* @param position The position of the grid.
* @return Return a pointer of vertex.
* @js NA
* @lua NA
*/
@ -98,7 +110,10 @@ public:
*/
CC_DEPRECATED_ATTRIBUTE inline Vec3 vertex(const Vec2& position) { return getVertex(position); }
/** returns the non-transformed vertex than belongs to certain position in the grid
/**
* @brief Get the non-transformed vertex that belongs to certain position in the grid.
* @param position The position of the grid.
* @return Return a pointer of vertex.
* @js NA
* @lua NA
*/
@ -110,7 +125,10 @@ public:
*/
CC_DEPRECATED_ATTRIBUTE inline Vec3 originalVertex(const Vec2& position) { return getOriginalVertex(position); }
/** sets a new vertex to a certain position of the grid
/**
* @brief Set a new vertex to a certain position of the grid.
* @param position The position of the grid.
* @param vertex The vertex will be used on the certain position of grid.
* @js NA
* @lua NA
*/
@ -124,17 +142,26 @@ public:
}
};
/** @brief Base class for TiledGrid3D actions */
/**
@brief Base class for TiledGrid3D actions
*/
class CC_DLL TiledGrid3DAction : public GridAction
{
public:
/** creates the action with size and duration
/**
* @brief Create the action with size and duration.
* @param duration The duration of the action. It's a value in seconds.
* @param gridSize Specify the grid size of the action.
* @return A pointer of TiledGrid3DAction. If creation failed, return nil.
* @js NA
* @lua NA
*/
static TiledGrid3DAction* create(float duration, const Size& gridSize);
/** returns the tile that belongs to a certain position of the grid
/**
* @brief Get the tile that belongs to a certain position of the grid.
* @param position The position of the tile want to get.
* @return A quadrilateral of the tile.
* @js NA
* @lua NA
*/
@ -146,19 +173,25 @@ public:
*/
CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Vec2& position) { return getTile(position); }
/** returns the non-transformed tile that belongs to a certain position of the grid
/**
* @brief Get the non-transformed tile that belongs to a certain position of the grid.
* @param position The position of the tile want to get.
* @return A quadrilateral of the tile.
* @js NA
* @lua NA
*/
Quad3 getOriginalTile(const Vec2& position) const;
/** @deprecated Use getOriginalTile() instead
/** @deprecated Use getOriginalTile() instead.
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Vec2& position) { return getOriginalTile(position); }
/** sets a new tile to a certain position of the grid
/**
* @brief Set a new tile to a certain position of the grid.
* @param position The position of the tile.
* @param coords The quadrilateral of the new tile.
* @js NA
* @lua NA
*/
@ -175,23 +208,33 @@ public:
}
};
/** @brief AccelDeccelAmplitude action */
/**
@brief AccelDeccelAmplitude action.
*/
class CC_DLL AccelDeccelAmplitude : public ActionInterval
{
public:
/** creates the action with an inner action that has the amplitude property, and a duration time */
/**
@brief Create the action with an inner action that has the amplitude property, and a duration time.
@@param action A pointer of the inner action.
@param duration Specify the duration of the AccelDeccelAmplitude action.
@return Return a pointer of AccelDeccelAmplitude action. When the creation failed, return nil.
*/
static AccelDeccelAmplitude* create(Action *action, float duration);
/** get amplitude rate */
/**
@brief Get the value of amplitude rate.
@return the value of amplitude rate.
*/
inline float getRate(void) const { return _rate; }
/** set amplitude rate */
/**
@brief Set the value of amplitude rate.
@param rate Specify the value of amplitude rate.
*/
inline void setRate(float rate) { _rate = rate; }
// Overrides
virtual void startWithTarget(Node *target) override;
/**
* @param time in seconds
*/
virtual void update(float time) override;
virtual AccelDeccelAmplitude* clone() const override;
virtual AccelDeccelAmplitude* reverse() const override;
@ -200,7 +243,12 @@ CC_CONSTRUCTOR_ACCESS:
AccelDeccelAmplitude() {}
virtual ~AccelDeccelAmplitude();
/** initializes the action with an inner action that has the amplitude property, and a duration time */
/**
@brief Initializes the action with an inner action that has the amplitude property, and a duration time.
@param action A pointer of the inner action.
@param duration Specify the duration of the AccelDeccelAmplitude action.
@return If the initialization success, return true; otherwise, return false.
*/
bool initWithAction(Action *action, float duration);
protected:
@ -211,23 +259,33 @@ private:
CC_DISALLOW_COPY_AND_ASSIGN(AccelDeccelAmplitude);
};
/** @brief AccelAmplitude action */
/**
@brief AccelAmplitude action.
*/
class CC_DLL AccelAmplitude : public ActionInterval
{
public:
/** creates the action with an inner action that has the amplitude property, and a duration time */
/**
@brief Create the action with an inner action that has the amplitude property, and a duration time.
@param action A pointer of the inner action.
@param duration Specify the duration of the AccelAmplitude action.
@return Return a pointer of AccelAmplitude action. When the creation failed, return nil.
*/
static AccelAmplitude* create(Action *action, float duration);
/** get amplitude rate */
/**
@brief Get the value of amplitude rate.
@return The value of amplitude rate.
*/
inline float getRate() const { return _rate; }
/** set amplitude rate */
/**
@brief Set the value of amplitude rate.
@param rate Specify the value of amplitude rate.
*/
inline void setRate(float rate) { _rate = rate; }
// Overrides
virtual void startWithTarget(Node *target) override;
/**
* @param time in seconds
*/
virtual void update(float time) override;
virtual AccelAmplitude* clone() const override;
virtual AccelAmplitude* reverse() const override;
@ -246,23 +304,33 @@ private:
CC_DISALLOW_COPY_AND_ASSIGN(AccelAmplitude);
};
/** @brief DeccelAmplitude action */
/**
@brief DeccelAmplitude action
*/
class CC_DLL DeccelAmplitude : public ActionInterval
{
public:
/** creates the action with an inner action that has the amplitude property, and a duration time */
/**
@brief Creates the action with an inner action that has the amplitude property, and a duration time.
@param action A pointer of the inner action.
@param duration Specify the duration of the DeccelAmplitude action.
@return Return a pointer of DeccelAmplitude. When the creation failed, return nil.
*/
static DeccelAmplitude* create(Action *action, float duration);
/** get amplitude rate */
/**
@brief Get the value of amplitude rate.
@return The value of amplitude rate.
*/
inline float getRate() const { return _rate; }
/** set amplitude rate */
/**
@brief Set the value of amplitude rate.
@param rate Specify the value.
*/
inline void setRate(float rate) { _rate = rate; }
// overrides
virtual void startWithTarget(Node *target) override;
/**
* @param time in seconds
*/
virtual void update(float time) override;
virtual DeccelAmplitude* clone() const override;
virtual DeccelAmplitude* reverse() const override;
@ -271,7 +339,12 @@ CC_CONSTRUCTOR_ACCESS:
DeccelAmplitude() {}
virtual ~DeccelAmplitude();
/** initializes the action with an inner action that has the amplitude property, and a duration time */
/**
@brief Initializes the action with an inner action that has the amplitude property, and a duration time.
@param action The pointer of inner action.
@param duration The duration of the DeccelAmplitude action.
@return If the initilization sucess, return true; otherwise, return false.
*/
bool initWithAction(Action *action, float duration);
protected:
@ -282,7 +355,8 @@ private:
CC_DISALLOW_COPY_AND_ASSIGN(DeccelAmplitude);
};
/** @brief StopGrid action.
/**
@brief StopGrid action.
@warning Don't call this action if another grid action is active.
Call if you want to remove the the grid effect. Example:
Sequence::actions(Lens::action(...), StopGrid::action(...), nullptr);
@ -290,7 +364,10 @@ private:
class CC_DLL StopGrid : public ActionInstant
{
public:
/** Allocates and initializes the action */
/**
@brief Create a StopGrid Action.
@return Return a pointer of StopGrid. When the creation failed, return nil.
*/
static StopGrid* create();
// Overrides
@ -311,11 +388,17 @@ private:
CC_DISALLOW_COPY_AND_ASSIGN(StopGrid);
};
/** @brief ReuseGrid action */
/**
@brief ReuseGrid action.
*/
class CC_DLL ReuseGrid : public ActionInstant
{
public:
/** creates an action with the number of times that the current grid will be reused */
/**
@brief Create an action with the number of times that the current grid will be reused.
@param times Specify times the grid will be reused.
@return Return a pointer of ReuseGrid. When the creation failed, return nil.
*/
static ReuseGrid* create(int times);
// Override
@ -327,7 +410,11 @@ CC_CONSTRUCTOR_ACCESS:
ReuseGrid() {}
virtual ~ReuseGrid() {}
/** initializes an action with the number of times that the current grid will be reused */
/**
@brief Initializes an action with the number of times that the current grid will be reused.
@param times Specify times the grid will be reused.
@return If the initialization sucess, return true; otherwise, return false.
*/
bool initWithTimes(int times);
protected:

View File

@ -36,36 +36,62 @@ NS_CC_BEGIN
*/
/**
@brief Waves3D action
@brief Waves3D action.
@detail This action is used for take effect on the target node as 3D waves.
You can control the effect by these parameters:
duration, grid size, waves count, amplitude.
*/
class CC_DLL Waves3D : public Grid3DAction
{
public:
/** creates an action with duration, grid size, waves and amplitude */
/**
@brief Create an action with duration, grid size, waves and amplitude.
@param duration Specify the duration of the Waves3D action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@param waves Specify the waves count of the Waves3D action.
@param amplitude Specify the amplitude of the Waves3D action.
@return If the creation sucess, return a pointer of Waves3D action; otherwise, return nil.
*/
static Waves3D* create(float duration, const Size& gridSize, unsigned int waves, float amplitude);
/** returns the amplitude of the effect */
/**
@brief Get the amplitude of the effect.
@return Return the amplitude of the effect.
*/
inline float getAmplitude() const { return _amplitude; }
/** sets the amplitude to the effect */
/**
@brief Set the amplitude to the effect.
@param amplitude The value of amplitude will be set.
*/
inline void setAmplitude(float amplitude) { _amplitude = amplitude; }
/** returns the amplitude rate */
/**
@brief Get the amplitude rate of the effect.
@return Return the amplitude rate of the effect.
*/
inline float getAmplitudeRate() const { return _amplitudeRate; }
/** sets the ampliture rate */
/**
@brief Set the ampliture rate of the effect.
@param amplitudeRate The value of amplitude rate will be set.
*/
inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; }
// Overrides
virtual Waves3D* clone() const override;
/**
* @param time in seconds
*/
virtual void update(float time) override;
CC_CONSTRUCTOR_ACCESS:
Waves3D() {}
virtual ~Waves3D() {}
/** initializes an action with duration, grid size, waves and amplitude */
/**
@brief Initializes an action with duration, grid size, waves and amplitude.
@param duration Specify the duration of the Waves3D action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@param waves Specify the waves count of the Waves3D action.
@param amplitude Specify the amplitude of the Waves3D action.
@return If the initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude);
protected:
@ -77,43 +103,62 @@ private:
CC_DISALLOW_COPY_AND_ASSIGN(Waves3D);
};
/** @brief FlipX3D action */
/**
@brief FlipX3D action.
@detail This action is used for flipping the target node on the x axis.
*/
class CC_DLL FlipX3D : public Grid3DAction
{
public:
/** creates the action with duration */
/**
@brief Create the action with duration.
@param duration Specify the duration of the FilpX3D action. It's a value in seconds.
@return If the creation sucess, return a pointer of FilpX3D action; otherwise, return nil.
*/
static FlipX3D* create(float duration);
// Override
virtual FlipX3D* clone() const override;
/**
* @param time in seconds
*/
virtual void update(float time) override;
CC_CONSTRUCTOR_ACCESS:
FlipX3D() {}
virtual ~FlipX3D() {}
/** initializes the action with duration */
/**
@brief Initializes an action with duration.
@param duration Specify the duration of the FlipX3D action. It's a value in seconds.
@return If the initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration);
/**
@brief Initializes an action with duration and grid size.
@param gridSize Specify the grid size of the FlipX3D action.
@param duration Specify the duration of the FlipX3D action. It's a value in seconds.
@return If the initialization success, return true; otherwise, return false.
*/
virtual bool initWithSize(const Size& gridSize, float duration);
private:
CC_DISALLOW_COPY_AND_ASSIGN(FlipX3D);
};
/** @brief FlipY3D action */
/**
@brief FlipY3D action.
@detail This action is used for flipping the target node on the y axis.
*/
class CC_DLL FlipY3D : public FlipX3D
{
public:
/** creates the action with duration */
/**
@brief Create the action with duration.
@param duration Specify the duration of the FlipY3D action. It's a value in seconds.
@return If the creation sucess, return a pointer of FlipY3D action; otherwise, return nil.
*/
static FlipY3D* create(float duration);
// Overrides
/**
* @param time in seconds
*/
virtual void update(float time) override;
virtual FlipY3D* clone() const override;
@ -124,35 +169,72 @@ private:
CC_DISALLOW_COPY_AND_ASSIGN(FlipY3D);
};
/** @brief Lens3D action */
/**
@brief Lens3D action.
@detail This action is used for take effect on the target node as lens.
You can create the action by these parameters:
duration, grid size, center position of lens, radius of lens.
Also you can change the lens effect value & whether effect is concave by the setter methods.
*/
class CC_DLL Lens3D : public Grid3DAction
{
public:
/** creates the action with center position, radius, a grid size and duration */
/**
@brief Create the action with center position, radius, a grid size and duration.
@param duration Specify the duration of the Lens3D action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@param position Specify the center position of the lens.
@param radius Specify the radius of the lens.
@return If the creation sucess, return a pointer of Lens3D action; otherwise, return nil.
*/
static Lens3D* create(float duration, const Size& gridSize, const Vec2& position, float radius);
/** Get lens center position */
/**
@brief Get the value of lens effect. Default value is 0.7.
@return The value of lens effect.
*/
inline float getLensEffect() const { return _lensEffect; }
/** Set lens center position */
/**
@brief Set the value of lens effect.
@param lensEffect The value of lens effect will be set.
*/
inline void setLensEffect(float lensEffect) { _lensEffect = lensEffect; }
/** Set whether lens is concave */
/**
@brief Set whether lens is concave.
@param concave Whether lens is concave.
*/
inline void setConcave(bool concave) { _concave = concave; }
/**
@brief Get the center position of lens effect.
@return The center position of lens effect.
*/
inline const Vec2& getPosition() const { return _position; }
/**
@brief Set the center position of lens effect.
@param The center position will be set.
*/
void setPosition(const Vec2& position);
// Overrides
virtual Lens3D* clone() const override;
/**
* @param time in seconds
*/
virtual void update(float time) override;
CC_CONSTRUCTOR_ACCESS:
Lens3D() {}
virtual ~Lens3D() {}
/** initializes the action with center position, radius, a grid size and duration */
/**
@brief Initializes the action with center position, radius, grid size and duration.
@param duration Specify the duration of the Lens3D action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@param position Specify the center position of the lens effect.
@param radius Specify the radius of the lens effect.
@return If the initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius);
protected:
@ -170,36 +252,79 @@ private:
CC_DISALLOW_COPY_AND_ASSIGN(Lens3D);
};
/** @brief Ripple3D action */
/**
@brief Ripple3D action.
@detail This action is used for take effect on the target node as ripple.
You can create the action by these parameters:
duration, grid size, center position of ripple,
radius of ripple, waves count, amplitude.
*/
class CC_DLL Ripple3D : public Grid3DAction
{
public:
/** creates the action with radius, number of waves, amplitude, a grid size and duration */
/**
@brief Create the action with center position, radius, number of waves, amplitude, a grid size and duration.
@param duration Specify the duration of the Ripple3D action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@param position Specify the center position of the ripple effect.
@param radius Specify the radius of the ripple effect.
@param waves Specify the waves count of the ripple effect.
@param amplitude Specify the amplitude of the ripple effect.
@return If the creation sucess, return a pointer of Ripple3D action; otherwise, return nil.
*/
static Ripple3D* create(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude);
/** get center position */
/**
@brief Get the center position of ripple effect.
@return The center position of ripple effect.
*/
inline const Vec2& getPosition() const { return _position; }
/** set center position */
/**
@brief Set the center position of ripple effect.
@param position The center position of ripple effect will be set.
*/
void setPosition(const Vec2& position);
/**
@brief Get the amplitude of ripple effect.
@return The amplitude of ripple effect.
*/
inline float getAmplitude() const { return _amplitude; }
/**
@brief Set the amplitude of ripple effect.
@param fAmplitude The amplitude of ripple effect.
*/
inline void setAmplitude(float fAmplitude) { _amplitude = fAmplitude; }
/**
@brief Get the amplitude rate of ripple effect.
@return The amplitude rate of ripple effect.
*/
inline float getAmplitudeRate() const { return _amplitudeRate; }
/**
@brief Set the amplitude rate of ripple effect.
@param fAmplitudeRate The amplitude rate of ripple effect.
*/
inline void setAmplitudeRate(float fAmplitudeRate) { _amplitudeRate = fAmplitudeRate; }
// Override
virtual Ripple3D* clone() const override;
/**
* @param time in seconds
*/
virtual void update(float time) override;
CC_CONSTRUCTOR_ACCESS:
Ripple3D() {}
virtual ~Ripple3D() {}
/** initializes the action with radius, number of waves, amplitude, a grid size and duration */
/**
@brief Initializes the action with center position, radius, number of waves, amplitude, a grid size and duration.
@param duration Specify the duration of the Ripple3D action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@param position Specify the center position of the ripple effect.
@param radius Specify the radius of the ripple effect.
@param waves Specify the waves count of the ripple effect.
@param amplitude Specify the amplitude of the ripple effect.
@return If the initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude);
protected:
@ -214,12 +339,24 @@ private:
CC_DISALLOW_COPY_AND_ASSIGN(Ripple3D);
};
/** @brief Shaky3D action */
/**
@brief Shaky3D action.
@detail This action is used for take effect on the target node as shaky.
You can create the action by these parameters:
duration, grid size, range, whether shake on the z axis.
*/
class CC_DLL Shaky3D : public Grid3DAction
{
public:
/** creates the action with a range, shake Z vertices, a grid and duration */
static Shaky3D* create(float duration, const Size& gridSize, int range, bool shakeZ);
/**
@brief Create the action with a range, shake Z vertices, a grid and duration.
@param duration Specify the duration of the Shaky3D action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@param range Specify the range of the shaky effect.
@param shakeZ Specify whether shake on the z axis.
@return If the creation sucess, return a pointer of Shaky3D action; otherwise, return nil.
*/
static Shaky3D* create(float initWithDuration, const Size& gridSize, int range, bool shakeZ);
// Overrides
virtual Shaky3D* clone() const override;
@ -230,9 +367,13 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~Shaky3D() {}
/**
* initializes the action with a range, shake Z vertices, a grid and duration
* @param duration in seconds
*/
@brief Initializes the action with a range, shake Z vertices, grid size and duration.
@param duration Specify the duration of the Shaky3D action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@param range Specify the range of the shaky effect.
@param shakeZ Specify whether shake on the z axis.
@return If the Initialization sucess, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, int range, bool shakeZ);
protected:
@ -243,31 +384,63 @@ private:
CC_DISALLOW_COPY_AND_ASSIGN(Shaky3D);
};
/** @brief Liquid action */
/**
@brief Liquid action.
@detail This action is used for take effect on the target node as liquid.
You can create the action by these parameters:
duration, grid size, waves count, amplitude of the liquid effect.
*/
class CC_DLL Liquid : public Grid3DAction
{
public:
/** creates the action with amplitude, a grid and duration */
/**
@brief Create the action with amplitude, grid size, waves count and duration.
@param duration Specify the duration of the Liquid action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@param waves Specify the waves count of the Liquid action.
@param amplitude Specify the amplitude of the Liquid action.
@return If the creation sucess, return a pointer of Liquid action; otherwise, return nil.
*/
static Liquid* create(float duration, const Size& gridSize, unsigned int waves, float amplitude);
/**
@brief Get the amplitude of the effect.
@return Return the amplitude of the effect.
*/
inline float getAmplitude() const { return _amplitude; }
/**
@brief Set the amplitude to the effect.
@param amplitude The value of amplitude will be set.
*/
inline void setAmplitude(float amplitude) { _amplitude = amplitude; }
/**
@brief Get the amplitude rate of the effect.
@return Return the amplitude rate of the effect.
*/
inline float getAmplitudeRate() const { return _amplitudeRate; }
/**
@brief Set the ampliture rate of the effect.
@param amplitudeRate The value of amplitude rate will be set.
*/
inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; }
// Overrides
virtual Liquid* clone() const override;
/**
* @param time in seconds
*/
virtual void update(float time) override;
CC_CONSTRUCTOR_ACCESS:
Liquid() {}
virtual ~Liquid() {}
/** initializes the action with amplitude, a grid and duration */
/**
@brief Initializes the action with amplitude, grid size, waves count and duration.
@param duration Specify the duration of the Liquid action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@param waves Specify the waves count of the Liquid action.
@param amplitude Specify the amplitude of the Liquid action.
@return If the initialization sucess, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude);
protected:
@ -279,31 +452,68 @@ private:
CC_DISALLOW_COPY_AND_ASSIGN(Liquid);
};
/** @brief Waves action */
/**
@brief Waves action.
@detail This action is used for take effect on the target node as waves.
You can control the effect by these parameters:
duration, grid size, waves count, amplitude,
whether waves on horizontal and whether waves on vertical.
*/
class CC_DLL Waves : public Grid3DAction
{
public:
/** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */
/**
@brief Create the action with amplitude, horizontal sin, vertical sin, grid size, waves count and duration.
@param duration Specify the duration of the Waves action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@param waves Specify the waves count of the Waves action.
@param amplitude Specify the amplitude of the Waves action.
@param horizontal Specify whether waves on horizontal.
@param vertical Specify whether waves on vertical.
@return If the creation sucess, return a pointer of Waves action; otherwise, return nil.
*/
static Waves* create(float duration, const Size& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical);
/**
@brief Get the amplitude of the effect.
@return Return the amplitude of the effect.
*/
inline float getAmplitude() const { return _amplitude; }
/**
@brief Set the amplitude to the effect.
@param amplitude The value of amplitude will be set.
*/
inline void setAmplitude(float amplitude) { _amplitude = amplitude; }
/**
@brief Get the amplitude rate of the effect.
@return Return the amplitude rate of the effect.
*/
inline float getAmplitudeRate() const { return _amplitudeRate; }
/**
@brief Set the ampliture rate of the effect.
@param amplitudeRate The value of amplitude rate will be set.
*/
inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; }
// Overrides
virtual Waves* clone() const override;
/**
* @param time in seconds
*/
virtual void update(float time) override;
CC_CONSTRUCTOR_ACCESS:
Waves() {}
virtual ~Waves() {}
/** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */
/**
@brief Initializes the action with amplitude, horizontal sin, vertical sin, grid size, waves count and duration.
@param duration Specify the duration of the Waves action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@param waves Specify the waves count of the Waves action.
@param amplitude Specify the amplitude of the Waves action.
@param horizontal Specify whether waves on horizontal.
@param vertical Specify whether waves on vertical.
@return If the initialization sucess, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical);
protected:
@ -317,37 +527,77 @@ private:
CC_DISALLOW_COPY_AND_ASSIGN(Waves);
};
/** @brief Twirl action */
/**
@brief Twirl action.
@detail This action is used for take effect on the target node as twirl.
You can control the effect by these parameters:
duration, grid size, center position, twirls count, amplitude.
*/
class CC_DLL Twirl : public Grid3DAction
{
public:
/** creates the action with center position, number of twirls, amplitude, a grid size and duration */
/**
@brief Create the action with center position, number of twirls, amplitude, a grid size and duration.
@param duration Specify the duration of the Twirl action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@param position Specify the center position of the twirl action.
@param twirls Specify the twirls count of the Twirl action.
@param amplitude Specify the amplitude of the Twirl action.
@return If the creation sucess, return a pointer of Twirl action; otherwise, return nil.
*/
static Twirl* create(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude);
/** get twirl center */
/**
@brief Get the center position of twirl action.
@return The center position of twirl action.
*/
inline const Vec2& getPosition() const { return _position; }
/** set twirl center */
/**
@brief Set the center position of twirl action.
@param position The center position of twirl action will be set.
*/
void setPosition(const Vec2& position);
/**
@brief Get the amplitude of the effect.
@return Return the amplitude of the effect.
*/
inline float getAmplitude() const { return _amplitude; }
/**
@brief Set the amplitude to the effect.
@param amplitude The value of amplitude will be set.
*/
inline void setAmplitude(float amplitude) { _amplitude = amplitude; }
/**
@brief Get the amplitude rate of the effect.
@return Return the amplitude rate of the effect.
*/
inline float getAmplitudeRate() const { return _amplitudeRate; }
/**
@brief Set the ampliture rate of the effect.
@param amplitudeRate The value of amplitude rate will be set.
*/
inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; }
// Overrides
virtual Twirl* clone() const override;
/**
* @param time in seconds
*/
virtual void update(float time) override;
CC_CONSTRUCTOR_ACCESS:
Twirl() {}
virtual ~Twirl() {}
/** initializes the action with center position, number of twirls, amplitude, a grid size and duration */
/**
@brief Initializes the action with center position, number of twirls, amplitude, a grid size and duration.
@param duration Specify the duration of the Twirl action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@param position Specify the center position of the twirl action.
@param twirls Specify the twirls count of the Twirl action.
@param amplitude Specify the amplitude of the Twirl action.
@return If the initialization sucess, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude);
protected:

View File

@ -37,10 +37,10 @@ NS_CC_BEGIN
/**
@brief This action simulates a page turn from the bottom right hand corner of the screen.
It's not much use by itself but is used by the PageTurnTransition.
Based on an original paper by L Hong et al.
http://www.parc.com/publication/1638/turning-pages-of-3d-electronic-books.html
@detail It's not much use by itself but is used by the PageTurnTransition.
Based on an original paper by L Hong et al.
http://www.parc.com/publication/1638/turning-pages-of-3d-electronic-books.html
@since v0.8.2
*/
@ -51,14 +51,17 @@ public:
* @js NA
*/
virtual GridBase* getGrid() override;
/** create the action */
/**
@brief Create an action with duration, grid size.
@param duration Specify the duration of the PageTurn3D action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@return If the creation sucess, return a pointer of PageTurn3D action; otherwise, return nil.
*/
static PageTurn3D* create(float duration, const Size& gridSize);
// Overrides
virtual PageTurn3D* clone() const override;
/**
* @param time in seconds
*/
virtual void update(float time) override;
};

View File

@ -36,15 +36,19 @@ NS_CC_BEGIN
*/
/**
@brief Progress to percentage
@brief Progress to percentage.
@detail This action show the target node from current percentage to the specified percentage.
You should specify the destination percentage when creating the action.
@since v0.99.1
*/
class CC_DLL ProgressTo : public ActionInterval
{
public:
/**
* Creates and initializes with a duration and a percent
* @param duration in seconds
* @brief Create and initializes with a duration and a destination percentage.
* @param duration Specify the duration of the ProgressTo action. It's a value in seconds.
* @param percent Specify the destination percentage.
* @return If the creation sucess, return a pointer of ProgressTo action; otherwise, return nil.
*/
static ProgressTo* create(float duration, float percent);
@ -54,9 +58,6 @@ public:
virtual ProgressTo* clone() const override;
virtual ProgressTo* reverse() const override;
virtual void startWithTarget(Node *target) override;
/**
* @param time in seconds
*/
virtual void update(float time) override;
CC_CONSTRUCTOR_ACCESS:
@ -64,8 +65,10 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~ProgressTo() {}
/**
* Initializes with a duration and a percent
* @param duration in seconds
* @brief Initializes with a duration and destination percentage.
* @param duration Specify the duration of the ProgressTo action. It's a value in seconds.
* @param percent Specify the destination percentage.
* @return If the creation sucess, return true; otherwise, return false.
*/
bool initWithDuration(float duration, float percent);
@ -78,15 +81,18 @@ private:
};
/**
@brief Progress from a percentage to another percentage
@brief Progress from a percentage to another percentage.
@since v0.99.1
*/
class CC_DLL ProgressFromTo : public ActionInterval
{
public:
/**
* Creates and initializes the action with a duration, a "from" percentage and a "to" percentage
* @param duration in seconds
* @brief Create and initializes the action with a duration, a "from" percentage and a "to" percentage.
* @param duration Specify the duration of the ProgressFromTo action. It's a value in seconds.
* @param fromPercentage Specify the source percentage.
* @param toPercentage Specify the destination percentage.
* @return If the creation sucess, return a pointer of ProgressFromTo action; otherwise, return nil.
*/
static ProgressFromTo* create(float duration, float fromPercentage, float toPercentage);
@ -96,16 +102,19 @@ public:
virtual ProgressFromTo* clone() const override;
virtual ProgressFromTo* reverse() const override;
virtual void startWithTarget(Node *target) override;
/**
* @param time in seconds
*/
virtual void update(float time) override;
CC_CONSTRUCTOR_ACCESS:
ProgressFromTo() {}
virtual ~ProgressFromTo() {}
/** Initializes the action with a duration, a "from" percentage and a "to" percentage */
/**
* @brief Initializes the action with a duration, a "from" percentage and a "to" percentage.
* @param duration Specify the duration of the ProgressFromTo action. It's a value in seconds.
* @param fromPercentage Specify the source percentage.
* @param toPercentage Specify the destination percentage.
* @return If the creation sucess, return true; otherwise, return false.
*/
bool initWithDuration(float duration, float fromPercentage, float toPercentage);
protected:

View File

@ -35,6 +35,15 @@ NS_CC_BEGIN
* @{
*/
/**
@brief The delegate class for ActionTween.
@detail If you want to use ActionTween on a node.
You should implement the node follow these steps:
1. The node should be inherit from ActionTweenDelegate.
2. Override the virtual method updateTweenAction in the node.
Then once you running ActionTween on the node, the method updateTweenAction will be incoked.
*/
class CC_DLL ActionTweenDelegate
{
public:
@ -43,6 +52,12 @@ public:
* @lua NA
*/
virtual ~ActionTweenDelegate() {}
/**
@brief The callback function when ActionTween is running.
@param value The new value of the specified key.
@param key The key of property which should be updated.
*/
virtual void updateTweenAction(float value, const std::string& key) = 0;
};
@ -70,24 +85,29 @@ class CC_DLL ActionTween : public ActionInterval
{
public:
/**
* creates an initializes the action with the property name (key), and the from and to parameters.
* @param duration in seconds
* @brief Create and initializes the action with the property name (key), and the from and to parameters.
* @param duration The duration of the ActionTween. It's a value in seconds.
* @param key The key of property which should be updated.
* @param from The value of the specified property when the action begin.
* @param to The value of the specified property when the action end.
* @return If the creation success, return a pointer of ActionTween; otherwise, return nil.
*/
static ActionTween* create(float duration, const std::string& key, float from, float to);
// Overrides
void startWithTarget(Node *target) override;
/**
* @param dt in seconds
*/
void update(float dt) override;
ActionTween* reverse() const override;
ActionTween *clone() const override;
CC_CONSTRUCTOR_ACCESS:
/**
* initializes the action with the property name (key), and the from and to parameters.
* @param duration in seconds
* @brief Initializes the action with the property name (key), and the from and to parameters.
* @param duration The duration of the ActionTween. It's a value in seconds.
* @param key The key of property which should be updated.
* @param from The value of the specified property when the action begin.
* @param to The value of the specified property when the action end.
* @return If the initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const std::string& key, float from, float to);

View File

@ -46,17 +46,20 @@ class SpriteFrame;
*/
/** AnimationFrame
A frame of the animation. It contains information like:
- sprite frame name
- # of delay units.
- offset
*
* A frame of the animation. It contains information like:
* - sprite frame name.
* - # of delay units.
* - offset
@since v2.0
*/
class CC_DLL AnimationFrame : public Ref, public Clonable
{
public:
/** @struct DisplayedEventInfo
* When the animation display,Dispatches the event of UserData.
*/
struct DisplayedEventInfo
{
Node* target;
@ -64,13 +67,23 @@ public:
};
/**
* Creates the animation frame with a spriteframe, number of delay units and a notification user info
* Creates the animation frame with a spriteframe, number of delay units and a notification user info.
*
* @param spriteFrame The animation frame with a spriteframe.
* @param delayUnits Number of delay units.
* @param userInfo A notification user info.
* @since 3.0
*/
static AnimationFrame* create(SpriteFrame* spriteFrame, float delayUnits, const ValueMap& userInfo);
/** Return a SpriteFrameName to be used.
*
* @return a SpriteFrameName to be used.
*/
SpriteFrame* getSpriteFrame() const { return _spriteFrame; };
/** Set the SpriteFrame.
*
* @param frame A SpriteFrame will be used.
*/
void setSpriteFrame(SpriteFrame* frame)
{
CC_SAFE_RETAIN(frame);
@ -78,19 +91,30 @@ public:
_spriteFrame = frame;
}
/** Gets the units of time the frame takes */
/** Gets the units of time the frame takes.
*
* @return The units of time the frame takes.
*/
float getDelayUnits() const { return _delayUnits; };
/** Sets the units of time the frame takes */
/** Sets the units of time the frame takes.
*
* @param delayUnits The units of time the frame takes.
*/
void setDelayUnits(float delayUnits) { _delayUnits = delayUnits; };
/** @brief Gets user infomation
A AnimationFrameDisplayedNotification notification will be broadcast when the frame is displayed with this dictionary as UserInfo. If UserInfo is nil, then no notification will be broadcast.
* A AnimationFrameDisplayedNotification notification will be broadcast when the frame is displayed with this dictionary as UserInfo.
* If UserInfo is nil, then no notification will be broadcast.
*
* @return A dictionary as UserInfo
*/
const ValueMap& getUserInfo() const { return _userInfo; };
ValueMap& getUserInfo() { return _userInfo; };
/** Sets user infomation */
/** Sets user infomation.
* @param userInfo A dictionary as UserInfo.
*/
void setUserInfo(const ValueMap& userInfo)
{
_userInfo = userInfo;
@ -131,89 +155,127 @@ private:
/** A Animation object is used to perform animations on the Sprite objects.
The Animation object contains AnimationFrame objects, and a possible delay between the frames.
You can animate a Animation object by using the Animate action. Example:
@code
sprite->runAction(Animate::create(animation));
@endcode
/** @class Animation
* A Animation object is used to perform animations on the Sprite objects.
* The Animation object contains AnimationFrame objects, and a possible delay between the frames.
* You can animate a Animation object by using the Animate action. Example:
* @code
* sprite->runAction(Animate::create(animation));
* @endcode
*/
class CC_DLL Animation : public Ref, public Clonable
{
public:
/** Creates an animation
@since v0.99.5
/** Creates an animation.
* @since v0.99.5
*/
static Animation* create(void);
/* Creates an animation with an array of SpriteFrame and a delay between frames in seconds.
The frames will be added with one "delay unit".
@since v0.99.5
* The frames will be added with one "delay unit".
* @since v0.99.5
* @param arrayOfSpriteFrameNames An array of SpriteFrame.
* @param delay A delay between frames in seconds.
* @param loops The times the animation is going to loop.
*/
static Animation* createWithSpriteFrames(const Vector<SpriteFrame*>& arrayOfSpriteFrameNames, float delay = 0.0f, unsigned int loops = 1);
/* Creates an animation with an array of AnimationFrame, the delay per units in seconds and and how many times it should be executed.
@since v2.0
* @since v2.0
* @js NA
* @param arrayOfAnimationFrameNames An animation with an array of AnimationFrame.
* @param delayPerUnit The delay per units in seconds and and how many times it should be executed.
* @param loops The times the animation is going to loop.
*/
static Animation* create(const Vector<AnimationFrame*>& arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops = 1);
/** Adds a SpriteFrame to a Animation.
The frame will be added with one "delay unit".
*
* @param frame The frame will be added with one "delay unit".
*/
void addSpriteFrame(SpriteFrame *frame);
/** Adds a frame with an image filename. Internally it will create a SpriteFrame and it will add it.
The frame will be added with one "delay unit".
Added to facilitate the migration from v0.8 to v0.9.
* The frame will be added with one "delay unit".
* Added to facilitate the migration from v0.8 to v0.9.
* @param filename The path of SpriteFrame.
*/
void addSpriteFrameWithFile(const std::string& filename);
/**
@deprecated. Use addSpriteFrameWithFile() instead
* @deprecated. Use addSpriteFrameWithFile() instead.
*/
CC_DEPRECATED_ATTRIBUTE void addSpriteFrameWithFileName(const std::string& filename){ addSpriteFrameWithFile(filename);}
/** Adds a frame with a texture and a rect. Internally it will create a SpriteFrame and it will add it.
The frame will be added with one "delay unit".
Added to facilitate the migration from v0.8 to v0.9.
* The frame will be added with one "delay unit".
* Added to facilitate the migration from v0.8 to v0.9.
* @param pobTexture A frame with a texture.
* @param rect The Texture of rect.
*/
void addSpriteFrameWithTexture(Texture2D* pobTexture, const Rect& rect);
/** Gets the total Delay units of the Animation. */
/** Gets the total Delay units of the Animation.
*
* @return The total Delay units of the Animation.
*/
float getTotalDelayUnits() const { return _totalDelayUnits; };
/** Sets the delay in seconds of the "delay unit" */
/** Sets the delay in seconds of the "delay unit".
*
* @param setDelayPerUnit The delay in seconds of the "delay unit".
*/
void setDelayPerUnit(float delayPerUnit) { _delayPerUnit = delayPerUnit; };
/** Gets the delay in seconds of the "delay unit" */
/** Gets the delay in seconds of the "delay unit".
*
* @return The delay in seconds of the "delay unit".
*/
float getDelayPerUnit() const { return _delayPerUnit; };
/** Gets the duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit */
/** Gets the duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit.
*
* @return Result of totalDelayUnits * delayPerUnit.
*/
float getDuration() const;
/** Gets the array of AnimationFrames */
/** Gets the array of AnimationFrames.
*
* @return The array of AnimationFrames.
*/
const Vector<AnimationFrame*>& getFrames() const { return _frames; };
/** Sets the array of AnimationFrames */
/** Sets the array of AnimationFrames.
*
* @param frames The array of AnimationFrames.
*/
void setFrames(const Vector<AnimationFrame*>& frames)
{
_frames = frames;
}
/** Checks whether to restore the original frame when animation finishes. */
/** Checks whether to restore the original frame when animation finishes.
*
* @return Restore the original frame when animation finishes.
*/
bool getRestoreOriginalFrame() const { return _restoreOriginalFrame; };
/** Sets whether to restore the original frame when animation finishes */
/** Sets whether to restore the original frame when animation finishes.
*
* @param restoreOriginalFrame Whether to restore the original frame when animation finishes.
*/
void setRestoreOriginalFrame(bool restoreOriginalFrame) { _restoreOriginalFrame = restoreOriginalFrame; };
/** Gets the times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... */
/** Gets the times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ...
*
* @return The times the animation is going to loop.
*/
unsigned int getLoops() const { return _loops; };
/** Sets the times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... */
/** Sets the times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ...
*
* @param loops The times the animation is going to loop.
*/
void setLoops(unsigned int loops) { _loops = loops; };
// overrides
@ -223,16 +285,16 @@ CC_CONSTRUCTOR_ACCESS:
Animation();
virtual ~Animation(void);
/** Initializes a Animation */
/** Initializes a Animation. */
bool init();
/** Initializes a Animation with frames and a delay between frames
@since v0.99.5
/** Initializes a Animation with frames and a delay between frames.
* @since v0.99.5
*/
bool initWithSpriteFrames(const Vector<SpriteFrame*>& arrayOfSpriteFrameNames, float delay = 0.0f, unsigned int loops = 1);
/** Initializes a Animation with AnimationFrame
@since v2.0
/** Initializes a Animation with AnimationFrame.
* @since v2.0
*/
bool initWithAnimationFrames(const Vector<AnimationFrame*>& arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops);
@ -240,16 +302,16 @@ protected:
/** total Delay units of the Animation. */
float _totalDelayUnits;
/** Delay in seconds of the "delay unit" */
/** Delay in seconds of the "delay unit". */
float _delayPerUnit;
/** duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit */
/** duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit. */
float _duration;
/** array of AnimationFrames */
/** array of AnimationFrames. */
Vector<AnimationFrame*> _frames;
/** whether or not it shall restore the original frame when the animation finishes */
/** whether or not it shall restore the original frame when the animation finishes. */
bool _restoreOriginalFrame;
/** how many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... */

View File

@ -36,6 +36,7 @@ THE SOFTWARE.
NS_CC_BEGIN
class Animation;
/**
@ -44,12 +45,10 @@ class Animation;
*/
/** Singleton that manages the Animations.
It saves in a cache the animations. You should use this class if you want to save your animations in a cache.
Before v0.99.5, the recommend way was to save them on the Sprite. Since v0.99.5, you should use this class instead.
@since v0.99.5
*/
* It saves in a cache the animations. You should use this class if you want to save your animations in a cache.
* Before v0.99.5, the recommend way was to save them on the Sprite. Since v0.99.5, you should use this class instead.
* @since v0.99.5
*/
class CC_DLL AnimationCache : public Ref
{
public:
@ -62,27 +61,33 @@ public:
* @lua NA
*/
~AnimationCache();
/** Returns the shared instance of the Animation cache */
/** Returns the shared instance of the Animation cache.
*
* @return The shared instance of the Animation cache.
*/
static AnimationCache* getInstance();
/** Purges the cache. It releases all the Animation objects and the shared instance.
*/
/** Purges the cache. It releases all the Animation objects and the shared instance. */
static void destroyInstance();
/** @deprecated Use getInstance() instead */
/** @deprecated Use getInstance() instead. */
CC_DEPRECATED_ATTRIBUTE static AnimationCache* sharedAnimationCache() { return AnimationCache::getInstance(); }
/** @deprecated Use destroyInstance() instead */
/** @deprecated Use destroyInstance() instead. */
CC_DEPRECATED_ATTRIBUTE static void purgeSharedAnimationCache() { return AnimationCache::destroyInstance(); }
bool init(void);
/** Adds a Animation with a name.
*/
*
* @param animation An animation.
* @param name The name of animation.
*/
void addAnimation(Animation *animation, const std::string& name);
/** Deletes a Animation from the cache.
*
* @param name The name of animation.
*/
void removeAnimation(const std::string& name);
/** @deprecated. Use removeAnimation() instead
@ -92,29 +97,33 @@ public:
CC_DEPRECATED_ATTRIBUTE void removeAnimationByName(const std::string& name){ removeAnimation(name);}
/** Returns a Animation that was previously added.
If the name is not found it will return nil.
You should retain the returned copy if you are going to use it.
*/
* If the name is not found it will return nil.
* You should retain the returned copy if you are going to use it.
*
* @return A Animation that was previously added. If the name is not found it will return nil.
*/
Animation* getAnimation(const std::string& name);
/**
@deprecated. Use getAnimation() instead
* @deprecated. Use getAnimation() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE Animation* animationByName(const std::string& name){ return getAnimation(name); }
/** Adds an animation from an NSDictionary
Make sure that the frames were previously loaded in the SpriteFrameCache.
@param plist The path of the relative file,it use to find the plist path for load SpriteFrames.
@since v1.1
/** Adds an animation from an NSDictionary.
* Make sure that the frames were previously loaded in the SpriteFrameCache.
* @param dictionary An NSDictionary.
* @param plist The path of the relative file,it use to find the plist path for load SpriteFrames.
* @since v1.1
*/
void addAnimationsWithDictionary(const ValueMap& dictionary,const std::string& plist);
/** Adds an animation from a plist file.
Make sure that the frames were previously loaded in the SpriteFrameCache.
@since v1.1
* Make sure that the frames were previously loaded in the SpriteFrameCache.
* @since v1.1
* @js addAnimations
* @lua addAnimations
* @param plist An animation from a plist file.
*/
void addAnimationsWithFile(const std::string& plist);

View File

@ -42,26 +42,36 @@ NS_CC_BEGIN
class TextureAtlas;
/** @brief AtlasNode is a subclass of Node that implements the RGBAProtocol and TextureProtocol protocol
It knows how to render a TextureAtlas object.
If you are going to render a TextureAtlas consider subclassing AtlasNode (or a subclass of AtlasNode)
All features from Node are valid, plus the following features:
- opacity and RGB colors
*/
/** @brief AtlasNode is a subclass of Node that implements the RGBAProtocol and TextureProtocol protocol.
* It knows how to render a TextureAtlas object.
* If you are going to render a TextureAtlas consider subclassing AtlasNode (or a subclass of AtlasNode).
* All features from Node are valid, plus the following features:
* - opacity and RGB colors.
*/
class CC_DLL AtlasNode : public Node, public TextureProtocol
{
public:
/** creates a AtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/
/** creates a AtlasNode with an Atlas file the width and height of each item and the quantity of items to render.
*
* @param filename The path of Atlas file.
* @param tileWidth The width of the item.
* @param tileHeight The height of the item.
* @param itemsToRender The quantity of items to render.
*/
static AtlasNode * create(const std::string& filename, int tileWidth, int tileHeight, int itemsToRender);
/** updates the Atlas (indexed vertex array).
* Shall be overridden in subclasses
* Shall be overridden in subclasses.
*/
virtual void updateAtlasValues();
/** Set an buffer manager of the texture vertex. */
void setTextureAtlas(TextureAtlas* textureAtlas);
/** Return the buffer manager of the texture vertex.
*
* @return Return A TextureAtlas.
*/
TextureAtlas* getTextureAtlas() const;
void setQuadsToDraw(ssize_t quadsToDraw);
@ -95,10 +105,10 @@ CC_CONSTRUCTOR_ACCESS:
AtlasNode();
virtual ~AtlasNode();
/** initializes an AtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/
/** Initializes an AtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/
bool initWithTileFile(const std::string& tile, int tileWidth, int tileHeight, int itemsToRender);
/** initializes an AtlasNode with a texture the width and height of each item measured in points and the quantity of items to render*/
/** Initializes an AtlasNode with a texture the width and height of each item measured in points and the quantity of items to render*/
bool initWithTexture(Texture2D* texture, int tileWidth, int tileHeight, int itemsToRender);
protected:
@ -109,30 +119,30 @@ protected:
friend class Director;
void setIgnoreContentScaleFactor(bool bIgnoreContentScaleFactor);
//! chars per row
/** Chars per row. */
int _itemsPerRow;
//! chars per column
/** Chars per column. */
int _itemsPerColumn;
//! width of each char
/** Width of each char. */
int _itemWidth;
//! height of each char
/** Height of each char. */
int _itemHeight;
Color3B _colorUnmodified;
TextureAtlas* _textureAtlas;
// protocol variables
/** Protocol variables. */
bool _isOpacityModifyRGB;
BlendFunc _blendFunc;
// quads to draw
/** Quads to draw. */
ssize_t _quadsToDraw;
// color uniform
/** Color uniform. */
GLint _uniformColor;
// This varible is only used for LabelAtlas FPS display. So plz don't modify its value.
/** This varible is only used for LabelAtlas FPS display. So plz don't modify its value. */
bool _ignoreContentScaleFactor;
// quad command
/** Quad command. */
QuadCommand _quadCommand;
private:

View File

@ -316,6 +316,14 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
}
void ClippingNode::setCameraMask(unsigned short mask, bool applyChildren)
{
Node::setCameraMask(mask, applyChildren);
if (_stencil)
_stencil->setCameraMask(mask, applyChildren);
}
Node* ClippingNode::getStencil() const
{
return _stencil;

View File

@ -104,6 +104,8 @@ public:
virtual void onExit() override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
virtual void setCameraMask(unsigned short mask, bool applyChildren = true) override;
CC_CONSTRUCTOR_ACCESS:
ClippingNode();

View File

@ -910,6 +910,20 @@ void Label::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
}
}
void Label::setCameraMask(unsigned short mask, bool applyChildren)
{
SpriteBatchNode::setCameraMask(mask, applyChildren);
if (_textSprite)
{
_textSprite->setCameraMask(mask, applyChildren);
}
if (_shadowNode)
{
_shadowNode->setCameraMask(mask, applyChildren);
}
}
void Label::createSpriteWithFontDefinition()
{
_currentLabelType = LabelType::STRING_TEXTURE;
@ -918,6 +932,8 @@ void Label::createSpriteWithFontDefinition()
texture->initWithString(_originalUTF8String.c_str(),_fontDefinition);
_textSprite = Sprite::createWithTexture(texture);
//set camera mask using label's camera mask, because _textSprite may be null when setting camera mask to label
_textSprite->setCameraMask(getCameraMask());
_textSprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
this->setContentSize(_textSprite->getContentSize());
texture->release();
@ -1059,6 +1075,8 @@ void Label::drawTextSprite(Renderer *renderer, uint32_t parentFlags)
{
_shadowNode->setBlendFunc(_blendFunc);
}
//set camera mask using label's mask. Because _shadowNode may be null when setting the label's camera mask
_shadowNode->setCameraMask(getCameraMask());
_shadowNode->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
_shadowNode->setColor(_shadowColor);
_shadowNode->setOpacity(_shadowOpacity * _displayedOpacity);

View File

@ -266,6 +266,8 @@ public:
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual void setCameraMask(unsigned short mask, bool applyChildren = true) override;
CC_DEPRECATED_ATTRIBUTE static Label* create(const std::string& text, const std::string& font, float fontSize,
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
TextVAlignment vAlignment = TextVAlignment::TOP);

View File

@ -370,7 +370,18 @@ Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,c
}
}
}
sprite->setAdditionalTransform(&nodedata->transform);
// set locale transform
Vec3 pos;
Quaternion qua;
Vec3 scale;
nodedata->transform.decompose(&scale, &qua, &pos);
sprite->setPosition3D(pos);
sprite->setRotationQuat(qua);
sprite->setScaleX(scale.x);
sprite->setScaleY(scale.y);
sprite->setScaleZ(scale.z);
sprite->addMesh(mesh);
sprite->autorelease();
sprite->genGLProgramState();
@ -527,7 +538,18 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m
if(node)
{
node->setName(nodedata->id);
node->setAdditionalTransform(&nodedata->transform);
// set locale transform
Vec3 pos;
Quaternion qua;
Vec3 scale;
nodedata->transform.decompose(&scale, &qua, &pos);
node->setPosition3D(pos);
node->setRotationQuat(qua);
node->setScaleX(scale.x);
node->setScaleY(scale.y);
node->setScaleZ(scale.z);
if(root)
{
root->addChild(node);
@ -687,15 +709,19 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
color.a = getDisplayedOpacity() / 255.0f;
//check light and determine the shader used
const auto& lights = Director::getInstance()->getRunningScene()->getLights();
bool usingLight = false;
for (const auto light : lights) {
usingLight = ((unsigned int)light->getLightFlag() & _lightMask) > 0;
if (usingLight)
break;
const auto& scene = Director::getInstance()->getRunningScene();
if (scene)
{
const auto& lights = scene->getLights();
bool usingLight = false;
for (const auto light : lights) {
usingLight = ((unsigned int)light->getLightFlag() & _lightMask) > 0;
if (usingLight)
break;
}
if (usingLight != _shaderUsingLight)
genGLProgramState(usingLight);
}
if (usingLight != _shaderUsingLight)
genGLProgramState(usingLight);
int i = 0;
for (auto& mesh : _meshes) {

View File

@ -41,7 +41,7 @@ class CC_DLL AutoreleasePool
{
public:
/**
* @warn Don't create an auto release pool in heap, create it in stack.
* @warn Don't create an autorelease pool in heap, create it in stack.
* @js NA
* @lua NA
*/
@ -49,6 +49,11 @@ public:
/**
* Create an autorelease pool with specific name. This name is useful for debugging.
* @warn Don't create an autorelease pool in heap, create it in stack.
* @js NA
* @lua NA
*
* @param name The name of created autorelease pool.
*/
AutoreleasePool(const std::string &name);
@ -59,13 +64,13 @@ public:
~AutoreleasePool();
/**
* Add a given object to this pool.
* Add a given object to this autorelease pool.
*
* The same object may be added several times to the same pool; When the
* pool is destructed, the object's Ref::release() method will be called
* for each time it was added.
* The same object may be added several times to an autorelease pool. When the
* pool is destructed, the object's `Ref::release()` method will be called
* the same times as it was added.
*
* @param object The object to add to the pool.
* @param object The object to be added into the autorelease pool.
* @js NA
* @lua NA
*/
@ -74,8 +79,8 @@ public:
/**
* Clear the autorelease pool.
*
* Ref::release() will be called for each time the managed object is
* added to the pool.
* It will invoke each element's `release()` function.
*
* @js NA
* @lua NA
*/
@ -83,22 +88,34 @@ public:
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
/**
* Whether the pool is doing `clear` operation.
* Whether the autorelease pool is doing `clear` operation.
*
* @return True if autorelase pool is clearning, false if not.
*
* @js NA
* @lua NA
*/
bool isClearing() const { return _isClearing; };
#endif
/**
* Checks whether the pool contains the specified object.
* Checks whether the autorelease pool contains the specified object.
*
* @param object The object to be checked.
* @return True if the autorelease pool contains the object, false if not
* @js NA
* @lua NA
*/
bool contains(Ref* object) const;
/**
* Dump the objects that are put into autorelease pool. It is used for debugging.
* Dump the objects that are put into the autorelease pool. It is used for debugging.
*
* The result will look like:
* Object pointer address object id reference count
*
* @js NA
* @lua NA
*/
void dump();
@ -125,21 +142,15 @@ private:
/*
* @js NA
* @cond
*/
class CC_DLL PoolManager
{
public:
/**
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE static PoolManager* sharedPoolManager() { return getInstance(); }
static PoolManager* getInstance();
/**
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE static void purgePoolManager() { destroyInstance(); }
static void destroyInstance();
@ -151,10 +162,7 @@ public:
bool isObjectInPools(Ref* obj) const;
/**
* @js NA
* @lua NA
*/
friend class AutoreleasePool;
private:
@ -168,6 +176,9 @@ private:
std::vector<AutoreleasePool*> _releasePoolStack;
};
/**
* @endcond
*/
// end of base_nodes group
/// @}

View File

@ -35,29 +35,57 @@ NS_CC_BEGIN
/*
* @js NA
* @lua NA
*/
class CC_DLL Data
{
public:
/**
* This parameter is defined for convenient reference if a null Data object is needed.
*/
static const Data Null;
/**
* Constructor of Data.
*/
Data();
/**
* Copy constructor of Data.
*/
Data(const Data& other);
/**
* Copy constructor of Data.
*/
Data(Data&& other);
/**
* Destructor of Data.
*/
~Data();
// Assignment operator
/**
* Overroads of operator=.
*/
Data& operator= (const Data& other);
/**
* Overroads of operator=.
*/
Data& operator= (Data&& other);
/**
* @js NA
* @lua NA
* Gets internal bytes of Data. It will retrun the pointer directly used in Data, so don't delete it.
*
* @return Pointer of bytes used internal in Data.
*/
unsigned char* getBytes() const;
/**
* @js NA
* @lua NA
* Gets the size of the bytes.
*
* @return The size of bytes of Data.
*/
ssize_t getSize() const;
@ -77,10 +105,16 @@ public:
*/
void fastSet(unsigned char* bytes, const ssize_t size);
/** Clears data, free buffer and reset data size */
/**
* Clears data, free buffer and reset data size.
*/
void clear();
/** Check whether the data is null. */
/**
* Check whether the data is null.
*
* @return True if the the Data is null, false if not.
*/
bool isNull() const;
private:

View File

@ -41,8 +41,7 @@ class __Dictionary;
class __Set;
/**
* @addtogroup data_structures
* @{
* @cond
*/
/**
@ -106,8 +105,9 @@ private:
std::string _result;
};
// end of data_structure group
/// @}
/**
* @endcond
*/
NS_CC_END

View File

@ -248,8 +248,6 @@ void Director::setGLDefaultValues()
CCASSERT(_openGLView, "opengl view should not be null");
setAlphaBlending(true);
// FIXME: Fix me, should enable/disable depth test according the depth format as cocos2d-iphone did
// [self setDepthTest: view_.depthFormat];
setDepthTest(false);
setProjection(_projection);
}

View File

@ -40,20 +40,25 @@ NS_CC_BEGIN
class Ref;
/** Interface that defines how to clone an Ref */
/**
* Interface that defines how to clone an Ref.
* @lua NA
* @js NA
*/
class CC_DLL Clonable
{
public:
/** returns a copy of the Ref */
/** Returns a copy of the Ref. */
virtual Clonable* clone() const = 0;
/**
* @js NA
* @lua NA
*/
virtual ~Clonable() {};
/** returns a copy of the Ref.
* @deprecated Use clone() instead
/** Returns a copy of the Ref.
* @deprecated Use clone() instead.
*/
CC_DEPRECATED_ATTRIBUTE Ref* copy() const
{
@ -63,6 +68,10 @@ public:
}
};
/**
* Ref is used for reference count manangement. If a class inherits from Ref,
* then it is easy to be shared in different places.
*/
class CC_DLL Ref
{
public:
@ -125,6 +134,8 @@ protected:
public:
/**
* Destructor
*
* @js NA
* @lua NA
*/

View File

@ -46,11 +46,10 @@ NS_CC_BEGIN
class Scheduler;
typedef std::function<void(float)> ccSchedulerFunc;
//
// Timer
//
/** @brief Light-weight timer */
//
/**
* @cond
*/
class CC_DLL Timer : public Ref
{
protected:
@ -106,13 +105,9 @@ class CC_DLL TimerTargetCallback : public Timer
public:
TimerTargetCallback();
/** Initializes a timer with a target, a lambda and an interval in seconds, repeat in number of times to repeat, delay in seconds. */
// Initializes a timer with a target, a lambda and an interval in seconds, repeat in number of times to repeat, delay in seconds.
bool initWithCallback(Scheduler* scheduler, const ccSchedulerFunc& callback, void *target, const std::string& key, float seconds, unsigned int repeat, float delay);
/**
* @js NA
* @lua NA
*/
inline const ccSchedulerFunc& getCallback() const { return _callback; };
inline const std::string& getKey() const { return _key; };
@ -142,9 +137,11 @@ private:
#endif
//
// Scheduler
//
/**
* @endcond
*/
struct _listEntry;
struct _hashSelectorEntry;
struct _hashUpdateEntry;
@ -167,21 +164,39 @@ The 'custom selectors' should be avoided when possible. It is faster, and consum
class CC_DLL Scheduler : public Ref
{
public:
// Priority level reserved for system services.
/** Priority level reserved for system services.
* @lua NA
* @js NA
*/
static const int PRIORITY_SYSTEM;
// Minimum priority level for user scheduling.
/** Minimum priority level for user scheduling.
* Priority level of user scheduling should bigger then this value.
*
* @lua NA
* @js NA
*/
static const int PRIORITY_NON_SYSTEM_MIN;
/**
* Constructor
*
* @js ctor
*/
Scheduler();
/**
* Destructor
*
* @js NA
* @lua NA
*/
virtual ~Scheduler();
/**
* Gets the time scale of schedule callbacks.
* @see Scheduler::setTimeScale()
*/
inline float getTimeScale() { return _timeScale; }
/** Modifies the time of all scheduled callbacks.
You can use this property to create a 'slow motion' or 'fast forward' effect.
@ -193,7 +208,7 @@ public:
inline void setTimeScale(float timeScale) { _timeScale = timeScale; }
/** 'update' the scheduler.
You should NEVER call this method, unless you know what you are doing.
* You should NEVER call this method, unless you know what you are doing.
* @js NA
* @lua NA
*/
@ -208,30 +223,54 @@ public:
If 'interval' is 0, it will be called every frame, but if so, it's recommended to use 'scheduleUpdate' instead.
If the 'callback' is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
repeat let the action be repeated repeat + 1 times, use CC_REPEAT_FOREVER to let the action run continuously
delay is the amount of time the action will wait before it'll start
@param key The key to identify the callback
delay is the amount of time the action will wait before it'll start.
@param callback The callback function.
@param target The target of the callback function.
@param interval The interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
@param repeat repeat+1 times to schedule the callback.
@param delay Schedule call back after `delay` seconds. If the value is not 0, the first schedule will happen after `delay` seconds.
But it will only affect first schedule. After first schedule, the delay time is determined by `interval`.
@param paused Whether or not to pause the schedule.
@param key The key to identify the callback function, because there is not way to identify a std::function<>.
@since v3.0
*/
void schedule(const ccSchedulerFunc& callback, void *target, float interval, unsigned int repeat, float delay, bool paused, const std::string& key);
/** Calls scheduleCallback with CC_REPEAT_FOREVER and a 0 delay
/** The scheduled method will be called every 'interval' seconds for ever.
@param callback The callback function.
@param target The target of the callback function.
@param interval The interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
@param paused Whether or not to pause the schedule.
@param key The key to identify the callback function, because there is not way to identify a std::function<>.
@since v3.0
*/
void schedule(const ccSchedulerFunc& callback, void *target, float interval, bool paused, const std::string& key);
/** The scheduled method will be called every 'interval' seconds.
/** The scheduled method will be called every `interval` seconds.
If paused is true, then it won't be called until it is resumed.
If 'interval' is 0, it will be called every frame, but if so, it's recommended to use 'scheduleUpdate' instead.
If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
repeat let the action be repeated repeat + 1 times, use CC_REPEAT_FOREVER to let the action run continuously
delay is the amount of time the action will wait before it'll start
@since v3.0, repeat and delay added in v1.1
@param selector The callback function.
@param target The target of the callback function.
@param interval The interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
@param repeat repeat+1 times to schedule the callback.
@param delay Schedule call back after `delay` seconds. If the value is not 0, the first schedule will happen after `delay` seconds.
But it will only affect first schedule. After first schedule, the delay time is determined by `interval`.
@param paused Whether or not to pause the schedule.
@since v3.0
*/
void schedule(SEL_SCHEDULE selector, Ref *target, float interval, unsigned int repeat, float delay, bool paused);
/** calls scheduleSelector with CC_REPEAT_FOREVER and a 0 delay */
/** The scheduled method will be called every `interval` seconds for ever.
@param selector The callback function.
@param target The target of the callback function.
@param interval The interval to schedule the callback. If the value is 0, then the callback will be scheduled every frame.
@param paused Whether or not to pause the schedule.
*/
void schedule(SEL_SCHEDULE selector, Ref *target, float interval, bool paused);
/** Schedules the 'update' selector for a given target with a given priority.
@ -249,11 +288,15 @@ public:
}
#if CC_ENABLE_SCRIPT_BINDING
// schedule for script bindings
// Schedule for script bindings.
/** The scheduled script callback will be called every 'interval' seconds.
If paused is true, then it won't be called until it is resumed.
If 'interval' is 0, it will be called every frame.
return schedule script entry ID, used for unscheduleScriptFunc().
@warn Don't invoke this function unless you know what you are doing.
@js NA
@lua NA
*/
unsigned int scheduleScriptFunc(unsigned int handler, float interval, bool paused);
#endif
@ -263,23 +306,29 @@ public:
/** Unschedules a callback for a key and a given target.
If you want to unschedule the 'callbackPerFrame', use unscheduleUpdate.
@param key The key to identify the callback function, because there is not way to identify a std::function<>.
@param target The target to be unscheduled.
@since v3.0
*/
void unschedule(const std::string& key, void *target);
/** Unschedule a selector for a given target.
If you want to unschedule the "update", use unscheudleUpdate.
/** Unschedules a selector for a given target.
If you want to unschedule the "update", use `unscheudleUpdate()`.
@param selector The selector that is unscheduled.
@param target The target of the unscheduled selector.
@since v3.0
*/
void unschedule(SEL_SCHEDULE selector, Ref *target);
/** Unschedules the update selector for a given target
@param target The target to be unscheduled.
@since v0.99.3
*/
void unscheduleUpdate(void *target);
/** Unschedules all selectors for a given target.
This also includes the "update" selector.
@param target The target to be unscheduled.
@since v0.99.3
@js unscheduleCallbackForTarget
@lua NA
@ -290,16 +339,22 @@ public:
You should NEVER call this method, unless you know what you are doing.
@since v0.99.3
*/
void unscheduleAll(void);
void unscheduleAll();
/** Unschedules all selectors from all targets with a minimum priority.
You should only call this with kPriorityNonSystemMin or higher.
You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher.
@param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which
priority is higher than minPriority will be unscheduled.
@since v2.0.0
*/
void unscheduleAllWithMinPriority(int minPriority);
#if CC_ENABLE_SCRIPT_BINDING
/** Unschedule a script entry. */
/** Unschedule a script entry.
* @warn Don't invoke this function unless you know what you are doing.
* @js NA
* @lua NA
*/
void unscheduleScriptEntry(unsigned int scheduleScriptEntryID);
#endif
@ -308,11 +363,17 @@ public:
// isScheduled
/** Checks whether a callback associated with 'key' and 'target' is scheduled.
@param key The key to identify the callback function, because there is not way to identify a std::function<>.
@param target The target of the callback.
@return True if the specified callback is invoked, false if not.
@since v3.0.0
*/
bool isScheduled(const std::string& key, void *target);
/** Checks whether a selector for a given taget is scheduled.
@param selector The selector to be checked.
@param target The target of the callback.
@return True if the specified selector is invoked, false if not.
@since v3.0
*/
bool isScheduled(SEL_SCHEDULE selector, Ref *target);
@ -322,6 +383,7 @@ public:
/** Pauses the target.
All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
If the target is not present, nothing happens.
@param target The target to be paused.
@since v0.99.3
*/
void pauseTarget(void *target);
@ -329,15 +391,18 @@ public:
/** Resumes the target.
The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
If the target is not present, nothing happens.
@param target The target to be resumed.
@since v0.99.3
*/
void resumeTarget(void *target);
/** Returns whether or not the target is paused
@since v1.0.0
* In js: var isTargetPaused(var jsObject)
* @lua NA
*/
/** Returns whether or not the target is paused.
* @param target The target to be checked.
* @return True if the target is paused, false if not.
* @since v1.0.0
* @js isTargetPaused(var jsObject)
* @lua NA
*/
bool isTargetPaused(void *target);
/** Pause all selectors from all targets.
@ -347,19 +412,23 @@ public:
std::set<void*> pauseAllTargets();
/** Pause all selectors from all targets with a minimum priority.
You should only call this with kPriorityNonSystemMin or higher.
You should only call this with PRIORITY_NON_SYSTEM_MIN or higher.
@param minPriority The minimum priority of selector to be paused. Which means, all selectors which
priority is higher than minPriority will be paused.
@since v2.0.0
*/
std::set<void*> pauseAllTargetsWithMinPriority(int minPriority);
/** Resume selectors on a set of targets.
This can be useful for undoing a call to pauseAllSelectors.
@param targetsToResume The set of targets to be resumed.
@since v2.0.0
*/
void resumeTargets(const std::set<void*>& targetsToResume);
/** calls a function on the cocos2d thread. Useful when you need to call a cocos2d function from another thread.
/** Calls a function on the cocos2d thread. Useful when you need to call a cocos2d function from another thread.
This function is thread safe.
@param function The function to be run in cocos2d thread.
@since v3.0
*/
void performFunctionInCocosThread( const std::function<void()> &function);
@ -374,7 +443,7 @@ public:
If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
repeat let the action be repeated repeat + 1 times, use CC_REPEAT_FOREVER to let the action run continuously
delay is the amount of time the action will wait before it'll start
@deprecated Please use 'Scheduler::schedule' instead.
@deprecated Please use `Scheduler::schedule` instead.
@since v0.99.3, repeat and delay added in v1.1
*/
CC_DEPRECATED_ATTRIBUTE void scheduleSelector(SEL_SCHEDULE selector, Ref *target, float interval, unsigned int repeat, float delay, bool paused)
@ -382,8 +451,8 @@ public:
schedule(selector, target, interval, repeat, delay, paused);
};
/** calls scheduleSelector with CC_REPEAT_FOREVER and a 0 delay
* @deprecated Please use 'Scheduler::schedule' instead.
/** Calls scheduleSelector with CC_REPEAT_FOREVER and a 0 delay.
* @deprecated Please use `Scheduler::schedule` instead.
*/
CC_DEPRECATED_ATTRIBUTE void scheduleSelector(SEL_SCHEDULE selector, Ref *target, float interval, bool paused)
{

View File

@ -31,7 +31,7 @@ NS_CC_BEGIN
CC_DLL const char* cocos2dVersion()
{
return "cocos2d-x 3.5rc0";
return "cocos2d-x 3.5";
}
NS_CC_END

View File

@ -1276,7 +1276,10 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod
readername.append("Reader");
NodeReaderProtocol* reader = dynamic_cast<NodeReaderProtocol*>(ObjectFactory::getInstance()->createObject(readername));
node = reader->createNodeWithFlatBuffers(options->data());
if (reader)
{
node = reader->createNodeWithFlatBuffers(options->data());
}
Widget* widget = dynamic_cast<Widget*>(node);
if (widget)

View File

@ -67,7 +67,8 @@ enum class LanguageType
POLISH,
TURKISH,
UKRAINIAN,
ROMANIAN
ROMANIAN,
BULGARIAN
};
// END of platform group

View File

@ -188,6 +188,10 @@ LanguageType Application::getCurrentLanguage()
{
ret = LanguageType::ROMANIAN;
}
else if (0 == strcmp("bg", pLanguageName))
{
ret = LanguageType::BULGARIAN;
}
return ret;
}

View File

@ -161,6 +161,9 @@ LanguageType Application::getCurrentLanguage()
else if ([languageCode isEqualToString:@"ro"]){
ret = LanguageType::ROMANIAN;
}
else if ([languageCode isEqualToString:@"bg"]){
ret = LanguageType::BULGARIAN;
}
return ret;
}

View File

@ -257,6 +257,10 @@ LanguageType Application::getCurrentLanguage()
{
ret = LanguageType::ROMANIAN;
}
else if (0 == strcmp("bg", pLanguageName))
{
ret = LanguageType::BULGARIAN;
}
return ret;
}

View File

@ -215,6 +215,9 @@ LanguageType Application::getCurrentLanguage()
else if ([languageCode isEqualToString:@"ro"]){
ret = LanguageType::ROMANIAN;
}
else if ([languageCode isEqualToString:@"bg"]){
ret = LanguageType::BULGARIAN;
}
return ret;
}

View File

@ -194,6 +194,9 @@ LanguageType Application::getCurrentLanguage()
case LANG_ROMANIAN:
ret = LanguageType::ROMANIAN;
break;
case LANG_BULGARIAN:
ret = LanguageType::BULGARIAN;
break;
}
return ret;

View File

@ -205,6 +205,10 @@ LanguageType Application::getCurrentLanguage()
{
ret = LanguageType::ROMANIAN;
}
else if (strncmp(code, "bg", 2) == 0)
{
ret = LanguageType::BULGARIAN;
}
return ret;
}

View File

@ -297,7 +297,8 @@ void MeshCommand::batchDraw()
_glProgramState->applyGLProgram(_mv);
_glProgramState->applyUniforms();
if (Director::getInstance()->getRunningScene()->getLights().size() > 0)
const auto& scene = Director::getInstance()->getRunningScene();
if (scene && scene->getLights().size() > 0)
setLightUniforms();
// Draw
@ -339,7 +340,8 @@ void MeshCommand::execute()
_glProgramState->apply(_mv);
if (Director::getInstance()->getRunningScene()->getLights().size() > 0)
const auto& scene = Director::getInstance()->getRunningScene();
if (scene && scene->getLights().size() > 0)
setLightUniforms();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer);

View File

@ -30,41 +30,68 @@
NS_CC_BEGIN
/** Command used to render one or more Quads */
/**
Command used to render one or more Quads, similar to TrianglesCommand.
Every QuadCommand will have generate material ID by give textureID, glProgramState, Blend function
if the material id is the same, these QuadCommands could be batched to save draw call.
*/
class CC_DLL QuadCommand : public RenderCommand
{
public:
/**Constructor.*/
QuadCommand();
/**Destructor.*/
~QuadCommand();
/** Initializes the command with a globalZOrder, a texture ID, a `GLProgram`, a blending function, a pointer to quads,
* quantity of quads, and the Model View transform to be used for the quads */
/** Initializes the command.
@param globalOrder GlobalZOrder of the command.
@param textureID The openGL handle of the used texture.
@param glProgramState The specified glProgram and its uniform.
@param blendType Blend function for the command.
@param quads Rendered quads for the command.
@param quadCount The number of quads when rendering.
@param mv ModelView matrix for the command.
@param flags to indicate that the command is using 3D rendering or not.
*/
void init(float globalOrder, GLuint textureID, GLProgramState* shader, const BlendFunc& blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount,
const Mat4& mv, uint32_t flags);
/**Deprecated function, the params is similar as the upper init function, with flags equals 0.*/
CC_DEPRECATED_ATTRIBUTE void init(float globalOrder, GLuint textureID, GLProgramState* shader, const BlendFunc& blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount,
const Mat4& mv);
/**Apply the texture, shaders, programs, blend functions to GPU pipeline.*/
void useMaterial() const;
/**Get the material id of command.*/
inline uint32_t getMaterialID() const { return _materialID; }
/**Get the openGL texture handle.*/
inline GLuint getTextureID() const { return _textureID; }
/**Get the pointer of the rendered quads.*/
inline V3F_C4B_T2F_Quad* getQuads() const { return _quads; }
/**Get the number of quads for rendering.*/
inline ssize_t getQuadCount() const { return _quadsCount; }
/**Get the glprogramstate.*/
inline GLProgramState* getGLProgramState() const { return _glProgramState; }
/**Get the blend function.*/
inline BlendFunc getBlendType() const { return _blendType; }
/**Get the model view matrix.*/
inline const Mat4& getModelView() const { return _mv; }
protected:
/**Generate the material ID by textureID, glProgramState, and blend function.*/
void generateMaterialID();
/**Generated material id.*/
uint32_t _materialID;
/**OpenGL handle for texture.*/
GLuint _textureID;
/**GLprogramstate for the commmand. encapsulate shaders and uniforms.*/
GLProgramState* _glProgramState;
/**Blend function when rendering the triangles.*/
BlendFunc _blendType;
/**The pointer to the rendered quads.*/
V3F_C4B_T2F_Quad* _quads;
/**The number of quads for rendering.*/
ssize_t _quadsCount;
/**Model view matrix when rendering the triangles.*/
Mat4 _mv;
};

View File

@ -29,47 +29,81 @@
#include "renderer/CCGLProgramState.h"
NS_CC_BEGIN
/**
Command used to render one or more Triangles, which is similar to QuadCommand.
Every TrianglesCommand will have generate material ID by give textureID, glProgramState, Blend function
if the material id is the same, these TrianglesCommands could be batched to save draw call.
*/
class CC_DLL TrianglesCommand : public RenderCommand
{
public:
/**The structure of Triangles. */
struct Triangles
{
/**Vertex data pointer.*/
V3F_C4B_T2F* verts;
/**Index data pointer.*/
unsigned short* indices;
/**The number of vertices.*/
ssize_t vertCount;
/**The number of indices.*/
ssize_t indexCount;
};
/**Construtor.*/
TrianglesCommand();
/**Destructor.*/
~TrianglesCommand();
/** Initializes the command with a globalZOrder, a texture ID, a `GLProgram`, a blending function, a pointer to triangles,
* quantity of quads, and the Model View transform to be used for the quads */
/** Initializes the command.
@param globalOrder GlobalZOrder of the command.
@param textureID The openGL handle of the used texture.
@param glProgramState The specified glProgram and its uniform.
@param blendType Blend function for the command.
@param triangles Rendered triangles for the command.
@param mv ModelView matrix for the command.
@param flags to indicate that the command is using 3D rendering or not.
*/
void init(float globalOrder, GLuint textureID, GLProgramState* glProgramState, BlendFunc blendType, const Triangles& triangles,const Mat4& mv, uint32_t flags);
/**Deprecated function, the params is similar as the upper init function, with flags equals 0.*/
CC_DEPRECATED_ATTRIBUTE void init(float globalOrder, GLuint textureID, GLProgramState* glProgramState, BlendFunc blendType, const Triangles& triangles,const Mat4& mv);
/**Apply the texture, shaders, programs, blend functions to GPU pipeline.*/
void useMaterial() const;
/**Get the material id of command.*/
inline uint32_t getMaterialID() const { return _materialID; }
/**Get the openGL texture handle.*/
inline GLuint getTextureID() const { return _textureID; }
/**Get a const reference of triangles.*/
inline const Triangles& getTriangles() const { return _triangles; }
/**Get the vertex count in the triangles.*/
inline ssize_t getVertexCount() const { return _triangles.vertCount; }
/**Get the index count of the triangles.*/
inline ssize_t getIndexCount() const { return _triangles.indexCount; }
/**Get the vertex data pointer.*/
inline const V3F_C4B_T2F* getVertices() const { return _triangles.verts; }
/**Get the index data pointer.*/
inline const unsigned short* getIndices() const { return _triangles.indices; }
/**Get the glprogramstate.*/
inline GLProgramState* getGLProgramState() const { return _glProgramState; }
/**Get the blend function.*/
inline BlendFunc getBlendType() const { return _blendType; }
/**Get the model view matrix.*/
inline const Mat4& getModelView() const { return _mv; }
protected:
/**Generate the material ID by textureID, glProgramState, and blend function.*/
void generateMaterialID();
/**Generated material id.*/
uint32_t _materialID;
/**OpenGL handle for texture.*/
GLuint _textureID;
/**GLprogramstate for the commmand. encapsulate shaders and uniforms.*/
GLProgramState* _glProgramState;
/**Blend function when rendering the triangles.*/
BlendFunc _blendType;
/**Rendered triangles.*/
Triangles _triangles;
/**Model view matrix when rendering the triangles.*/
Mat4 _mv;
};

View File

@ -33,85 +33,218 @@ NS_CC_BEGIN
class EventListenerCustom;
/**
VertexBuffer is an abstraction of low level openGL Vertex Buffer Object.
It is used to save an array of vertices.
*/
class CC_DLL VertexBuffer : public Ref
{
public:
/**
Create an instance of VertexBuffer.
@param sizePerVertex Size in bytes of one vertex.
@param vertexNumber The number of vertex.
@param usage A hint to indicate whether the vertexBuffer are updated frequently or not to let GL optimise it.
*/
static VertexBuffer* create(int sizePerVertex, int vertexNumber, GLenum usage = GL_STATIC_DRAW);
/**Get the size in bytes of one vertex.*/
int getSizePerVertex() const;
/**Get the number of vertices.*/
int getVertexNumber() const;
/**
Update all or part of vertice data, if the range specified exceeds the vertex buffer, it will be clipped.
@param verts The pointer of the vertex data.
@param count The number of vertices to update.
@param begin The first vertex to update.
*/
bool updateVertices(const void* verts, int count, int begin);
/**
Get the size of the vertex array in bytes, equals getSizePerVertex() * getVertexNumber().
*/
int getSize() const;
/**
Get the internal openGL handle.
*/
GLuint getVBO() const;
protected:
/**
Constructor.
*/
VertexBuffer();
/**
Destructor.
*/
virtual ~VertexBuffer();
/**
Init the storage of vertex buffer.
@param sizePerVertex Size in bytes of one vertex.
@param vertexNumber The number of vertex.
@param usage A hint to indicate whether the vertexBuffer are updated frequently or not to let GL optimise it.
*/
bool init(int sizePerVertex, int vertexNumber, GLenum usage = GL_STATIC_DRAW);
protected:
//event listener for foreground
/**
Event handler for foreground.
*/
void recreateVBO() const;
/**
Event listener for foreground.
*/
EventListenerCustom* _recreateVBOEventListener;
protected:
/**
Internal handle for openGL.
*/
mutable GLuint _vbo;
/**
Size in bytes for one vertex.
*/
int _sizePerVertex;
/**
Number of vertices.
*/
int _vertexNumber;
//buffer used for shadow copy
/**
Buffer used for shadow copy.
*/
std::vector<unsigned char> _shadowCopy;
/**
Hint for optimisation in GL.
*/
GLenum _usage;
protected:
/**
Static member to indicate that use _shadowCopy or not.
*/
static bool _enableShadowCopy;
public:
/**
Static getter for shadowCopy.
*/
static bool isShadowCopyEnabled() { return _enableShadowCopy; }
/**
Static setter for shadowCopy.
*/
static void enableShadowCopy(bool enabled) { _enableShadowCopy = enabled; }
};
/**
IndexBuffer is an abstraction of low level openGL Buffer Object.
It used to save an array of indices.
*/
class CC_DLL IndexBuffer : public Ref
{
public:
/**
Enum for the type of index, short indices and int indices could be used.
*/
enum class IndexType
{
/**Short index will be used.*/
INDEX_TYPE_SHORT_16,
/**Int index will be used.*/
INDEX_TYPE_UINT_32
};
public:
/**
Create an instance of IndexBuffer.
@param type type of index.
@param number The number of indices.
@param usage A hint to indicate whether the vertexBuffer are updated frequently or not to let GL optimise it.
*/
static IndexBuffer* create(IndexType type, int number, GLenum usage = GL_STATIC_DRAW);
/**
Getter for type of indices.
*/
IndexType getType() const;
/**
Get the size in bytes for one index, will be 2 for INDEX_TYPE_SHORT_16 and 4 for INDEX_TYPE_UINT_32.
*/
int getSizePerIndex() const;
/**
Get the number of indices.
*/
int getIndexNumber() const;
/**
Update all or part of indices data, if the range specified exceeds the vertex buffer, it will be clipped.
@param indices The pointer of the index data.
@param count The number of indices to update.
@param begin The start index to update.
*/
bool updateIndices(const void* indices, int count, int begin);
/**
Get the size in bytes of the array of indices.
*/
int getSize() const;
/**
Get the openGL handle for index buffer.
*/
GLuint getVBO() const;
protected:
/**
Constructor.
*/
IndexBuffer();
/**
Destructor.
*/
virtual ~IndexBuffer();
/**
Init the storageof IndexBuffer.
@param type type of index.
@param number The number of indices.
@param usage A hint to indicate whether the vertexBuffer are updated frequently or not to let GL optimise it.
*/
bool init(IndexType type, int number, GLenum usage = GL_STATIC_DRAW);
protected:
/**
Handle for openGL.
*/
mutable GLuint _vbo;
/**
Type for index.
*/
IndexType _type;
/**
Number of indices.
*/
int _indexNumber;
protected:
//event listener for foreground
/**
Event handler for foreground.
*/
void recreateVBO() const;
/**
Event listener for foreground.
*/
EventListenerCustom* _recreateVBOEventListener;
//buffer used for shadow copy
/**
Buffer used for shadow copy.
*/
std::vector<unsigned char> _shadowCopy;
/**
Hint for optimisation in GL.
*/
GLenum _usage;
protected:
/**
Static member to indicate that use _shadowCopy or not.
*/
static bool _enableShadowCopy;
public:
/**
Static getter for shadowCopy.
*/
static bool isShadowCopyEnabled() { return _enableShadowCopy; }
/**
Static setter for shadowCopy.
*/
static void enableShadowCopy(bool enabled) { _enableShadowCopy = enabled; }
};

View File

@ -31,55 +31,144 @@
NS_CC_BEGIN
class VertexBuffer;
/**
VertexStreamAttribute is used to specify the vertex attribute for drawing, which is correspondent to
glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr).
_semantic -> index
_size -> size
_type -> type
_normalize -> normalized
_offset is used to compute the start offset in a interleaved array, take a V3F_C4B_T2F array,
offset of vertex will be 0, offset of color would be 0 + sizeof(float) * 3 = 12,
offset of texture coord would be 12 + sizeof(char) * 4 = 16.
*/
struct CC_DLL VertexStreamAttribute
{
/**
Constructor.
*/
VertexStreamAttribute()
: _normalize(false),_offset(0),_semantic(0),_type(0),_size(0)
{
}
/**
Constructor
@param offset The offset of the attribute.
@param semantic The semantic (Position, Texcoord, Color etc) of attribute.
@param type The type of attribute, could be GL_FLOAT, GL_UNSIGNED_BYTE etc.
@param size Describe how many elements of type in the attribute.
*/
VertexStreamAttribute(int offset, int semantic, int type, int size)
: _normalize(false),_offset(offset),_semantic(semantic),_type(type),_size(size)
{
}
/**
Constructor
@param offset The offset of the attribute.
@param semantic The semantic (Position, Texcoord, Color etc) of attribute.
@param type The type of attribute, could be GL_FLOAT, GL_UNSIGNED_BYTE etc.
@param size Describe how many elements of type in the attribute.
@param normalize If true, the data will be normalized by deviding 255.
*/
VertexStreamAttribute(int offset, int semantic, int type, int size, bool normalize)
: _normalize(normalize),_offset(offset),_semantic(semantic),_type(type),_size(size)
{
}
/**
Whether the attribute should be normalized or not.
*/
bool _normalize;
/**
The offset of the attribute in the buffer.
*/
int _offset;
/**
Describe that the attribute usage, could be Position, Color etc.
*/
int _semantic;
/**
Describe the type of attribute, could be GL_FLOAT, GL_UNSIGNED_BYTE etc.
*/
int _type;
/**
Describe how many elements of type in the attribute.
*/
int _size;
};
/**
VertexData is a class used for specify input streams for GPU rendering pipeline,
a VertexData will be composed by several streams, every stream will contain a VertexStreamAttribute
and the binding VertexBuffer. Streams will be identified by semantic.
*/
class CC_DLL VertexData : public Ref
{
public:
/**
Create function, used to create a instance of VertexData.
*/
static VertexData* create();
/**
Get the number of streams in the VertexData.
*/
size_t getVertexStreamCount() const;
/**
Set a stream to VertexData,given that stream is identified by semantic, so if the semantic is not
specified before, it will add a stream, or it will override the old one.
@param buffer The binding buffer of the stream.
@param stream The binding vertex attribute, its member semantic will be used as the identifier.
*/
bool setStream(VertexBuffer* buffer, const VertexStreamAttribute& stream);
/**
Remove the given streams.
@param semantic The semantic of the stream.
*/
void removeStream(int semantic);
/**
Get the attribute of stream, const version.
@param semantic The semantic of the stream.
*/
const VertexStreamAttribute* getStreamAttribute(int semantic) const;
/**
Get the attribute of stream.
@param semantic The semantic of the stream.
*/
VertexStreamAttribute* getStreamAttribute(int semantic);
/**
Get the binded buffer of the stream.
@param semantic The semantic of the stream.
*/
VertexBuffer* getStreamBuffer(int semantic) const;
/**
Called for rendering, it will bind the state of vertex data to current rendering pipeline.
*/
void use();
protected:
/**
Constructor.
*/
VertexData();
/**
Destructor.
*/
virtual ~VertexData();
protected:
/**
Simple struct to bundle buffer and attribute.
*/
struct BufferAttribute
{
VertexBuffer* _buffer;
VertexStreamAttribute _stream;
};
/**
Streams in the VertexData.
*/
std::map<int, BufferAttribute> _vertexStreams;
};

View File

@ -98,6 +98,7 @@ void main(void)
// Apply spot attenuation
attenuation *= smoothstep(u_SpotLightSourceOuterAngleCos[i], u_SpotLightSourceInnerAngleCos[i], spotCurrentAngleCos);
attenuation = clamp(attenuation, 0.0, 1.0);
combinedColor.xyz += computeLighting(normal, vertexToSpotLightDirection, u_SpotLightSourceColor[i], attenuation);
}
\n#endif\n

View File

@ -98,6 +98,7 @@ void main(void)
// Apply spot attenuation
attenuation *= smoothstep(u_SpotLightSourceOuterAngleCos[i], u_SpotLightSourceInnerAngleCos[i], spotCurrentAngleCos);
attenuation = clamp(attenuation, 0.0, 1.0);
combinedColor.xyz += computeLighting(normal, vertexToSpotLightDirection, u_SpotLightSourceColor[i], attenuation);
}
\n#endif\n

View File

@ -67,6 +67,14 @@
-- @param #cc.Node stencil
-- @return ClippingNode#ClippingNode ret (return value: cc.ClippingNode)
--------------------------------
--
-- @function [parent=#ClippingNode] setCameraMask
-- @param self
-- @param #unsigned short mask
-- @param #bool applyChildren
-- @return ClippingNode#ClippingNode self (return value: cc.ClippingNode)
--------------------------------
--
-- @function [parent=#ClippingNode] visit

View File

@ -478,4 +478,12 @@
-- @param #color3b_table parentColor
-- @return Label#Label self (return value: cc.Label)
--------------------------------
--
-- @function [parent=#Label] setCameraMask
-- @param self
-- @param #unsigned short mask
-- @param #bool applyChildren
-- @return Label#Label self (return value: cc.Label)
return nil

View File

@ -51,11 +51,13 @@ void PUDoAffectorEventHandler::handle (PUParticleSystem3D* particleSystem, PUPar
auto children = system->getChildren();
for(auto iter : children)
{
technique = static_cast<PUParticleSystem3D *>(iter);
affector = technique->getAffector(_affectorName);
if (affector)
{
break;
technique = dynamic_cast<PUParticleSystem3D *>(iter);
if (technique){
affector = technique->getAffector(_affectorName);
if (affector)
{
break;
}
}
}
}

View File

@ -138,8 +138,8 @@ void PUDoEnableComponentEventHandler::handle (PUParticleSystem3D* particleSystem
if (system){
auto children = system->getChildren();
for (auto iter : children){
PUParticleSystem3D *child = static_cast<PUParticleSystem3D *>(iter);
if (child->getName() == _componentName){
PUParticleSystem3D *child = dynamic_cast<PUParticleSystem3D *>(iter);
if (child && child->getName() == _componentName){
child->setEnabled(_componentEnabled);
break;
}

View File

@ -80,7 +80,7 @@ void PUDoPlacementParticleEventHandler::handle (PUParticleSystem3D* particleSyst
auto children = parentSystem->getChildren();
for(auto iter : children)
{
PUParticleSystem3D *child = static_cast<PUParticleSystem3D *>(iter);
PUParticleSystem3D *child = dynamic_cast<PUParticleSystem3D *>(iter);
if (child){
system = child;
emitter = system->getEmitter(_forceEmitterName);