Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into Bridge

This commit is contained in:
samuele3hu 2013-09-14 19:53:08 +08:00
commit 85ca0136f0
265 changed files with 5591 additions and 1638 deletions

View File

@ -56,6 +56,10 @@ public:
@brief Get the shared Engine object,it will new one when first time be called @brief Get the shared Engine object,it will new one when first time be called
*/ */
static SimpleAudioEngine* getInstance(); static SimpleAudioEngine* getInstance();
/**
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE static SimpleAudioEngine* sharedEngine() { return SimpleAudioEngine::getInstance(); } CC_DEPRECATED_ATTRIBUTE static SimpleAudioEngine* sharedEngine() { return SimpleAudioEngine::getInstance(); }
/** /**
@ -73,47 +77,63 @@ public:
/** /**
@brief Preload background music @brief Preload background music
@param pszFilePath The path of the background music file. @param pszFilePath The path of the background music file.
* @js preloadMusic
* @lua preloadMusic
*/ */
virtual void preloadBackgroundMusic(const char* pszFilePath); virtual void preloadBackgroundMusic(const char* pszFilePath);
/** /**
@brief Play background music @brief Play background music
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo @param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
@param bLoop Whether the background music loop or not @param bLoop Whether the background music loop or not
*/ * @js playMusic
* @lua playMusic
*/
virtual void playBackgroundMusic(const char* pszFilePath, bool bLoop = false); virtual void playBackgroundMusic(const char* pszFilePath, bool bLoop = false);
/** /**
@brief Stop playing background music @brief Stop playing background music
@param bReleaseData If release the background music data or not.As default value is false @param bReleaseData If release the background music data or not.As default value is false
*/ * @js stopMusic
* @lua stopMusic
*/
virtual void stopBackgroundMusic(bool bReleaseData = false); virtual void stopBackgroundMusic(bool bReleaseData = false);
/** /**
@brief Pause playing background music @brief Pause playing background music
* @js pauseMusic
* @lua pauseMusic
*/ */
virtual void pauseBackgroundMusic(); virtual void pauseBackgroundMusic();
/** /**
@brief Resume playing background music @brief Resume playing background music
* @js resumeMusic
* @lua resumeMusic
*/ */
virtual void resumeBackgroundMusic(); virtual void resumeBackgroundMusic();
/** /**
@brief Rewind playing background music @brief Rewind playing background music
* @js rewindMusic
* @lua rewindMusic
*/ */
virtual void rewindBackgroundMusic(); virtual void rewindBackgroundMusic();
/** /**
@brief Indicates whether any background music can be played or not. @brief Indicates whether any background music can be played or not.
@return <i>true</i> if background music can be played, otherwise <i>false</i>. @return <i>true</i> if background music can be played, otherwise <i>false</i>.
* @js willPlayMusic
* @lua willPlayMusic
*/ */
virtual bool willPlayBackgroundMusic(); virtual bool willPlayBackgroundMusic();
/** /**
@brief Indicates whether the background music is playing @brief Indicates whether the background music is playing
@return <i>true</i> if the background music is playing, otherwise <i>false</i> @return <i>true</i> if the background music is playing, otherwise <i>false</i>
*/ * @js isMusicPlaying
* @lua isMusicPlaying
*/
virtual bool isBackgroundMusicPlaying(); virtual bool isBackgroundMusicPlaying();
// //
@ -121,14 +141,18 @@ public:
// //
/** /**
@brief The volume of the background music within the range of 0.0 as the minimum and 1.0 as the maximum. @brief The volume of the background music within the range of 0.0 as the minimum and 1.0 as the maximum.
*/ * @js getMusicVolume
* @lua getMusicVolume
*/
virtual float getBackgroundMusicVolume(); virtual float getBackgroundMusicVolume();
/** /**
@brief Set the volume of background music @brief Set the volume of background music
@param volume must be within the range of 0.0 as the minimum and 1.0 as the maximum. @param volume must be within the range of 0.0 as the minimum and 1.0 as the maximum.
*/ * @js setMusicVolume
* @lua setMusicVolume
*/
virtual void setBackgroundMusicVolume(float volume); virtual void setBackgroundMusicVolume(float volume);
/** /**

View File

@ -92,7 +92,7 @@ float Camera::getZEye(void)
return FLT_EPSILON; return FLT_EPSILON;
} }
void Camera::setEyeXYZ(float fEyeX, float fEyeY, float fEyeZ) void Camera::setEye(float fEyeX, float fEyeY, float fEyeZ)
{ {
_eyeX = fEyeX; _eyeX = fEyeX;
_eyeY = fEyeY; _eyeY = fEyeY;
@ -101,7 +101,7 @@ void Camera::setEyeXYZ(float fEyeX, float fEyeY, float fEyeZ)
_dirty = true; _dirty = true;
} }
void Camera::setCenterXYZ(float fCenterX, float fCenterY, float fCenterZ) void Camera::setCenter(float fCenterX, float fCenterY, float fCenterZ)
{ {
_centerX = fCenterX; _centerX = fCenterX;
_centerY = fCenterY; _centerY = fCenterY;
@ -110,7 +110,7 @@ void Camera::setCenterXYZ(float fCenterX, float fCenterY, float fCenterZ)
_dirty = true; _dirty = true;
} }
void Camera::setUpXYZ(float fUpX, float fUpY, float fUpZ) void Camera::setUp(float fUpX, float fUpY, float fUpZ)
{ {
_upX = fUpX; _upX = fUpX;
_upY = fUpY; _upY = fUpY;
@ -119,21 +119,21 @@ void Camera::setUpXYZ(float fUpX, float fUpY, float fUpZ)
_dirty = true; _dirty = true;
} }
void Camera::getEyeXYZ(float *pEyeX, float *pEyeY, float *pEyeZ) const void Camera::getEye(float *pEyeX, float *pEyeY, float *pEyeZ) const
{ {
*pEyeX = _eyeX; *pEyeX = _eyeX;
*pEyeY = _eyeY; *pEyeY = _eyeY;
*pEyeZ = _eyeZ; *pEyeZ = _eyeZ;
} }
void Camera::getCenterXYZ(float *pCenterX, float *pCenterY, float *pCenterZ) const void Camera::getCenter(float *pCenterX, float *pCenterY, float *pCenterZ) const
{ {
*pCenterX = _centerX; *pCenterX = _centerX;
*pCenterY = _centerY; *pCenterY = _centerY;
*pCenterZ = _centerZ; *pCenterZ = _centerZ;
} }
void Camera::getUpXYZ(float *pUpX, float *pUpY, float *pUpZ) const void Camera::getUp(float *pUpX, float *pUpY, float *pUpZ) const
{ {
*pUpX = _upX; *pUpX = _upX;
*pUpY = _upY; *pUpY = _upY;

View File

@ -68,12 +68,21 @@ class CC_DLL Camera : public Object
public: public:
/** returns the Z eye */ /** returns the Z eye */
static float getZEye(); static float getZEye();
/**
* @js ctor
*/
Camera(void); Camera(void);
/**
* @js NA
* @lua NA
*/
~Camera(void); ~Camera(void);
void init(void); void init(void);
/**
* @js NA
* @lua NA
*/
const char* description(void) const; const char* description(void) const;
/** sets the dirty value */ /** sets the dirty value */
@ -86,18 +95,68 @@ public:
/** Sets the camera using gluLookAt using its eye, center and up_vector */ /** Sets the camera using gluLookAt using its eye, center and up_vector */
void locate(void); void locate(void);
/** sets the eye values in points */ /** sets the eye values in points */
void setEyeXYZ(float fEyeX, float fEyeY, float fEyeZ); void setEye(float fEyeX, float fEyeY, float fEyeZ);
/**
@deprecated. Use setEye() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE void setEyeXYZ(float fEyeX, float fEyeY, float fEyeZ){ setEye(fEyeX, fEyeY, fEyeZ);}
/** sets the center values in points */ /** sets the center values in points */
void setCenterXYZ(float fCenterX, float fCenterY, float fCenterZ); void setCenter(float fCenterX, float fCenterY, float fCenterZ);
/**
@deprecated. Use setCenter() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE void setCenterXYZ(float fCenterX, float fCenterY, float fCenterZ){ setCenter(fCenterX,fCenterY,fCenterZ);}
/** sets the up values */ /** sets the up values */
void setUpXYZ(float fUpX, float fUpY, float fUpZ); void setUp(float fUpX, float fUpY, float fUpZ);
/**
@deprecated. Use setUp() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE void setUpXYZ(float fUpX, float fUpY, float fUpZ){ setUp(fUpX,fUpY,fUpZ); }
/** get the eye vector values in points */ /** get the eye vector values in points
void getEyeXYZ(float *pEyeX, float *pEyeY, float *pEyeZ) const; * @code
/** get the center vector values int points */ * when this function bound to js or lua,the input params are changed
void getCenterXYZ(float *pCenterX, float *pCenterY, float *pCenterZ) const; * in js: var getEye()
/** get the up vector values */ * in lua:local getEye()
void getUpXYZ(float *pUpX, float *pUpY, float *pUpZ) const; * @endcode
*/
void getEye(float *pEyeX, float *pEyeY, float *pEyeZ) const;
/**
@deprecated. Use getEye() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE void getEyeXYZ(float *pEyeX, float *pEyeY, float *pEyeZ) const { getEye(pEyeX, pEyeY, pEyeZ); }
/** get the center vector values int points
* when this function bound to js or lua,the input params are changed
* in js: var getCenter()
* in lua:local getCenter()
*/
void getCenter(float *pCenterX, float *pCenterY, float *pCenterZ) const;
/**
@deprecated. Use getCenter() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE void getCenterXYZ(float *pCenterX, float *pCenterY, float *pCenterZ) const{ getCenter(pCenterX,pCenterY,pCenterZ); }
/** get the up vector values
* when this function bound to js or lua,the input params are changed
* in js: var getUp()
* in lua:local getUp()
*/
void getUp(float *pUpX, float *pUpY, float *pUpZ) const;
/**
@deprecated. Use getUp() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE void getUpXYZ(float *pUpX, float *pUpY, float *pUpZ) const{ getUp(pUpX, pUpY, pUpZ); }
protected: protected:
float _eyeX; float _eyeX;

View File

@ -60,7 +60,10 @@ public:
CC_DEPRECATED_ATTRIBUTE static void purgeConfiguration(); CC_DEPRECATED_ATTRIBUTE static void purgeConfiguration();
public: public:
/**
* @js NA
* @lua NA
*/
virtual ~Configuration(); virtual ~Configuration();
/** OpenGL Max texture size. */ /** OpenGL Max texture size. */

View File

@ -104,8 +104,14 @@ public:
/** @deprecated Use getInstance() instead */ /** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Director* sharedDirector() { return Director::getInstance(); } CC_DEPRECATED_ATTRIBUTE static Director* sharedDirector() { return Director::getInstance(); }
/**
* @js ctor
*/
Director(void); Director(void);
/**
* @js NA
* @lua NA
*/
virtual ~Director(void); virtual ~Director(void);
virtual bool init(void); virtual bool init(void);
@ -127,7 +133,10 @@ public:
/** seconds per frame */ /** seconds per frame */
inline float getSecondsPerFrame() { return _secondsPerFrame; } inline float getSecondsPerFrame() { return _secondsPerFrame; }
/** Get the EGLView, where everything is rendered */ /** Get the EGLView, where everything is rendered
* @js NA
* @lua NA
*/
inline EGLView* getOpenGLView() { return _openGLView; } inline EGLView* getOpenGLView() { return _openGLView; }
void setOpenGLView(EGLView *pobOpenGLView); void setOpenGLView(EGLView *pobOpenGLView);
@ -142,6 +151,8 @@ public:
/** Sets an OpenGL projection /** Sets an OpenGL projection
@since v0.8.2 @since v0.8.2
* @js NA
* @lua NA
*/ */
inline Projection getProjection() { return _projection; } inline Projection getProjection() { return _projection; }
void setProjection(Projection projection); void setProjection(Projection projection);
@ -169,8 +180,14 @@ public:
/** Director delegate. It shall implemente the DirectorDelegate protocol /** Director delegate. It shall implemente the DirectorDelegate protocol
@since v0.99.5 @since v0.99.5
* @js NA
* @lua NA
*/ */
DirectorDelegate* getDelegate() const; DirectorDelegate* getDelegate() const;
/**
* @js NA
* @lua NA
*/
void setDelegate(DirectorDelegate* delegate); void setDelegate(DirectorDelegate* delegate);
// window size // window size
@ -250,6 +267,7 @@ public:
/** Ends the execution, releases the running scene. /** Ends the execution, releases the running scene.
It doesn't remove the OpenGL view from its parent. You have to do it manually. It doesn't remove the OpenGL view from its parent. You have to do it manually.
* @lua endToLua
*/ */
void end(); void end();
@ -336,38 +354,52 @@ public:
/** Gets the TouchDispatcher associated with this director /** Gets the TouchDispatcher associated with this director
@since v2.0 @since v2.0
* @js NA
* @lua NA
*/ */
TouchDispatcher* getTouchDispatcher() const; TouchDispatcher* getTouchDispatcher() const;
/** Sets the TouchDispatcher associated with this director /** Sets the TouchDispatcher associated with this director
@since v2.0 @since v2.0
* @js NA
* @lua NA
*/ */
void setTouchDispatcher(TouchDispatcher* touchDispatcher); void setTouchDispatcher(TouchDispatcher* touchDispatcher);
/** Gets the KeyboardDispatcher associated with this director /** Gets the KeyboardDispatcher associated with this director
@note Supported on Mac and Linux only now. @note Supported on Mac and Linux only now.
@since v3.0 @since v3.0
* @js NA
* @lua NA
*/ */
KeyboardDispatcher* getKeyboardDispatcher() const; KeyboardDispatcher* getKeyboardDispatcher() const;
/** Sets the KeyboardDispatcher associated with this director /** Sets the KeyboardDispatcher associated with this director
@note Supported on Mac and Linux only now. @note Supported on Mac and Linux only now.
@since v3.0 @since v3.0
* @js NA
* @lua NA
*/ */
void setKeyboardDispatcher(KeyboardDispatcher* keyboardDispatcher); void setKeyboardDispatcher(KeyboardDispatcher* keyboardDispatcher);
/** Gets the KeypadDispatcher associated with this director /** Gets the KeypadDispatcher associated with this director
@since v2.0 @since v2.0
* @js NA
* @lua NA
*/ */
KeypadDispatcher* getKeypadDispatcher() const; KeypadDispatcher* getKeypadDispatcher() const;
/** Sets the KeypadDispatcher associated with this director /** Sets the KeypadDispatcher associated with this director
@since v2.0 @since v2.0
* @js NA
* @lua NA
*/ */
void setKeypadDispatcher(KeypadDispatcher* keypadDispatcher); void setKeypadDispatcher(KeypadDispatcher* keypadDispatcher);
/** Gets Accelerometer associated with this director /** Gets Accelerometer associated with this director
@since v2.0 @since v2.0
*@js NA
*@lua NA
*/ */
Accelerometer* getAccelerometer() const; Accelerometer* getAccelerometer() const;

View File

@ -50,7 +50,10 @@ public:
static Timer* create(Object *target, SEL_SCHEDULE selector); static Timer* create(Object *target, SEL_SCHEDULE selector);
/** Allocates a timer with a target, a selector and an interval in seconds. */ /** Allocates a timer with a target, a selector and an interval in seconds. */
static Timer* create(Object *target, SEL_SCHEDULE selector, float seconds); static Timer* create(Object *target, SEL_SCHEDULE selector, float seconds);
/** Allocates a timer with a script callback function and an interval in seconds. */ /** Allocates a timer with a script callback function and an interval in seconds.
* @js NA
* @lua NA
*/
static Timer* createWithScriptHandler(int nHandler, float seconds); static Timer* createWithScriptHandler(int nHandler, float seconds);
CC_DEPRECATED_ATTRIBUTE static Timer* timerWithTarget(Object *target, SEL_SCHEDULE selector) { return Timer::create(target, selector); } CC_DEPRECATED_ATTRIBUTE static Timer* timerWithTarget(Object *target, SEL_SCHEDULE selector) { return Timer::create(target, selector); }
@ -70,7 +73,10 @@ public:
float getInterval() const; float getInterval() const;
/** set interval in seconds */ /** set interval in seconds */
void setInterval(float interval); void setInterval(float interval);
/**
* @js NA
* @lua NA
*/
SEL_SCHEDULE getSelector() const; SEL_SCHEDULE getSelector() const;
/** triggers the timer */ /** triggers the timer */
@ -120,8 +126,14 @@ public:
// Minimum priority level for user scheduling. // Minimum priority level for user scheduling.
static const int PRIORITY_NON_SYSTEM_MIN; static const int PRIORITY_NON_SYSTEM_MIN;
/**
* @js ctor
*/
Scheduler(); Scheduler();
/**
* @js NA
* @lua NA
*/
~Scheduler(void); ~Scheduler(void);
inline float getTimeScale(void) { return _timeScale; } inline float getTimeScale(void) { return _timeScale; }
@ -136,6 +148,8 @@ public:
/** 'update' the scheduler. /** '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
*/ */
void update(float dt); void update(float dt);
@ -220,6 +234,8 @@ public:
/** Returns whether or not the target is paused /** Returns whether or not the target is paused
@since v1.0.0 @since v1.0.0
* In js: var isTargetPaused(var jsObject)
* @lua NA
*/ */
bool isTargetPaused(Object *target); bool isTargetPaused(Object *target);

View File

@ -46,11 +46,19 @@ class CC_DLL Action : public Object, public Clonable
public: public:
/// Default tag used for all the actions /// Default tag used for all the actions
static const int INVALID_TAG = -1; static const int INVALID_TAG = -1;
/**
* @js ctor
*/
Action(void); Action(void);
/**
* @js NA
* @lua NA
*/
virtual ~Action(void); virtual ~Action(void);
/**
* @js NA
* @lua NA
*/
const char* description() const; const char* description() const;
/** returns a clone of action */ /** returns a clone of action */
@ -123,9 +131,16 @@ protected:
class CC_DLL FiniteTimeAction : public Action class CC_DLL FiniteTimeAction : public Action
{ {
public: public:
/**
* @js ctor
*/
FiniteTimeAction() FiniteTimeAction()
: _duration(0) : _duration(0)
{} {}
/**
* @js NA
* @lua NA
*/
virtual ~FiniteTimeAction(){} virtual ~FiniteTimeAction(){}
//! get duration in seconds of the action //! get duration in seconds of the action
inline float getDuration(void) const { return _duration; } inline float getDuration(void) const { return _duration; }
@ -157,8 +172,14 @@ class CC_DLL Speed : public Action
public: public:
/** create the action */ /** create the action */
static Speed* create(ActionInterval* pAction, float fSpeed); static Speed* create(ActionInterval* pAction, float fSpeed);
/**
* @js ctor
*/
Speed(); Speed();
/**
* @js NA
* @lua NA
*/
virtual ~Speed(void); virtual ~Speed(void);
inline float getSpeed(void) const { return _speed; } inline float getSpeed(void) const { return _speed; }
@ -209,7 +230,9 @@ public:
* with no boundary. * with no boundary.
*/ */
static Follow* create(Node *followedNode, const Rect& rect = Rect::ZERO); static Follow* create(Node *followedNode, const Rect& rect = Rect::ZERO);
/**
* @js ctor
*/
Follow() Follow()
: _followedNode(NULL) : _followedNode(NULL)
, _boundarySet(false) , _boundarySet(false)
@ -220,6 +243,10 @@ public:
, _bottomBoundary(0.0) , _bottomBoundary(0.0)
, _worldRect(Rect::ZERO) , _worldRect(Rect::ZERO)
{} {}
/**
* @js NA
* @lua NA
*/
virtual ~Follow(void); virtual ~Follow(void);
inline bool isBoundarySet(void) const { return _boundarySet; } inline bool isBoundarySet(void) const { return _boundarySet; }

View File

@ -44,6 +44,9 @@ class Camera;
class CC_DLL ActionCamera : public ActionInterval //<NSCopying> class CC_DLL ActionCamera : public ActionInterval //<NSCopying>
{ {
public: public:
/**
* @js ctor
*/
ActionCamera() ActionCamera()
:_centerXOrig(0) :_centerXOrig(0)
,_centerYOrig(0) ,_centerYOrig(0)
@ -55,6 +58,10 @@ public:
,_upYOrig(0) ,_upYOrig(0)
,_upZOrig(0) ,_upZOrig(0)
{} {}
/**
* @js NA
* @lua NA
*/
virtual ~ActionCamera(){} virtual ~ActionCamera(){}
// Overrides // Overrides
@ -86,7 +93,9 @@ class CC_DLL OrbitCamera : public ActionCamera //<NSCopying>
public: 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 */
static OrbitCamera* create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); static OrbitCamera* create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX);
/**
* @js ctor
*/
OrbitCamera() OrbitCamera()
: _radius(0.0) : _radius(0.0)
, _deltaRadius(0.0) , _deltaRadius(0.0)
@ -99,6 +108,10 @@ public:
, _radX(0.0) , _radX(0.0)
, _radDeltaX(0.0) , _radDeltaX(0.0)
{} {}
/**
* @js NA
* @lua NA
*/
~OrbitCamera(){} ~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 */

View File

@ -58,43 +58,78 @@ class CC_DLL PointArray : public Object, public Clonable
{ {
public: public:
/** creates and initializes a Points array with capacity */ /** creates and initializes a Points array with capacity
* @js NA
*/
static PointArray* create(unsigned int capacity); static PointArray* create(unsigned int capacity);
/**
* @js NA
* @lua NA
*/
virtual ~PointArray(); virtual ~PointArray();
/**
* @js NA
* @lua NA
*/
PointArray(); PointArray();
/** initializes a Catmull Rom config with a capacity hint */ /** initializes a Catmull Rom config with a capacity hint
* @js NA
*/
bool initWithCapacity(unsigned int capacity); bool initWithCapacity(unsigned int capacity);
/** appends a control point */ /** appends a control point
* @js NA
*/
void addControlPoint(Point controlPoint); void addControlPoint(Point controlPoint);
/** inserts a controlPoint at index */ /** inserts a controlPoint at index
* @js NA
*/
void insertControlPoint(Point &controlPoint, unsigned int index); void insertControlPoint(Point &controlPoint, unsigned int index);
/** replaces an existing controlPoint at index */ /** replaces an existing controlPoint at index
* @js NA
*/
void replaceControlPoint(Point &controlPoint, unsigned int index); void replaceControlPoint(Point &controlPoint, unsigned int index);
/** get the value of a controlPoint at a given index */ /** get the value of a controlPoint at a given index
* @js NA
*/
Point getControlPointAtIndex(unsigned int index); Point getControlPointAtIndex(unsigned int index);
/** deletes a control point at a given index */ /** deletes a control point at a given index
* @js NA
*/
void removeControlPointAtIndex(unsigned int index); void removeControlPointAtIndex(unsigned int index);
/** returns the number of objects of the control point array */ /** returns the number of objects of the control point array
* @js NA
*/
unsigned int count() const; unsigned int 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
*/
PointArray* reverse() const; 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(); void reverseInline();
/**
* @js NA
* @lua NA
*/
virtual PointArray* clone() const; virtual PointArray* clone() const;
/**
* @js NA
*/
const std::vector<Point*>* getControlPoints() const; const std::vector<Point*>* getControlPoints() const;
/**
* @js NA
*/
void setControlPoints(std::vector<Point*> *controlPoints); void setControlPoints(std::vector<Point*> *controlPoints);
private: private:
/** Array that contains the control points */ /** Array that contains the control points */
@ -109,10 +144,23 @@ class CC_DLL CardinalSplineTo : public ActionInterval
{ {
public: 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)
* @endcode
*/
static CardinalSplineTo* create(float duration, PointArray* points, float tension); static CardinalSplineTo* create(float duration, PointArray* points, float tension);
/**
* @js NA
* @lua NA
*/
virtual ~CardinalSplineTo(); virtual ~CardinalSplineTo();
/**
* @js NA
* @lua NA
*/
CardinalSplineTo(); CardinalSplineTo();
/** initializes the action with a duration and an array of points */ /** initializes the action with a duration and an array of points */
@ -121,6 +169,10 @@ public:
virtual void updatePosition(Point &newPos); virtual void updatePosition(Point &newPos);
inline PointArray* getPoints() { return _points; } inline PointArray* getPoints() { return _points; }
/**
* @js NA
* @lua NA
*/
inline void setPoints(PointArray* points) inline void setPoints(PointArray* points)
{ {
CC_SAFE_RETAIN(points); CC_SAFE_RETAIN(points);
@ -151,7 +203,13 @@ class CC_DLL CardinalSplineBy : public CardinalSplineTo
{ {
public: 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)
* @endcode
*/
static CardinalSplineBy* create(float duration, PointArray* points, float tension); static CardinalSplineBy* create(float duration, PointArray* points, float tension);
CardinalSplineBy(); CardinalSplineBy();
@ -175,7 +233,13 @@ class CC_DLL CatmullRomTo : public CardinalSplineTo
{ {
public: 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 dt,var table)
* in lua: lcaol create(local dt, local table)
* @endcode
*/
static CatmullRomTo* create(float dt, PointArray* points); static CatmullRomTo* 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 */
@ -194,7 +258,13 @@ public:
class CC_DLL CatmullRomBy : public CardinalSplineBy class CC_DLL CatmullRomBy : public CardinalSplineBy
{ {
public: 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 dt,var table)
* in lua: lcaol create(local dt, local table)
* @endcode
*/
static CatmullRomBy* create(float dt, PointArray* points); 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 */

View File

@ -44,6 +44,10 @@ class Object;
class CC_DLL ActionEase : public ActionInterval class CC_DLL ActionEase : public ActionInterval
{ {
public: public:
/**
* @js NA
* @lua NA
*/
virtual ~ActionEase(void); virtual ~ActionEase(void);
/** initializes the action */ /** initializes the action */
@ -72,6 +76,10 @@ protected:
class CC_DLL EaseRateAction : public ActionEase class CC_DLL EaseRateAction : public ActionEase
{ {
public: public:
/**
* @js NA
* @lua NA
*/
virtual ~EaseRateAction(void); virtual ~EaseRateAction(void);
/** Initializes the action with the inner action and the rate parameter */ /** Initializes the action with the inner action and the rate parameter */

View File

@ -66,19 +66,34 @@ public:
/** returns the grid */ /** returns the grid */
virtual GridBase* getGrid(void); virtual GridBase* getGrid(void);
/** returns the vertex than belongs to certain position in the grid */ /** returns the vertex than belongs to certain position in the grid
* @js NA
* @lua NA
*/
Vertex3F getVertex(const Point& position) const; Vertex3F getVertex(const Point& position) const;
/** @deprecated Use getVertex() instead */ /** @deprecated Use getVertex() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE inline Vertex3F vertex(const Point& position) { return getVertex(position); } CC_DEPRECATED_ATTRIBUTE inline Vertex3F vertex(const Point& position) { return getVertex(position); }
/** returns the non-transformed vertex than belongs to certain position in the grid */ /** returns the non-transformed vertex than belongs to certain position in the grid
* @js NA
* @lua NA
*/
Vertex3F getOriginalVertex(const Point& position) const; Vertex3F getOriginalVertex(const Point& position) const;
/** @deprecated Use getOriginalVertex() instead */ /** @deprecated Use getOriginalVertex() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE inline Vertex3F originalVertex(const Point& position) { return getOriginalVertex(position); } CC_DEPRECATED_ATTRIBUTE inline Vertex3F originalVertex(const Point& position) { return getOriginalVertex(position); }
/** sets a new vertex to a certain position of the grid */ /** sets a new vertex to a certain position of the grid
* @js NA
* @lua NA
*/
void setVertex(const Point& position, const Vertex3F& vertex); void setVertex(const Point& position, const Vertex3F& vertex);
// Overrides // Overrides
@ -89,22 +104,40 @@ public:
class CC_DLL TiledGrid3DAction : public GridAction class CC_DLL TiledGrid3DAction : public GridAction
{ {
public: public:
/** creates the action with size and duration */ /** creates the action with size and duration
* @js NA
* @lua NA
*/
static TiledGrid3DAction* create(float duration, const Size& gridSize); static TiledGrid3DAction* create(float duration, const Size& gridSize);
/** returns the tile that belongs to a certain position of the grid */ /** returns the tile that belongs to a certain position of the grid
* @js NA
* @lua NA
*/
Quad3 getTile(const Point& position) const; Quad3 getTile(const Point& position) const;
/** @deprecated Use getTile() instead */ /** @deprecated Use getTile() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Point& position) { return getTile(position); } CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Point& position) { return getTile(position); }
/** returns the non-transformed tile that belongs to a certain position of the grid */ /** returns the non-transformed tile that belongs to a certain position of the grid
* @js NA
* @lua NA
*/
Quad3 getOriginalTile(const Point& position) const; Quad3 getOriginalTile(const Point& position) const;
/** @deprecated Use getOriginalTile() instead */ /** @deprecated Use getOriginalTile() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Point& position) { return getOriginalTile(position); } CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Point& position) { return getOriginalTile(position); }
/** sets a new tile to a certain position of the grid */ /** sets a new tile to a certain position of the grid
* @js NA
* @lua NA
*/
void setTile(const Point& position, const Quad3& coords); void setTile(const Point& position, const Quad3& coords);
/** returns the grid */ /** returns the grid */
@ -120,7 +153,10 @@ class CC_DLL AccelDeccelAmplitude : public ActionInterval
public: public:
/** creates the action with an inner action that has the amplitude property, and a duration time */ /** creates the action with an inner action that has the amplitude property, and a duration time */
static AccelDeccelAmplitude* create(Action *pAction, float duration); static AccelDeccelAmplitude* create(Action *pAction, float duration);
/**
* @js NA
* @lua NA
*/
virtual ~AccelDeccelAmplitude(void); virtual ~AccelDeccelAmplitude(void);
/** initializes the action with an inner action that has the amplitude property, and a duration time */ /** initializes the action with an inner action that has the amplitude property, and a duration time */
bool initWithAction(Action *pAction, float duration); bool initWithAction(Action *pAction, float duration);
@ -150,7 +186,10 @@ class CC_DLL AccelAmplitude : public ActionInterval
public: public:
/** creates the action with an inner action that has the amplitude property, and a duration time */ /** creates the action with an inner action that has the amplitude property, and a duration time */
static AccelAmplitude* create(Action *pAction, float duration); static AccelAmplitude* create(Action *pAction, float duration);
/**
* @js NA
* @lua NA
*/
virtual ~AccelAmplitude(void); virtual ~AccelAmplitude(void);
/** initializes the action with an inner action that has the amplitude property, and a duration time */ /** initializes the action with an inner action that has the amplitude property, and a duration time */
@ -178,7 +217,10 @@ class CC_DLL DeccelAmplitude : public ActionInterval
public: public:
/** creates the action with an inner action that has the amplitude property, and a duration time */ /** creates the action with an inner action that has the amplitude property, and a duration time */
static DeccelAmplitude* create(Action *pAction, float duration); static DeccelAmplitude* create(Action *pAction, float duration);
/**
* @js NA
* @lua NA
*/
virtual ~DeccelAmplitude(); virtual ~DeccelAmplitude();
/** initializes the action with an inner action that has the amplitude property, and a duration time */ /** initializes the action with an inner action that has the amplitude property, and a duration time */
bool initWithAction(Action *pAction, float duration); bool initWithAction(Action *pAction, float duration);

View File

@ -225,6 +225,9 @@ class CC_DLL CallFunc : public ActionInstant //<NSCopying>
public: public:
/** creates the action with the callback of type std::function<void()>. /** creates the action with the callback of type std::function<void()>.
This is the preferred way to create the callback. This is the preferred way to create the callback.
* When this funtion bound in js or lua ,the input param will be changed
* In js: var create(var func, var this, var [data]) or var create(var func)
* In lua:local create(local funcID)
*/ */
static CallFunc * create(const std::function<void()>& func); static CallFunc * create(const std::function<void()>& func);
@ -232,16 +235,25 @@ public:
typedef void (Object::*SEL_CallFunc)(); typedef void (Object::*SEL_CallFunc)();
@deprecated Use the std::function API instead. @deprecated Use the std::function API instead.
* @js NA
* @lua NA
*/ */
CC_DEPRECATED_ATTRIBUTE static CallFunc * create(Object* pSelectorTarget, SEL_CallFunc selector); CC_DEPRECATED_ATTRIBUTE static CallFunc * create(Object* pSelectorTarget, SEL_CallFunc selector);
public: public:
/**
* @js ctor
*/
CallFunc() CallFunc()
: _selectorTarget(NULL) : _selectorTarget(NULL)
, _callFunc(NULL) , _callFunc(NULL)
, _function(nullptr) , _function(nullptr)
{ {
} }
/**
* @js NA
* @lua NA
*/
virtual ~CallFunc(); virtual ~CallFunc();
/** initializes the action with the callback /** initializes the action with the callback
@ -251,6 +263,8 @@ public:
CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* pSelectorTarget); CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* pSelectorTarget);
/** initializes the action with the std::function<void()> /** initializes the action with the std::function<void()>
* @js NK
* @lua NK
*/ */
bool initWithFunction(const std::function<void()>& func); bool initWithFunction(const std::function<void()>& func);
@ -379,8 +393,14 @@ public:
typedef void (Object::*SEL_CallFuncO)(Object*); typedef void (Object::*SEL_CallFuncO)(Object*);
*/ */
CC_DEPRECATED_ATTRIBUTE static __CCCallFuncO * create(Object* selectorTarget, SEL_CallFuncO selector, Object* object); CC_DEPRECATED_ATTRIBUTE static __CCCallFuncO * create(Object* selectorTarget, SEL_CallFuncO selector, Object* object);
/**
* @js ctor
*/
__CCCallFuncO(); __CCCallFuncO();
/**
* @js NA
* @lua NA
*/
virtual ~__CCCallFuncO(); virtual ~__CCCallFuncO();
protected: protected:

View File

@ -93,13 +93,22 @@ class CC_DLL Sequence : public ActionInterval
public: public:
/** helper constructor to create an array of sequenceable actions */ /** helper constructor to create an array of sequenceable actions */
static Sequence* create(FiniteTimeAction *pAction1, ...) CC_REQUIRES_NULL_TERMINATION; static Sequence* create(FiniteTimeAction *pAction1, ...) CC_REQUIRES_NULL_TERMINATION;
/** helper constructor to create an array of sequenceable actions given an array */ /** helper constructor to create an array of sequenceable actions given an array
* @code
* When this funtion bound to the js or lua,the input params changed
* in js :var create(var object1,var object2, ...)
* in lua :local create(local object1,local object2, ...)
* @endcode
*/
static Sequence* create(Array *arrayOfActions); static Sequence* create(Array *arrayOfActions);
/** helper constructor to create an array of sequence-able actions */ /** helper constructor to create an array of sequence-able actions */
static Sequence* createWithVariableList(FiniteTimeAction *pAction1, va_list args); static Sequence* createWithVariableList(FiniteTimeAction *pAction1, va_list args);
/** creates the action */ /** creates the action */
static Sequence* createWithTwoActions(FiniteTimeAction *pActionOne, FiniteTimeAction *pActionTwo); static Sequence* createWithTwoActions(FiniteTimeAction *pActionOne, FiniteTimeAction *pActionTwo);
/**
* @js NA
* @lua NA
*/
virtual ~Sequence(void); virtual ~Sequence(void);
/** initializes the action */ /** initializes the action */
@ -128,7 +137,10 @@ class CC_DLL Repeat : public ActionInterval
public: public:
/** creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) */ /** creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) */
static Repeat* create(FiniteTimeAction *pAction, unsigned int times); static Repeat* create(FiniteTimeAction *pAction, unsigned int times);
/**
* @js NA
* @lua NA
*/
virtual ~Repeat(void); virtual ~Repeat(void);
/** initializes a Repeat action. Times is an unsigned integer between 1 and pow(2,30) */ /** initializes a Repeat action. Times is an unsigned integer between 1 and pow(2,30) */
@ -177,10 +189,16 @@ class CC_DLL RepeatForever : public ActionInterval
public: public:
/** creates the action */ /** creates the action */
static RepeatForever* create(ActionInterval *pAction); static RepeatForever* create(ActionInterval *pAction);
/**
* @js ctor
*/
RepeatForever() RepeatForever()
: _innerAction(NULL) : _innerAction(NULL)
{} {}
/**
* @js NA
* @lua NA
*/
virtual ~RepeatForever(); virtual ~RepeatForever();
/** initializes the action */ /** initializes the action */
@ -220,7 +238,13 @@ protected:
class CC_DLL Spawn : public ActionInterval class CC_DLL Spawn : public ActionInterval
{ {
public: public:
/** helper constructor to create an array of spawned actions */ /** helper constructor to create an array of spawned actions
* @code
* When this funtion bound to the js or lua,the input params changed
* in js :var create(var object1,var object2, ...)
* in lua :local create(local object1,local object2, ...)
* @endcode
*/
static Spawn* create(FiniteTimeAction *pAction1, ...) CC_REQUIRES_NULL_TERMINATION; static Spawn* create(FiniteTimeAction *pAction1, ...) CC_REQUIRES_NULL_TERMINATION;
/** helper constructor to create an array of spawned actions */ /** helper constructor to create an array of spawned actions */
@ -231,7 +255,10 @@ public:
/** creates the Spawn action */ /** creates the Spawn action */
static Spawn* createWithTwoActions(FiniteTimeAction *pAction1, FiniteTimeAction *pAction2); static Spawn* createWithTwoActions(FiniteTimeAction *pAction1, FiniteTimeAction *pAction2);
/**
* @js NA
* @lua NA
*/
virtual ~Spawn(void); virtual ~Spawn(void);
/** initializes the Spawn action with the 2 actions to spawn */ /** initializes the Spawn action with the 2 actions to spawn */
@ -477,7 +504,13 @@ typedef struct _ccBezierConfig {
class CC_DLL BezierBy : public ActionInterval class CC_DLL BezierBy : public ActionInterval
{ {
public: public:
/** creates the action with a duration and a bezier configuration */ /** creates the action with a duration and a bezier configuration
* @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)
* @endcode
*/
static BezierBy* create(float t, const ccBezierConfig& c); static BezierBy* create(float t, const ccBezierConfig& c);
/** initializes the action with a duration and a bezier configuration */ /** initializes the action with a duration and a bezier configuration */
@ -503,7 +536,13 @@ protected:
class CC_DLL BezierTo : public BezierBy class CC_DLL BezierTo : public BezierBy
{ {
public: public:
/** creates the action with a duration and a bezier configuration */ /** creates the action with a duration and a bezier configuration
* @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)
* @endcode
*/
static BezierTo* create(float t, const ccBezierConfig& c); static BezierTo* create(float t, const ccBezierConfig& c);
bool initWithDuration(float t, const ccBezierConfig &c); bool initWithDuration(float t, const ccBezierConfig &c);
@ -742,8 +781,14 @@ class CC_DLL ReverseTime : public ActionInterval
public: public:
/** creates the action */ /** creates the action */
static ReverseTime* create(FiniteTimeAction *pAction); static ReverseTime* create(FiniteTimeAction *pAction);
/**
* @js NA
* @lua NA
*/
virtual ~ReverseTime(void); virtual ~ReverseTime(void);
/**
* @js ctor
*/
ReverseTime(); ReverseTime();
/** initializes the action */ /** initializes the action */
@ -769,8 +814,14 @@ class CC_DLL Animate : public ActionInterval
public: public:
/** creates the action with an Animation and will restore the original frame when the animation is over */ /** creates the action with an Animation and will restore the original frame when the animation is over */
static Animate* create(Animation *pAnimation); static Animate* create(Animation *pAnimation);
/**
* @js ctor
*/
Animate(); Animate();
/**
* @js NA
* @lua NA
*/
virtual ~Animate(); virtual ~Animate();
/** initializes the action with an Animation and will restore the original frame when the animation is over */ /** initializes the action with an Animation and will restore the original frame when the animation is over */
@ -805,7 +856,14 @@ protected:
class CC_DLL TargetedAction : public ActionInterval class CC_DLL TargetedAction : public ActionInterval
{ {
public: public:
/**
* @js ctor
*/
TargetedAction(); TargetedAction();
/**
* @js NA
* @lua NA
*/
virtual ~TargetedAction(); virtual ~TargetedAction();
/** Create an action with the specified action and forced target */ /** Create an action with the specified action and forced target */

View File

@ -57,7 +57,14 @@ struct _hashElement;
class CC_DLL ActionManager : public Object class CC_DLL ActionManager : public Object
{ {
public: public:
/**
* @js ctor
*/
ActionManager(void); ActionManager(void);
/**
* @js NA
* @lua NA
*/
~ActionManager(void); ~ActionManager(void);
// actions // actions

View File

@ -82,7 +82,10 @@ class CC_DLL ShuffleTiles : public TiledGrid3DAction
public: public:
/** creates the action with a random seed, the grid size and the duration */ /** creates the action with a random seed, the grid size and the duration */
static ShuffleTiles* create(float duration, const Size& gridSize, unsigned int seed); static ShuffleTiles* create(float duration, const Size& gridSize, unsigned int seed);
/**
* @js NA
* @lua NA
*/
virtual ~ShuffleTiles(void); virtual ~ShuffleTiles(void);
/** initializes the action with a random seed, the grid size and the duration */ /** initializes the action with a random seed, the grid size and the duration */
bool initWithDuration(float duration, const Size& gridSize, unsigned int seed); bool initWithDuration(float duration, const Size& gridSize, unsigned int seed);
@ -176,7 +179,10 @@ public:
static TurnOffTiles* create(float duration, const Size& gridSize); static TurnOffTiles* create(float duration, const Size& gridSize);
/** creates the action with a random seed, the grid size and the duration */ /** creates the action with a random seed, the grid size and the duration */
static TurnOffTiles* create(float duration, const Size& gridSize, unsigned int seed); static TurnOffTiles* create(float duration, const Size& gridSize, unsigned int seed);
/**
* @js NA
* @lua NA
*/
~TurnOffTiles(void); ~TurnOffTiles(void);
/** initializes the action with a random seed, the grid size and the duration */ /** initializes the action with a random seed, the grid size and the duration */
bool initWithDuration(float duration, const Size& gridSize, unsigned int seed); bool initWithDuration(float duration, const Size& gridSize, unsigned int seed);

View File

@ -37,6 +37,10 @@ NS_CC_BEGIN
class CC_DLL ActionTweenDelegate class CC_DLL ActionTweenDelegate
{ {
public: public:
/**
* @js NA
* @lua NA
*/
virtual ~ActionTweenDelegate() {} virtual ~ActionTweenDelegate() {}
virtual void updateTweenAction(float value, const char* key) = 0; virtual void updateTweenAction(float value, const char* key) = 0;
}; };

View File

@ -54,7 +54,14 @@ 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*/
static AtlasNode * create(const char* tile,unsigned int tileWidth, unsigned int tileHeight, static AtlasNode * create(const char* tile,unsigned int tileWidth, unsigned int tileHeight,
unsigned int itemsToRender); unsigned int itemsToRender);
/**
* @js ctor
*/
AtlasNode(); AtlasNode();
/**
* @js NA
* @lua NA
*/
virtual ~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*/
@ -84,7 +91,18 @@ public:
virtual const Color3B& getColor(void) const override; virtual const Color3B& getColor(void) const override;
virtual void setColor(const Color3B& color) override; virtual void setColor(const Color3B& color) override;
virtual void setOpacity(GLubyte opacity) override; virtual void setOpacity(GLubyte opacity) override;
/**
* @code
* When this function bound into js or lua,the parameter will be changed
* In js: var setBlendFunc(var src, var dst)
* @endcode
* @lua NA
*/
virtual void setBlendFunc(const BlendFunc& blendFunc) override; virtual void setBlendFunc(const BlendFunc& blendFunc) override;
/**
* @js NA
* @lua NA
*/
virtual const BlendFunc& getBlendFunc() const override; virtual const BlendFunc& getBlendFunc() const override;
private : private :

View File

@ -29,7 +29,14 @@ THE SOFTWARE.
class GLBufferedNode class GLBufferedNode
{ {
public: public:
/**
* @js ctor
*/
GLBufferedNode(); GLBufferedNode();
/**
* @js NA
* @lua NA
*/
virtual ~GLBufferedNode(); virtual ~GLBufferedNode();
/** /**

View File

@ -144,11 +144,14 @@ public:
/** /**
* Default constructor * Default constructor
* @js ctor
*/ */
Node(void); Node(void);
/** /**
* Default destructor * Default destructor
* @js NA
* @lua NA
*/ */
virtual ~Node(void); virtual ~Node(void);
@ -161,6 +164,8 @@ public:
/** /**
* Gets the description string. It makes debugging easier. * Gets the description string. It makes debugging easier.
* @return A string terminated with '\0' * @return A string terminated with '\0'
* @js NA
* @lua NA
*/ */
const char* description(void) const; const char* description(void) const;
@ -299,6 +304,9 @@ public:
* @see setPosition(const Point&) * @see setPosition(const Point&)
* *
* @return The position (x,y) of the node in OpenGL coordinates * @return The position (x,y) of the node in OpenGL coordinates
* @code
* In js and lua return value is table which contains x,y
* @endcode
*/ */
virtual const Point& getPosition() const; virtual const Point& getPosition() const;
/** /**
@ -322,6 +330,9 @@ public:
* Gets position in a more efficient way, returns two number instead of a Point object * Gets position in a more efficient way, returns two number instead of a Point object
* *
* @see setPosition(float, float) * @see setPosition(float, float)
* @code
* In js,out value not return
* @endcode
*/ */
virtual void getPosition(float* x, float* y) const; virtual void getPosition(float* x, float* y) const;
/** /**
@ -520,9 +531,15 @@ public:
virtual int getOrderOfArrival() const; virtual int getOrderOfArrival() const;
/** @deprecated No longer needed */ /** @deprecated No longer needed
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE void setGLServerState(int serverState) { /* ignore */ }; CC_DEPRECATED_ATTRIBUTE void setGLServerState(int serverState) { /* ignore */ };
/** @deprecated No longer needed */ /** @deprecated No longer needed
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE int getGLServerState() const { return 0; } CC_DEPRECATED_ATTRIBUTE int getGLServerState() const { return 0; }
/** /**
@ -640,6 +657,8 @@ public:
* Removes this node itself from its parent node. * Removes this node itself from its parent node.
* If the node orphan, then nothing happens. * If the node orphan, then nothing happens.
* @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. * @param cleanup true if all actions and callbacks on this node should be removed, false otherwise.
* @js removeFromParent
* @lua removeFromParent
*/ */
virtual void removeFromParentAndCleanup(bool cleanup); virtual void removeFromParentAndCleanup(bool cleanup);
@ -668,6 +687,8 @@ public:
* Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter. * Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter.
* *
* @param cleanup true if all running actions on all children nodes should be cleanup, false oterwise. * @param cleanup true if all running actions on all children nodes should be cleanup, false oterwise.
* @js removeAllChildren
* @lua removeAllChildren
*/ */
virtual void removeAllChildrenWithCleanup(bool cleanup); virtual void removeAllChildrenWithCleanup(bool cleanup);
@ -697,8 +718,12 @@ public:
* Returns a grid object that is used when applying effects * Returns a grid object that is used when applying effects
* *
* @return A Grid object that is used when applying effects * @return A Grid object that is used when applying effects
* @js NA
*/ */
virtual GridBase* getGrid() { return _grid; } virtual GridBase* getGrid() { return _grid; }
/**
* @js NA
*/
virtual const GridBase* getGrid() const { return _grid; } virtual const GridBase* getGrid() const { return _grid; }
/** /**
@ -763,8 +788,14 @@ public:
* You can set everything in UserData pointer, a data block, a structure or an object. * You can set everything in UserData pointer, a data block, a structure or an object.
* *
* @return A custom user data pointer * @return A custom user data pointer
* @js NA
* @lua NA
*/ */
virtual void* getUserData() { return _userData; } virtual void* getUserData() { return _userData; }
/**
* @js NA
* @lua NA
*/
virtual const void* getUserData() const { return _userData; } virtual const void* getUserData() const { return _userData; }
/** /**
@ -775,6 +806,8 @@ public:
* especially before you change this data pointer, and before this node is autoreleased. * especially before you change this data pointer, and before this node is autoreleased.
* *
* @param userData A custom user data pointer * @param userData A custom user data pointer
* @js NA
* @lua NA
*/ */
virtual void setUserData(void *userData); virtual void setUserData(void *userData);
@ -784,8 +817,14 @@ public:
* Similar to userData, but instead of holding a void* it holds an object * Similar to userData, but instead of holding a void* it holds an object
* *
* @return A user assigned Object * @return A user assigned Object
* @js NA
* @lua NA
*/ */
virtual Object* getUserObject() { return _userObject; } virtual Object* getUserObject() { return _userObject; }
/**
* @js NA
* @lua NA
*/
virtual const Object* getUserObject() const { return _userObject; } virtual const Object* getUserObject() const { return _userObject; }
/** /**
@ -852,6 +891,7 @@ public:
/** /**
* Schedules for lua script. * Schedules for lua script.
* @js NA
*/ */
void scheduleUpdateWithPriorityLua(int handler, int priority); void scheduleUpdateWithPriorityLua(int handler, int priority);
@ -866,12 +906,16 @@ public:
* If the Node enters the 'stage' with a transition, this event is called when the transition starts. * If the Node enters the 'stage' with a transition, this event is called when the transition starts.
* During onEnter you can't access a "sister/brother" node. * During onEnter you can't access a "sister/brother" node.
* If you override onEnter, you shall call its parent's one, e.g., Node::onEnter(). * If you override onEnter, you shall call its parent's one, e.g., Node::onEnter().
* @js NA
* @lua NA
*/ */
virtual void onEnter(); virtual void onEnter();
/** Event callback that is invoked when the Node enters in the 'stage'. /** Event callback that is invoked when the Node enters in the 'stage'.
* If the Node enters the 'stage' with a transition, this event is called when the transition finishes. * If the Node enters the 'stage' with a transition, this event is called when the transition finishes.
* If you override onEnterTransitionDidFinish, you shall call its parent's one, e.g. Node::onEnterTransitionDidFinish() * If you override onEnterTransitionDidFinish, you shall call its parent's one, e.g. Node::onEnterTransitionDidFinish()
* @js NA
* @lua NA
*/ */
virtual void onEnterTransitionDidFinish(); virtual void onEnterTransitionDidFinish();
@ -880,12 +924,16 @@ public:
* If the Node leaves the 'stage' with a transition, this event is called when the transition finishes. * If the Node leaves the 'stage' with a transition, this event is called when the transition finishes.
* During onExit you can't access a sibling node. * During onExit you can't access a sibling node.
* If you override onExit, you shall call its parent's one, e.g., Node::onExit(). * If you override onExit, you shall call its parent's one, e.g., Node::onExit().
* @js NA
* @lua NA
*/ */
virtual void onExit(); virtual void onExit();
/** /**
* Event callback that is called every time the Node leaves the 'stage'. * Event callback that is called every time the Node leaves the 'stage'.
* If the Node leaves the 'stage' with a transition, this callback is called when the transition starts. * If the Node leaves the 'stage' with a transition, this callback is called when the transition starts.
* @js NA
* @lua NA
*/ */
virtual void onExitTransitionDidStart(); virtual void onExitTransitionDidStart();
@ -1029,6 +1077,8 @@ public:
* *
* @param selector A function selector * @param selector A function selector
* @return Whether the funcion selector is scheduled. * @return Whether the funcion selector is scheduled.
* @js NA
* @lua NA
*/ */
bool isScheduled(SEL_SCHEDULE selector); bool isScheduled(SEL_SCHEDULE selector);
@ -1038,6 +1088,8 @@ public:
* It will use the order number 0. This method will be called every frame. * It will use the order number 0. This method will be called every frame.
* Scheduled methods with a lower order value will be called before the ones that have a higher order value. * Scheduled methods with a lower order value will be called before the ones that have a higher order value.
* Only one "update" method could be scheduled per node. * Only one "update" method could be scheduled per node.
* @js NA
* @lua NA
*/ */
void scheduleUpdate(void); void scheduleUpdate(void);
@ -1047,6 +1099,8 @@ public:
* This selector will be called every frame. * This selector will be called every frame.
* Scheduled methods with a lower priority will be called before the ones that have a higher value. * Scheduled methods with a lower priority will be called before the ones that have a higher value.
* Only one "update" selector could be scheduled per node (You can't have 2 'update' selectors). * Only one "update" selector could be scheduled per node (You can't have 2 'update' selectors).
* @js NA
* @lua NA
*/ */
void scheduleUpdateWithPriority(int priority); void scheduleUpdateWithPriority(int priority);
@ -1071,6 +1125,7 @@ public:
* @param interval Tick interval in seconds. 0 means tick every frame. If interval = 0, it's recommended to use scheduleUpdate() instead. * @param interval Tick interval in seconds. 0 means tick every frame. If interval = 0, it's recommended to use scheduleUpdate() instead.
* @param repeat The selector will be excuted (repeat + 1) times, you can use kRepeatForever for tick infinitely. * @param repeat The selector will be excuted (repeat + 1) times, you can use kRepeatForever for tick infinitely.
* @param delay The amount of time that the first tick will wait before execution. * @param delay The amount of time that the first tick will wait before execution.
* @lua NA
*/ */
void schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay); void schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay);
@ -1080,6 +1135,7 @@ public:
* *
* @param selector The SEL_SCHEDULE selector to be scheduled. * @param selector The SEL_SCHEDULE selector to be scheduled.
* @param interval Callback interval time in seconds. 0 means tick every frame, * @param interval Callback interval time in seconds. 0 means tick every frame,
* @lua NA
*/ */
void schedule(SEL_SCHEDULE selector, float interval); void schedule(SEL_SCHEDULE selector, float interval);
@ -1089,6 +1145,7 @@ public:
* *
* @param selector The SEL_SCHEDULE selector to be scheduled. * @param selector The SEL_SCHEDULE selector to be scheduled.
* @param delay The amount of time that the first tick will wait before execution. * @param delay The amount of time that the first tick will wait before execution.
* @lua NA
*/ */
void scheduleOnce(SEL_SCHEDULE selector, float delay); void scheduleOnce(SEL_SCHEDULE selector, float delay);
@ -1097,6 +1154,7 @@ public:
* @see schedule(SEL_SCHEDULE, float, unsigned int, float) * @see schedule(SEL_SCHEDULE, float, unsigned int, float)
* *
* @param selector A function wrapped as a selector * @param selector A function wrapped as a selector
* @lua NA
*/ */
void schedule(SEL_SCHEDULE selector); void schedule(SEL_SCHEDULE selector);
@ -1105,12 +1163,14 @@ public:
* @see schedule(SEL_SCHEDULE, float, unsigned int, float) * @see schedule(SEL_SCHEDULE, float, unsigned int, float)
* *
* @param selector A function wrapped as a selector * @param selector A function wrapped as a selector
* @lua NA
*/ */
void unschedule(SEL_SCHEDULE selector); void unschedule(SEL_SCHEDULE selector);
/** /**
* Unschedule all scheduled selectors: custom selectors, and the 'update' selector. * Unschedule all scheduled selectors: custom selectors, and the 'update' selector.
* Actions are not affected by this method. * Actions are not affected by this method.
* @lua NA
*/ */
void unscheduleAllSelectors(void); void unscheduleAllSelectors(void);
@ -1395,7 +1455,14 @@ protected:
class CC_DLL NodeRGBA : public Node, public RGBAProtocol class CC_DLL NodeRGBA : public Node, public RGBAProtocol
{ {
public: public:
/**
* @js ctor
*/
NodeRGBA(); NodeRGBA();
/**
* @js NA
* @lua NA
*/
virtual ~NodeRGBA(); virtual ~NodeRGBA();
virtual bool init(); virtual bool init();

View File

@ -234,45 +234,79 @@ class CC_DLL Array : public Object, public Clonable
{ {
public: public:
/** Creates an empty array. Default capacity is 10 */ /** Creates an empty array. Default capacity is 10
* @js NA
* @lua NA
*/
static Array* create(); static Array* create();
/** Create an array with objects */ /** Create an array with objects
* @js NA
*/
static Array* create(Object* object, ...) CC_REQUIRES_NULL_TERMINATION; static Array* create(Object* object, ...) CC_REQUIRES_NULL_TERMINATION;
/** Create an array with one object */ /** Create an array with one object
* @js NA
*/
static Array* createWithObject(Object* object); static Array* createWithObject(Object* object);
/** Create an array with a default capacity */ /** Create an array with a default capacity
* @js NA
*/
static Array* createWithCapacity(int capacity); static Array* createWithCapacity(int capacity);
/** Create an array with from an existing array */ /** Create an array with from an existing array
* @js NA
*/
static Array* createWithArray(Array* otherArray); static Array* createWithArray(Array* otherArray);
/** /**
@brief Generate a Array pointer by file @brief Generate a Array pointer by file
@param pFileName The file name of *.plist file @param pFileName The file name of *.plist file
@return The Array pointer generated from the file @return The Array pointer generated from the file
* @js NA
*/ */
static Array* createWithContentsOfFile(const char* pFileName); static Array* createWithContentsOfFile(const char* pFileName);
/* /*
@brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the @brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the
invoker should call release(). invoker should call release().
* @js NA
* @lua NA
*/ */
static Array* createWithContentsOfFileThreadSafe(const char* pFileName); static Array* createWithContentsOfFileThreadSafe(const char* pFileName);
/**
* @js NA
* @lua NA
*/
~Array(); ~Array();
/** Initializes an array */ /** Initializes an array
* @js NA
* @lua NA
*/
bool init(); bool init();
/** Initializes an array with one object */ /** Initializes an array with one object
* @js NA
* @lua NA
*/
bool initWithObject(Object* object); bool initWithObject(Object* object);
/** Initializes an array with some objects */ /** Initializes an array with some objects
* @js NA
* @lua NA
*/
bool initWithObjects(Object* object, ...) CC_REQUIRES_NULL_TERMINATION; bool initWithObjects(Object* object, ...) CC_REQUIRES_NULL_TERMINATION;
/** Initializes an array with capacity */ /** Initializes an array with capacity
* @js NA
* @lua NA
*/
bool initWithCapacity(int capacity); bool initWithCapacity(int capacity);
/** Initializes an array with an existing array */ /** Initializes an array with an existing array
* @js NA
* @lua NA
*/
bool initWithArray(Array* otherArray); bool initWithArray(Array* otherArray);
// Querying an Array // Querying an Array
/** Returns element count of the array */ /** Returns element count of the array
* @js NA
*/
int count() const int count() const
{ {
#if CC_USE_ARRAY_VECTOR #if CC_USE_ARRAY_VECTOR
@ -281,7 +315,9 @@ public:
return data->num; return data->num;
#endif #endif
} }
/** Returns capacity of the array */ /** Returns capacity of the array
* @js NA
*/
int capacity() const int capacity() const
{ {
#if CC_USE_ARRAY_VECTOR #if CC_USE_ARRAY_VECTOR
@ -290,11 +326,20 @@ public:
return data->max; return data->max;
#endif #endif
} }
/** Returns index of a certain object, return UINT_MAX if doesn't contain the object */ /** Returns index of a certain object, return UINT_MAX if doesn't contain the object
* @js NA
* @lua NA
*/
int getIndexOfObject(Object* object) const; int getIndexOfObject(Object* object) const;
/**
* @js NA
*/
CC_DEPRECATED_ATTRIBUTE int indexOfObject(Object* object) const { return getIndexOfObject(object); } CC_DEPRECATED_ATTRIBUTE int indexOfObject(Object* object) const { return getIndexOfObject(object); }
/** Returns an element with a certain index */ /** Returns an element with a certain index
* @js NA
* @lua NA
*/
Object* getObjectAtIndex(int index) Object* getObjectAtIndex(int index)
{ {
CCASSERT(index>=0 && index < count(), "index out of range in getObjectAtIndex()"); CCASSERT(index>=0 && index < count(), "index out of range in getObjectAtIndex()");
@ -305,7 +350,9 @@ public:
#endif #endif
} }
CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(int index) { return getObjectAtIndex(index); } CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(int index) { return getObjectAtIndex(index); }
/** Returns the last element of the array */ /** Returns the last element of the array
* @js NA
*/
Object* getLastObject() Object* getLastObject()
{ {
#if CC_USE_ARRAY_VECTOR #if CC_USE_ARRAY_VECTOR
@ -317,25 +364,53 @@ public:
return nullptr; return nullptr;
#endif #endif
} }
/**
* @js NA
*/
CC_DEPRECATED_ATTRIBUTE Object* lastObject() { return getLastObject(); } CC_DEPRECATED_ATTRIBUTE Object* lastObject() { return getLastObject(); }
/** Returns a random element */ /** Returns a random element
* @js NA
* @lua NA
*/
Object* getRandomObject(); Object* getRandomObject();
/**
* @js NA
*/
CC_DEPRECATED_ATTRIBUTE Object* randomObject() { return getRandomObject(); } CC_DEPRECATED_ATTRIBUTE Object* randomObject() { return getRandomObject(); }
/** Returns a Boolean value that indicates whether object is present in array. */ /** Returns a Boolean value that indicates whether object is present in array.
* @js NA
*/
bool containsObject(Object* object) const; bool containsObject(Object* object) const;
/** @since 1.1 */ /** @since 1.1
* @js NA
*/
bool isEqualToArray(Array* otherArray); bool isEqualToArray(Array* otherArray);
// Adding Objects // Adding Objects
/** Add a certain object */ /** Add a certain object
* @js NA
*/
void addObject(Object* object); void addObject(Object* object);
/** Add all elements of an existing array */ /**
* @js NA
*/
/** Add all elements of an existing array
* @js NA
*/
void addObjectsFromArray(Array* otherArray); void addObjectsFromArray(Array* otherArray);
/** Insert a certain object at a certain index */ /** Insert a certain object at a certain index
* @js NA
*/
void insertObject(Object* object, int index); void insertObject(Object* object, int index);
/** sets a certain object at a certain index */ /** sets a certain object at a certain index
* @js NA
* @lua NA
*/
void setObject(Object* object, int index); void setObject(Object* object, int index);
/** sets a certain object at a certain index without retaining. Use it with caution */ /** sets a certain object at a certain index without retaining. Use it with caution
* @js NA
* @lua NA
*/
void fastSetObject(Object* object, int index) void fastSetObject(Object* object, int index)
{ {
#if CC_USE_ARRAY_VECTOR #if CC_USE_ARRAY_VECTOR
@ -345,7 +420,10 @@ public:
data->arr[index] = object; data->arr[index] = object;
#endif #endif
} }
/**
* @js NA
* @lua NA
*/
void swap( int indexOne, int indexTwo ) void swap( int indexOne, int indexTwo )
{ {
CCASSERT(indexOne >=0 && indexOne < count() && indexTwo >= 0 && indexTwo < count(), "Invalid indices"); CCASSERT(indexOne >=0 && indexOne < count() && indexTwo >= 0 && indexTwo < count(), "Invalid indices");
@ -358,38 +436,68 @@ public:
// Removing Objects // Removing Objects
/** Remove last object */ /** Remove last object
* @js NA
*/
void removeLastObject(bool releaseObj = true); void removeLastObject(bool releaseObj = true);
/** Remove a certain object */ /** Remove a certain object
* @js NA
*/
void removeObject(Object* object, bool releaseObj = true); void removeObject(Object* object, bool releaseObj = true);
/** Remove an element with a certain index */ /** Remove an element with a certain index
* @js NA
*/
void removeObjectAtIndex(int index, bool releaseObj = true); void removeObjectAtIndex(int index, bool releaseObj = true);
/** Remove all elements */ /** Remove all elements
* @js NA
*/
void removeObjectsInArray(Array* otherArray); void removeObjectsInArray(Array* otherArray);
/** Remove all objects */ /** Remove all objects
* @js NA
*/
void removeAllObjects(); void removeAllObjects();
/** Fast way to remove a certain object */ /** Fast way to remove a certain object
* @js NA
*/
void fastRemoveObject(Object* object); void fastRemoveObject(Object* object);
/** Fast way to remove an element with a certain index */ /** Fast way to remove an element with a certain index
* @js NA
*/
void fastRemoveObjectAtIndex(int index); void fastRemoveObjectAtIndex(int index);
// Rearranging Content // Rearranging Content
/** Swap two elements */ /** Swap two elements
* @js NA
*/
void exchangeObject(Object* object1, Object* object2); void exchangeObject(Object* object1, Object* object2);
/** Swap two elements with certain indexes */ /** Swap two elements with certain indexes
* @js NA
*/
void exchangeObjectAtIndex(int index1, int index2); void exchangeObjectAtIndex(int index1, int index2);
/** Replace object at index with another object. */ /** Replace object at index with another object.
* @js NA
*/
void replaceObjectAtIndex(int index, Object* object, bool releaseObject = true); void replaceObjectAtIndex(int index, Object* object, bool releaseObject = true);
/** Revers the array */ /** Revers the array
* @js NA
*/
void reverseObjects(); void reverseObjects();
/* Shrinks the array so the memory footprint corresponds with the number of items */ /* Shrinks the array so the memory footprint corresponds with the number of items
* @js NA
*/
void reduceMemoryFootprint(); void reduceMemoryFootprint();
/* override functions */ /* override functions
* @js NA
*/
virtual void acceptVisitor(DataVisitor &visitor); virtual void acceptVisitor(DataVisitor &visitor);
/**
* @js NA
* @lua NA
*/
virtual Array* clone() const; virtual Array* clone() const;
// ------------------------------------------ // ------------------------------------------
@ -398,16 +506,35 @@ public:
#if CC_USE_ARRAY_VECTOR #if CC_USE_ARRAY_VECTOR
typedef std::vector<RCPtr<Object>>::iterator iterator; typedef std::vector<RCPtr<Object>>::iterator iterator;
typedef std::vector<RCPtr<Object>>::const_iterator const_iterator; typedef std::vector<RCPtr<Object>>::const_iterator const_iterator;
/**
* @js NA
* @lua NA
*/
iterator begin() { return data.begin(); } iterator begin() { return data.begin(); }
/**
* @js NA
* @lua NA
*/
iterator end() { return data.end(); } iterator end() { return data.end(); }
const_iterator cbegin() { return data.cbegin(); } const_iterator cbegin() { return data.cbegin(); }
/**
* @js NA
* @lua NA
*/
const_iterator cend() { return data.cend(); } const_iterator cend() { return data.cend(); }
std::vector<RCPtr<Object>> data; std::vector<RCPtr<Object>> data;
#else #else
/**
* @js NA
* @lua NA
*/
Object** begin() { return &data->arr[0]; } Object** begin() { return &data->arr[0]; }
/**
* @js NA
* @lua NA
*/
Object** end() { return &data->arr[data->num]; } Object** end() { return &data->arr[data->num]; }
ccArray* data; ccArray* data;
@ -415,6 +542,10 @@ public:
#endif #endif
//protected: //protected:
/**
* @js NA
* @lua NA
*/
Array(); Array();
}; };

View File

@ -47,7 +47,15 @@ class CC_DLL AutoreleasePool : public Object
*/ */
Array *_managedObjectArray; Array *_managedObjectArray;
public: public:
/**
* @js NA
* @lua NA
*/
AutoreleasePool(); AutoreleasePool();
/**
* @js NA
* @lua NA
*/
~AutoreleasePool(); ~AutoreleasePool();
/** /**
@ -58,6 +66,8 @@ public:
* for each time it was added. * for each time it was added.
* *
* @param object The object to add to the pool. * @param object The object to add to the pool.
* @js NA
* @lua NA
*/ */
void addObject(Object *object); void addObject(Object *object);
@ -65,6 +75,8 @@ public:
* Remove a given object from this pool. * Remove a given object from this pool.
* *
* @param object The object to be removed from the pool. * @param object The object to be removed from the pool.
* @js NA
* @lua NA
*/ */
void removeObject(Object *object); void removeObject(Object *object);
@ -73,6 +85,8 @@ public:
* *
* Object::release() will be called for each time the managed object is * Object::release() will be called for each time the managed object is
* added to the pool. * added to the pool.
* @js NA
* @lua NA
*/ */
void clear(); void clear();
}; };
@ -84,19 +98,38 @@ class CC_DLL PoolManager
AutoreleasePool *getCurReleasePool(); AutoreleasePool *getCurReleasePool();
public: public:
/**
* @js NA
* @lua NA
*/
static PoolManager* sharedPoolManager(); static PoolManager* sharedPoolManager();
/**
* @js NA
* @lua NA
*/
static void purgePoolManager(); static void purgePoolManager();
/**
* @js NA
* @lua NA
*/
PoolManager(); PoolManager();
/**
* @js NA
* @lua NA
*/
~PoolManager(); ~PoolManager();
/** /**
* Clear all the AutoreleasePool on the pool stack. * Clear all the AutoreleasePool on the pool stack.
* @js NA
* @lua NA
*/ */
void finalize(); void finalize();
/** /**
* Push a new AutoreleasePool to the pool stack. * Push a new AutoreleasePool to the pool stack.
* @js NA
* @lua NA
*/ */
void push(); void push();
@ -107,6 +140,8 @@ public:
* the stack. * the stack.
* *
* The AutoreleasePool being poped is destructed. * The AutoreleasePool being poped is destructed.
* @js NA
* @lua NA
*/ */
void pop(); void pop();
@ -116,6 +151,8 @@ public:
* @param object The object to be removed. * @param object The object to be removed.
* *
* @see AutoreleasePool::removeObject * @see AutoreleasePool::removeObject
* @js NA
* @lua NA
*/ */
void removeObject(Object *object); void removeObject(Object *object);
@ -125,9 +162,14 @@ public:
* @param object The object to add. * @param object The object to add.
* *
* @see AutoreleasePool::addObject * @see AutoreleasePool::addObject
* @js NA
* @lua NA
*/ */
void addObject(Object *object); void addObject(Object *object);
/**
* @js NA
* @lua NA
*/
friend class AutoreleasePool; friend class AutoreleasePool;
}; };

View File

@ -33,10 +33,25 @@ NS_CC_BEGIN
class CC_DLL Data : public Object class CC_DLL Data : public Object
{ {
public: public:
/**
* @js NA
* @lua NA
*/
Data(unsigned char *pBytes, const unsigned long nSize); Data(unsigned char *pBytes, const unsigned long nSize);
/**
* @js NA
* @lua NA
*/
Data(Data *pData); Data(Data *pData);
/**
* @js NA
* @lua NA
*/
~Data(); ~Data();
/**
* @js NA
* @lua NA
*/
static Data* create(unsigned char *pBytes, const unsigned long nSize) static Data* create(unsigned char *pBytes, const unsigned long nSize)
{ {
Data* pRet = new Data(pBytes, nSize); Data* pRet = new Data(pBytes, nSize);
@ -46,11 +61,21 @@ public:
} }
return pRet; return pRet;
} }
/**
* @js NA
* @lua NA
*/
unsigned char* getBytes() const; unsigned char* getBytes() const;
/**
* @js NA
* @lua NA
*/
unsigned long getSize() const; unsigned long getSize() const;
/* override functions */ /** override functions
* @js NA
* @lua NA
*/
virtual void acceptVisitor(DataVisitor &visitor) { visitor.visit(this); } virtual void acceptVisitor(DataVisitor &visitor) { visitor.visit(this); }
private: private:

View File

@ -63,6 +63,10 @@ class Data;
class CC_DLL DataVisitor class CC_DLL DataVisitor
{ {
public: public:
/**
* @js NA
* @lua NA
*/
virtual ~DataVisitor() {} virtual ~DataVisitor() {}
/** default method, called from non-overloaded methods and for unrecognized objects */ /** default method, called from non-overloaded methods and for unrecognized objects */

View File

@ -81,6 +81,8 @@ private:
public: public:
/** /**
* The destructor of DictElement. * The destructor of DictElement.
* @js NA
* @lua NA
*/ */
~DictElement(); ~DictElement();
@ -174,20 +176,28 @@ class CC_DLL Dictionary : public Object, public Clonable
public: public:
/** /**
* The constructor of Dictionary. * The constructor of Dictionary.
* @js NA
* @lua NA
*/ */
Dictionary(); Dictionary();
/** /**
* The destructor of Dictionary * The destructor of Dictionary
* @js NA
* @lua NA
*/ */
~Dictionary(); ~Dictionary();
/** Initializes the dictionary. It returns true if the initializations was successful. */ /** Initializes the dictionary. It returns true if the initializations was successful.
* @js NA
* @lua NA
*/
bool init(); bool init();
/** /**
* Get the count of elements in Dictionary. * Get the count of elements in Dictionary.
* *
* @return The count of elements. * @return The count of elements.
* @js NA
*/ */
unsigned int count(); unsigned int count();
@ -195,6 +205,7 @@ public:
* Return all keys of elements. * Return all keys of elements.
* *
* @return The array contains all keys of elements. It's an autorelease object yet. * @return The array contains all keys of elements. It's an autorelease object yet.
* @js NA
*/ */
Array* allKeys(); Array* allKeys();
@ -202,6 +213,7 @@ public:
* Get all keys according to the specified object. * Get all keys according to the specified object.
* @warning We use '==' to compare two objects * @warning We use '==' to compare two objects
* @return The array contains all keys for the specified object. It's an autorelease object yet. * @return The array contains all keys for the specified object. It's an autorelease object yet.
* @js NA
*/ */
Array* allKeysForObject(Object* object); Array* allKeysForObject(Object* object);
@ -222,6 +234,7 @@ public:
* } * }
* @endcode * @endcode
* @see objectForKey(intptr_t) * @see objectForKey(intptr_t)
* @js NA
*/ */
Object* objectForKey(const std::string& key); Object* objectForKey(const std::string& key);
@ -232,6 +245,7 @@ public:
* @param key The integer key for searching. * @param key The integer key for searching.
* @return The object matches the key. * @return The object matches the key.
* @see objectForKey(const std::string&) * @see objectForKey(const std::string&)
* @js NA
*/ */
Object* objectForKey(intptr_t key); Object* objectForKey(intptr_t key);
@ -242,6 +256,7 @@ public:
* @return An instance of String. * @return An instance of String.
* It will return an empty string if the objects aren't String pointer or the key wasn't found. * It will return an empty string if the objects aren't String pointer or the key wasn't found.
* @see valueForKey(intptr_t) * @see valueForKey(intptr_t)
* @js NA
*/ */
const String* valueForKey(const std::string& key); const String* valueForKey(const std::string& key);
@ -252,6 +267,7 @@ public:
* @return An instance of String. * @return An instance of String.
* It will return an empty string if the objects aren't String pointer or the key wasn't found. * It will return an empty string if the objects aren't String pointer or the key wasn't found.
* @see valueForKey(intptr_t) * @see valueForKey(intptr_t)
* @js NA
*/ */
const String* valueForKey(intptr_t key); const String* valueForKey(intptr_t key);
@ -265,6 +281,7 @@ public:
* @param pObject The Object to be inserted. * @param pObject The Object to be inserted.
* @param key The string key for searching. * @param key The string key for searching.
* @see setObject(Object*, intptr_t) * @see setObject(Object*, intptr_t)
* @js NA
*/ */
void setObject(Object* pObject, const std::string& key); void setObject(Object* pObject, const std::string& key);
@ -277,6 +294,7 @@ public:
* @param pObject The Object to be inserted. * @param pObject The Object to be inserted.
* @param key The string key for searching. * @param key The string key for searching.
* @see setObject(Object*, const std::string&) * @see setObject(Object*, const std::string&)
* @js NA
*/ */
void setObject(Object* pObject, intptr_t key); void setObject(Object* pObject, intptr_t key);
@ -286,6 +304,7 @@ public:
* @param key The string key for searching. * @param key The string key for searching.
* @see removeObjectForKey(intptr_t), removeObjectsForKeys(Array*), * @see removeObjectForKey(intptr_t), removeObjectsForKeys(Array*),
* removeObjectForElememt(DictElement*), removeAllObjects(). * removeObjectForElememt(DictElement*), removeAllObjects().
* @js NA
*/ */
void removeObjectForKey(const std::string& key); void removeObjectForKey(const std::string& key);
@ -295,6 +314,7 @@ public:
* @param key The integer key for searching. * @param key The integer key for searching.
* @see removeObjectForKey(const std::string&), removeObjectsForKeys(Array*), * @see removeObjectForKey(const std::string&), removeObjectsForKeys(Array*),
* removeObjectForElememt(DictElement*), removeAllObjects(). * removeObjectForElememt(DictElement*), removeAllObjects().
* @js NA
*/ */
void removeObjectForKey(intptr_t key); void removeObjectForKey(intptr_t key);
@ -304,6 +324,7 @@ public:
* @param pKeyArray The array contains keys to be removed. * @param pKeyArray The array contains keys to be removed.
* @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t), * @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t),
* removeObjectForElememt(DictElement*), removeAllObjects(). * removeObjectForElememt(DictElement*), removeAllObjects().
* @js NA
*/ */
void removeObjectsForKeys(Array* pKeyArray); void removeObjectsForKeys(Array* pKeyArray);
@ -313,6 +334,8 @@ public:
* @param pElement The element need to be removed. * @param pElement The element need to be removed.
* @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t), * @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t),
* removeObjectsForKeys(Array*), removeAllObjects(). * removeObjectsForKeys(Array*), removeAllObjects().
* @js NA
* @lua NA
*/ */
void removeObjectForElememt(DictElement* pElement); void removeObjectForElememt(DictElement* pElement);
@ -321,6 +344,7 @@ public:
* *
* @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t), * @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t),
* removeObjectsForKeys(Array*), removeObjectForElememt(DictElement*). * removeObjectsForKeys(Array*), removeObjectForElememt(DictElement*).
* @js NA
*/ */
void removeAllObjects(); void removeAllObjects();
@ -329,6 +353,8 @@ public:
* *
* @return The random object. * @return The random object.
* @see objectForKey(intptr_t), objectForKey(const std::string&) * @see objectForKey(intptr_t), objectForKey(const std::string&)
* @js NA
* @lua NA
*/ */
Object* randomObject(); Object* randomObject();
@ -336,6 +362,7 @@ public:
* Create a dictionary. * Create a dictionary.
* @return A dictionary which is an autorelease object. * @return A dictionary which is an autorelease object.
* @see createWithDictionary(Dictionary*), createWithContentsOfFile(const char*), createWithContentsOfFileThreadSafe(const char*). * @see createWithDictionary(Dictionary*), createWithContentsOfFile(const char*), createWithContentsOfFileThreadSafe(const char*).
* @js NA
*/ */
static Dictionary* create(); static Dictionary* create();
@ -345,6 +372,7 @@ public:
* @param srcDict The exist dictionary. * @param srcDict The exist dictionary.
* @return A dictionary which is an autorelease object. * @return A dictionary which is an autorelease object.
* @see create(), createWithContentsOfFile(const char*), createWithContentsOfFileThreadSafe(const char*). * @see create(), createWithContentsOfFile(const char*), createWithContentsOfFileThreadSafe(const char*).
* @js NA
*/ */
static Dictionary* createWithDictionary(Dictionary* srcDict); static Dictionary* createWithDictionary(Dictionary* srcDict);
@ -353,6 +381,7 @@ public:
* @param pFileName The name of the plist file. * @param pFileName The name of the plist file.
* @return A dictionary which is an autorelease object. * @return A dictionary which is an autorelease object.
* @see create(), createWithDictionary(Dictionary*), createWithContentsOfFileThreadSafe(const char*). * @see create(), createWithDictionary(Dictionary*), createWithContentsOfFileThreadSafe(const char*).
* @js NA
*/ */
static Dictionary* createWithContentsOfFile(const char *pFileName); static Dictionary* createWithContentsOfFile(const char *pFileName);
@ -360,6 +389,8 @@ public:
* Write a dictionary to a plist file. * Write a dictionary to a plist file.
* @param fullPath The full path of the plist file. You can get writeable path by getWritablePath() * @param fullPath The full path of the plist file. You can get writeable path by getWritablePath()
* @return true if successed, false if failed * @return true if successed, false if failed
* @js NA
* @lua NA
*/ */
bool writeToFile(const char *fullPath); bool writeToFile(const char *fullPath);
@ -373,11 +404,20 @@ public:
* *
* @param pFileName The name of the plist file. * @param pFileName The name of the plist file.
* @return A dictionary which isn't an autorelease object. * @return A dictionary which isn't an autorelease object.
* @js NA
* @lua NA
*/ */
static Dictionary* createWithContentsOfFileThreadSafe(const char *pFileName); static Dictionary* createWithContentsOfFileThreadSafe(const char *pFileName);
/* override functions */ /* override functions
* @js NA
* @lua NA
*/
virtual void acceptVisitor(DataVisitor &visitor); virtual void acceptVisitor(DataVisitor &visitor);
/**
* @js NA
* @lua NA
*/
virtual Dictionary* clone() const; virtual Dictionary* clone() const;
private: private:

View File

@ -24,6 +24,7 @@ THE SOFTWARE.
#include "CCGeometry.h" #include "CCGeometry.h"
#include "ccMacros.h" #include "ccMacros.h"
#include <algorithm>
// implementation of Point // implementation of Point
NS_CC_BEGIN NS_CC_BEGIN

View File

@ -60,28 +60,81 @@ public:
float y; float y;
public: public:
/**
* @js NA
*/
Point(); Point();
/**
* @js NA
*/
Point(float x, float y); Point(float x, float y);
/**
* @js NA
* @lua NA
*/
Point(const Point& other); Point(const Point& other);
/**
* @js NA
* @lua NA
*/
explicit Point(const Size& size); explicit Point(const Size& size);
/**
* @js NA
* @lua NA
*/
Point& operator= (const Point& other); Point& operator= (const Point& other);
/**
* @js NA
* @lua NA
*/
Point& operator= (const Size& size); Point& operator= (const Size& size);
/**
* @js NA
* @lua NA
*/
Point operator+(const Point& right) const; Point operator+(const Point& right) const;
/**
* @js NA
* @lua NA
*/
Point operator-(const Point& right) const; Point operator-(const Point& right) const;
/**
* @js NA
* @lua NA
*/
Point operator-() const; Point operator-() const;
/**
* @js NA
* @lua NA
*/
Point operator*(float a) const; Point operator*(float a) const;
/**
* @js NA
* @lua NA
*/
Point operator/(float a) const; Point operator/(float a) const;
/**
* @js NA
* @lua NA
*/
void setPoint(float x, float y); void setPoint(float x, float y);
/**
* @js NA
*/
bool equals(const Point& target) const; bool equals(const Point& target) const;
/** @returns if points have fuzzy equality which means equal with some degree of variance. /** @returns if points have fuzzy equality which means equal with some degree of variance.
@since v2.1.4 @since v2.1.4
* @js NA
* @lua NA
*/ */
bool fuzzyEquals(const Point& target, float variance) const; bool fuzzyEquals(const Point& target, float variance) const;
/** Calculates distance between point an origin /** Calculates distance between point an origin
@return float @return float
@since v2.1.4 @since v2.1.4
* @js NA
* @lua NA
*/ */
inline float getLength() const { inline float getLength() const {
return sqrtf(x*x + y*y); return sqrtf(x*x + y*y);
@ -90,6 +143,8 @@ public:
/** Calculates the square length of a Point (not calling sqrt() ) /** Calculates the square length of a Point (not calling sqrt() )
@return float @return float
@since v2.1.4 @since v2.1.4
* @js NA
* @lua NA
*/ */
inline float getLengthSq() const { inline float getLengthSq() const {
return dot(*this); //x*x + y*y; return dot(*this); //x*x + y*y;
@ -98,7 +153,9 @@ public:
/** Calculates the square distance between two points (not calling sqrt() ) /** Calculates the square distance between two points (not calling sqrt() )
@return float @return float
@since v2.1.4 @since v2.1.4
*/ * @js NA
* @lua NA
*/
inline float getDistanceSq(const Point& other) const { inline float getDistanceSq(const Point& other) const {
return (*this - other).getLengthSq(); return (*this - other).getLengthSq();
}; };
@ -106,6 +163,8 @@ public:
/** Calculates the distance between two points /** Calculates the distance between two points
@return float @return float
@since v2.1.4 @since v2.1.4
* @js NA
* @lua NA
*/ */
inline float getDistance(const Point& other) const { inline float getDistance(const Point& other) const {
return (*this - other).getLength(); return (*this - other).getLength();
@ -113,19 +172,25 @@ public:
/** @returns the angle in radians between this vector and the x axis /** @returns the angle in radians between this vector and the x axis
@since v2.1.4 @since v2.1.4
*/ * @js NA
* @lua NA
*/
inline float getAngle() const { inline float getAngle() const {
return atan2f(y, x); return atan2f(y, x);
}; };
/** @returns the angle in radians between two vector directions /** @returns the angle in radians between two vector directions
@since v2.1.4 @since v2.1.4
*/ * @js NA
* @lua NA
*/
float getAngle(const Point& other) const; float getAngle(const Point& other) const;
/** Calculates dot product of two points. /** Calculates dot product of two points.
@return float @return float
@since v2.1.4 @since v2.1.4
* @js NA
* @lua NA
*/ */
inline float dot(const Point& other) const { inline float dot(const Point& other) const {
return x*other.x + y*other.y; return x*other.x + y*other.y;
@ -134,6 +199,8 @@ public:
/** Calculates cross product of two points. /** Calculates cross product of two points.
@return float @return float
@since v2.1.4 @since v2.1.4
* @js NA
* @lua NA
*/ */
inline float cross(const Point& other) const { inline float cross(const Point& other) const {
return x*other.y - y*other.x; return x*other.y - y*other.x;
@ -142,6 +209,8 @@ public:
/** Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) >= 0 /** Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) >= 0
@return Point @return Point
@since v2.1.4 @since v2.1.4
* @js NA
* @lua NA
*/ */
inline Point getPerp() const { inline Point getPerp() const {
return Point(-y, x); return Point(-y, x);
@ -150,6 +219,8 @@ public:
/** Calculates midpoint between two points. /** Calculates midpoint between two points.
@return Point @return Point
@since v3.0 @since v3.0
* @js NA
* @lua NA
*/ */
inline Point getMidpoint(const Point& other) const inline Point getMidpoint(const Point& other) const
{ {
@ -158,6 +229,8 @@ public:
/** Clamp a point between from and to. /** Clamp a point between from and to.
@since v3.0 @since v3.0
* @js NA
* @lua NA
*/ */
inline Point getClampPoint(const Point& min_inclusive, const Point& max_inclusive) const inline Point getClampPoint(const Point& min_inclusive, const Point& max_inclusive) const
{ {
@ -170,6 +243,8 @@ public:
* For example: let's try to take the floor of x,y * For example: let's try to take the floor of x,y
* p.compOp(floorf); * p.compOp(floorf);
@since v3.0 @since v3.0
* @js NA
* @lua NA
*/ */
inline Point compOp(std::function<float(float)> function) const inline Point compOp(std::function<float(float)> function) const
{ {
@ -179,6 +254,8 @@ public:
/** Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) <= 0 /** Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) <= 0
@return Point @return Point
@since v2.1.4 @since v2.1.4
* @js NA
* @lua NA
*/ */
inline Point getRPerp() const { inline Point getRPerp() const {
return Point(y, -x); return Point(y, -x);
@ -187,6 +264,8 @@ public:
/** Calculates the projection of this over other. /** Calculates the projection of this over other.
@return Point @return Point
@since v2.1.4 @since v2.1.4
* @js NA
* @lua NA
*/ */
inline Point project(const Point& other) const { inline Point project(const Point& other) const {
return other * (dot(other)/other.dot(other)); return other * (dot(other)/other.dot(other));
@ -196,6 +275,8 @@ public:
@return Point vector with an angle of this.getAngle() + other.getAngle(), @return Point vector with an angle of this.getAngle() + other.getAngle(),
and a length of this.getLength() * other.getLength(). and a length of this.getLength() * other.getLength().
@since v2.1.4 @since v2.1.4
* @js NA
* @lua NA
*/ */
inline Point rotate(const Point& other) const { inline Point rotate(const Point& other) const {
return Point(x*other.x - y*other.y, x*other.y + y*other.x); return Point(x*other.x - y*other.y, x*other.y + y*other.x);
@ -205,6 +286,8 @@ public:
@return Point vector with an angle of this.getAngle() - other.getAngle(), @return Point vector with an angle of this.getAngle() - other.getAngle(),
and a length of this.getLength() * other.getLength(). and a length of this.getLength() * other.getLength().
@since v2.1.4 @since v2.1.4
* @js NA
* @lua NA
*/ */
inline Point unrotate(const Point& other) const { inline Point unrotate(const Point& other) const {
return Point(x*other.x + y*other.y, y*other.x - x*other.y); return Point(x*other.x + y*other.y, y*other.x - x*other.y);
@ -214,6 +297,8 @@ public:
* If the point is 0, it returns (1, 0) * If the point is 0, it returns (1, 0)
@return Point @return Point
@since v2.1.4 @since v2.1.4
* @js NA
* @lua NA
*/ */
inline Point normalize() const { inline Point normalize() const {
float length = getLength(); float length = getLength();
@ -227,6 +312,8 @@ public:
alpha == 1 ? b alpha == 1 ? b
otherwise a value between a..b otherwise a value between a..b
@since v2.1.4 @since v2.1.4
* @js NA
* @lua NA
*/ */
inline Point lerp(const Point& other, float alpha) const { inline Point lerp(const Point& other, float alpha) const {
return *this * (1.f - alpha) + other * alpha; return *this * (1.f - alpha) + other * alpha;
@ -237,9 +324,15 @@ public:
@param angle is the angle of rotation ccw in radians @param angle is the angle of rotation ccw in radians
@returns the rotated point @returns the rotated point
@since v2.1.4 @since v2.1.4
* @js NA
* @lua NA
*/ */
Point rotateByAngle(const Point& pivot, float angle) const; Point rotateByAngle(const Point& pivot, float angle) const;
/**
* @js NA
* @lua NA
*/
static inline Point forAngle(const float a) static inline Point forAngle(const float a)
{ {
return Point(cosf(a), sinf(a)); return Point(cosf(a), sinf(a));
@ -259,42 +352,54 @@ public:
the hit point is C + T * (D - C); the hit point is C + T * (D - C);
the hit point also is A + S * (B - A); the hit point also is A + S * (B - A);
@since 3.0 @since 3.0
* @js NA
* @lua NA
*/ */
static bool isLineIntersect(const Point& A, const Point& B, static bool isLineIntersect(const Point& A, const Point& B,
const Point& C, const Point& D, const Point& C, const Point& D,
float *S = nullptr, float *T = nullptr); float *S = nullptr, float *T = nullptr);
/* /**
returns true if Line A-B overlap with segment C-D returns true if Line A-B overlap with segment C-D
@since v3.0 @since v3.0
* @js NA
* @lua NA
*/ */
static bool isLineOverlap(const Point& A, const Point& B, static bool isLineOverlap(const Point& A, const Point& B,
const Point& C, const Point& D); const Point& C, const Point& D);
/* /**
returns true if Line A-B parallel with segment C-D returns true if Line A-B parallel with segment C-D
@since v3.0 @since v3.0
* @js NA
* @lua NA
*/ */
static bool isLineParallel(const Point& A, const Point& B, static bool isLineParallel(const Point& A, const Point& B,
const Point& C, const Point& D); const Point& C, const Point& D);
/* /**
returns true if Segment A-B overlap with segment C-D returns true if Segment A-B overlap with segment C-D
@since v3.0 @since v3.0
* @js NA
* @lua NA
*/ */
static bool isSegmentOverlap(const Point& A, const Point& B, static bool isSegmentOverlap(const Point& A, const Point& B,
const Point& C, const Point& D, const Point& C, const Point& D,
Point* S = nullptr, Point* E = nullptr); Point* S = nullptr, Point* E = nullptr);
/* /**
returns true if Segment A-B intersects with segment C-D returns true if Segment A-B intersects with segment C-D
@since v3.0 @since v3.0
* @js NA
* @lua NA
*/ */
static bool isSegmentIntersect(const Point& A, const Point& B, const Point& C, const Point& D); static bool isSegmentIntersect(const Point& A, const Point& B, const Point& C, const Point& D);
/* /**
returns the intersection point of line A-B, C-D returns the intersection point of line A-B, C-D
@since v3.0 @since v3.0
* @js NA
* @lua NA
*/ */
static Point getIntersectPoint(const Point& A, const Point& B, const Point& C, const Point& D); static Point getIntersectPoint(const Point& A, const Point& B, const Point& C, const Point& D);
@ -315,17 +420,62 @@ public:
float height; float height;
public: public:
/**
* @js NA
*/
Size(); Size();
/**
* @js NA
*/
Size(float width, float height); Size(float width, float height);
/**
* @js NA
* @lua NA
*/
Size(const Size& other); Size(const Size& other);
/**
* @js NA
* @lua NA
*/
explicit Size(const Point& point); explicit Size(const Point& point);
/**
* @js NA
* @lua NA
*/
Size& operator= (const Size& other); Size& operator= (const Size& other);
/**
* @js NA
* @lua NA
*/
Size& operator= (const Point& point); Size& operator= (const Point& point);
/**
* @js NA
* @lua NA
*/
Size operator+(const Size& right) const; Size operator+(const Size& right) const;
/**
* @js NA
* @lua NA
*/
Size operator-(const Size& right) const; Size operator-(const Size& right) const;
/**
* @js NA
* @lua NA
*/
Size operator*(float a) const; Size operator*(float a) const;
/**
* @js NA
* @lua NA
*/
Size operator/(float a) const; Size operator/(float a) const;
/**
* @js NA
* @lua NA
*/
void setSize(float width, float height); void setSize(float width, float height);
/**
* @js NA
*/
bool equals(const Size& target) const; bool equals(const Size& target) const;
static const Size ZERO; static const Size ZERO;
@ -338,20 +488,69 @@ public:
Size size; Size size;
public: public:
/**
* @js NA
*/
Rect(); Rect();
/**
* @js NA
*/
Rect(float x, float y, float width, float height); Rect(float x, float y, float width, float height);
/**
* @js NA
* @lua NA
*/
Rect(const Rect& other); Rect(const Rect& other);
/**
* @js NA
* @lua NA
*/
Rect& operator= (const Rect& other); Rect& operator= (const Rect& other);
/**
* @js NA
* @lua NA
*/
void setRect(float x, float y, float width, float height); void setRect(float x, float y, float width, float height);
/**
* @js NA
*/
float getMinX() const; /// return the leftmost x-value of current rect float getMinX() const; /// return the leftmost x-value of current rect
/**
* @js NA
*/
float getMidX() const; /// return the midpoint x-value of current rect float getMidX() const; /// return the midpoint x-value of current rect
/**
* @js NA
*/
float getMaxX() const; /// return the rightmost x-value of current rect float getMaxX() const; /// return the rightmost x-value of current rect
/**
* @js NA
*/
float getMinY() const; /// return the bottommost y-value of current rect float getMinY() const; /// return the bottommost y-value of current rect
/**
* @js NA
*/
float getMidY() const; /// return the midpoint y-value of current rect float getMidY() const; /// return the midpoint y-value of current rect
/**
* @js NA
*/
float getMaxY() const; /// return the topmost y-value of current rect float getMaxY() const; /// return the topmost y-value of current rect
bool equals(const Rect& rect) const; /**
* @js NA
*/
bool equals(const Rect& rect) const;
/**
* @js NA
*/
bool containsPoint(const Point& point) const; bool containsPoint(const Point& point) const;
/**
* @js NA
*/
bool intersectsRect(const Rect& rect) const; bool intersectsRect(const Rect& rect) const;
/**
* @js NA
* @lua NA
*/
Rect unionWithRect(const Rect & rect) const; Rect unionWithRect(const Rect & rect) const;
static const Rect ZERO; static const Rect ZERO;

View File

@ -44,11 +44,16 @@ public:
pRet->autorelease(); pRet->autorelease();
return pRet; return pRet;
} }
/**
* @js NA
*/
Integer(int v) Integer(int v)
: _value(v) {} : _value(v) {}
int getValue() const {return _value;} int getValue() const {return _value;}
/**
* @js NA
* @lua NA
*/
virtual ~Integer() { virtual ~Integer() {
CCLOGINFO("deallocing ~Integer: %p", this); CCLOGINFO("deallocing ~Integer: %p", this);
} }

View File

@ -49,6 +49,10 @@ class CC_DLL Clonable
public: public:
/** returns a copy of the object */ /** returns a copy of the object */
virtual Clonable* clone() const = 0; virtual Clonable* clone() const = 0;
/**
* @js NA
* @lua NA
*/
virtual ~Clonable() {}; virtual ~Clonable() {};
/** returns a copy of the object. /** returns a copy of the object.
@ -79,9 +83,14 @@ public:
* Constructor * Constructor
* *
* The object's reference count is 1 after construction. * The object's reference count is 1 after construction.
* @js NA
*/ */
Object(); Object();
/**
* @js NA
* @lua NA
*/
virtual ~Object(); virtual ~Object();
/** /**
@ -93,6 +102,7 @@ public:
* destructed. * destructed.
* *
* @see retain, autorelease * @see retain, autorelease
* @js NA
*/ */
inline void release() inline void release()
{ {
@ -109,6 +119,7 @@ public:
* This increases the object's reference count. * This increases the object's reference count.
* *
* @see release, autorelease * @see release, autorelease
* @js NA
*/ */
inline void retain() inline void retain()
{ {
@ -128,6 +139,8 @@ public:
* @returns The object itself. * @returns The object itself.
* *
* @see AutoreleasePool, retain, release * @see AutoreleasePool, retain, release
* @js NA
* @lua NA
*/ */
Object* autorelease(); Object* autorelease();
@ -136,6 +149,7 @@ public:
* reference to the object. That is, whether the reference count is 1. * reference to the object. That is, whether the reference count is 1.
* *
* @returns Whether the object's reference count is 1. * @returns Whether the object's reference count is 1.
* @js NA
*/ */
bool isSingleReference() const; bool isSingleReference() const;
@ -143,6 +157,7 @@ public:
* Returns the object's current reference count. * Returns the object's current reference count.
* *
* @returns The object's reference count. * @returns The object's reference count.
* @js NA
*/ */
unsigned int retainCount() const; unsigned int retainCount() const;
@ -153,11 +168,19 @@ public:
* @param object The object to be compared to this object. * @param object The object to be compared to this object.
* *
* @returns True if this object and @p object are equal, otherwise false. * @returns True if this object and @p object are equal, otherwise false.
* @js NA
* @lua NA
*/ */
virtual bool isEqual(const Object* object); virtual bool isEqual(const Object* object);
/**
* @js NA
* @lua NA
*/
virtual void acceptVisitor(DataVisitor &visitor); virtual void acceptVisitor(DataVisitor &visitor);
/**
* @js NA
* @lua NA
*/
virtual void update(float dt) {CC_UNUSED_PARAM(dt);}; virtual void update(float dt) {CC_UNUSED_PARAM(dt);};
friend class AutoreleasePool; friend class AutoreleasePool;

View File

@ -40,8 +40,15 @@ typedef std::set<Object *>::iterator SetIterator;
class CC_DLL Set : public Object class CC_DLL Set : public Object
{ {
public: public:
/**
* @js ctor
*/
Set(void); Set(void);
Set(const Set &rSetObject); Set(const Set &rSetObject);
/**
* @js NA
* @lua NA
*/
virtual ~Set(void); virtual ~Set(void);
/** /**
@ -79,17 +86,24 @@ public:
bool containsObject(Object *pObject); bool containsObject(Object *pObject);
/** /**
*@brief Return the iterator that points to the first element. *@brief Return the iterator that points to the first element.
* @js NA
* @lua NA
*/ */
SetIterator begin(); SetIterator begin();
/** /**
*@brief Return the iterator that points to the position after the last element. *@brief Return the iterator that points to the position after the last element.
* @js NA
* @lua NA
*/ */
SetIterator end(); SetIterator end();
/** /**
*@brief Return the first element if it contains elements, or null if it doesn't contain any element. *@brief Return the first element if it contains elements, or null if it doesn't contain any element.
*/ */
Object* anyObject(); Object* anyObject();
/**
* @js NA
* @lua NA
*/
virtual void acceptVisitor(DataVisitor &visitor); virtual void acceptVisitor(DataVisitor &visitor);
private: private:

View File

@ -43,58 +43,111 @@ NS_CC_BEGIN
class CC_DLL String : public Object, public Clonable class CC_DLL String : public Object, public Clonable
{ {
public: public:
/**
* @js NA
* @lua NA
*/
String(); String();
/**
* @js NA
* @lua NA
*/
String(const char* str); String(const char* str);
/**
* @js NA
* @lua NA
*/
String(const std::string& str); String(const std::string& str);
/**
* @js NA
* @lua NA
*/
String(const String& str); String(const String& str);
/**
* @js NA
* @lua NA
*/
virtual ~String(); virtual ~String();
/* override assignment operator */ /* override assignment operator
* @js NA
* @lua NA
*/
String& operator= (const String& other); String& operator= (const String& other);
/** init a string with format, it's similar with the c function 'sprintf' */ /** init a string with format, it's similar with the c function 'sprintf'
* @js NA
* @lua NA
*/
bool initWithFormat(const char* format, ...) CC_FORMAT_PRINTF(2, 3); bool initWithFormat(const char* format, ...) CC_FORMAT_PRINTF(2, 3);
/** convert to int value */ /** convert to int value
* @js NA
*/
int intValue() const; int intValue() const;
/** convert to unsigned int value */ /** convert to unsigned int value
* @js NA
*/
unsigned int uintValue() const; unsigned int uintValue() const;
/** convert to float value */ /** convert to float value
* @js NA
*/
float floatValue() const; float floatValue() const;
/** convert to double value */ /** convert to double value
* @js NA
*/
double doubleValue() const; double doubleValue() const;
/** convert to bool value */ /** convert to bool value
* @js NA
*/
bool boolValue() const; bool boolValue() const;
/** get the C string */ /** get the C string
* @js NA
*/
const char* getCString() const; const char* getCString() const;
/** get the length of string */ /** get the length of string
* @js NA
*/
unsigned int length() const; unsigned int length() const;
/** compare to a c string */ /** compare to a c string
* @js NA
*/
int compare(const char *) const; int compare(const char *) const;
/** append additional characters at the end of its current value */ /** append additional characters at the end of its current value
* @js NA
* @lua NA
*/
void append(const std::string& str); void append(const std::string& str);
/** append(w/ format) additional characters at the end of its current value */ /** append(w/ format) additional characters at the end of its current value
* @js NA
* @lua NA
*/
void appendWithFormat(const char* format, ...); void appendWithFormat(const char* format, ...);
/** split a string */ /** split a string
* @js NA
* @lua NA
*/
Array* componentsSeparatedByString(const char *delimiter); Array* componentsSeparatedByString(const char *delimiter);
/* override functions */ /* override functions
* @js NA
*/
virtual bool isEqual(const Object* pObject); virtual bool isEqual(const Object* pObject);
/** create a string with std string, you can also pass a c string pointer because the default constructor of std::string can access a c string pointer. /** create a string with std string, you can also pass a c string pointer because the default constructor of std::string can access a c string pointer.
* @return A String pointer which is an autorelease object pointer, * @return A String pointer which is an autorelease object pointer,
* it means that you needn't do a release operation unless you retain it. * it means that you needn't do a release operation unless you retain it.
* @js NA
*/ */
static String* create(const std::string& str); static String* create(const std::string& str);
@ -102,22 +155,32 @@ public:
* if you want to change it, you should modify the kMaxStringLen macro in String.cpp file. * if you want to change it, you should modify the kMaxStringLen macro in String.cpp file.
* @return A String pointer which is an autorelease object pointer, * @return A String pointer which is an autorelease object pointer,
* it means that you needn't do a release operation unless you retain it. * it means that you needn't do a release operation unless you retain it.
*/ * @js NA
*/
static String* createWithFormat(const char* format, ...) CC_FORMAT_PRINTF(1, 2); static String* createWithFormat(const char* format, ...) CC_FORMAT_PRINTF(1, 2);
/** create a string with binary data /** create a string with binary data
* @return A String pointer which is an autorelease object pointer, * @return A String pointer which is an autorelease object pointer,
* it means that you needn't do a release operation unless you retain it. * it means that you needn't do a release operation unless you retain it.
* @js NA
*/ */
static String* createWithData(const unsigned char* pData, unsigned long nLen); static String* createWithData(const unsigned char* pData, unsigned long nLen);
/** create a string with a file, /** create a string with a file,
* @return A String pointer which is an autorelease object pointer, * @return A String pointer which is an autorelease object pointer,
* it means that you needn't do a release operation unless you retain it. * it means that you needn't do a release operation unless you retain it.
* @js NA
*/ */
static String* createWithContentsOfFile(const char* filename); static String* createWithContentsOfFile(const char* filename);
/**
* @js NA
* @lua NA
*/
virtual void acceptVisitor(DataVisitor &visitor); virtual void acceptVisitor(DataVisitor &visitor);
/**
* @js NA
* @lua NA
*/
virtual String* clone() const; virtual String* clone() const;
private: private:

View File

@ -46,7 +46,14 @@ class CC_DLL DrawNode : public Node
public: public:
/** creates and initialize a DrawNode node */ /** creates and initialize a DrawNode node */
static DrawNode* create(); static DrawNode* create();
/**
* @js ctor
*/
DrawNode(); DrawNode();
/**
* @js NA
* @lua NA
*/
virtual ~DrawNode(); virtual ~DrawNode();
virtual bool init(); virtual bool init();
@ -57,17 +64,35 @@ public:
/** draw a segment with a radius and color */ /** draw a segment with a radius and color */
void drawSegment(const Point &from, const Point &to, float radius, const Color4F &color); void drawSegment(const Point &from, const Point &to, float radius, const Color4F &color);
/** draw a polygon with a fill color and line color */ /** draw a polygon with a fill color and line color
* @code
* When this function bound into js or lua,the parameter will be changed
* In js: var drawPolygon(var Arrayofpoints, var fillColor, var width, var borderColor)
* In lua:local drawPolygon(local pointTable,local tableCount,local fillColor,local width,local borderColor)
* @endcode
*/
void drawPolygon(Point *verts, unsigned int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor); void drawPolygon(Point *verts, unsigned int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor);
/** Clear the geometry in the node's buffer. */ /** Clear the geometry in the node's buffer. */
void clear(); void clear();
/**
* @js NA
* @lua NA
*/
const BlendFunc& getBlendFunc() const; const BlendFunc& getBlendFunc() const;
/**
* @code
* When this function bound into js or lua,the parameter will be changed
* In js: var setBlendFunc(var src, var dst)
* @endcode
* @lua NA
*/
void setBlendFunc(const BlendFunc &blendFunc); void setBlendFunc(const BlendFunc &blendFunc);
/** listen the event that coming to foreground on Android /** listen the event that coming to foreground on Android
*/ * @js NA
* @lua NA
*/
void listenBackToForeground(Object *obj); void listenBackToForeground(Object *obj);
// Overrides // Overrides

View File

@ -42,7 +42,14 @@ class Texture2D;
class Grabber : public Object class Grabber : public Object
{ {
public: public:
/**
* @js ctor
*/
Grabber(void); Grabber(void);
/**
* @js NA
* @lua NA
*/
~Grabber(void); ~Grabber(void);
void grab(Texture2D *texture); void grab(Texture2D *texture);

View File

@ -56,7 +56,10 @@ public:
static GridBase* create(const Size& gridSize, Texture2D *texture, bool flipped); static GridBase* create(const Size& gridSize, Texture2D *texture, bool flipped);
/** create one Grid */ /** create one Grid */
static GridBase* create(const Size& gridSize); static GridBase* create(const Size& gridSize);
/**
* @js NA
* @lua NA
*/
virtual ~GridBase(void); virtual ~GridBase(void);
bool initWithSize(const Size& gridSize, Texture2D *texture, bool bFlipped); bool initWithSize(const Size& gridSize, Texture2D *texture, bool bFlipped);
@ -115,20 +118,41 @@ public:
static Grid3D* create(const Size& gridSize, Texture2D *texture, bool bFlipped); static Grid3D* create(const Size& gridSize, Texture2D *texture, bool bFlipped);
/** create one Grid */ /** create one Grid */
static Grid3D* create(const Size& gridSize); static Grid3D* create(const Size& gridSize);
/**
* @js ctor
*/
Grid3D(); Grid3D();
/**
* @js NA
* @lua NA
*/
~Grid3D(void); ~Grid3D(void);
/** returns the vertex at a given position */ /** returns the vertex at a given position
* @js NA
* @lua NA
*/
Vertex3F getVertex(const Point& pos) const; Vertex3F getVertex(const Point& pos) const;
/** @deprecated Use getVertex() instead */ /** @deprecated Use getVertex() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE Vertex3F vertex(const Point& pos) const { return getVertex(pos); } CC_DEPRECATED_ATTRIBUTE Vertex3F vertex(const Point& pos) const { return getVertex(pos); }
/** returns the original (non-transformed) vertex at a given position */ /** returns the original (non-transformed) vertex at a given position
* @js NA
* @lua NA
*/
Vertex3F getOriginalVertex(const Point& pos) const; Vertex3F getOriginalVertex(const Point& pos) const;
/** @deprecated Use getOriginalVertex() instead */ /** @deprecated Use getOriginalVertex() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE Vertex3F originalVertex(const Point& pos) const { return getOriginalVertex(pos); } CC_DEPRECATED_ATTRIBUTE Vertex3F originalVertex(const Point& pos) const { return getOriginalVertex(pos); }
/** sets a new vertex at a given position */ /** sets a new vertex at a given position
* @js NA
* @lua NA
*/
void setVertex(const Point& pos, const Vertex3F& vertex); void setVertex(const Point& pos, const Vertex3F& vertex);
// Overrides // Overrides
@ -157,20 +181,41 @@ public:
static TiledGrid3D* create(const Size& gridSize, Texture2D *texture, bool bFlipped); static TiledGrid3D* create(const Size& gridSize, Texture2D *texture, bool bFlipped);
/** create one Grid */ /** create one Grid */
static TiledGrid3D* create(const Size& gridSize); static TiledGrid3D* create(const Size& gridSize);
/**
* @js ctor
*/
TiledGrid3D(); TiledGrid3D();
/**
* @js NA
* @lua NA
*/
~TiledGrid3D(); ~TiledGrid3D();
/** returns the tile at the given position */ /** returns the tile at the given position
* @js NA
* @lua NA
*/
Quad3 getTile(const Point& pos) const; Quad3 getTile(const Point& pos) const;
/** returns the tile at the given position */ /** returns the tile at the given position
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Point& pos) const { return getTile(pos); } CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Point& pos) const { return getTile(pos); }
/** returns the original tile (untransformed) at the given position */ /** returns the original tile (untransformed) at the given position
* @js NA
* @lua NA
*/
Quad3 getOriginalTile(const Point& pos) const; Quad3 getOriginalTile(const Point& pos) const;
/** returns the original tile (untransformed) at the given position */ /** returns the original tile (untransformed) at the given position
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Point& pos) const { return getOriginalTile(pos); } CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Point& pos) const { return getOriginalTile(pos); }
/** sets a new tile */ /** sets a new tile
* @js NA
* @lua NA
*/
void setTile(const Point& pos, const Quad3& coords); void setTile(const Point& pos, const Quad3& coords);
// Overrides // Overrides

View File

@ -42,6 +42,8 @@ public:
* Changes the color with R,G,B bytes * Changes the color with R,G,B bytes
* *
* @param color Example: Color3B(255,100,0) means R=255, G=100, B=0 * @param color Example: Color3B(255,100,0) means R=255, G=100, B=0
* @js NA
* @lua NA
*/ */
virtual void setColor(const Color3B& color) = 0; virtual void setColor(const Color3B& color) = 0;
@ -49,6 +51,8 @@ public:
* Returns color that is currently used. * Returns color that is currently used.
* *
* @return The Color3B contains R,G,B bytes. * @return The Color3B contains R,G,B bytes.
* @js NA
* @lua NA
*/ */
virtual const Color3B& getColor() const = 0; virtual const Color3B& getColor() const = 0;
@ -56,6 +60,8 @@ public:
* Returns the displayed color. * Returns the displayed color.
* *
* @return The Color3B contains R,G,B bytes. * @return The Color3B contains R,G,B bytes.
* @js NA
* @lua NA
*/ */
virtual const Color3B& getDisplayedColor() const = 0; virtual const Color3B& getDisplayedColor() const = 0;
@ -63,6 +69,8 @@ public:
* Returns the displayed opacity. * Returns the displayed opacity.
* *
* @return The opacity of sprite, from 0 ~ 255 * @return The opacity of sprite, from 0 ~ 255
* @js NA
* @lua NA
*/ */
virtual GLubyte getDisplayedOpacity() const = 0; virtual GLubyte getDisplayedOpacity() const = 0;
/** /**
@ -72,6 +80,8 @@ public:
* 0 indicates fully transparent and 255 is fully opaque. * 0 indicates fully transparent and 255 is fully opaque.
* *
* @return The opacity of sprite, from 0 ~ 255 * @return The opacity of sprite, from 0 ~ 255
* @js NA
* @lua NA
*/ */
virtual GLubyte getOpacity() const = 0; virtual GLubyte getOpacity() const = 0;
@ -79,6 +89,8 @@ public:
* Changes the opacity. * Changes the opacity.
* *
* @param opacity Goes from 0 to 255, where 255 means fully opaque and 0 means fully transparent. * @param opacity Goes from 0 to 255, where 255 means fully opaque and 0 means fully transparent.
* @js NA
* @lua NA
*/ */
virtual void setOpacity(GLubyte opacity) = 0; virtual void setOpacity(GLubyte opacity) = 0;
@ -91,6 +103,8 @@ public:
* *
* @param value If true, then the opacity will be applied as: glColor(R,G,B,opacity); * @param value If true, then the opacity will be applied as: glColor(R,G,B,opacity);
* If false, then the opacity will be applied as: glColor(opacity, opacity, opacity, opacity); * If false, then the opacity will be applied as: glColor(opacity, opacity, opacity, opacity);
* @js NA
* @lua NA
*/ */
virtual void setOpacityModifyRGB(bool value) = 0; virtual void setOpacityModifyRGB(bool value) = 0;
@ -99,28 +113,46 @@ public:
* or glColor(opacity, opacity, opacity, opacity) * or glColor(opacity, opacity, opacity, opacity)
* *
* @return Returns opacity modify flag. * @return Returns opacity modify flag.
* @js NA
* @lua NA
*/ */
virtual bool isOpacityModifyRGB() const = 0; virtual bool isOpacityModifyRGB() const = 0;
/** /**
* whether or not color should be propagated to its children. * whether or not color should be propagated to its children.
* @js NA
* @lua NA
*/ */
virtual bool isCascadeColorEnabled() const = 0; virtual bool isCascadeColorEnabled() const = 0;
/**
* @js NA
* @lua NA
*/
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) = 0; virtual void setCascadeColorEnabled(bool cascadeColorEnabled) = 0;
/** /**
* recursive method that updates display color * recursive method that updates display color
* @js NA
* @lua NA
*/ */
virtual void updateDisplayedColor(const Color3B& color) = 0; virtual void updateDisplayedColor(const Color3B& color) = 0;
/** /**
* whether or not opacity should be propagated to its children. * whether or not opacity should be propagated to its children.
* @js NA
* @lua NA
*/ */
virtual bool isCascadeOpacityEnabled() const = 0; virtual bool isCascadeOpacityEnabled() const = 0;
/**
* @js NA
* @lua NA
*/
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) = 0; virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) = 0;
/** /**
* recursive method that updates the displayed opacity. * recursive method that updates the displayed opacity.
* @js NA
* @lua NA
*/ */
virtual void updateDisplayedOpacity(GLubyte opacity) = 0; virtual void updateDisplayedOpacity(GLubyte opacity) = 0;
}; };
@ -138,7 +170,8 @@ public:
* *
* @param blendFunc A structure with source and destination factor to specify pixel arithmetic, * @param blendFunc A structure with source and destination factor to specify pixel arithmetic,
* e.g. {GL_ONE, GL_ONE}, {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}. * e.g. {GL_ONE, GL_ONE}, {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}.
* * @js NA
* @lua NA
*/ */
virtual void setBlendFunc(const BlendFunc &blendFunc) = 0; virtual void setBlendFunc(const BlendFunc &blendFunc) = 0;
@ -146,6 +179,8 @@ public:
* Returns the blending function that is currently being used. * Returns the blending function that is currently being used.
* *
* @return A BlendFunc structure with source and destination factor which specified pixel arithmetic. * @return A BlendFunc structure with source and destination factor which specified pixel arithmetic.
* @js NA
* @lua NA
*/ */
virtual const BlendFunc &getBlendFunc() const = 0; virtual const BlendFunc &getBlendFunc() const = 0;
}; };
@ -166,6 +201,8 @@ public:
* Returns the currently used texture * Returns the currently used texture
* *
* @return The texture that is currenlty being used. * @return The texture that is currenlty being used.
* @js NA
* @lua NA
*/ */
virtual Texture2D* getTexture() const = 0; virtual Texture2D* getTexture() const = 0;
@ -173,6 +210,8 @@ public:
* Sets a new texuture. It will be retained. * Sets a new texuture. It will be retained.
* *
* @param texture A valid Texture2D object, which will be applied to this sprite object. * @param texture A valid Texture2D object, which will be applied to this sprite object.
* @js NA
* @lua NA
*/ */
virtual void setTexture(Texture2D *texture) = 0; virtual void setTexture(Texture2D *texture) = 0;
}; };
@ -187,6 +226,8 @@ public:
* Sets a new label using an string * Sets a new label using an string
* *
* @param label A null terminated string * @param label A null terminated string
* @js NA
* @lua NA
*/ */
virtual void setString(const char *label) = 0; virtual void setString(const char *label) = 0;
@ -194,6 +235,8 @@ public:
* Returns the string that is currently being used in this label * Returns the string that is currently being used in this label
* *
* @return The string that is currently being used in this label * @return The string that is currently being used in this label
* @js NA
* @lua NA
*/ */
virtual const char* getString() const = 0; virtual const char* getString() const = 0;
}; };
@ -206,6 +249,8 @@ class CC_DLL DirectorDelegate
public: public:
/** /**
* Will be called by Director when the projection is updated, and "custom" projection is used * Will be called by Director when the projection is updated, and "custom" projection is used
* @js NA
* @lua NA
*/ */
virtual void updateProjection() = 0; virtual void updateProjection() = 0;
}; };

View File

@ -427,7 +427,10 @@ public:
struct FontDefinition struct FontDefinition
{ {
public: public:
/**
* @js NA
* @lua NA
*/
FontDefinition() FontDefinition()
: _fontSize(0) : _fontSize(0)
, _alignment(TextHAlignment::CENTER) , _alignment(TextHAlignment::CENTER)

View File

@ -45,7 +45,14 @@ typedef std::function<void(int)> KeyboardDelegate;
class CC_DLL KeyboardDispatcher : public Object class CC_DLL KeyboardDispatcher : public Object
{ {
public: public:
/**
* @js ctor
*/
KeyboardDispatcher(); KeyboardDispatcher();
/**
* @js NA
* @lua NA
*/
~KeyboardDispatcher(); ~KeyboardDispatcher();
/** /**

View File

@ -38,10 +38,17 @@ NS_CC_BEGIN
class CC_DLL KeypadDelegate class CC_DLL KeypadDelegate
{ {
public: public:
// The back key clicked /** The back key clicked
* @js NA
* @lua NA
*/
virtual void keyBackClicked() {} virtual void keyBackClicked() {}
// The menu key clicked. only available on wophone & android /** The menu key clicked. only available on wophone & android
* @js NA
* @lua NA
*/
virtual void keyMenuClicked() {}; virtual void keyMenuClicked() {};
}; };
@ -53,17 +60,34 @@ Object than contains the KeypadDelegate.
class CC_DLL KeypadHandler : public Object class CC_DLL KeypadHandler : public Object
{ {
public: public:
/**
* @js NA
* @lua NA
*/
virtual ~KeypadHandler(void); virtual ~KeypadHandler(void);
/** delegate */ /** delegate
* @js NA
* @lua NA
*/
KeypadDelegate* getDelegate(); KeypadDelegate* getDelegate();
/**
* @js NA
* @lua NA
*/
void setDelegate(KeypadDelegate *pDelegate); void setDelegate(KeypadDelegate *pDelegate);
/** initializes a KeypadHandler with a delegate */ /** initializes a KeypadHandler with a delegate
* @js NA
* @lua NA
*/
virtual bool initWithDelegate(KeypadDelegate *pDelegate); virtual bool initWithDelegate(KeypadDelegate *pDelegate);
public: public:
/** allocates a KeypadHandler with a delegate */ /** allocates a KeypadHandler with a delegate
* @js NA
* @lua NA
*/
static KeypadHandler* handlerWithDelegate(KeypadDelegate *pDelegate); static KeypadHandler* handlerWithDelegate(KeypadDelegate *pDelegate);
protected: protected:

View File

@ -49,7 +49,14 @@ struct _ccCArray;
class CC_DLL KeypadDispatcher : public Object class CC_DLL KeypadDispatcher : public Object
{ {
public: public:
/**
* @js ctor
*/
KeypadDispatcher(); KeypadDispatcher();
/**
* @js NA
* @lua NA
*/
~KeypadDispatcher(); ~KeypadDispatcher();
/** /**

View File

@ -39,7 +39,7 @@ Font::Font() : _usedGlyphs(GlyphCollection::ASCII), _customGlyphs(nullptr)
{ {
} }
const char * Font::getGlyphCollection(GlyphCollection glyphs) const char * Font::getGlyphCollection(GlyphCollection glyphs) const
{ {
switch (glyphs) switch (glyphs)
{ {
@ -85,7 +85,7 @@ void Font::setCurrentGlyphCollection(GlyphCollection glyphs, const char *customG
} }
} }
const char * Font::getCurrentGlyphCollection() const char * Font::getCurrentGlyphCollection() const
{ {
if (_customGlyphs) if (_customGlyphs)
{ {
@ -107,9 +107,9 @@ Font* Font::createWithFNT(const char* fntFilePath)
return FontFNT::create(fntFilePath); return FontFNT::create(fntFilePath);
} }
unsigned short int * Font::getUTF16Text(const char *pText, int &outNumLetters) unsigned short int * Font::getUTF16Text(const char *text, int &outNumLetters) const
{ {
unsigned short* utf16String = cc_utf8_to_utf16(pText); unsigned short* utf16String = cc_utf8_to_utf16(text);
if(!utf16String) if(!utf16String)
return 0; return 0;
@ -118,28 +118,28 @@ unsigned short int * Font::getUTF16Text(const char *pText, int &outNumLetters)
return utf16String; return utf16String;
} }
int Font::getUTF16TextLenght(unsigned short int *pText) int Font::getUTF16TextLenght(unsigned short int *text) const
{ {
return cc_wcslen(pText); return cc_wcslen(text);
} }
unsigned short int * Font::trimUTF16Text(unsigned short int *pText, int newBegin, int newEnd) unsigned short int * Font::trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const
{ {
if ( newBegin<0 || newEnd<=0 ) if ( newBegin < 0 || newEnd <= 0 )
return 0; return 0;
if ( newBegin>=newEnd ) if ( newBegin >= newEnd )
return 0; return 0;
if (newEnd >= cc_wcslen(pText)) if (newEnd >= cc_wcslen(text))
return 0; return 0;
int newLenght = newEnd - newBegin + 2; int newLenght = newEnd - newBegin + 2;
unsigned short* trimmedString = new unsigned short[newLenght]; unsigned short* trimmedString = new unsigned short[newLenght];
for(int c = 0; c < (newLenght-1); ++c) for(int c = 0; c < (newLenght - 1); ++c)
{ {
trimmedString[c] = pText[newBegin + c]; trimmedString[c] = text[newBegin + c];
} }
// last char // last char
@ -149,15 +149,9 @@ unsigned short int * Font::trimUTF16Text(unsigned short int *pText, int newBegi
return trimmedString; return trimmedString;
} }
Rect Font::getRectForChar(unsigned short theChar) Rect Font::getRectForChar(unsigned short theChar) const
{ {
Rect temp; return Rect::ZERO;
temp.size.width = 0;
temp.size.height = 0;
temp.origin.x = 0;
temp.origin.y = 0;
return temp;
} }
NS_CC_END NS_CC_END

View File

@ -47,25 +47,29 @@ public:
virtual FontAtlas *createFontAtlas() = 0; virtual FontAtlas *createFontAtlas() = 0;
virtual Size * getAdvancesForTextUTF16(unsigned short *pText, int &outNumLetters) = 0; virtual Size * getAdvancesForTextUTF16(unsigned short *text, int &outNumLetters) const = 0;
virtual const char * getCurrentGlyphCollection(); virtual const char * getCurrentGlyphCollection() const;
virtual int getLetterPadding() { return 0; } virtual int getLetterPadding() const { return 0; }
virtual unsigned char * getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) { return 0; } virtual unsigned char * getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) const { return 0; }
virtual GlyphDef * getGlyphDefintionsForText(const char *pText, int &outNumGlyphs, bool UTF16text = false) { return 0; } virtual GlyphDef * getGlyphDefintionsForText(const char *text, int &outNumGlyphs, bool UTF16text = false) const { return 0; }
virtual int getFontMaxHeight() { return 0; } virtual int getFontMaxHeight() const { return 0; }
virtual Rect getRectForChar(unsigned short theChar); virtual Rect getRectForChar(unsigned short theChar) const;
virtual int getUTF16TextLenght(unsigned short int *pText); virtual int getUTF16TextLenght(unsigned short int *text) const;
virtual unsigned short int * getUTF16Text(const char *pText, int &outNumLetters); virtual unsigned short int * getUTF16Text(const char *text, int &outNumLetters) const;
virtual unsigned short int * trimUTF16Text(unsigned short int *pText, int newBegin, int newEnd); virtual unsigned short int * trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const;
protected: protected:
Font(); Font();
/**
* @js NA
* @lua NA
*/
virtual ~Font() {} virtual ~Font() {}
void setCurrentGlyphCollection(GlyphCollection glyphs, const char *customGlyphs = 0); void setCurrentGlyphCollection(GlyphCollection glyphs, const char *customGlyphs = 0);
const char * getGlyphCollection(GlyphCollection glyphs); const char * getGlyphCollection(GlyphCollection glyphs) const;
private: private:

View File

@ -62,7 +62,7 @@ Texture2D & FontAtlas::getTexture(int slot)
return *(_atlasTextures[slot]); return *(_atlasTextures[slot]);
} }
float FontAtlas::getCommonLineHeight() float FontAtlas::getCommonLineHeight() const
{ {
return _commonLineHeight; return _commonLineHeight;
} }
@ -72,7 +72,7 @@ void FontAtlas::setCommonLineHeight(float newHeight)
_commonLineHeight = newHeight; _commonLineHeight = newHeight;
} }
Font & FontAtlas::getFont() Font & FontAtlas::getFont() const
{ {
return _font; return _font;
} }

View File

@ -50,19 +50,25 @@ struct FontLetterDefinition
class CC_DLL FontAtlas : public Object class CC_DLL FontAtlas : public Object
{ {
public: public:
/**
* @js ctor
*/
FontAtlas(Font &theFont); FontAtlas(Font &theFont);
/**
* @js NA
* @lua NA
*/
virtual ~FontAtlas(); virtual ~FontAtlas();
void addLetterDefinition(const FontLetterDefinition &letterDefinition); void addLetterDefinition(const FontLetterDefinition &letterDefinition);
bool getLetterDefinitionForChar(unsigned short letteCharUTF16, FontLetterDefinition &outDefinition); bool getLetterDefinitionForChar(unsigned short letteCharUTF16, FontLetterDefinition &outDefinition);
void addTexture(Texture2D &texture, int slot); void addTexture(Texture2D &texture, int slot);
float getCommonLineHeight(); float getCommonLineHeight() const;
void setCommonLineHeight(float newHeight); void setCommonLineHeight(float newHeight);
Texture2D & getTexture(int slot); Texture2D & getTexture(int slot);
Font & getFont(); Font & getFont() const;
private: private:

View File

@ -31,10 +31,10 @@ FontAtlas * FontAtlasFactory::createAtlasFromTTF(const char* fntFilePath, int fo
FontAtlas * FontAtlasFactory::createAtlasFromFNT(const char* fntFilePath) FontAtlas * FontAtlasFactory::createAtlasFromFNT(const char* fntFilePath)
{ {
Font *pFont = Font::createWithFNT(fntFilePath); Font *font = Font::createWithFNT(fntFilePath);
if(pFont) if(font)
return pFont->createFontAtlas(); return font->createFontAtlas();
else else
return nullptr; return nullptr;
} }

View File

@ -27,7 +27,7 @@
NS_CC_BEGIN NS_CC_BEGIN
const int FontDefinitionTTF::_DEFAUL_ATALS_TEXTURE_SIZE = 1024; const int FontDefinitionTTF::DEFAUL_ATALS_TEXTURE_SIZE = 1024;
FontDefinitionTTF::FontDefinitionTTF():_textImages(0), _commonLineHeight(0) FontDefinitionTTF::FontDefinitionTTF():_textImages(0), _commonLineHeight(0)
{ {
@ -36,18 +36,18 @@ FontDefinitionTTF::FontDefinitionTTF():_textImages(0), _commonLineHeight(0)
FontDefinitionTTF* FontDefinitionTTF::create(Font *font, int textureSize) FontDefinitionTTF* FontDefinitionTTF::create(Font *font, int textureSize)
{ {
if (textureSize == 0) if (textureSize == 0)
textureSize = _DEFAUL_ATALS_TEXTURE_SIZE; textureSize = DEFAUL_ATALS_TEXTURE_SIZE;
FontDefinitionTTF *ret = new FontDefinitionTTF; FontDefinitionTTF *ret = new FontDefinitionTTF;
if(!ret) if (!ret)
return 0; return 0;
const char *pGlyph = font->getCurrentGlyphCollection(); const char *glyph = font->getCurrentGlyphCollection();
if (!pGlyph) if (!glyph)
return nullptr; return nullptr;
if ( ret->initDefinition(font, pGlyph, textureSize ) ) if (ret->initDefinition(font, glyph, textureSize))
{ {
return ret; return ret;
} }
@ -69,34 +69,33 @@ FontDefinitionTTF::~FontDefinitionTTF()
bool FontDefinitionTTF::prepareLetterDefinitions(TextFontPagesDef *pageDefs) bool FontDefinitionTTF::prepareLetterDefinitions(TextFontPagesDef *pageDefs)
{ {
// get all the pages // get all the pages
TextFontPagesDef *pPages = pageDefs; TextFontPagesDef *pages = pageDefs;
if (!pPages) if (!pages)
return (false); return (false);
float maxLineHeight = -1; float maxLineHeight = -1;
// loops all the pages // loops all the pages
for (int cPages = 0; cPages<pPages->getNumPages(); ++cPages) for (int cPages = 0; cPages < pages->getNumPages(); ++cPages)
{ {
// loops all the lines in this page // loops all the lines in this page
for (int cLines = 0; cLines<pPages->getPageAt(cPages)->getNumLines(); ++cLines) for (int cLines = 0; cLines<pages->getPageAt(cPages)->getNumLines(); ++cLines)
{ {
float posXUV = 0.0; float posXUV = 0.0;
float posYUV = pPages->getPageAt(cPages)->getLineAt(cLines)->getY(); float posYUV = pages->getPageAt(cPages)->getLineAt(cLines)->getY();
int charsCounter = 0; int charsCounter = 0;
for (int c = 0; c < pPages->getPageAt(cPages)->getLineAt(cLines)->getNumGlyph(); ++c) for (int c = 0; c < pages->getPageAt(cPages)->getLineAt(cLines)->getNumGlyph(); ++c)
{ {
// the current glyph // the current glyph
GlyphDef currentGlyph = pPages->getPageAt(cPages)->getLineAt(cLines)->getGlyphAt(c); GlyphDef currentGlyph = pages->getPageAt(cPages)->getLineAt(cLines)->getGlyphAt(c);
// letter width // letter width
float letterWidth = currentGlyph.getRect().size.width; float letterWidth = currentGlyph.getRect().size.width;
// letter height // letter height
float letterHeight = pPages->getPageAt(cPages)->getLineAt(cLines)->getHeight(); float letterHeight = pages->getPageAt(cPages)->getLineAt(cLines)->getHeight();
// add this letter definition // add this letter definition
FontLetterDefinition tempDef; FontLetterDefinition tempDef;
@ -180,7 +179,7 @@ bool FontDefinitionTTF::initDefinition(cocos2d::Font *font, const char *letters,
return prepareLetterDefinitions(_textImages->getPages()); return prepareLetterDefinitions(_textImages->getPages());
} }
void FontDefinitionTTF::addLetterDefinition(FontLetterDefinition &defToAdd) void FontDefinitionTTF::addLetterDefinition(const FontLetterDefinition &defToAdd)
{ {
if (_fontLettersDefinitionUTF16.find(defToAdd.letteCharUTF16) == _fontLettersDefinitionUTF16.end()) if (_fontLettersDefinitionUTF16.find(defToAdd.letteCharUTF16) == _fontLettersDefinitionUTF16.end())
{ {
@ -191,10 +190,10 @@ void FontDefinitionTTF::addLetterDefinition(FontLetterDefinition &defToAdd)
FontAtlas * FontDefinitionTTF::createFontAtlas() FontAtlas * FontDefinitionTTF::createFontAtlas()
{ {
int numTextures = 0; int numTextures = 0;
TextFontPagesDef *pPages = _textImages->getPages(); TextFontPagesDef *pages = _textImages->getPages();
if (pPages) if (pages)
numTextures = pPages->getNumPages(); numTextures = pages->getNumPages();
else else
return nullptr; return nullptr;

View File

@ -41,18 +41,24 @@ public:
FontAtlas * createFontAtlas(); FontAtlas * createFontAtlas();
private: private:
/**
* @js ctor
*/
FontDefinitionTTF(); FontDefinitionTTF();
/**
* @js NA
* @lua NA
*/
~FontDefinitionTTF(); ~FontDefinitionTTF();
bool initDefinition(Font *font, const char *letters, int textureSize); bool initDefinition(Font *font, const char *letters, int textureSize);
bool prepareLetterDefinitions(TextFontPagesDef *pageDefs); bool prepareLetterDefinitions(TextFontPagesDef *pageDefs);
void addLetterDefinition(FontLetterDefinition &defToAdd); void addLetterDefinition(const FontLetterDefinition &defToAdd);
TextImage * _textImages; TextImage * _textImages;
std::map<unsigned short, FontLetterDefinition> _fontLettersDefinitionUTF16; std::map<unsigned short, FontLetterDefinition> _fontLettersDefinitionUTF16;
float _commonLineHeight; float _commonLineHeight;
static const int _DEFAUL_ATALS_TEXTURE_SIZE; static const int DEFAUL_ATALS_TEXTURE_SIZE;
}; };

View File

@ -19,7 +19,7 @@ FontFNT * FontFNT::create(const char* fntFilePath)
// add the texture // add the texture
Texture2D *tempTexture = TextureCache::getInstance()->addImage(newConf->getAtlasName()); Texture2D *tempTexture = TextureCache::getInstance()->addImage(newConf->getAtlasName());
if ( !tempTexture ) if (!tempTexture)
{ {
delete newConf; delete newConf;
return nullptr; return nullptr;
@ -42,39 +42,39 @@ FontFNT::~FontFNT()
_configuration->release(); _configuration->release();
} }
Size * FontFNT::getAdvancesForTextUTF16(unsigned short *pText, int &outNumLetters) Size * FontFNT::getAdvancesForTextUTF16(unsigned short *text, int &outNumLetters) const
{ {
if (!pText) if (!text)
return 0; return 0;
outNumLetters = cc_wcslen(pText); outNumLetters = cc_wcslen(text);
if (!outNumLetters) if (!outNumLetters)
return 0; return 0;
Size *pSizes = new Size[outNumLetters]; Size *sizes = new Size[outNumLetters];
if (!pSizes) if (!sizes)
return 0; return 0;
for (int c = 0; c<outNumLetters; ++c) for (int c = 0; c < outNumLetters; ++c)
{ {
int advance = 0; int advance = 0;
int kerning = 0; int kerning = 0;
advance = getAdvanceForChar(pText[c]); advance = getAdvanceForChar(text[c]);
if ( c < (outNumLetters-1) ) if (c < (outNumLetters-1))
kerning = getHorizontalKerningForChars(pText[c], pText[c+1]); kerning = getHorizontalKerningForChars(text[c], text[c+1]);
pSizes[c].width = (advance + kerning); sizes[c].width = (advance + kerning);
} }
return pSizes; return sizes;
} }
int FontFNT::getAdvanceForChar(unsigned short theChar) int FontFNT::getAdvanceForChar(unsigned short theChar) const
{ {
tFontDefHashElement *element = NULL; tFontDefHashElement *element = nullptr;
// unichar is a short, and an int is needed on HASH_FIND_INT // unichar is a short, and an int is needed on HASH_FIND_INT
unsigned int key = theChar; unsigned int key = theChar;
@ -85,28 +85,28 @@ int FontFNT::getAdvanceForChar(unsigned short theChar)
return element->fontDef.xAdvance; return element->fontDef.xAdvance;
} }
int FontFNT::getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) int FontFNT::getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const
{ {
int ret = 0; int ret = 0;
unsigned int key = (firstChar<<16) | (secondChar & 0xffff); unsigned int key = (firstChar << 16) | (secondChar & 0xffff);
if( _configuration->_kerningDictionary ) if (_configuration->_kerningDictionary)
{ {
tKerningHashElement *element = NULL; tKerningHashElement *element = nullptr;
HASH_FIND_INT(_configuration->_kerningDictionary, &key, element); HASH_FIND_INT(_configuration->_kerningDictionary, &key, element);
if(element) if (element)
ret = element->amount; ret = element->amount;
} }
return ret; return ret;
} }
Rect FontFNT::getRectForCharInternal(unsigned short theChar) Rect FontFNT::getRectForCharInternal(unsigned short theChar) const
{ {
Rect retRect; Rect retRect;
ccBMFontDef fontDef; ccBMFontDef fontDef;
tFontDefHashElement *element = NULL; tFontDefHashElement *element = nullptr;
unsigned int key = theChar; unsigned int key = theChar;
HASH_FIND_INT(_configuration->_fontDefDictionary, &key, element); HASH_FIND_INT(_configuration->_fontDefDictionary, &key, element);
@ -119,7 +119,7 @@ Rect FontFNT::getRectForCharInternal(unsigned short theChar)
return retRect; return retRect;
} }
Rect FontFNT::getRectForChar(unsigned short theChar) Rect FontFNT::getRectForChar(unsigned short theChar) const
{ {
return getRectForCharInternal(theChar); return getRectForCharInternal(theChar);
} }
@ -146,15 +146,15 @@ FontAtlas * FontFNT::createFontAtlas()
ccBMFontDef fontDef; ccBMFontDef fontDef;
tFontDefHashElement *current_element, *tmp; tFontDefHashElement *currentElement, *tmp;
// Purge uniform hash // Purge uniform hash
HASH_ITER(hh, _configuration->_fontDefDictionary, current_element, tmp) HASH_ITER(hh, _configuration->_fontDefDictionary, currentElement, tmp)
{ {
FontLetterDefinition tempDefinition; FontLetterDefinition tempDefinition;
fontDef = current_element->fontDef; fontDef = currentElement->fontDef;
Rect tempRect; Rect tempRect;
tempRect = fontDef.rect; tempRect = fontDef.rect;

View File

@ -37,20 +37,24 @@ public:
static FontFNT * create(const char* fntFilePath); static FontFNT * create(const char* fntFilePath);
virtual Size* getAdvancesForTextUTF16(unsigned short *pText, int &outNumLetters) override; virtual Size* getAdvancesForTextUTF16(unsigned short *text, int &outNumLetters) const override;
virtual Rect getRectForChar(unsigned short theChar) override; virtual Rect getRectForChar(unsigned short theChar) const override;
virtual FontAtlas *createFontAtlas() override; virtual FontAtlas *createFontAtlas() override;
protected: protected:
FontFNT(CCBMFontConfiguration *theContfig) : _configuration(theContfig) {} FontFNT(CCBMFontConfiguration *theContfig) : _configuration(theContfig) {}
/**
* @js NA
* @lua NA
*/
virtual ~FontFNT(); virtual ~FontFNT();
private: private:
int getAdvanceForChar(unsigned short theChar); int getAdvanceForChar(unsigned short theChar) const;
int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar); int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const;
Rect getRectForCharInternal(unsigned short theChar); Rect getRectForCharInternal(unsigned short theChar) const;
CCBMFontConfiguration * _configuration; CCBMFontConfiguration * _configuration;

View File

@ -51,7 +51,7 @@ FontFreeType * FontFreeType::create(const std::string &fontName, int fontSize, G
tempFont->setCurrentGlyphCollection(glyphs, customGlyphs); tempFont->setCurrentGlyphCollection(glyphs, customGlyphs);
if( !tempFont->createFontObject(fontName, fontSize)) if (!tempFont->createFontObject(fontName, fontSize))
{ {
delete tempFont; delete tempFont;
return nullptr; return nullptr;
@ -94,11 +94,10 @@ FontFreeType::FontFreeType() : _letterPadding(5)
bool FontFreeType::createFontObject(const std::string &fontName, int fontSize) bool FontFreeType::createFontObject(const std::string &fontName, int fontSize)
{ {
unsigned char* data = NULL; int dpi = 72;
int dpi = 72;
int len = 0; int len = 0;
data = FileUtils::getInstance()->getFileData(fontName.c_str(), "rb", (unsigned long *)(&len) ); unsigned char* data = FileUtils::getInstance()->getFileData(fontName.c_str(), "rb", (unsigned long *)(&len));
if (!data) if (!data)
return false; return false;
@ -107,16 +106,16 @@ bool FontFreeType::createFontObject(const std::string &fontName, int fontSize)
FT_Face face; FT_Face face;
// create the face from the data // create the face from the data
if ( FT_New_Memory_Face(getFTLibrary(), data, len, 0, &face ) ) if (FT_New_Memory_Face(getFTLibrary(), data, len, 0, &face ))
return false; return false;
//we want to use unicode //we want to use unicode
if( FT_Select_Charmap(face, FT_ENCODING_UNICODE) ) if (FT_Select_Charmap(face, FT_ENCODING_UNICODE))
return false; return false;
// set the requested font size // set the requested font size
int fontSizePoints = (int)(64.f * fontSize); int fontSizePoints = (int)(64.f * fontSize);
if( FT_Set_Char_Size(face, fontSizePoints, fontSizePoints, dpi, dpi) ) if (FT_Set_Char_Size(face, fontSizePoints, fontSizePoints, dpi, dpi))
return false; return false;
// store the face globally // store the face globally
@ -137,10 +136,9 @@ FontFreeType::~FontFreeType()
FontAtlas * FontFreeType::createFontAtlas() FontAtlas * FontFreeType::createFontAtlas()
{ {
FontDefinitionTTF *def = 0; FontDefinitionTTF *def = FontDefinitionTTF::create(this);
def = FontDefinitionTTF::create(this);
if(!def) if (!def)
return nullptr; return nullptr;
FontAtlas *atlas = def->createFontAtlas(); FontAtlas *atlas = def->createFontAtlas();
@ -150,7 +148,7 @@ FontAtlas * FontFreeType::createFontAtlas()
return atlas; return atlas;
} }
bool FontFreeType::getBBOXFotChar(unsigned short theChar, Rect &outRect) bool FontFreeType::getBBOXFotChar(unsigned short theChar, Rect &outRect) const
{ {
if (!_fontRef) if (!_fontRef)
return false; return false;
@ -174,17 +172,17 @@ bool FontFreeType::getBBOXFotChar(unsigned short theChar, Rect &outRect)
return true; return true;
} }
GlyphDef * FontFreeType::getGlyphDefintionsForText(const char *pText, int &outNumGlyphs, bool UTF16text) GlyphDef * FontFreeType::getGlyphDefintionsForText(const char *text, int &outNumGlyphs, bool UTF16text) const
{ {
unsigned short* utf16String = 0; unsigned short* utf16String = 0;
if (UTF16text) if (UTF16text)
{ {
utf16String = (unsigned short*) pText; utf16String = (unsigned short*) text;
} }
else else
{ {
utf16String = cc_utf8_to_utf16(pText); utf16String = cc_utf8_to_utf16(text);
} }
// //
@ -196,17 +194,17 @@ GlyphDef * FontFreeType::getGlyphDefintionsForText(const char *pText, int &outNu
return 0; return 0;
// allocate the needed Glyphs // allocate the needed Glyphs
GlyphDef *pGlyphs = new GlyphDef[numChar]; GlyphDef *glyphs = new GlyphDef[numChar];
assert( pGlyphs != NULL ); assert(glyphs != nullptr);
if (!pGlyphs) if (!glyphs)
return 0; return 0;
// sore result as CCRect // sore result as CCRect
for (int c=0; c<numChar; ++c) for (int c = 0; c < numChar; ++c)
{ {
Rect tempRect; Rect tempRect;
if( !getBBOXFotChar(utf16String[c], tempRect) ) if (!getBBOXFotChar(utf16String[c], tempRect))
{ {
log("Warning: Cannot find definition for glyph: %c in font:%s", utf16String[c], _fontName.c_str()); log("Warning: Cannot find definition for glyph: %c in font:%s", utf16String[c], _fontName.c_str());
@ -215,20 +213,17 @@ GlyphDef * FontFreeType::getGlyphDefintionsForText(const char *pText, int &outNu
tempRect.size.width = 0; tempRect.size.width = 0;
tempRect.size.height = 0; tempRect.size.height = 0;
pGlyphs[c].setRect(tempRect); glyphs[c].setRect(tempRect);
pGlyphs[c].setUTF16Letter(utf16String[c]); glyphs[c].setUTF16Letter(utf16String[c]);
pGlyphs[c].setValid(false); glyphs[c].setValid(false);
pGlyphs[c].setPadding(_letterPadding); glyphs[c].setPadding(_letterPadding);
} }
else else
{ {
glyphs[c].setRect(tempRect);
pGlyphs[c].setRect(tempRect); glyphs[c].setUTF16Letter(utf16String[c]);
pGlyphs[c].setUTF16Letter(utf16String[c]); glyphs[c].setPadding(_letterPadding);
pGlyphs[c].setPadding(_letterPadding); glyphs[c].setValid(true);
pGlyphs[c].setValid(true);
} }
} }
@ -239,40 +234,40 @@ GlyphDef * FontFreeType::getGlyphDefintionsForText(const char *pText, int &outNu
delete [] utf16String; delete [] utf16String;
// done // done
return pGlyphs; return glyphs;
} }
Size * FontFreeType::getAdvancesForTextUTF16(unsigned short *pText, int &outNumLetters) Size * FontFreeType::getAdvancesForTextUTF16(unsigned short *text, int &outNumLetters) const
{ {
if (!pText) if (!text)
return 0; return 0;
outNumLetters = cc_wcslen(pText); outNumLetters = cc_wcslen(text);
if (!outNumLetters) if (!outNumLetters)
return 0; return 0;
Size *pSizes = new Size[outNumLetters]; Size *sizes = new Size[outNumLetters];
if (!pSizes) if (!sizes)
return 0; return 0;
for (int c = 0; c<outNumLetters; ++c) for (int c = 0; c < outNumLetters; ++c)
{ {
int advance = 0; int advance = 0;
int kerning = 0; int kerning = 0;
advance = getAdvanceForChar(pText[c]) - getBearingXForChar(pText[c]); advance = getAdvanceForChar(text[c]) - getBearingXForChar(text[c]);
if ( c < (outNumLetters-1) ) if (c < (outNumLetters-1))
kerning = getHorizontalKerningForChars(pText[c], pText[c+1]); kerning = getHorizontalKerningForChars(text[c], text[c+1]);
pSizes[c].width = (advance + kerning); sizes[c].width = (advance + kerning);
} }
return pSizes; return sizes;
} }
int FontFreeType::getAdvanceForChar(unsigned short theChar) int FontFreeType::getAdvanceForChar(unsigned short theChar) const
{ {
if (!_fontRef) if (!_fontRef)
return 0; return 0;
@ -291,26 +286,26 @@ int FontFreeType::getAdvanceForChar(unsigned short theChar)
return (_fontRef->glyph->advance.x >> 6); return (_fontRef->glyph->advance.x >> 6);
} }
int FontFreeType::getBearingXForChar(unsigned short theChar) int FontFreeType::getBearingXForChar(unsigned short theChar) const
{ {
if (!_fontRef) if (!_fontRef)
return 0; return 0;
// get the ID to the char we need // get the ID to the char we need
int glyph_index = FT_Get_Char_Index(_fontRef, theChar); int glyphIndex = FT_Get_Char_Index(_fontRef, theChar);
if (!glyph_index) if (!glyphIndex)
return 0; return 0;
// load glyph infos // load glyph infos
if (FT_Load_Glyph(_fontRef, glyph_index, FT_LOAD_DEFAULT)) if (FT_Load_Glyph(_fontRef, glyphIndex, FT_LOAD_DEFAULT))
return 0; return 0;
return (_fontRef->glyph->metrics.horiBearingX >>6); return (_fontRef->glyph->metrics.horiBearingX >>6);
} }
int FontFreeType::getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) int FontFreeType::getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const
{ {
if (!_fontRef) if (!_fontRef)
return 0; return 0;
@ -321,43 +316,43 @@ int FontFreeType::getHorizontalKerningForChars(unsigned short firstChar, unsign
return 0; return 0;
// get the ID to the char we need // get the ID to the char we need
int glyph_index1 = FT_Get_Char_Index(_fontRef, firstChar); int glyphIndex1 = FT_Get_Char_Index(_fontRef, firstChar);
if (!glyph_index1) if (!glyphIndex1)
return 0; return 0;
// get the ID to the char we need // get the ID to the char we need
int glyph_index2 = FT_Get_Char_Index(_fontRef, secondChar); int glyphIndex2 = FT_Get_Char_Index(_fontRef, secondChar);
if (!glyph_index2) if (!glyphIndex2)
return 0; return 0;
FT_Vector kerning; FT_Vector kerning;
if (FT_Get_Kerning( _fontRef, glyph_index1, glyph_index2, FT_KERNING_DEFAULT, &kerning )) if (FT_Get_Kerning( _fontRef, glyphIndex1, glyphIndex2, FT_KERNING_DEFAULT, &kerning))
return 0; return 0;
return ( kerning.x >> 6 ); return (kerning.x >> 6);
} }
int FontFreeType::getFontMaxHeight() int FontFreeType::getFontMaxHeight() const
{ {
return (_fontRef->size->metrics.height >> 6); return (_fontRef->size->metrics.height >> 6);
} }
unsigned char * FontFreeType::getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) unsigned char * FontFreeType::getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) const
{ {
if (!_fontRef) if (!_fontRef)
return 0; return 0;
// get the ID to the char we need // get the ID to the char we need
int glyph_index = FT_Get_Char_Index(_fontRef, theChar); int glyphIndex = FT_Get_Char_Index(_fontRef, theChar);
if (!glyph_index) if (!glyphIndex)
return 0; return 0;
// load glyph infos // load glyph infos
if (FT_Load_Glyph(_fontRef, glyph_index, FT_LOAD_DEFAULT)) if (FT_Load_Glyph(_fontRef, glyphIndex, FT_LOAD_DEFAULT))
return 0; return 0;
if (FT_Render_Glyph( _fontRef->glyph, FT_RENDER_MODE_NORMAL )) if (FT_Render_Glyph( _fontRef->glyph, FT_RENDER_MODE_NORMAL ))
@ -370,7 +365,7 @@ unsigned char * FontFreeType::getGlyphBitmap(unsigned short theChar, int &outW
return _fontRef->glyph->bitmap.buffer; return _fontRef->glyph->bitmap.buffer;
} }
int FontFreeType::getLetterPadding() int FontFreeType::getLetterPadding() const
{ {
return _letterPadding; return _letterPadding;
} }

View File

@ -41,11 +41,11 @@ public:
static FontFreeType * create(const std::string &fontName, int fontSize, GlyphCollection glyphs, const char *customGlyphs); static FontFreeType * create(const std::string &fontName, int fontSize, GlyphCollection glyphs, const char *customGlyphs);
virtual FontAtlas * createFontAtlas() override; virtual FontAtlas * createFontAtlas() override;
virtual Size * getAdvancesForTextUTF16(unsigned short *pText, int &outNumLetters) override; virtual Size * getAdvancesForTextUTF16(unsigned short *text, int &outNumLetters) const override;
virtual GlyphDef * getGlyphDefintionsForText(const char *pText, int &outNumGlyphs, bool UTF16text = false) override; virtual GlyphDef * getGlyphDefintionsForText(const char *text, int &outNumGlyphs, bool UTF16text = false) const override;
unsigned char * getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) override; unsigned char * getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) const override;
virtual int getFontMaxHeight() override; virtual int getFontMaxHeight() const override;
virtual int getLetterPadding() override; virtual int getLetterPadding() const override;
protected: protected:
@ -60,10 +60,10 @@ private:
void shutdownFreeType(); void shutdownFreeType();
FT_Library getFTLibrary(); FT_Library getFTLibrary();
bool getBBOXFotChar(unsigned short theChar, Rect &outRect); bool getBBOXFotChar(unsigned short theChar, Rect &outRect) const;
int getAdvanceForChar(unsigned short theChar); int getAdvanceForChar(unsigned short theChar) const;
int getBearingXForChar(unsigned short theChar); int getBearingXForChar(unsigned short theChar) const;
int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar); int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const;
static FT_Library _FTlibrary; static FT_Library _FTlibrary;
static bool _FTInitialized; static bool _FTInitialized;

View File

@ -343,7 +343,7 @@ void Label::resetCurrentString()
} }
Sprite * Label::createNewSpriteFromLetterDefinition(FontLetterDefinition &theDefinition, Texture2D *theTexture) Sprite * Label::createNewSpriteFromLetterDefinition(const FontLetterDefinition &theDefinition, Texture2D *theTexture)
{ {
Rect uvRect; Rect uvRect;
uvRect.size.height = theDefinition.height; uvRect.size.height = theDefinition.height;
@ -372,7 +372,7 @@ Sprite * Label::createNewSpriteFromLetterDefinition(FontLetterDefinition &theDef
return tempSprite; return tempSprite;
} }
Sprite * Label::updateSpriteWithLetterDefinition(Sprite *spriteToUpdate, FontLetterDefinition &theDefinition, Texture2D *theTexture) Sprite * Label::updateSpriteWithLetterDefinition(Sprite *spriteToUpdate, const FontLetterDefinition &theDefinition, Texture2D *theTexture)
{ {
if (!spriteToUpdate) if (!spriteToUpdate)
{ {
@ -454,7 +454,7 @@ Sprite * Label::getSprite()
{ {
if (_spriteArrayCache->count()) if (_spriteArrayCache->count())
{ {
Sprite *retSprite = static_cast<Sprite *>( _spriteArrayCache->getLastObject() ); Sprite *retSprite = static_cast<Sprite *>(_spriteArrayCache->getLastObject());
_spriteArrayCache->removeLastObject(); _spriteArrayCache->removeLastObject();
return retSprite; return retSprite;
} }
@ -467,7 +467,7 @@ Sprite * Label::getSprite()
///// PROTOCOL STUFF ///// PROTOCOL STUFF
Sprite * Label::getSpriteChild(int ID) Sprite * Label::getSpriteChild(int ID) const
{ {
Object* pObj = NULL; Object* pObj = NULL;
CCARRAY_FOREACH(_spriteArray, pObj) CCARRAY_FOREACH(_spriteArray, pObj)
@ -481,7 +481,7 @@ Sprite * Label::getSpriteChild(int ID)
return 0; return 0;
} }
Array* Label::getChildrenLetters() Array* Label::getChildrenLetters() const
{ {
return _spriteArray; return _spriteArray;
} }
@ -516,29 +516,29 @@ Sprite * Label::getSpriteForChar(unsigned short int theChar, int spriteIndexHint
return retSprite; return retSprite;
} }
float Label::getLetterPosXLeft( Sprite* sp ) float Label::getLetterPosXLeft( Sprite* sp ) const
{ {
float scaleX = _scaleX; float scaleX = _scaleX;
return sp->getPosition().x * scaleX - (sp->getContentSize().width * scaleX * sp->getAnchorPoint().x); return sp->getPosition().x * scaleX - (sp->getContentSize().width * scaleX * sp->getAnchorPoint().x);
} }
float Label::getLetterPosXRight( Sprite* sp ) float Label::getLetterPosXRight( Sprite* sp ) const
{ {
float scaleX = _scaleX; float scaleX = _scaleX;
return sp->getPosition().x * scaleX + (sp->getContentSize().width * scaleX * sp->getAnchorPoint().x); return sp->getPosition().x * scaleX + (sp->getContentSize().width * scaleX * sp->getAnchorPoint().x);
} }
int Label::getCommonLineHeight() int Label::getCommonLineHeight() const
{ {
return _commonLineHeight; return _commonLineHeight;
} }
int Label::getKerningForCharsPair(unsigned short first, unsigned short second) int Label::getKerningForCharsPair(unsigned short first, unsigned short second) const
{ {
return 0; return 0;
} }
int Label::getXOffsetForChar(unsigned short c) int Label::getXOffsetForChar(unsigned short c) const
{ {
FontLetterDefinition tempDefinition; FontLetterDefinition tempDefinition;
bool validDefinition = _fontAtlas->getLetterDefinitionForChar(c, tempDefinition); bool validDefinition = _fontAtlas->getLetterDefinitionForChar(c, tempDefinition);
@ -548,7 +548,7 @@ int Label::getXOffsetForChar(unsigned short c)
return (tempDefinition.offsetX); return (tempDefinition.offsetX);
} }
int Label::getYOffsetForChar(unsigned short c) int Label::getYOffsetForChar(unsigned short c) const
{ {
FontLetterDefinition tempDefinition; FontLetterDefinition tempDefinition;
bool validDefinition = _fontAtlas->getLetterDefinitionForChar(c, tempDefinition); bool validDefinition = _fontAtlas->getLetterDefinitionForChar(c, tempDefinition);
@ -558,7 +558,7 @@ int Label::getYOffsetForChar(unsigned short c)
return (tempDefinition.offsetY); return (tempDefinition.offsetY);
} }
int Label::getAdvanceForChar(unsigned short c, int hintPositionInString) int Label::getAdvanceForChar(unsigned short c, int hintPositionInString) const
{ {
if (_advances) if (_advances)
{ {
@ -576,13 +576,13 @@ int Label::getAdvanceForChar(unsigned short c, int hintPositionInString)
} }
} }
Rect Label::getRectForChar(unsigned short c) Rect Label::getRectForChar(unsigned short c) const
{ {
return _fontAtlas->getFont().getRectForChar(c); return _fontAtlas->getFont().getRectForChar(c);
} }
// string related stuff // string related stuff
int Label::getStringNumLines() int Label::getStringNumLines() const
{ {
int quantityOfLines = 1; int quantityOfLines = 1;
@ -603,17 +603,17 @@ int Label::getStringNumLines()
return quantityOfLines; return quantityOfLines;
} }
int Label::getStringLenght() int Label::getStringLenght() const
{ {
return _currentUTF8String ? cc_wcslen(_currentUTF8String) : 0; return _currentUTF8String ? cc_wcslen(_currentUTF8String) : 0;
} }
unsigned short Label::getCharAtStringPosition(int position) unsigned short Label::getCharAtStringPosition(int position) const
{ {
return _currentUTF8String[position]; return _currentUTF8String[position];
} }
unsigned short * Label::getUTF8String() unsigned short * Label::getUTF8String() const
{ {
return _currentUTF8String; return _currentUTF8String;
} }
@ -623,23 +623,23 @@ void Label::assignNewUTF8String(unsigned short *newString)
setCurrentString(newString); setCurrentString(newString);
} }
TextHAlignment Label::getTextAlignment() TextHAlignment Label::getTextAlignment() const
{ {
return _alignment; return _alignment;
} }
// label related stuff // label related stuff
float Label::getMaxLineWidth() float Label::getMaxLineWidth() const
{ {
return _width; return _width;
} }
bool Label::breakLineWithoutSpace() bool Label::breakLineWithoutSpace() const
{ {
return _lineBreakWithoutSpaces; return _lineBreakWithoutSpaces;
} }
Size Label::getLabelContentSize() Size Label::getLabelContentSize() const
{ {
return getContentSize(); return getContentSize();
} }

View File

@ -38,7 +38,6 @@ enum class GlyphCollection {
NEHE, NEHE,
ASCII, ASCII,
CUSTOM CUSTOM
}; };
//fwd //fwd
@ -52,75 +51,81 @@ class CC_DLL Label : public SpriteBatchNode, public LabelProtocol, public RGBAPr
public: public:
// static create // static create
static Label* createWithTTF( const char* label, const char* fontFilePath, int fontSize, int lineSize = 0, TextHAlignment alignment = TextHAlignment::CENTER, GlyphCollection glyphs = GlyphCollection::NEHE, const char *customGlyphs = 0 ); static Label* createWithTTF(const char* label, const char* fontFilePath, int fontSize, int lineSize = 0, TextHAlignment alignment = TextHAlignment::CENTER, GlyphCollection glyphs = GlyphCollection::NEHE, const char *customGlyphs = 0);
static Label* createWithBMFont( const char* label, const char* bmfontFilePath, TextHAlignment alignment = TextHAlignment::CENTER, int lineSize = 0 ); static Label* createWithBMFont(const char* label, const char* bmfontFilePath, TextHAlignment alignment = TextHAlignment::CENTER, int lineSize = 0);
bool setText(const char *stringToRender, float lineWidth, TextHAlignment alignment = TextHAlignment::LEFT, bool lineBreakWithoutSpaces = false); bool setText(const char *stringToRender, float lineWidth, TextHAlignment alignment = TextHAlignment::LEFT, bool lineBreakWithoutSpaces = false);
virtual void setString(const char *stringToRender); virtual void setString(const char *stringToRender) override;
virtual void setAlignment(TextHAlignment alignment); virtual void setAlignment(TextHAlignment alignment);
virtual void setWidth(float width); virtual void setWidth(float width);
virtual void setLineBreakWithoutSpace(bool breakWithoutSpace); virtual void setLineBreakWithoutSpace(bool breakWithoutSpace);
virtual void setScale(float scale); virtual void setScale(float scale) override;
virtual void setScaleX(float scaleX); virtual void setScaleX(float scaleX) override;
virtual void setScaleY(float scaleY); virtual void setScaleY(float scaleY) override;
// RGBAProtocol // RGBAProtocol
virtual bool isOpacityModifyRGB() const; virtual bool isOpacityModifyRGB() const override;
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB); virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override;
virtual void setOpacity(GLubyte opacity); virtual void setOpacity(GLubyte opacity) override;
virtual void updateDisplayedOpacity(GLubyte parentOpacity); virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
virtual bool isCascadeOpacityEnabled() const; virtual bool isCascadeOpacityEnabled() const override;
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled); virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override;
virtual void setColor(const Color3B& color); virtual void setColor(const Color3B& color) override;
virtual void updateDisplayedColor(const Color3B& parentColor); virtual void updateDisplayedColor(const Color3B& parentColor) override;
virtual bool isCascadeColorEnabled() const; virtual bool isCascadeColorEnabled() const override;
virtual void setCascadeColorEnabled(bool cascadeColorEnabled); virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override;
virtual const Color3B& getColor(void) const; virtual const Color3B& getColor(void) const override;
virtual const Color3B& getDisplayedColor() const; virtual const Color3B& getDisplayedColor() const override;
virtual unsigned char getOpacity() const; virtual unsigned char getOpacity() const override;
virtual unsigned char getDisplayedOpacity() const; virtual unsigned char getDisplayedOpacity() const override;
// CCLabelTextFormat protocol implementation // CCLabelTextFormat protocol implementation
virtual Sprite * getSpriteChild(int ID); virtual Sprite * getSpriteChild(int ID) const override;
virtual Array * getChildrenLetters(); virtual Array * getChildrenLetters() const override;
virtual Sprite * getSpriteForChar(unsigned short int theChar, int spriteIndexHint); virtual Sprite * getSpriteForChar(unsigned short int theChar, int spriteIndexHint) override;
virtual float getLetterPosXLeft( Sprite* sp ); virtual float getLetterPosXLeft( Sprite* sp ) const override;
virtual float getLetterPosXRight( Sprite* sp ); virtual float getLetterPosXRight( Sprite* sp ) const override;
// font related stuff // font related stuff
virtual int getCommonLineHeight(); virtual int getCommonLineHeight() const override;
virtual int getKerningForCharsPair(unsigned short first, unsigned short second); virtual int getKerningForCharsPair(unsigned short first, unsigned short second) const override;
virtual int getXOffsetForChar(unsigned short c); virtual int getXOffsetForChar(unsigned short c) const override;
virtual int getYOffsetForChar(unsigned short c); virtual int getYOffsetForChar(unsigned short c) const override;
virtual int getAdvanceForChar(unsigned short c, int hintPositionInString); virtual int getAdvanceForChar(unsigned short c, int hintPositionInString) const override;
virtual Rect getRectForChar(unsigned short c) ; virtual Rect getRectForChar(unsigned short c) const override;
// string related stuff // string related stuff
virtual int getStringNumLines(); virtual int getStringNumLines() const override;
virtual int getStringLenght(); virtual int getStringLenght() const override;
virtual unsigned short getCharAtStringPosition(int position); virtual unsigned short getCharAtStringPosition(int position) const override;
virtual unsigned short * getUTF8String(); virtual unsigned short * getUTF8String() const override;
virtual void assignNewUTF8String(unsigned short *newString); virtual void assignNewUTF8String(unsigned short *newString) override;
virtual TextHAlignment getTextAlignment(); virtual TextHAlignment getTextAlignment() const override;
// label related stuff // label related stuff
virtual float getMaxLineWidth() ; virtual float getMaxLineWidth() const override;
virtual bool breakLineWithoutSpace(); virtual bool breakLineWithoutSpace() const override;
virtual Size getLabelContentSize(); virtual Size getLabelContentSize() const override;
virtual void setLabelContentSize(const Size &newSize); virtual void setLabelContentSize(const Size &newSize) override;
// carloX // carloX
const char * getString() const { return "not implemented"; } const char * getString() const { return "not implemented"; }
private: private:
/**
Label(FontAtlas *pAtlas, TextHAlignment alignment); * @js NA
*/
Label(FontAtlas *atlas, TextHAlignment alignment);
/**
* @js NA
* @lua NA
*/
~Label(); ~Label();
static Label* createWithAtlas(FontAtlas *pAtlas, TextHAlignment alignment = TextHAlignment::LEFT, int lineSize = 0); static Label* createWithAtlas(FontAtlas *atlas, TextHAlignment alignment = TextHAlignment::LEFT, int lineSize = 0);
bool init(); bool init();
@ -134,8 +139,8 @@ private:
void resetCurrentString(); void resetCurrentString();
Sprite * getSprite(); Sprite * getSprite();
Sprite * createNewSpriteFromLetterDefinition(FontLetterDefinition &theDefinition, Texture2D *theTexture); Sprite * createNewSpriteFromLetterDefinition(const FontLetterDefinition &theDefinition, Texture2D *theTexture);
Sprite * updateSpriteWithLetterDefinition(Sprite *spriteToUpdate, FontLetterDefinition &theDefinition, Texture2D *theTexture); Sprite * updateSpriteWithLetterDefinition(Sprite *spriteToUpdate, const FontLetterDefinition &theDefinition, Texture2D *theTexture);
Sprite * getSpriteForLetter(unsigned short int newLetter); Sprite * getSpriteForLetter(unsigned short int newLetter);
Sprite * updateSpriteForLetter(Sprite *spriteToUpdate, unsigned short int newLetter); Sprite * updateSpriteForLetter(Sprite *spriteToUpdate, unsigned short int newLetter);

View File

@ -51,9 +51,16 @@ A more flexible class is LabelBMFont. It supports variable width characters and
class CC_DLL LabelAtlas : public AtlasNode, public LabelProtocol class CC_DLL LabelAtlas : public AtlasNode, public LabelProtocol
{ {
public: public:
/**
* @js ctor
*/
LabelAtlas() LabelAtlas()
:_string("") :_string("")
{} {}
/**
* @js NA
* @lua NA
*/
virtual ~LabelAtlas() virtual ~LabelAtlas()
{ {
_string.clear(); _string.clear();

View File

@ -124,8 +124,19 @@ public://@public
// Character Set defines the letters that actually exist in the font // Character Set defines the letters that actually exist in the font
std::set<unsigned int> *_characterSet; std::set<unsigned int> *_characterSet;
public: public:
/**
* @js ctor
*/
CCBMFontConfiguration(); CCBMFontConfiguration();
/**
* @js NA
* @lua NA
*/
virtual ~CCBMFontConfiguration(); virtual ~CCBMFontConfiguration();
/**
* @js NA
* @lua NA
*/
const char * description() const; const char * description() const;
/** allocates a CCBMFontConfiguration with a FNT file */ /** allocates a CCBMFontConfiguration with a FNT file */
@ -182,8 +193,14 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only)
class CC_DLL LabelBMFont : public SpriteBatchNode, public LabelProtocol, public RGBAProtocol class CC_DLL LabelBMFont : public SpriteBatchNode, public LabelProtocol, public RGBAProtocol
{ {
public: public:
/**
* @js ctor
*/
LabelBMFont(); LabelBMFont();
/**
* @js NA
* @lua NA
*/
virtual ~LabelBMFont(); virtual ~LabelBMFont();
/** Purges the cached data. /** Purges the cached data.
Removes from memory the cached configurations and the atlas name dictionary. Removes from memory the cached configurations and the atlas name dictionary.

View File

@ -57,8 +57,19 @@ NS_CC_BEGIN
class CC_DLL LabelTTF : public Sprite, public LabelProtocol class CC_DLL LabelTTF : public Sprite, public LabelProtocol
{ {
public: public:
/**
* @js ctor
*/
LabelTTF(); LabelTTF();
/**
* @js NA
* @lua NA
*/
virtual ~LabelTTF(); virtual ~LabelTTF();
/**
* @js NA
* @lua NA
*/
const char* description() const; const char* description() const;
/** creates a LabelTTF with a font name and font size in points /** creates a LabelTTF with a font name and font size in points

View File

@ -32,33 +32,33 @@ class CC_DLL LabelTextFormatProtocol
public: public:
// sprite related stuff // sprite related stuff
virtual cocos2d::Sprite *getSpriteChild(int ID) = 0; virtual cocos2d::Sprite *getSpriteChild(int ID) const = 0;
virtual cocos2d::Array *getChildrenLetters() = 0; virtual cocos2d::Array *getChildrenLetters() const = 0;
virtual cocos2d::Sprite *getSpriteForChar(unsigned short int theChar, int spriteIndexHint) = 0; virtual cocos2d::Sprite *getSpriteForChar(unsigned short int theChar, int spriteIndexHint) = 0;
virtual float getLetterPosXLeft( cocos2d::Sprite* sp ) = 0; virtual float getLetterPosXLeft(cocos2d::Sprite* sp) const = 0;
virtual float getLetterPosXRight( cocos2d::Sprite* sp ) = 0; virtual float getLetterPosXRight(cocos2d::Sprite* sp) const = 0;
// font related stuff // font related stuff
virtual int getCommonLineHeight() = 0; virtual int getCommonLineHeight() const = 0;
virtual int getKerningForCharsPair(unsigned short first, unsigned short second) = 0; virtual int getKerningForCharsPair(unsigned short first, unsigned short second) const = 0;
virtual int getXOffsetForChar(unsigned short c) = 0; virtual int getXOffsetForChar(unsigned short c) const = 0;
virtual int getYOffsetForChar(unsigned short c) = 0; virtual int getYOffsetForChar(unsigned short c) const = 0;
virtual int getAdvanceForChar(unsigned short c, int hintPositionInString) = 0; virtual int getAdvanceForChar(unsigned short c, int hintPositionInString) const = 0;
virtual cocos2d::Rect getRectForChar(unsigned short c) = 0; virtual cocos2d::Rect getRectForChar(unsigned short c) const = 0;
// string related stuff // string related stuff
virtual int getStringNumLines() = 0; virtual int getStringNumLines() const = 0;
virtual int getStringLenght() = 0; virtual int getStringLenght() const = 0;
virtual unsigned short getCharAtStringPosition(int position) = 0; virtual unsigned short getCharAtStringPosition(int position) const = 0;
virtual unsigned short * getUTF8String() = 0; virtual unsigned short * getUTF8String() const = 0;
virtual void assignNewUTF8String(unsigned short *newString) = 0; virtual void assignNewUTF8String(unsigned short *newString) = 0;
virtual TextHAlignment getTextAlignment() = 0; virtual TextHAlignment getTextAlignment() const = 0;
// label related stuff // label related stuff
virtual float getMaxLineWidth() = 0; virtual float getMaxLineWidth() const = 0;
virtual bool breakLineWithoutSpace() = 0; virtual bool breakLineWithoutSpace() const = 0;
virtual cocos2d::Size getLabelContentSize() = 0; virtual cocos2d::Size getLabelContentSize() const = 0;
virtual void setLabelContentSize(const Size &newSize) = 0; virtual void setLabelContentSize(const Size &newSize) = 0;
}; };

View File

@ -49,7 +49,7 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
unsigned int line = 1, i = 0; unsigned int line = 1, i = 0;
bool start_line = false, start_word = false; bool isStartOfLine = false, isStartOfWord = false;
float startOfLine = -1, startOfWord = -1; float startOfLine = -1, startOfWord = -1;
int skip = 0; int skip = 0;
@ -76,16 +76,16 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
unsigned short character = strWhole[i]; unsigned short character = strWhole[i];
if (!start_word) if (!isStartOfWord)
{ {
startOfWord = theLabel->getLetterPosXLeft( characterSprite ); startOfWord = theLabel->getLetterPosXLeft( characterSprite );
start_word = true; isStartOfWord = true;
} }
if (!start_line) if (!isStartOfLine)
{ {
startOfLine = startOfWord; startOfLine = startOfWord;
start_line = true; isStartOfLine = true;
} }
// Newline. // Newline.
@ -96,12 +96,12 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
last_word.push_back('\n'); last_word.push_back('\n');
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end()); multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
last_word.clear(); last_word.clear();
start_word = false; isStartOfWord = false;
start_line = false; isStartOfLine = false;
startOfWord = -1; startOfWord = -1;
startOfLine = -1; startOfLine = -1;
i+=justSkipped; i += justSkipped;
line++; ++line;
if (i >= stringLength) if (i >= stringLength)
break; break;
@ -111,12 +111,12 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
if (!startOfWord) if (!startOfWord)
{ {
startOfWord = theLabel->getLetterPosXLeft( characterSprite ); startOfWord = theLabel->getLetterPosXLeft( characterSprite );
start_word = true; isStartOfWord = true;
} }
if (!startOfLine) if (!startOfLine)
{ {
startOfLine = startOfWord; startOfLine = startOfWord;
start_line = true; isStartOfLine = true;
} }
} }
@ -126,14 +126,14 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
last_word.push_back(character); last_word.push_back(character);
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end()); multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
last_word.clear(); last_word.clear();
start_word = false; isStartOfWord = false;
startOfWord = -1; startOfWord = -1;
i++; ++i;
continue; continue;
} }
// Out of bounds. // Out of bounds.
if ( theLabel->getLetterPosXRight( characterSprite ) - startOfLine > theLabel->getMaxLineWidth() ) if (theLabel->getLetterPosXRight( characterSprite ) - startOfLine > theLabel->getMaxLineWidth())
{ {
if (!theLabel->breakLineWithoutSpace()) if (!theLabel->breakLineWithoutSpace())
{ {
@ -148,10 +148,10 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
if (multiline_string.size() > 0) if (multiline_string.size() > 0)
multiline_string.push_back('\n'); multiline_string.push_back('\n');
line++; ++line;
start_line = false; isStartOfLine = false;
startOfLine = -1; startOfLine = -1;
i++; ++i;
} }
else else
{ {
@ -160,11 +160,11 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
last_word.push_back('\n'); last_word.push_back('\n');
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end()); multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
last_word.clear(); last_word.clear();
start_word = false; isStartOfWord = false;
start_line = false; isStartOfLine = false;
startOfWord = -1; startOfWord = -1;
startOfLine = -1; startOfLine = -1;
line++; ++line;
if (i >= stringLength) if (i >= stringLength)
break; break;
@ -172,15 +172,15 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
if (!startOfWord) if (!startOfWord)
{ {
startOfWord = theLabel->getLetterPosXLeft( characterSprite ); startOfWord = theLabel->getLetterPosXLeft( characterSprite );
start_word = true; isStartOfWord = true;
} }
if (!startOfLine) if (!startOfLine)
{ {
startOfLine = startOfWord; startOfLine = startOfWord;
start_line = true; isStartOfLine = true;
} }
j--; --j;
} }
continue; continue;
@ -189,7 +189,7 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
{ {
// Character is normal. // Character is normal.
last_word.push_back(character); last_word.push_back(character);
i++; ++i;
continue; continue;
} }
} }
@ -197,15 +197,15 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end()); multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
int size = multiline_string.size(); int size = multiline_string.size();
unsigned short* str_new = new unsigned short[size + 1]; unsigned short* strNew = new unsigned short[size + 1];
for (int i = 0; i < size; ++i) for (int i = 0; i < size; ++i)
{ {
str_new[i] = multiline_string[i]; strNew[i] = multiline_string[i];
} }
str_new[size] = 0; strNew[size] = 0;
theLabel->assignNewUTF8String(str_new); theLabel->assignNewUTF8String(strNew);
return true; return true;
} }
@ -220,28 +220,28 @@ bool LabelTextFormatter::alignText(LabelTextFormatProtocol *theLabel)
int i = 0; int i = 0;
int lineNumber = 0; int lineNumber = 0;
int str_len = cc_wcslen(theLabel->getUTF8String()); int strLen = cc_wcslen(theLabel->getUTF8String());
vector<unsigned short> last_line; vector<unsigned short> lastLine;
for (int ctr = 0; ctr <= str_len; ++ctr) for (int ctr = 0; ctr <= strLen; ++ctr)
{ {
unsigned short int currentChar = theLabel->getCharAtStringPosition(ctr); unsigned short int currentChar = theLabel->getCharAtStringPosition(ctr);
if (currentChar == '\n' || currentChar == 0) if (currentChar == '\n' || currentChar == 0)
{ {
float lineWidth = 0.0f; float lineWidth = 0.0f;
unsigned int line_length = last_line.size(); unsigned int lineLength = lastLine.size();
// if last line is empty we must just increase lineNumber and work with next line // if last line is empty we must just increase lineNumber and work with next line
if (line_length == 0) if (lineLength == 0)
{ {
lineNumber++; lineNumber++;
continue; continue;
} }
int index = i + line_length - 1 + lineNumber; int index = i + lineLength - 1 + lineNumber;
if (index < 0) continue; if (index < 0) continue;
Sprite* lastChar = theLabel->getSpriteChild(index); Sprite* lastChar = theLabel->getSpriteChild(index);
if ( lastChar == NULL ) if (lastChar == nullptr)
continue; continue;
lineWidth = lastChar->getPosition().x + lastChar->getContentSize().width / 2.0f; lineWidth = lastChar->getPosition().x + lastChar->getContentSize().width / 2.0f;
@ -261,7 +261,7 @@ bool LabelTextFormatter::alignText(LabelTextFormatProtocol *theLabel)
if (shift != 0) if (shift != 0)
{ {
for (unsigned j = 0; j < line_length; j++) for (unsigned j = 0; j < lineLength; ++j)
{ {
index = i + j + lineNumber; index = i + j + lineNumber;
if (index < 0) continue; if (index < 0) continue;
@ -273,14 +273,14 @@ bool LabelTextFormatter::alignText(LabelTextFormatProtocol *theLabel)
} }
} }
i += line_length; i += lineLength;
lineNumber++; ++lineNumber;
last_line.clear(); lastLine.clear();
continue; continue;
} }
last_line.push_back(currentChar); lastLine.push_back(currentChar);
} }
return true; return true;
@ -311,7 +311,7 @@ bool LabelTextFormatter::createStringSprites(LabelTextFormatProtocol *theLabel)
int commonLineHeight = theLabel->getCommonLineHeight(); int commonLineHeight = theLabel->getCommonLineHeight();
totalHeight = commonLineHeight * quantityOfLines; totalHeight = commonLineHeight * quantityOfLines;
nextFontPositionY = 0 - ( commonLineHeight - totalHeight ); nextFontPositionY = 0 - (commonLineHeight - totalHeight);
Rect rect; Rect rect;
@ -340,9 +340,9 @@ bool LabelTextFormatter::createStringSprites(LabelTextFormatProtocol *theLabel)
} }
// get the sprite to this letter // get the sprite to this letter
Sprite *pLetterSprite = theLabel->getSpriteForChar(c, i); Sprite *letterSprite = theLabel->getSpriteForChar(c, i);
if (!pLetterSprite) if (!letterSprite)
{ {
log("WARNING: can't find letter definition in font file for letter: %c", c); log("WARNING: can't find letter definition in font file for letter: %c", c);
continue; continue;
@ -352,11 +352,11 @@ bool LabelTextFormatter::createStringSprites(LabelTextFormatProtocol *theLabel)
int yOffset = commonLineHeight - charYOffset; int yOffset = commonLineHeight - charYOffset;
Point fontPos = Point( (float)nextFontPositionX + charXOffset + charRect.size.width * 0.5f + kerningAmount, Point fontPos = Point((float)nextFontPositionX + charXOffset + charRect.size.width * 0.5f + kerningAmount,
(float)nextFontPositionY + yOffset - charRect.size.height * 0.5f ); (float)nextFontPositionY + yOffset - charRect.size.height * 0.5f);
// set the sprite position // set the sprite position
pLetterSprite->setPosition(CC_POINT_PIXELS_TO_POINTS(fontPos)); letterSprite->setPosition(CC_POINT_PIXELS_TO_POINTS(fontPos));
// update kerning // update kerning
nextFontPositionX += charAdvance + kerningAmount; nextFontPositionX += charAdvance + kerningAmount;

View File

@ -81,7 +81,7 @@ bool TextPageDef::generatePageTexture(bool releasePageData)
} }
Size imageSize = Size((float)(_width), (float)(_height)); Size imageSize = Size((float)(_width), (float)(_height));
if( (imageSize.width <=0) || (imageSize.height<=0) ) if((imageSize.width <= 0) || (imageSize.height <= 0))
return false; return false;
_pageTexture = new Texture2D(); _pageTexture = new Texture2D();
@ -92,7 +92,7 @@ bool TextPageDef::generatePageTexture(bool releasePageData)
bool textureCreated = _pageTexture->initWithData(_pageData, dataLenght, Texture2D::PixelFormat::RGBA8888, _width, _height, imageSize); bool textureCreated = _pageTexture->initWithData(_pageData, dataLenght, Texture2D::PixelFormat::RGBA8888, _width, _height, imageSize);
// release the page data if requested // release the page data if requested
if ( releasePageData && textureCreated ) if (releasePageData && textureCreated)
{ {
delete [] _pageData; delete [] _pageData;
_pageData = 0; _pageData = 0;
@ -123,7 +123,7 @@ TextFontPagesDef::TextFontPagesDef()
TextFontPagesDef::~TextFontPagesDef() TextFontPagesDef::~TextFontPagesDef()
{ {
int numPages = _pages.size(); int numPages = _pages.size();
for( int c = 0; c<numPages; ++c ) for( int c = 0; c < numPages; ++c )
{ {
if (_pages[c]) if (_pages[c])
delete _pages[c]; delete _pages[c];
@ -143,7 +143,7 @@ TextImage::~TextImage()
_font->release(); _font->release();
} }
bool TextImage::initWithString(const char *text, int nWidth, int nHeight, cocos2d::Font* font, bool releaseRAWData) bool TextImage::initWithString(const char *text, int width, int height, cocos2d::Font* font, bool releaseRAWData)
{ {
bool textIsUTF16 = false; bool textIsUTF16 = false;
@ -157,14 +157,14 @@ bool TextImage::initWithString(const char *text, int nWidth, int nHeight, cocos2
_font = font; _font = font;
// generate the glyphs for the requested text (glyphs are latter's bounding boxes) // generate the glyphs for the requested text (glyphs are latter's bounding boxes)
if ( !generateTextGlyphs(text) ) if (!generateTextGlyphs(text))
return false; return false;
Size constrainSize; Size constrainSize;
unsigned short int *strUTF16 = 0; unsigned short int *strUTF16 = 0;
int stringNumChars; int stringNumChars;
if ( textIsUTF16 ) if (textIsUTF16)
{ {
strUTF16 = (unsigned short int *)text; strUTF16 = (unsigned short int *)text;
stringNumChars = cc_wcslen(strUTF16); stringNumChars = cc_wcslen(strUTF16);
@ -179,11 +179,11 @@ bool TextImage::initWithString(const char *text, int nWidth, int nHeight, cocos2
return false; return false;
// create all the needed pages // create all the needed pages
if (!createPageDefinitions(strUTF16, nWidth, nHeight, _font->getFontMaxHeight())) if (!createPageDefinitions(strUTF16, width, height, _font->getFontMaxHeight()))
return false; return false;
// release the original string if needed // release the original string if needed
if ( !textIsUTF16 ) if (!textIsUTF16)
delete [] strUTF16; delete [] strUTF16;
// actually create the needed images // actually create the needed images
@ -212,7 +212,7 @@ bool TextImage::createPageDefinitions(unsigned short int *inText, int imageWidth
// create the first page (ther is going to be at least one page) // create the first page (ther is going to be at least one page)
TextPageDef *currentPageDef = new TextPageDef(currentPage, imageWidth, imageHeight); TextPageDef *currentPageDef = new TextPageDef(currentPage, imageWidth, imageHeight);
if ( !currentPageDef ) if (!currentPageDef)
return false; return false;
// add the current page // add the current page
@ -223,14 +223,14 @@ bool TextImage::createPageDefinitions(unsigned short int *inText, int imageWidth
do { do {
// choose texture page // choose texture page
if ( ( currentY + lineHeight ) > imageHeight ) if ((currentY + lineHeight) > imageHeight)
{ {
currentY = 0; currentY = 0;
currentPage += 1; currentPage += 1;
// create a new page and add // create a new page and add
currentPageDef = new TextPageDef(currentPage, imageWidth, imageHeight); currentPageDef = new TextPageDef(currentPage, imageWidth, imageHeight);
if ( !currentPageDef ) if (!currentPageDef)
return false; return false;
_fontPages->addPage(currentPageDef); _fontPages->addPage(currentPageDef);
@ -251,7 +251,7 @@ bool TextImage::createPageDefinitions(unsigned short int *inText, int imageWidth
// create the new line and add to the current page // create the new line and add to the current page
TextLineDef *newLine = new TextLineDef(0.0, currentY, newLineSize, lineHeight); TextLineDef *newLine = new TextLineDef(0.0, currentY, newLineSize, lineHeight);
if ( !newLine ) if (!newLine)
return false; return false;
// add all the glyphs to this line // add all the glyphs to this line
@ -268,7 +268,7 @@ bool TextImage::createPageDefinitions(unsigned short int *inText, int imageWidth
delta = (stringLenght - numFittingChar); delta = (stringLenght - numFittingChar);
// there is still some leftover, need to work on it // there is still some leftover, need to work on it
if ( delta ) if (delta)
{ {
// create the new string // create the new string
unsigned short int *tempS = _font->trimUTF16Text(strUTF16, numFittingChar, (stringLenght - 1)); unsigned short int *tempS = _font->trimUTF16Text(strUTF16, numFittingChar, (stringLenght - 1));
@ -286,7 +286,7 @@ bool TextImage::createPageDefinitions(unsigned short int *inText, int imageWidth
// go to next line // go to next line
currentY += lineHeight; currentY += lineHeight;
} while( delta ); } while(delta);
if (needToReleaseText) if (needToReleaseText)
delete [] strUTF16; delete [] strUTF16;
@ -305,7 +305,7 @@ int TextImage::getNumGlyphsFittingInSize(std::map<unsigned short int, GlyphDef>
// get the string to UTF8 // get the string to UTF8
int numChar = cc_wcslen(strUTF8); int numChar = cc_wcslen(strUTF8);
for (int c = 0; c<numChar; ++c) for (int c = 0; c < numChar; ++c)
{ {
widthWithBBX += (glyphDefs[strUTF8[c]].getRect().size.width + glyphDefs[strUTF8[c]].getPadding()); widthWithBBX += (glyphDefs[strUTF8[c]].getRect().size.width + glyphDefs[strUTF8[c]].getPadding());
@ -332,7 +332,7 @@ bool TextImage::addGlyphsToLine(TextLineDef *line, const char *lineText, bool te
if (textIsUTF16) if (textIsUTF16)
{ {
UTF16string = (unsigned short int *) lineText; UTF16string = (unsigned short int *)lineText;
numLetters = cc_wcslen(UTF16string); numLetters = cc_wcslen(UTF16string);
} }
else else
@ -340,7 +340,7 @@ bool TextImage::addGlyphsToLine(TextLineDef *line, const char *lineText, bool te
UTF16string = _font->getUTF16Text(lineText, numLetters); UTF16string = _font->getUTF16Text(lineText, numLetters);
} }
for (int c=0; c<numLetters; ++c) for (int c = 0; c < numLetters; ++c)
{ {
_textGlyphs[UTF16string[c]].setCommonHeight(line->getHeight()); _textGlyphs[UTF16string[c]].setCommonHeight(line->getHeight());
line->addGlyph(_textGlyphs[UTF16string[c]] ); line->addGlyph(_textGlyphs[UTF16string[c]] );
@ -352,24 +352,24 @@ bool TextImage::addGlyphsToLine(TextLineDef *line, const char *lineText, bool te
return true; return true;
} }
bool TextImage::generateTextGlyphs(const char * pText) bool TextImage::generateTextGlyphs(const char * text)
{ {
if (!_font) if (!_font)
return false; return false;
int numGlyphs = 0; int numGlyphs = 0;
GlyphDef *pNewGlyphs = _font->getGlyphDefintionsForText(pText, numGlyphs); GlyphDef *newGlyphs = _font->getGlyphDefintionsForText(text, numGlyphs);
if (!pNewGlyphs) if (!newGlyphs)
return false; return false;
if (!_textGlyphs.empty()) if (!_textGlyphs.empty())
_textGlyphs.clear(); _textGlyphs.clear();
for (int c=0; c < numGlyphs; ++c) for (int c = 0; c < numGlyphs; ++c)
_textGlyphs[pNewGlyphs[c].getUTF8Letter()] = pNewGlyphs[c]; _textGlyphs[newGlyphs[c].getUTF8Letter()] = newGlyphs[c];
delete [] pNewGlyphs; delete [] newGlyphs;
return true; return true;
} }
@ -381,13 +381,13 @@ bool TextImage::createImageDataFromPages(TextFontPagesDef *thePages, bool releas
for (int c = 0; c < numPages; ++c) for (int c = 0; c < numPages; ++c)
{ {
unsigned char *pPageData = 0; unsigned char *pageData = 0;
pPageData = preparePageGlyphData(thePages->getPageAt(c)); pageData = preparePageGlyphData(thePages->getPageAt(c));
if (pPageData) if (pageData)
{ {
// set the page data // set the page data
thePages->getPageAt(c)->setPageData(pPageData); thePages->getPageAt(c)->setPageData(pageData);
// crete page texture and relase RAW data // crete page texture and relase RAW data
thePages->getPageAt(c)->preparePageTexture(releaseRAWData); thePages->getPageAt(c)->preparePageTexture(releaseRAWData);
@ -396,7 +396,6 @@ bool TextImage::createImageDataFromPages(TextFontPagesDef *thePages, bool releas
{ {
return false; return false;
} }
} }
return true; return true;
@ -432,18 +431,18 @@ unsigned char * TextImage::renderGlyphData(TextPageDef *thePage)
int numLines = thePage->getNumLines(); int numLines = thePage->getNumLines();
for (int c = 0; c<numLines; ++c) for (int c = 0; c < numLines; ++c)
{ {
TextLineDef *pCurrentLine = thePage->getLineAt(c); TextLineDef *currentLine = thePage->getLineAt(c);
float origX = _font->getLetterPadding(); float origX = _font->getLetterPadding();
float origY = pCurrentLine->getY(); float origY = currentLine->getY();
int numGlyphToRender = pCurrentLine->getNumGlyph(); int numGlyphToRender = currentLine->getNumGlyph();
for (int cglyph = 0; cglyph < numGlyphToRender; ++cglyph) for (int cglyph = 0; cglyph < numGlyphToRender; ++cglyph)
{ {
GlyphDef currGlyph = pCurrentLine->getGlyphAt(cglyph); GlyphDef currGlyph = currentLine->getGlyphAt(cglyph);
renderCharAt(currGlyph.getUTF8Letter(), origX, origY, data, pageWidth); renderCharAt(currGlyph.getUTF8Letter(), origX, origY, data, pageWidth);
origX += (currGlyph.getRect().size.width + _font->getLetterPadding()); origX += (currGlyph.getRect().size.width + _font->getLetterPadding());
} }
@ -454,9 +453,9 @@ unsigned char * TextImage::renderGlyphData(TextPageDef *thePage)
char outFilename[512]; char outFilename[512];
sprintf(outFilename,"testIMG%d", counter); sprintf(outFilename,"testIMG%d", counter);
++counter; ++counter;
Image *pImage = new Image; Image *image = new Image;
pImage->initWithRawData(data, (pageWidth * pageWidth * 4), 1024, 1024, 8, false); image->initWithRawData(data, (pageWidth * pageWidth * 4), 1024, 1024, 8, false);
pImage->saveToFile(outFilename); image->saveToFile(outFilename);
#endif #endif
// we are done here // we are done here
@ -475,7 +474,7 @@ bool TextImage::renderCharAt(unsigned short int charToRender, int posX, int posY
// get the glyph's bitmap // get the glyph's bitmap
sourceBitmap = _font->getGlyphBitmap(charToRender, sourceWidth, sourceHeight); sourceBitmap = _font->getGlyphBitmap(charToRender, sourceWidth, sourceHeight);
if(!sourceBitmap) if (!sourceBitmap)
return false; return false;
int iX = posX; int iX = posX;

View File

@ -43,12 +43,12 @@ class CC_DLL GlyphDef
public: public:
GlyphDef() : _validGlyph(false) { /*do nothing*/ } GlyphDef() : _validGlyph(false) { /*do nothing*/ }
GlyphDef(unsigned short int letterUTF8, Rect &rect) { _gliphRect = rect; _uTF16Letter = letterUTF8; } GlyphDef(unsigned short int letterUTF8, const Rect &rect) { _gliphRect = rect; _uTF16Letter = letterUTF8; }
void setUTF16Letter(unsigned short int letterUTF8) { _uTF16Letter = letterUTF8; } void setUTF16Letter(unsigned short int letterUTF8) { _uTF16Letter = letterUTF8; }
void setRect(Rect & theRect) { _gliphRect = theRect; } void setRect(const Rect & theRect) { _gliphRect = theRect; }
unsigned short int getUTF8Letter() { return _uTF16Letter; } unsigned short int getUTF8Letter() { return _uTF16Letter; }
Rect & getRect() { return _gliphRect; } const Rect & getRect() const { return _gliphRect; }
void setPadding(float padding) { _padding = padding; } void setPadding(float padding) { _padding = padding; }
float getPadding() { return _padding; } float getPadding() { return _padding; }
void setCommonHeight(float commonHeight) { _commonHeight = commonHeight; } void setCommonHeight(float commonHeight) { _commonHeight = commonHeight; }
@ -77,14 +77,14 @@ public:
TextLineDef(float x, float y, float width, float height); TextLineDef(float x, float y, float width, float height);
float getX() { return _x; } float getX() const { return _x; }
float getY() { return _y; } float getY() const { return _y; }
float getWidth() { return _width; } float getWidth() const { return _width; }
float getHeight() { return _height; } float getHeight() const { return _height; }
void addGlyph(GlyphDef theGlyph) { _glyphs.push_back(theGlyph); } void addGlyph(GlyphDef theGlyph) { _glyphs.push_back(theGlyph); }
int getNumGlyph() { return _glyphs.size(); } int getNumGlyph() const { return _glyphs.size(); }
GlyphDef & getGlyphAt(int index) { return _glyphs[index]; } const GlyphDef & getGlyphAt(int index) const { return _glyphs[index]; }
private: private:
@ -104,18 +104,24 @@ private:
class CC_DLL TextPageDef class CC_DLL TextPageDef
{ {
public: public:
/**
* @js NA
*/
TextPageDef(int pageNum, int width, int height); TextPageDef(int pageNum, int width, int height);
/**
* @js NA
* @lua NA
*/
~TextPageDef(); ~TextPageDef();
void addLine(TextLineDef *theLine) { _lines.push_back(theLine); } void addLine(TextLineDef *theLine) { _lines.push_back(theLine); }
int getNumLines() { return _lines.size(); } int getNumLines() const { return _lines.size(); }
TextLineDef * getLineAt(int index) { return _lines[index]; } TextLineDef * getLineAt(int index) const { return _lines[index]; }
int getWidth() { return _width; } int getWidth() const { return _width; }
int getHeight() { return _height; } int getHeight() const { return _height; }
int getPageNumber() { return _pageNum; } int getPageNumber() const { return _pageNum; }
void setPageData(unsigned char *pData) { _pageData = pData; } void setPageData(unsigned char *data) { _pageData = data; }
unsigned char * getPageData() { return _pageData; } const unsigned char * getPageData() const { return _pageData; }
Texture2D *getPageTexture(); Texture2D *getPageTexture();
void preparePageTexture(bool releaseRAWData = true); void preparePageTexture(bool releaseRAWData = true);
@ -139,13 +145,19 @@ private:
class CC_DLL TextFontPagesDef class CC_DLL TextFontPagesDef
{ {
public: public:
/**
* @js ctor
*/
TextFontPagesDef(); TextFontPagesDef();
/**
* @js NA
* @lua NA
*/
~TextFontPagesDef(); ~TextFontPagesDef();
void addPage(TextPageDef *newPage) { _pages.push_back(newPage); } void addPage(TextPageDef *newPage) { _pages.push_back(newPage); }
int getNumPages() { return _pages.size(); } int getNumPages() const { return _pages.size(); }
TextPageDef* getPageAt(int index) { return _pages[index]; } TextPageDef* getPageAt(int index) const { return _pages[index]; }
private: private:
@ -159,20 +171,26 @@ private:
class CC_DLL TextImage class CC_DLL TextImage
{ {
public: public:
/**
* @js ctor
*/
TextImage(); TextImage();
/**
* @js NA
* @lua NA
*/
~TextImage(); ~TextImage();
bool initWithString(const char *text, int nWidth, int nHeight, Font* font, bool releaseRAWData = true); bool initWithString(const char *text, int width, int height, Font* font, bool releaseRAWData = true);
TextFontPagesDef * getPages() { return _fontPages; } TextFontPagesDef * getPages() const { return _fontPages; }
Font * getFont() { return _font; } Font * getFont() const { return _font; }
private: private:
bool createImageDataFromPages(TextFontPagesDef *thePages, bool releaseRAWData = true); bool createImageDataFromPages(TextFontPagesDef *thePages, bool releaseRAWData = true);
bool addGlyphsToLine(TextLineDef *line, const char *lineText, bool textIsUTF16 = false); bool addGlyphsToLine(TextLineDef *line, const char *lineText, bool textIsUTF16 = false);
bool generateTextGlyphs(const char * pText); bool generateTextGlyphs(const char * text);
int getNumGlyphsFittingInSize(std::map<unsigned short int, GlyphDef> &glyphDefs, unsigned short int *strUTF8, Font *pFont, Size *constrainSize, int &outNewSize); int getNumGlyphsFittingInSize(std::map<unsigned short int, GlyphDef> &glyphDefs, unsigned short int *strUTF8, Font *pFont, Size *constrainSize, int &outNewSize);
bool createPageDefinitions(unsigned short int *inText, int imageWidth, int imageHeight, int lineHeight); bool createPageDefinitions(unsigned short int *inText, int imageWidth, int imageHeight, int lineHeight);
unsigned char * preparePageGlyphData(TextPageDef *thePage); unsigned char * preparePageGlyphData(TextPageDef *thePage);

View File

@ -60,7 +60,14 @@ class CC_DLL Layer : public Node, public TouchDelegate, public KeypadDelegate
public: public:
/** creates a fullscreen black layer */ /** creates a fullscreen black layer */
static Layer *create(void); static Layer *create(void);
/**
* @js ctor
*/
Layer(); Layer();
/**
* @js NA
* @lua NA
*/
virtual ~Layer(); virtual ~Layer();
virtual bool init(); virtual bool init();
@ -75,7 +82,10 @@ public:
virtual void ccTouchesMoved(Set *touches, Event *event); virtual void ccTouchesMoved(Set *touches, Event *event);
virtual void ccTouchesEnded(Set *touches, Event *event); virtual void ccTouchesEnded(Set *touches, Event *event);
virtual void ccTouchesCancelled(Set *touches, Event *event); virtual void ccTouchesCancelled(Set *touches, Event *event);
/**
* @js NA
* @lua NA
*/
virtual void didAccelerate(Acceleration* accelerationValue); virtual void didAccelerate(Acceleration* accelerationValue);
/** If isTouchEnabled, this method is called onEnter. Override it to change the /** If isTouchEnabled, this method is called onEnter. Override it to change the
@ -124,7 +134,15 @@ public:
virtual bool isKeyboardEnabled() const; virtual bool isKeyboardEnabled() const;
virtual void setKeyboardEnabled(bool value); virtual void setKeyboardEnabled(bool value);
/**
* @js NA
* @lua NA
*/
virtual void keyPressed(int keyCode) {}; virtual void keyPressed(int keyCode) {};
/**
* @js NA
* @lua NA
*/
virtual void keyReleased(int keyCode) {}; virtual void keyReleased(int keyCode) {};
virtual bool isKeypadEnabled() const; virtual bool isKeypadEnabled() const;
@ -135,8 +153,20 @@ public:
// //
// Overrides // Overrides
// //
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
/**
* @js NA
* @lua NA
*/
virtual void onExit() override; virtual void onExit() override;
/**
* @js NA
* @lua NA
*/
virtual void onEnterTransitionDidFinish() override; virtual void onEnterTransitionDidFinish() override;
protected: protected:
@ -170,8 +200,14 @@ class CC_DLL LayerRGBA : public Layer, public RGBAProtocol
{ {
public: public:
CREATE_FUNC(LayerRGBA); CREATE_FUNC(LayerRGBA);
/**
* @js ctor
*/
LayerRGBA(); LayerRGBA();
/**
* @js NA
* @lua NA
*/
virtual ~LayerRGBA(); virtual ~LayerRGBA();
virtual bool init(); virtual bool init();
@ -222,14 +258,26 @@ public:
static LayerColor * create(const Color4B& color, GLfloat width, GLfloat height); static LayerColor * create(const Color4B& color, GLfloat width, GLfloat height);
/** creates a Layer with color. Width and height are the window size. */ /** creates a Layer with color. Width and height are the window size. */
static LayerColor * create(const Color4B& color); static LayerColor * create(const Color4B& color);
/**
* @js ctor
*/
LayerColor(); LayerColor();
/**
* @js NA
* @lua NA
*/
virtual ~LayerColor(); virtual ~LayerColor();
virtual bool init(); virtual bool init();
/** initializes a Layer with color, width and height in Points */ /** initializes a Layer with color, width and height in Points
* @js init
* @lua init
*/
bool initWithColor(const Color4B& color, GLfloat width, GLfloat height); bool initWithColor(const Color4B& color, GLfloat width, GLfloat height);
/** initializes a Layer with color. Width and height are the window size. */ /** initializes a Layer with color. Width and height are the window size.
* @js init
* @lua init
*/
bool initWithColor(const Color4B& color); bool initWithColor(const Color4B& color);
/** change width in Points*/ /** change width in Points*/
@ -249,7 +297,18 @@ public:
virtual void setOpacity(GLubyte opacity) override; virtual void setOpacity(GLubyte opacity) override;
virtual void setContentSize(const Size & var) override; virtual void setContentSize(const Size & var) override;
/** BlendFunction. Conforms to BlendProtocol protocol */ /** BlendFunction. Conforms to BlendProtocol protocol */
/**
* @js NA
* @lua NA
*/
virtual const BlendFunc& getBlendFunc() const override; virtual const BlendFunc& getBlendFunc() const override;
/**
*@code
*When this function bound into js or lua,the parameter will be changed
*In js: var setBlendFunc(var src, var dst)
*In lua: local setBlendFunc(local src, local dst)
*@endcode
*/
virtual void setBlendFunc(const BlendFunc& blendFunc) override; virtual void setBlendFunc(const BlendFunc& blendFunc) override;
protected: protected:
@ -295,10 +354,16 @@ public:
static LayerGradient* create(const Color4B& start, const Color4B& end, const Point& v); static LayerGradient* create(const Color4B& start, const Color4B& end, const Point& v);
virtual bool init(); virtual bool init();
/** Initializes the Layer with a gradient between start and end. */ /** Initializes the Layer with a gradient between start and end.
* @js init
* @lua init
*/
bool initWithColor(const Color4B& start, const Color4B& end); bool initWithColor(const Color4B& start, const Color4B& end);
/** Initializes the Layer with a gradient between start and end in the direction of v. */ /** Initializes the Layer with a gradient between start and end in the direction of v.
* @js init
* @lua init
*/
bool initWithColor(const Color4B& start, const Color4B& end, const Point& v); bool initWithColor(const Color4B& start, const Color4B& end, const Point& v);
/** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors /** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors
@ -354,28 +419,49 @@ Features:
class CC_DLL LayerMultiplex : public Layer class CC_DLL LayerMultiplex : public Layer
{ {
public: public:
/** creates and initializes a LayerMultiplex object */ /** creates and initializes a LayerMultiplex object
* @js NA
* @lua NA
*/
static LayerMultiplex* create(); static LayerMultiplex* create();
/** creates a LayerMultiplex with an array of layers. /** creates a LayerMultiplex with an array of layers.
@since v2.1 @since v2.1
* @js NA
*/ */
static LayerMultiplex* createWithArray(Array* arrayOfLayers); static LayerMultiplex* createWithArray(Array* arrayOfLayers);
/** creates a LayerMultiplex with one or more layers using a variable argument list. */ /** creates a LayerMultiplex with one or more layers using a variable argument list.
* @code
* When this function bound to lua or js,the input params are changed.
* In js:var create(...)
* In lua:local create(...)
* @endcode
*/
static LayerMultiplex * create(Layer* layer, ... ); static LayerMultiplex * create(Layer* layer, ... );
/** /**
* lua script can not init with undetermined number of variables * lua script can not init with undetermined number of variables
* so add these functions to be used with lua. * so add these functions to be used with lua.
* @js NA
* @lua NA
*/ */
static LayerMultiplex * createWithLayer(Layer* layer); static LayerMultiplex * createWithLayer(Layer* layer);
/**
* @js ctor
*/
LayerMultiplex(); LayerMultiplex();
/**
* @js NA
* @lua NA
*/
virtual ~LayerMultiplex(); virtual ~LayerMultiplex();
virtual bool init(); virtual bool init();
/** initializes a MultiplexLayer with one or more layers using a variable argument list. */ /** initializes a MultiplexLayer with one or more layers using a variable argument list.
* @js NA
* @lua NA
*/
bool initWithLayers(Layer* layer, va_list params); bool initWithLayers(Layer* layer, va_list params);
/** initializes a MultiplexLayer with an array of layers /** initializes a MultiplexLayer with an array of layers

View File

@ -53,6 +53,10 @@ public:
static Scene *create(void); static Scene *create(void);
Scene(); Scene();
/**
* @js NA
* @lua NA
*/
virtual ~Scene(); virtual ~Scene();
bool init(); bool init();

View File

@ -77,8 +77,14 @@ public:
/** creates a base transition with duration and incoming scene */ /** creates a base transition with duration and incoming scene */
static TransitionScene * create(float t, Scene *scene); static TransitionScene * create(float t, Scene *scene);
/**
* @js ctor
*/
TransitionScene(); TransitionScene();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionScene(); virtual ~TransitionScene();
/** initializes a transition with duration and incoming scene */ /** initializes a transition with duration and incoming scene */
@ -94,7 +100,15 @@ public:
// Overrides // Overrides
// //
virtual void draw() override; virtual void draw() override;
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
/**
* @js NA
* @lua NA
*/
virtual void onExit() override; virtual void onExit() override;
virtual void cleanup() override; virtual void cleanup() override;
@ -120,8 +134,14 @@ class CC_DLL TransitionSceneOriented : public TransitionScene
public: public:
/** creates a base transition with duration and incoming scene */ /** creates a base transition with duration and incoming scene */
static TransitionSceneOriented * create(float t,Scene* scene, Orientation orientation); static TransitionSceneOriented * create(float t,Scene* scene, Orientation orientation);
/**
* @js ctor
*/
TransitionSceneOriented(); TransitionSceneOriented();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionSceneOriented(); virtual ~TransitionSceneOriented();
/** initializes a transition with duration and incoming scene */ /** initializes a transition with duration and incoming scene */
@ -140,11 +160,19 @@ public:
static TransitionRotoZoom* create(float t, Scene* scene); static TransitionRotoZoom* create(float t, Scene* scene);
TransitionRotoZoom(); TransitionRotoZoom();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionRotoZoom(); virtual ~TransitionRotoZoom();
// //
// Overrides // Overrides
// //
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
}; };
@ -155,13 +183,23 @@ class CC_DLL TransitionJumpZoom : public TransitionScene
{ {
public: public:
static TransitionJumpZoom* create(float t, Scene* scene); static TransitionJumpZoom* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionJumpZoom(); TransitionJumpZoom();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionJumpZoom(); virtual ~TransitionJumpZoom();
// //
// Overrides // Overrides
// //
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
}; };
@ -172,8 +210,14 @@ class CC_DLL TransitionMoveInL : public TransitionScene, public TransitionEaseSc
{ {
public: public:
static TransitionMoveInL* create(float t, Scene* scene); static TransitionMoveInL* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionMoveInL(); TransitionMoveInL();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionMoveInL(); virtual ~TransitionMoveInL();
/** initializes the scenes */ /** initializes the scenes */
virtual void initScenes(void); virtual void initScenes(void);
@ -185,6 +229,10 @@ public:
// //
// Overrides // Overrides
// //
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
}; };
@ -195,8 +243,14 @@ class CC_DLL TransitionMoveInR : public TransitionMoveInL
{ {
public: public:
static TransitionMoveInR* create(float t, Scene* scene); static TransitionMoveInR* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionMoveInR(); TransitionMoveInR();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionMoveInR(); virtual ~TransitionMoveInR();
virtual void initScenes(); virtual void initScenes();
}; };
@ -208,8 +262,14 @@ class CC_DLL TransitionMoveInT : public TransitionMoveInL
{ {
public: public:
static TransitionMoveInT* create(float t, Scene* scene); static TransitionMoveInT* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionMoveInT(); TransitionMoveInT();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionMoveInT(); virtual ~TransitionMoveInT();
virtual void initScenes(); virtual void initScenes();
}; };
@ -221,8 +281,14 @@ class CC_DLL TransitionMoveInB : public TransitionMoveInL
{ {
public: public:
static TransitionMoveInB* create(float t, Scene* scene); static TransitionMoveInB* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionMoveInB(); TransitionMoveInB();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionMoveInB(); virtual ~TransitionMoveInB();
virtual void initScenes(); virtual void initScenes();
}; };
@ -234,8 +300,14 @@ class CC_DLL TransitionSlideInL : public TransitionScene, public TransitionEaseS
{ {
public: public:
static TransitionSlideInL* create(float t, Scene* scene); static TransitionSlideInL* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionSlideInL(); TransitionSlideInL();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionSlideInL(); virtual ~TransitionSlideInL();
virtual ActionInterval* easeActionWithAction(ActionInterval * action); virtual ActionInterval* easeActionWithAction(ActionInterval * action);
@ -248,6 +320,10 @@ public:
// //
// Overrides // Overrides
// //
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
protected: protected:
@ -261,8 +337,14 @@ class CC_DLL TransitionSlideInR : public TransitionSlideInL
{ {
public: public:
static TransitionSlideInR* create(float t, Scene* scene); static TransitionSlideInR* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionSlideInR(); TransitionSlideInR();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionSlideInR(); virtual ~TransitionSlideInR();
/** initializes the scenes */ /** initializes the scenes */
@ -281,8 +363,14 @@ class CC_DLL TransitionSlideInB : public TransitionSlideInL
{ {
public: public:
static TransitionSlideInB* create(float t, Scene* scene); static TransitionSlideInB* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionSlideInB(); TransitionSlideInB();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionSlideInB(); virtual ~TransitionSlideInB();
/** initializes the scenes */ /** initializes the scenes */
@ -301,8 +389,14 @@ class CC_DLL TransitionSlideInT : public TransitionSlideInL
{ {
public: public:
static TransitionSlideInT* create(float t, Scene* scene); static TransitionSlideInT* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionSlideInT(); TransitionSlideInT();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionSlideInT(); virtual ~TransitionSlideInT();
/** initializes the scenes */ /** initializes the scenes */
@ -321,8 +415,14 @@ class CC_DLL TransitionShrinkGrow : public TransitionScene , public TransitionEa
{ {
public: public:
static TransitionShrinkGrow* create(float t, Scene* scene); static TransitionShrinkGrow* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionShrinkGrow(); TransitionShrinkGrow();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionShrinkGrow(); virtual ~TransitionShrinkGrow();
// //
@ -341,13 +441,23 @@ class CC_DLL TransitionFlipX : public TransitionSceneOriented
public: public:
static TransitionFlipX* create(float t, Scene* s, Orientation o); static TransitionFlipX* create(float t, Scene* s, Orientation o);
static TransitionFlipX* create(float t, Scene* s); static TransitionFlipX* create(float t, Scene* s);
/**
* @js ctor
*/
TransitionFlipX(); TransitionFlipX();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFlipX(); virtual ~TransitionFlipX();
// //
// Overrides // Overrides
// //
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
}; };
@ -360,13 +470,23 @@ class CC_DLL TransitionFlipY : public TransitionSceneOriented
public: public:
static TransitionFlipY* create(float t, Scene* s, Orientation o); static TransitionFlipY* create(float t, Scene* s, Orientation o);
static TransitionFlipY* create(float t, Scene* s); static TransitionFlipY* create(float t, Scene* s);
/**
* @js ctor
*/
TransitionFlipY(); TransitionFlipY();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFlipY(); virtual ~TransitionFlipY();
// //
// Overrides // Overrides
// //
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
}; };
@ -379,13 +499,23 @@ class CC_DLL TransitionFlipAngular : public TransitionSceneOriented
public: public:
static TransitionFlipAngular* create(float t, Scene* s, Orientation o); static TransitionFlipAngular* create(float t, Scene* s, Orientation o);
static TransitionFlipAngular* create(float t, Scene* s); static TransitionFlipAngular* create(float t, Scene* s);
/**
* @js ctor
*/
TransitionFlipAngular(); TransitionFlipAngular();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFlipAngular(); virtual ~TransitionFlipAngular();
// //
// Overrides // Overrides
// //
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
}; };
@ -398,13 +528,23 @@ class CC_DLL TransitionZoomFlipX : public TransitionSceneOriented
public: public:
static TransitionZoomFlipX* create(float t, Scene* s, Orientation o); static TransitionZoomFlipX* create(float t, Scene* s, Orientation o);
static TransitionZoomFlipX* create(float t, Scene* s); static TransitionZoomFlipX* create(float t, Scene* s);
/**
* @js ctor
*/
TransitionZoomFlipX(); TransitionZoomFlipX();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionZoomFlipX(); virtual ~TransitionZoomFlipX();
// //
// Overrides // Overrides
// //
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
}; };
@ -417,13 +557,23 @@ class CC_DLL TransitionZoomFlipY : public TransitionSceneOriented
public: public:
static TransitionZoomFlipY* create(float t, Scene* s, Orientation o); static TransitionZoomFlipY* create(float t, Scene* s, Orientation o);
static TransitionZoomFlipY* create(float t, Scene* s); static TransitionZoomFlipY* create(float t, Scene* s);
/**
* @js ctor
*/
TransitionZoomFlipY(); TransitionZoomFlipY();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionZoomFlipY(); virtual ~TransitionZoomFlipY();
// //
// Overrides // Overrides
// //
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
}; };
@ -436,13 +586,23 @@ class CC_DLL TransitionZoomFlipAngular : public TransitionSceneOriented
public: public:
static TransitionZoomFlipAngular* create(float t, Scene* s, Orientation o); static TransitionZoomFlipAngular* create(float t, Scene* s, Orientation o);
static TransitionZoomFlipAngular* create(float t, Scene* s); static TransitionZoomFlipAngular* create(float t, Scene* s);
/**
* @js ctor
*/
TransitionZoomFlipAngular(); TransitionZoomFlipAngular();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionZoomFlipAngular(); virtual ~TransitionZoomFlipAngular();
// //
// Overrides // Overrides
// //
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
}; };
@ -457,8 +617,14 @@ public:
*/ */
static TransitionFade* create(float duration,Scene* scene, const Color3B& color); static TransitionFade* create(float duration,Scene* scene, const Color3B& color);
static TransitionFade* create(float duration,Scene* scene); static TransitionFade* create(float duration,Scene* scene);
/**
* @js ctor
*/
TransitionFade(); TransitionFade();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFade(); virtual ~TransitionFade();
/** initializes the transition with a duration and with an RGB color */ /** initializes the transition with a duration and with an RGB color */
@ -468,7 +634,15 @@ public:
// Overrides // Overrides
// //
bool initWithDuration(float t,Scene* scene); bool initWithDuration(float t,Scene* scene);
/**
* @js NA
* @lua NA
*/
virtual void onEnter(); virtual void onEnter();
/**
* @js NA
* @lua NA
*/
virtual void onExit(); virtual void onExit();
protected: protected:
@ -484,15 +658,29 @@ class CC_DLL TransitionCrossFade : public TransitionScene
{ {
public : public :
static TransitionCrossFade* create(float t, Scene* scene); static TransitionCrossFade* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionCrossFade(); TransitionCrossFade();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionCrossFade(); virtual ~TransitionCrossFade();
// //
// Overrides // Overrides
// //
virtual void draw() override; virtual void draw() override;
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
/**
* @js NA
* @lua NA
*/
virtual void onExit() override; virtual void onExit() override;
}; };
@ -504,13 +692,23 @@ class CC_DLL TransitionTurnOffTiles : public TransitionScene ,public TransitionE
{ {
public : public :
static TransitionTurnOffTiles* create(float t, Scene* scene); static TransitionTurnOffTiles* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionTurnOffTiles(); TransitionTurnOffTiles();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionTurnOffTiles(); virtual ~TransitionTurnOffTiles();
// //
// Overrides // Overrides
// //
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override; virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
@ -525,8 +723,14 @@ class CC_DLL TransitionSplitCols : public TransitionScene , public TransitionEas
{ {
public: public:
static TransitionSplitCols* create(float t, Scene* scene); static TransitionSplitCols* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionSplitCols(); TransitionSplitCols();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionSplitCols(); virtual ~TransitionSplitCols();
virtual ActionInterval* action(void); virtual ActionInterval* action(void);
@ -534,6 +738,10 @@ public:
// //
// Overrides // Overrides
// //
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override; virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
}; };
@ -545,8 +753,14 @@ class CC_DLL TransitionSplitRows : public TransitionSplitCols
{ {
public: public:
static TransitionSplitRows* create(float t, Scene* scene); static TransitionSplitRows* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionSplitRows(); TransitionSplitRows();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionSplitRows(); virtual ~TransitionSplitRows();
// //
@ -562,14 +776,24 @@ class CC_DLL TransitionFadeTR : public TransitionScene , public TransitionEaseSc
{ {
public: public:
static TransitionFadeTR* create(float t, Scene* scene); static TransitionFadeTR* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionFadeTR(); TransitionFadeTR();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFadeTR(); virtual ~TransitionFadeTR();
virtual ActionInterval* actionWithSize(const Size& size); virtual ActionInterval* actionWithSize(const Size& size);
// //
// Overrides // Overrides
// //
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override; virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
@ -584,8 +808,14 @@ class CC_DLL TransitionFadeBL : public TransitionFadeTR
{ {
public: public:
static TransitionFadeBL* create(float t, Scene* scene); static TransitionFadeBL* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionFadeBL(); TransitionFadeBL();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFadeBL(); virtual ~TransitionFadeBL();
// //
@ -602,8 +832,14 @@ class CC_DLL TransitionFadeUp : public TransitionFadeTR
{ {
public: public:
static TransitionFadeUp* create(float t, Scene* scene); static TransitionFadeUp* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionFadeUp(); TransitionFadeUp();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFadeUp(); virtual ~TransitionFadeUp();
// //
@ -619,8 +855,14 @@ class CC_DLL TransitionFadeDown : public TransitionFadeTR
{ {
public: public:
static TransitionFadeDown* create(float t, Scene* scene); static TransitionFadeDown* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionFadeDown(); TransitionFadeDown();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFadeDown(); virtual ~TransitionFadeDown();
// //

View File

@ -55,8 +55,14 @@ public:
* scene is being turned from left over the outgoing scene. * scene is being turned from left over the outgoing scene.
*/ */
static TransitionPageTurn* create(float t,Scene* scene,bool backwards); static TransitionPageTurn* create(float t,Scene* scene,bool backwards);
/**
* @js ctor
*/
TransitionPageTurn(); TransitionPageTurn();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionPageTurn(); virtual ~TransitionPageTurn();
/** /**

View File

@ -76,8 +76,14 @@ public:
/** creates a Menu with MenuItem objects */ /** creates a Menu with MenuItem objects */
static Menu* createWithItems(MenuItem *firstItem, va_list args); static Menu* createWithItems(MenuItem *firstItem, va_list args);
/**
* @js ctor
*/
Menu() : _selectedItem(NULL) {} Menu() : _selectedItem(NULL) {}
/**
* @js NA
* @lua NA
*/
virtual ~Menu(){} virtual ~Menu(){}
/** initializes an empty Menu */ /** initializes an empty Menu */

View File

@ -65,18 +65,30 @@ public:
CC_DEPRECATED_ATTRIBUTE static MenuItem* create(Object *rec, SEL_MenuHandler selector); CC_DEPRECATED_ATTRIBUTE static MenuItem* create(Object *rec, SEL_MenuHandler selector);
/** Creates a MenuItem with a target/selector */ /** Creates a MenuItem with a target/selector */
static MenuItem* create(const ccMenuCallback& callback); static MenuItem* create(const ccMenuCallback& callback);
/**
* @js ctor
*/
MenuItem() MenuItem()
: _selected(false) : _selected(false)
, _enabled(false) , _enabled(false)
, _callback(nullptr) , _callback(nullptr)
, _target(NULL) , _target(NULL)
{} {}
/**
* @js NA
* @lua NA
*/
virtual ~MenuItem(); virtual ~MenuItem();
/** Initializes a MenuItem with a target/selector */ /** Initializes a MenuItem with a target/selector
* @js NA
* @lua NA
*/
bool initWithCallback(const ccMenuCallback& callback); bool initWithCallback(const ccMenuCallback& callback);
/** Initializes a MenuItem with a target/selector */ /** Initializes a MenuItem with a target/selector
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE bool initWithTarget( Object *rec, SEL_MenuHandler selector); CC_DEPRECATED_ATTRIBUTE bool initWithTarget( Object *rec, SEL_MenuHandler selector);
/** Returns the outside box */ /** Returns the outside box */
@ -94,9 +106,17 @@ public:
/** returns whether or not the item is selected */ /** returns whether or not the item is selected */
virtual bool isSelected() const; virtual bool isSelected() const;
/** set the callback to the menu item */ /** set the callback to the menu item
* @code
* In js,can contain two params,the second param is jsptr
* @endcode
* @lua NA
*/
void setCallback(const ccMenuCallback& callback); void setCallback(const ccMenuCallback& callback);
/** set the target/selector of the menu item*/ /** set the target/selector of the menu item
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE void setTarget(Object *rec, SEL_MenuHandler selector); CC_DEPRECATED_ATTRIBUTE void setTarget(Object *rec, SEL_MenuHandler selector);
protected: protected:
@ -126,11 +146,17 @@ public:
/** creates a MenuItemLabel with a Label. Target and selector will be nil */ /** creates a MenuItemLabel with a Label. Target and selector will be nil */
static MenuItemLabel* create(Node *label); static MenuItemLabel* create(Node *label);
/**
* @js ctor
*/
MenuItemLabel() MenuItemLabel()
: _originalScale(0.0) : _originalScale(0.0)
, _label(NULL) , _label(NULL)
{} {}
/**
* @js NA
* @lua NA
*/
virtual ~MenuItemLabel(); virtual ~MenuItemLabel();
/** initializes a MenuItemLabel with a Label, target and selector */ /** initializes a MenuItemLabel with a Label, target and selector */
@ -183,8 +209,14 @@ public:
CC_DEPRECATED_ATTRIBUTE static MenuItemAtlasFont* create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector); CC_DEPRECATED_ATTRIBUTE static MenuItemAtlasFont* create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector);
/** creates a menu item from a string and atlas. Use it with MenuItemToggle */ /** creates a menu item from a string and atlas. Use it with MenuItemToggle */
static MenuItemAtlasFont* create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback); static MenuItemAtlasFont* create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback);
/**
* @js ctor
*/
MenuItemAtlasFont(){} MenuItemAtlasFont(){}
/**
* @js NA
* @lua NA
*/
virtual ~MenuItemAtlasFont(){} virtual ~MenuItemAtlasFont(){}
/** initializes a menu item from a string and atlas with a target/selector */ /** initializes a menu item from a string and atlas with a target/selector */
@ -206,8 +238,14 @@ public:
CC_DEPRECATED_ATTRIBUTE static MenuItemFont * create(const char *value, Object* target, SEL_MenuHandler selector); CC_DEPRECATED_ATTRIBUTE static MenuItemFont * create(const char *value, Object* target, SEL_MenuHandler selector);
/** creates a menu item from a string with a target/selector */ /** creates a menu item from a string with a target/selector */
static MenuItemFont * create(const char *value, const ccMenuCallback& callback); static MenuItemFont * create(const char *value, const ccMenuCallback& callback);
/**
* @js ctor
*/
MenuItemFont() : _fontSize(0), _fontName(""){} MenuItemFont() : _fontSize(0), _fontName(""){}
/**
* @js NA
* @lua NA
*/
virtual ~MenuItemFont(){} virtual ~MenuItemFont(){}
/** initializes a menu item from a string with a target/selector */ /** initializes a menu item from a string with a target/selector */
@ -229,20 +267,26 @@ public:
/** set font size /** set font size
* c++ can not overload static and non-static member functions with the same parameter types * c++ can not overload static and non-static member functions with the same parameter types
* so change the name to setFontSizeObj * so change the name to setFontSizeObj
* @js setFontSize
*/ */
void setFontSizeObj(unsigned int s); void setFontSizeObj(unsigned int s);
/** get font size */ /** get font size
* @js getFontSize
*/
unsigned int getFontSizeObj() const; unsigned int getFontSizeObj() const;
CC_DEPRECATED_ATTRIBUTE unsigned int fontSizeObj() const { return getFontSizeObj(); }; CC_DEPRECATED_ATTRIBUTE unsigned int fontSizeObj() const { return getFontSizeObj(); };
/** set the font name /** set the font name
* c++ can not overload static and non-static member functions with the same parameter types * c++ can not overload static and non-static member functions with the same parameter types
* so change the name to setFontNameObj * so change the name to setFontNameObj
* @js setFontName
*/ */
void setFontNameObj(const char* name); void setFontNameObj(const char* name);
/** returns the name of the Font */ /** returns the name of the Font
* @js getFontNameObj
*/
const char* getFontNameObj() const; const char* getFontNameObj() const;
/** deprecated Use getFontNameObj() instead */ /** deprecated Use getFontNameObj() instead */
@ -352,8 +396,14 @@ public:
CC_DEPRECATED_ATTRIBUTE static MenuItemImage* create(const char *normalImage, const char *selectedImage, const char *disabledImage, Object* target, SEL_MenuHandler selector); CC_DEPRECATED_ATTRIBUTE static MenuItemImage* create(const char *normalImage, const char *selectedImage, const char *disabledImage, Object* target, SEL_MenuHandler selector);
/** creates a menu item with a normal,selected and disabled image with a callable object */ /** creates a menu item with a normal,selected and disabled image with a callable object */
static MenuItemImage* create(const char *normalImage, const char *selectedImage, const char *disabledImage, const ccMenuCallback& callback); static MenuItemImage* create(const char *normalImage, const char *selectedImage, const char *disabledImage, const ccMenuCallback& callback);
/**
* @js ctor
*/
MenuItemImage(){} MenuItemImage(){}
/**
* @js NA
* @lua NA
*/
virtual ~MenuItemImage(){} virtual ~MenuItemImage(){}
bool init(); bool init();
@ -386,18 +436,33 @@ public:
static MenuItemToggle* create(); static MenuItemToggle* create();
/** creates a menu item with a item */ /** creates a menu item with a item */
static MenuItemToggle* create(MenuItem *item); static MenuItemToggle* create(MenuItem *item);
/** creates a menu item from a Array with a target selector */ /** creates a menu item from a Array with a target selector
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE static MenuItemToggle * createWithTarget(Object* target, SEL_MenuHandler selector, Array* menuItems); CC_DEPRECATED_ATTRIBUTE static MenuItemToggle * createWithTarget(Object* target, SEL_MenuHandler selector, Array* menuItems);
/** creates a menu item from a list of items with a target/selector */ /** creates a menu item from a list of items with a target/selector
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE static MenuItemToggle* createWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, ...)CC_REQUIRES_NULL_TERMINATION; CC_DEPRECATED_ATTRIBUTE static MenuItemToggle* createWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, ...)CC_REQUIRES_NULL_TERMINATION;
/**
* @js ctor
*/
MenuItemToggle() MenuItemToggle()
: _selectedIndex(0) : _selectedIndex(0)
, _subItems(NULL) , _subItems(NULL)
{} {}
/**
* @js NA
* @lua NA
*/
virtual ~MenuItemToggle(); virtual ~MenuItemToggle();
/** initializes a menu item from a list of items with a target selector */ /** initializes a menu item from a list of items with a target selector
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, va_list args); CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, va_list args);
/** initializes a menu item from a list of items with a callable object */ /** initializes a menu item from a list of items with a callable object */
bool initWithCallback(const ccMenuCallback& callback, MenuItem* item, va_list args); bool initWithCallback(const ccMenuCallback& callback, MenuItem* item, va_list args);
@ -421,6 +486,8 @@ public:
/** Gets the array that contains the subitems. /** Gets the array that contains the subitems.
You can add/remove items in runtime, and you can replace the array with a new one. You can add/remove items in runtime, and you can replace the array with a new one.
@since v0.7.2 @since v0.7.2
* @js NA
* @lua NA
*/ */
inline Array* getSubItems() const { return _subItems; }; inline Array* getSubItems() const { return _subItems; };

View File

@ -49,7 +49,10 @@ public:
The stencil node will be retained. The stencil node will be retained.
*/ */
static ClippingNode* create(Node *pStencil); static ClippingNode* create(Node *pStencil);
/**
* @js NA
* @lua NA
*/
virtual ~ClippingNode(); virtual ~ClippingNode();
/** Initializes a clipping node without a stencil. /** Initializes a clipping node without a stencil.
@ -84,9 +87,25 @@ public:
void setInverted(bool bInverted); void setInverted(bool bInverted);
// Overrides // Overrides
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override; virtual void onEnter() override;
/**
* @js NA
* @lua NA
*/
virtual void onEnterTransitionDidFinish() override; virtual void onEnterTransitionDidFinish() override;
/**
* @js NA
* @lua NA
*/
virtual void onExitTransitionDidStart() override; virtual void onExitTransitionDidStart() override;
/**
* @js NA
* @lua NA
*/
virtual void onExit() override; virtual void onExit() override;
virtual void visit() override; virtual void visit() override;

View File

@ -53,8 +53,14 @@ public:
static MotionStreak* create(float fade, float minSeg, float stroke, const Color3B& color, const char* path); static MotionStreak* create(float fade, float minSeg, float stroke, const Color3B& color, const char* path);
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture */ /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture */
static MotionStreak* create(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture); static MotionStreak* create(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture);
/**
* @js ctor
*/
MotionStreak(); MotionStreak();
/**
* @js NA
* @lua NA
*/
virtual ~MotionStreak(); virtual ~MotionStreak();
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture filename */ /** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture filename */
@ -80,11 +86,27 @@ public:
// Overrides // Overrides
virtual void setPosition(const Point& position) override; virtual void setPosition(const Point& position) override;
/**
* @js NA
* @lua NA
*/
virtual void draw() override; virtual void draw() override;
/**
* @js NA
* @lua NA
*/
virtual void update(float delta) override; virtual void update(float delta) override;
virtual Texture2D* getTexture() const override; virtual Texture2D* getTexture() const override;
virtual void setTexture(Texture2D *texture) override; virtual void setTexture(Texture2D *texture) override;
/**
* @js NA
* @lua NA
*/
virtual void setBlendFunc(const BlendFunc &blendFunc) override; virtual void setBlendFunc(const BlendFunc &blendFunc) override;
/**
* @js NA
* @lua NA
*/
virtual const BlendFunc& getBlendFunc() const override; virtual const BlendFunc& getBlendFunc() const override;
virtual GLubyte getOpacity() const override; virtual GLubyte getOpacity() const override;
virtual void setOpacity(GLubyte opacity) override; virtual void setOpacity(GLubyte opacity) override;

View File

@ -62,8 +62,14 @@ public:
/** Creates a progress timer with the sprite as the shape the timer goes through */ /** Creates a progress timer with the sprite as the shape the timer goes through */
static ProgressTimer* create(Sprite* sp); static ProgressTimer* create(Sprite* sp);
/**
* @js ctor
*/
ProgressTimer(); ProgressTimer();
/**
* @js NA
* @lua NA
*/
virtual ~ProgressTimer(); virtual ~ProgressTimer();
/** Initializes a progress timer with the sprite as the shape the timer goes through */ /** Initializes a progress timer with the sprite as the shape the timer goes through */
@ -81,6 +87,10 @@ public:
void setPercentage(float fPercentage); void setPercentage(float fPercentage);
void setSprite(Sprite *pSprite); void setSprite(Sprite *pSprite);
void setType(Type type); void setType(Type type);
/**
* @js setReverseDirection
* @lua setReverseDirection
*/
void setReverseProgress(bool reverse); void setReverseProgress(bool reverse);
inline bool isReverseDirection() { return _reverseDirection; }; inline bool isReverseDirection() { return _reverseDirection; };

View File

@ -58,8 +58,14 @@ public:
/** creates a RenderTexture object with width and height in Points, pixel format is RGBA8888 */ /** creates a RenderTexture object with width and height in Points, pixel format is RGBA8888 */
static RenderTexture * create(int w, int h); static RenderTexture * create(int w, int h);
/**
* @js ctor
*/
RenderTexture(); RenderTexture();
/**
* @js NA
* @lua NA
*/
virtual ~RenderTexture(); virtual ~RenderTexture();
/** initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ /** initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */

View File

@ -72,8 +72,14 @@ public:
/** initializes the particle system with the name of a file on disk (for a list of supported formats look at the Texture2D class), a capacity of particles */ /** initializes the particle system with the name of a file on disk (for a list of supported formats look at the Texture2D class), a capacity of particles */
static ParticleBatchNode* create(const char* fileImage, unsigned int capacity = kParticleDefaultCapacity); static ParticleBatchNode* create(const char* fileImage, unsigned int capacity = kParticleDefaultCapacity);
/**
* @js ctor
*/
ParticleBatchNode(); ParticleBatchNode();
/**
* @js NA
* @lua NA
*/
virtual ~ParticleBatchNode(); virtual ~ParticleBatchNode();
/** initializes the particle system with Texture2D, a capacity of particles */ /** initializes the particle system with Texture2D, a capacity of particles */
@ -107,7 +113,18 @@ public:
virtual void draw(void) override; virtual void draw(void) override;
virtual Texture2D* getTexture(void) const override; virtual Texture2D* getTexture(void) const override;
virtual void setTexture(Texture2D *texture) override; virtual void setTexture(Texture2D *texture) override;
/**
* @code
* When this function bound into js or lua,the parameter will be changed
* In js: var setBlendFunc(var src, var dst)
* @endcode
* @lua NA
*/
virtual void setBlendFunc(const BlendFunc &blendFunc) override; virtual void setBlendFunc(const BlendFunc &blendFunc) override;
/**
* @js NA
* @lua NA
*/
virtual const BlendFunc& getBlendFunc(void) const override; virtual const BlendFunc& getBlendFunc(void) const override;
private: private:

View File

@ -39,7 +39,14 @@ NS_CC_BEGIN
class CC_DLL ParticleFire : public ParticleSystemQuad class CC_DLL ParticleFire : public ParticleSystemQuad
{ {
public: public:
/**
* @js ctor
*/
ParticleFire(){} ParticleFire(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleFire(){} virtual ~ParticleFire(){}
bool init(){ return initWithTotalParticles(250); } bool init(){ return initWithTotalParticles(250); }
virtual bool initWithTotalParticles(unsigned int numberOfParticles); virtual bool initWithTotalParticles(unsigned int numberOfParticles);
@ -52,7 +59,14 @@ public:
class CC_DLL ParticleFireworks : public ParticleSystemQuad class CC_DLL ParticleFireworks : public ParticleSystemQuad
{ {
public: public:
/**
* @js ctor
*/
ParticleFireworks(){} ParticleFireworks(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleFireworks(){} virtual ~ParticleFireworks(){}
bool init(){ return initWithTotalParticles(1500); } bool init(){ return initWithTotalParticles(1500); }
virtual bool initWithTotalParticles(unsigned int numberOfParticles); virtual bool initWithTotalParticles(unsigned int numberOfParticles);
@ -65,7 +79,14 @@ public:
class CC_DLL ParticleSun : public ParticleSystemQuad class CC_DLL ParticleSun : public ParticleSystemQuad
{ {
public: public:
/**
* @js ctor
*/
ParticleSun(){} ParticleSun(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleSun(){} virtual ~ParticleSun(){}
bool init(){ return initWithTotalParticles(350); } bool init(){ return initWithTotalParticles(350); }
virtual bool initWithTotalParticles(unsigned int numberOfParticles); virtual bool initWithTotalParticles(unsigned int numberOfParticles);
@ -78,7 +99,14 @@ public:
class CC_DLL ParticleGalaxy : public ParticleSystemQuad class CC_DLL ParticleGalaxy : public ParticleSystemQuad
{ {
public: public:
/**
* @js ctor
*/
ParticleGalaxy(){} ParticleGalaxy(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleGalaxy(){} virtual ~ParticleGalaxy(){}
bool init(){ return initWithTotalParticles(200); } bool init(){ return initWithTotalParticles(200); }
virtual bool initWithTotalParticles(unsigned int numberOfParticles); virtual bool initWithTotalParticles(unsigned int numberOfParticles);
@ -91,7 +119,14 @@ public:
class CC_DLL ParticleFlower : public ParticleSystemQuad class CC_DLL ParticleFlower : public ParticleSystemQuad
{ {
public: public:
/**
* @js ctor
*/
ParticleFlower(){} ParticleFlower(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleFlower(){} virtual ~ParticleFlower(){}
bool init(){ return initWithTotalParticles(250); } bool init(){ return initWithTotalParticles(250); }
virtual bool initWithTotalParticles(unsigned int numberOfParticles); virtual bool initWithTotalParticles(unsigned int numberOfParticles);
@ -104,7 +139,14 @@ public:
class CC_DLL ParticleMeteor : public ParticleSystemQuad class CC_DLL ParticleMeteor : public ParticleSystemQuad
{ {
public: public:
/**
* @js ctor
*/
ParticleMeteor(){} ParticleMeteor(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleMeteor(){} virtual ~ParticleMeteor(){}
bool init(){ return initWithTotalParticles(150); } bool init(){ return initWithTotalParticles(150); }
virtual bool initWithTotalParticles(unsigned int numberOfParticles); virtual bool initWithTotalParticles(unsigned int numberOfParticles);
@ -117,7 +159,14 @@ public:
class CC_DLL ParticleSpiral : public ParticleSystemQuad class CC_DLL ParticleSpiral : public ParticleSystemQuad
{ {
public: public:
/**
* @js ctor
*/
ParticleSpiral(){} ParticleSpiral(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleSpiral(){} virtual ~ParticleSpiral(){}
bool init(){ return initWithTotalParticles(500); } bool init(){ return initWithTotalParticles(500); }
virtual bool initWithTotalParticles(unsigned int numberOfParticles); virtual bool initWithTotalParticles(unsigned int numberOfParticles);
@ -130,7 +179,14 @@ public:
class CC_DLL ParticleExplosion : public ParticleSystemQuad class CC_DLL ParticleExplosion : public ParticleSystemQuad
{ {
public: public:
/**
* @js ctor
*/
ParticleExplosion(){} ParticleExplosion(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleExplosion(){} virtual ~ParticleExplosion(){}
bool init(){ return initWithTotalParticles(700); } bool init(){ return initWithTotalParticles(700); }
virtual bool initWithTotalParticles(unsigned int numberOfParticles); virtual bool initWithTotalParticles(unsigned int numberOfParticles);
@ -143,7 +199,14 @@ public:
class CC_DLL ParticleSmoke : public ParticleSystemQuad class CC_DLL ParticleSmoke : public ParticleSystemQuad
{ {
public: public:
/**
* @js ctor
*/
ParticleSmoke(){} ParticleSmoke(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleSmoke(){} virtual ~ParticleSmoke(){}
bool init(){ return initWithTotalParticles(200); } bool init(){ return initWithTotalParticles(200); }
virtual bool initWithTotalParticles(unsigned int numberOfParticles); virtual bool initWithTotalParticles(unsigned int numberOfParticles);
@ -156,7 +219,14 @@ public:
class CC_DLL ParticleSnow : public ParticleSystemQuad class CC_DLL ParticleSnow : public ParticleSystemQuad
{ {
public: public:
/**
* @js ctor
*/
ParticleSnow(){} ParticleSnow(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleSnow(){} virtual ~ParticleSnow(){}
bool init(){ return initWithTotalParticles(700); } bool init(){ return initWithTotalParticles(700); }
virtual bool initWithTotalParticles(unsigned int numberOfParticles); virtual bool initWithTotalParticles(unsigned int numberOfParticles);
@ -169,7 +239,14 @@ public:
class CC_DLL ParticleRain : public ParticleSystemQuad class CC_DLL ParticleRain : public ParticleSystemQuad
{ {
public: public:
/**
* @js ctor
*/
ParticleRain(){} ParticleRain(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleRain(){} virtual ~ParticleRain(){}
bool init(){ return initWithTotalParticles(1000); } bool init(){ return initWithTotalParticles(1000); }
virtual bool initWithTotalParticles(unsigned int numberOfParticles); virtual bool initWithTotalParticles(unsigned int numberOfParticles);

View File

@ -171,8 +171,14 @@ public:
//! create a system with a fixed number of particles //! create a system with a fixed number of particles
static ParticleSystem* createWithTotalParticles(unsigned int numberOfParticles); static ParticleSystem* createWithTotalParticles(unsigned int numberOfParticles);
/**
* @js ctor
*/
ParticleSystem(); ParticleSystem();
/**
* @js NA
* @lua NA
*/
virtual ~ParticleSystem(); virtual ~ParticleSystem();
/** initializes a ParticleSystem*/ /** initializes a ParticleSystem*/
@ -374,7 +380,18 @@ public:
virtual void update(float dt) override; virtual void update(float dt) override;
virtual Texture2D* getTexture() const override; virtual Texture2D* getTexture() const override;
virtual void setTexture(Texture2D *texture) override; virtual void setTexture(Texture2D *texture) override;
/**
*@code
*When this function bound into js or lua,the parameter will be changed
*In js: var setBlendFunc(var src, var dst)
*In lua: local setBlendFunc(local src, local dst)
*@endcode
*/
virtual void setBlendFunc(const BlendFunc &blendFunc) override; virtual void setBlendFunc(const BlendFunc &blendFunc) override;
/**
* @js NA
* @lua NA
*/
virtual const BlendFunc &getBlendFunc() const override; virtual const BlendFunc &getBlendFunc() const override;
protected: protected:
virtual void updateBlendFunc(); virtual void updateBlendFunc();

View File

@ -62,8 +62,14 @@ public:
This plist files can be created manually or with Particle Designer: This plist files can be created manually or with Particle Designer:
*/ */
static ParticleSystemQuad * create(const char *plistFile); static ParticleSystemQuad * create(const char *plistFile);
/**
* @js ctor
*/
ParticleSystemQuad(); ParticleSystemQuad();
/**
* @js NA
* @lua NA
*/
virtual ~ParticleSystemQuad(); virtual ~ParticleSystemQuad();
/** initializes the indices for the vertices*/ /** initializes the indices for the vertices*/
@ -79,21 +85,53 @@ public:
void setDisplayFrame(SpriteFrame *spriteFrame); void setDisplayFrame(SpriteFrame *spriteFrame);
/** Sets a new texture with a rect. The rect is in Points. /** Sets a new texture with a rect. The rect is in Points.
@since v0.99.4 @since v0.99.4
*/ * @js NA
* @lua NA
*/
void setTextureWithRect(Texture2D *texture, const Rect& rect); void setTextureWithRect(Texture2D *texture, const Rect& rect);
/** listen the event that coming to foreground on Android /** listen the event that coming to foreground on Android
* @js NA
* @lua NA
*/ */
void listenBackToForeground(Object *obj); void listenBackToForeground(Object *obj);
// Overrides // Overrides
/**
* @js NA
* @lua NA
*/
virtual bool initWithTotalParticles(unsigned int numberOfParticles) override; virtual bool initWithTotalParticles(unsigned int numberOfParticles) override;
/**
* @js NA
* @lua NA
*/
virtual void setTexture(Texture2D* texture) override; virtual void setTexture(Texture2D* texture) override;
/**
* @js NA
* @lua NA
*/
virtual void updateQuadWithParticle(tParticle* particle, const Point& newPosition) override; virtual void updateQuadWithParticle(tParticle* particle, const Point& newPosition) override;
/**
* @js NA
* @lua NA
*/
virtual void postStep() override; virtual void postStep() override;
/**
* @js NA
* @lua NA
*/
virtual void draw() override; virtual void draw() override;
/**
* @js NA
* @lua NA
*/
virtual void setBatchNode(ParticleBatchNode* batchNode) override; virtual void setBatchNode(ParticleBatchNode* batchNode) override;
/**
* @js NA
* @lua NA
*/
virtual void setTotalParticles(int tp) override; virtual void setTotalParticles(int tp) override;
private: private:

View File

@ -39,7 +39,10 @@ public:
double z; double z;
double timestamp; double timestamp;
/**
* @js NA
* @lua NA
*/
Acceleration(): x(0), y(0), z(0), timestamp(0) {} Acceleration(): x(0), y(0), z(0), timestamp(0) {}
}; };

View File

@ -28,40 +28,55 @@ public:
OS_TIZEN OS_TIZEN
}; };
/**
* @js NA
* @lua NA
*/
virtual ~ApplicationProtocol() {} virtual ~ApplicationProtocol() {}
/** /**
@brief Implement Director and Scene init code here. @brief Implement Director and Scene init code here.
@return true Initialize success, app continue. @return true Initialize success, app continue.
@return false Initialize failed, app terminate. @return false Initialize failed, app terminate.
* @js NA
* @lua NA
*/ */
virtual bool applicationDidFinishLaunching() = 0; virtual bool applicationDidFinishLaunching() = 0;
/** /**
@brief This function will be called when the application enters background. @brief This function will be called when the application enters background.
* @js NA
* @lua NA
*/ */
virtual void applicationDidEnterBackground() = 0; virtual void applicationDidEnterBackground() = 0;
/** /**
@brief This function will be called when the application enters foreground. @brief This function will be called when the application enters foreground.
* @js NA
* @lua NA
*/ */
virtual void applicationWillEnterForeground() = 0; virtual void applicationWillEnterForeground() = 0;
/** /**
@brief Callback by Director for limit FPS. @brief Callback by Director for limit FPS.
@param interval The time, expressed in seconds, between current frame and next. @param interval The time, expressed in seconds, between current frame and next.
* @js NA
* @lua NA
*/ */
virtual void setAnimationInterval(double interval) = 0; virtual void setAnimationInterval(double interval) = 0;
/** /**
@brief Get current language config @brief Get current language config
@return Current language config @return Current language config
* @js NA
* @lua NA
*/ */
virtual LanguageType getCurrentLanguage() = 0; virtual LanguageType getCurrentLanguage() = 0;
/** /**
@brief Get target platform @brief Get target platform
* @js NA
* @lua NA
*/ */
virtual Platform getTargetPlatform() = 0; virtual Platform getTargetPlatform() = 0;
}; };

View File

@ -43,7 +43,14 @@ class Set;
class CC_DLL EGLViewProtocol class CC_DLL EGLViewProtocol
{ {
public: public:
/**
* @js ctor
*/
EGLViewProtocol(); EGLViewProtocol();
/**
* @js NA
* @lua NA
*/
virtual ~EGLViewProtocol(); virtual ~EGLViewProtocol();
/** Force destroying EGL view, subclass must implement this method. */ /** Force destroying EGL view, subclass must implement this method. */

View File

@ -64,6 +64,8 @@ public:
/** /**
* The destructor of FileUtils. * The destructor of FileUtils.
* @js NA
* @lua NA
*/ */
virtual ~FileUtils(); virtual ~FileUtils();
@ -176,6 +178,8 @@ public:
* @param filename The plist file name. * @param filename The plist file name.
* *
@since v2.1 @since v2.1
* @js loadFilenameLookup
* @lua loadFilenameLookup
*/ */
virtual void loadFilenameLookupDictionaryFromFile(const std::string &filename); virtual void loadFilenameLookupDictionaryFromFile(const std::string &filename);
@ -204,6 +208,8 @@ public:
* @param searchResolutionsOrder The source array that contains the search order of the resources. * @param searchResolutionsOrder The source array that contains the search order of the resources.
* @see getSearchResolutionsOrder(void), fullPathForFilename(const char*). * @see getSearchResolutionsOrder(void), fullPathForFilename(const char*).
* @since v2.1 * @since v2.1
* In js:var setSearchResolutionsOrder(var jsval)
* @lua NA
*/ */
virtual void setSearchResolutionsOrder(const std::vector<std::string>& searchResolutionsOrder); virtual void setSearchResolutionsOrder(const std::vector<std::string>& searchResolutionsOrder);
@ -220,6 +226,7 @@ public:
* *
* @see setSearchResolutionsOrder(const std::vector<std::string>&), fullPathForFilename(const char*). * @see setSearchResolutionsOrder(const std::vector<std::string>&), fullPathForFilename(const char*).
* @since v2.1 * @since v2.1
* @lua NA
*/ */
virtual const std::vector<std::string>& getSearchResolutionsOrder(); virtual const std::vector<std::string>& getSearchResolutionsOrder();
@ -239,6 +246,8 @@ public:
* @param searchPaths The array contains search paths. * @param searchPaths The array contains search paths.
* @see fullPathForFilename(const char*) * @see fullPathForFilename(const char*)
* @since v2.1 * @since v2.1
* In js:var setSearchPaths(var jsval);
* @lua NA
*/ */
virtual void setSearchPaths(const std::vector<std::string>& searchPaths); virtual void setSearchPaths(const std::vector<std::string>& searchPaths);
@ -254,6 +263,7 @@ public:
* *
* @return The array of search paths. * @return The array of search paths.
* @see fullPathForFilename(const char*). * @see fullPathForFilename(const char*).
* @lua NA
*/ */
virtual const std::vector<std::string>& getSearchPaths() const; virtual const std::vector<std::string>& getSearchPaths() const;

View File

@ -56,8 +56,14 @@ class CC_DLL Image : public Object
{ {
public: public:
friend class TextureCache; friend class TextureCache;
/**
* @js ctor
*/
Image(); Image();
/**
* @js NA
* @lua NA
*/
virtual ~Image(); virtual ~Image();
/** Supported formats for Image */ /** Supported formats for Image */
@ -110,6 +116,8 @@ public:
@param data stream buffer which holds the image data. @param data stream buffer which holds the image data.
@param dataLen data length expressed in (number of) bytes. @param dataLen data length expressed in (number of) bytes.
@return true if loaded correctly. @return true if loaded correctly.
* @js NA
* @lua NA
*/ */
bool initWithImageData(const unsigned char * data, int dataLen); bool initWithImageData(const unsigned char * data, int dataLen);
@ -124,6 +132,8 @@ public:
@param alignMask the test Alignment @param alignMask the test Alignment
@param fontName the name of the font used to draw the text. If nil, use the default system font. @param fontName the name of the font used to draw the text. If nil, use the default system font.
@param size the font size, if 0, use the system default size. @param size the font size, if 0, use the system default size.
* @js NA
* @lua NA
*/ */
bool initWithString( bool initWithString(
const char * text, const char * text,

View File

@ -39,8 +39,20 @@ typedef unsigned char CC_XML_CHAR;
class CC_DLL SAXDelegator class CC_DLL SAXDelegator
{ {
public: public:
/**
* @js NA
* @lua NA
*/
virtual void startElement(void *ctx, const char *name, const char **atts) = 0; virtual void startElement(void *ctx, const char *name, const char **atts) = 0;
/**
* @js NA
* @lua NA
*/
virtual void endElement(void *ctx, const char *name) = 0; virtual void endElement(void *ctx, const char *name) = 0;
/**
* @js NA
* @lua NA
*/
virtual void textHandler(void *ctx, const char *s, int len) = 0; virtual void textHandler(void *ctx, const char *s, int len) = 0;
}; };
@ -48,17 +60,50 @@ class CC_DLL SAXParser
{ {
SAXDelegator* _delegator; SAXDelegator* _delegator;
public: public:
/**
* @js NA
* @lua NA
*/
SAXParser(); SAXParser();
/**
* @js NA
* @lua NA
*/
~SAXParser(void); ~SAXParser(void);
/**
* @js NA
* @lua NA
*/
bool init(const char *pszEncoding); bool init(const char *pszEncoding);
/**
* @js NA
* @lua NA
*/
bool parse(const char* pXMLData, unsigned int uDataLength); bool parse(const char* pXMLData, unsigned int uDataLength);
/**
* @js NA
* @lua NA
*/
bool parse(const char *pszFile); bool parse(const char *pszFile);
/**
* @js NA
* @lua NA
*/
void setDelegator(SAXDelegator* pDelegator); void setDelegator(SAXDelegator* pDelegator);
/**
* @js NA
* @lua NA
*/
static void startElement(void *ctx, const CC_XML_CHAR *name, const CC_XML_CHAR **atts); static void startElement(void *ctx, const CC_XML_CHAR *name, const CC_XML_CHAR **atts);
/**
* @js NA
* @lua NA
*/
static void endElement(void *ctx, const CC_XML_CHAR *name); static void endElement(void *ctx, const CC_XML_CHAR *name);
/**
* @js NA
* @lua NA
*/
static void textHandler(void *ctx, const CC_XML_CHAR *name, int len); static void textHandler(void *ctx, const CC_XML_CHAR *name, int len);
}; };

View File

@ -42,9 +42,20 @@ NS_CC_BEGIN
class CC_DLL Thread class CC_DLL Thread
{ {
public: public:
/**
* @js NA
* @lua NA
*/
Thread() : _autoReleasePool(nullptr) {} Thread() : _autoReleasePool(nullptr) {}
/**
* @js NA
* @lua NA
*/
~Thread(); ~Thread();
/**
* @js NA
* @lua NA
*/
void createAutoreleasePool(); void createAutoreleasePool();
private: private:

View File

@ -34,7 +34,14 @@ namespace cocos2d {
class Accelerometer class Accelerometer
{ {
public: public:
/**
* @js ctor
*/
Accelerometer(); Accelerometer();
/**
* @js NA
* @lua NA
*/
~Accelerometer(); ~Accelerometer();
void setDelegate(std::function<void(Acceleration*)> function); void setDelegate(std::function<void(Acceleration*)> function);

View File

@ -9,7 +9,14 @@ NS_CC_BEGIN
class CC_DLL Application : public ApplicationProtocol class CC_DLL Application : public ApplicationProtocol
{ {
public: public:
/**
* @js ctor
*/
Application(); Application();
/**
* @js NA
* @lua NA
*/
virtual ~Application(); virtual ~Application();
/** /**

View File

@ -33,7 +33,14 @@ NS_CC_BEGIN
class CC_DLL EGLView : public EGLViewProtocol class CC_DLL EGLView : public EGLViewProtocol
{ {
public: public:
/**
* @js ctor
*/
EGLView(); EGLView();
/**
* @js NA
* @lua NA
*/
virtual ~EGLView(); virtual ~EGLView();
bool isOpenGLReady(); bool isOpenGLReady();

View File

@ -45,6 +45,10 @@ class CC_DLL FileUtilsAndroid : public FileUtils
friend class FileUtils; friend class FileUtils;
FileUtilsAndroid(); FileUtilsAndroid();
public: public:
/**
* @js NA
* @lua NA
*/
virtual ~FileUtilsAndroid(); virtual ~FileUtilsAndroid();
static void setassetmanager(AAssetManager* a); static void setassetmanager(AAssetManager* a);

View File

@ -32,7 +32,14 @@ NS_CC_BEGIN
class Lock class Lock
{ {
public: public:
/**
* @js ctor
*/
Lock(void); Lock(void);
/**
* @js NA
* @lua NA
*/
~Lock(void); ~Lock(void);
void lock(void); void lock(void);

View File

@ -16,7 +16,14 @@ namespace cocos2d {
class Accelerometer class Accelerometer
{ {
public: public:
/**
* @js ctor
*/
Accelerometer(){} Accelerometer(){}
/**
* @js NA
* @lua NA
*/
~Accelerometer(){} ~Accelerometer(){}
static Accelerometer* sharedAccelerometer() { return NULL; }; static Accelerometer* sharedAccelerometer() { return NULL; };

View File

@ -11,7 +11,14 @@ class Rect;
class CC_DLL Application : public ApplicationProtocol class CC_DLL Application : public ApplicationProtocol
{ {
public: public:
/**
* @js ctor
*/
Application(); Application();
/**
* @js NA
* @lua NA
*/
virtual ~Application(); virtual ~Application();
/** /**

View File

@ -36,7 +36,14 @@ NS_CC_BEGIN
class CC_DLL EGLView : public EGLViewProtocol class CC_DLL EGLView : public EGLViewProtocol
{ {
public: public:
/**
* @js ctor
*/
EGLView(); EGLView();
/**
* @js NA
* @lua NA
*/
virtual ~EGLView(); virtual ~EGLView();
bool isOpenGLReady(); bool isOpenGLReady();

View File

@ -32,7 +32,14 @@ NS_CC_BEGIN
class CC_DLL TextureCacheEmscripten : public TextureCache class CC_DLL TextureCacheEmscripten : public TextureCache
{ {
public: public:
/**
* @js ctor
*/
TextureCacheEmscripten(); TextureCacheEmscripten();
/**
* @js NA
* @lua NA
*/
virtual ~TextureCacheEmscripten(); virtual ~TextureCacheEmscripten();
void addImageAsync(const char *path, Object *target, SEL_CallFuncO selector); void addImageAsync(const char *path, Object *target, SEL_CallFuncO selector);

View File

@ -33,7 +33,14 @@ NS_CC_BEGIN
class Accelerometer class Accelerometer
{ {
public: public:
/**
* @js ctor
*/
Accelerometer(); Accelerometer();
/**
* @js NA
* @lua NA
*/
~Accelerometer(); ~Accelerometer();
void setDelegate(std::function<void(Acceleration*)> function); void setDelegate(std::function<void(Acceleration*)> function);

View File

@ -35,7 +35,14 @@ class Rect;
class CC_DLL Application : public ApplicationProtocol class CC_DLL Application : public ApplicationProtocol
{ {
public: public:
/**
* @js ctor
*/
Application(); Application();
/**
* @js NA
* @lua NA
*/
virtual ~Application(); virtual ~Application();
/** /**

View File

@ -35,22 +35,53 @@ NS_CC_BEGIN
class CC_DLL EGLView : public EGLViewProtocol class CC_DLL EGLView : public EGLViewProtocol
{ {
public: public:
/**
* @js NA
* @lua NA
*/
EGLView(); EGLView();
/**
* @js NA
* @lua NA
*/
~EGLView(); ~EGLView();
/**
* @js NA
* @lua NA
*/
virtual bool isOpenGLReady(); virtual bool isOpenGLReady();
/**
* @js NA
* @lua NA
*/
virtual bool setContentScaleFactor(float contentScaleFactor); virtual bool setContentScaleFactor(float contentScaleFactor);
// keep compatible // keep compatible
/**
* @js NA
* @lua NA
*/
virtual void end(); virtual void end();
/**
* @js NA
* @lua NA
*/
virtual void swapBuffers(); virtual void swapBuffers();
/**
* @js NA
* @lua NA
*/
virtual void setIMEKeyboardState(bool bOpen); virtual void setIMEKeyboardState(bool bOpen);
/** returns the singleton */ /** returns the singleton
* @js NA
*/
static EGLView* getInstance(); static EGLView* getInstance();
/** @deprecated Use getInstance() instead */ /** @deprecated Use getInstance() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView(); CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
}; };

View File

@ -16,7 +16,14 @@ namespace cocos2d {
class Accelerometer class Accelerometer
{ {
public: public:
/**
* @js ctor
*/
Accelerometer(){} Accelerometer(){}
/**
* @js NA
* @lua NA
*/
~Accelerometer(){} ~Accelerometer(){}
static Accelerometer* sharedAccelerometer() { return NULL; }; static Accelerometer* sharedAccelerometer() { return NULL; };

View File

@ -18,7 +18,14 @@ class Rect;
class Application : public ApplicationProtocol class Application : public ApplicationProtocol
{ {
public: public:
/**
* @js ctor
*/
Application(); Application();
/**
* @js NA
* @lua NA
*/
virtual ~Application(); virtual ~Application();
/** /**

View File

@ -22,7 +22,14 @@ NS_CC_BEGIN
class CC_DLL EGLView : public EGLViewProtocol class CC_DLL EGLView : public EGLViewProtocol
{ {
public: public:
/**
* @js ctor
*/
EGLView(); EGLView();
/**
* @js NA
* @lua NA
*/
virtual ~EGLView(); virtual ~EGLView();
/* override functions */ /* override functions */

View File

@ -34,6 +34,10 @@ class CC_DLL Accelerometer
{ {
public: public:
Accelerometer() {} Accelerometer() {}
/**
* @js NA
* @lua NA
*/
~Accelerometer() {} ~Accelerometer() {}
void setDelegate(std::function<void(Acceleration*)> function) { CC_UNUSED_PARAM(function); } void setDelegate(std::function<void(Acceleration*)> function) { CC_UNUSED_PARAM(function); }

View File

@ -34,7 +34,14 @@ NS_CC_BEGIN
class CC_DLL Application : public ApplicationProtocol class CC_DLL Application : public ApplicationProtocol
{ {
public: public:
/**
* @js ctor
*/
Application(); Application();
/**
* @js NA
* @lua NA
*/
virtual ~Application(); virtual ~Application();
/** /**
@ -49,6 +56,8 @@ public:
/** /**
@brief Run the message loop. @brief Run the message loop.
* @js NA
* @lua NA
*/ */
int run(); int run();

View File

@ -34,7 +34,14 @@ NS_CC_BEGIN
class CC_DLL EGLView : public EGLViewProtocol class CC_DLL EGLView : public EGLViewProtocol
{ {
public: public:
/**
* @js ctor
*/
EGLView(); EGLView();
/**
* @js NA
* @lua NA
*/
virtual ~EGLView(); virtual ~EGLView();
/* override functions */ /* override functions */

View File

@ -33,7 +33,14 @@ namespace cocos2d {
class Accelerometer class Accelerometer
{ {
public: public:
/**
* @js ctor
*/
Accelerometer(){} Accelerometer(){}
/**
* @js NA
* @lua NA
*/
~Accelerometer(){} ~Accelerometer(){}
static Accelerometer* sharedAccelerometer() { return NULL; }; static Accelerometer* sharedAccelerometer() { return NULL; };

View File

@ -34,7 +34,14 @@ class Rect;
class Application : public ApplicationProtocol class Application : public ApplicationProtocol
{ {
public: public:
/**
* @js ctor
*/
Application(); Application();
/**
* @js NA
* @lua NA
*/
virtual ~Application(); virtual ~Application();
/** /**

View File

@ -43,7 +43,14 @@ NS_CC_BEGIN
class EGLView : public EGLViewProtocol class EGLView : public EGLViewProtocol
{ {
public: public:
/**
* @js ctor
*/
EGLView(); EGLView();
/**
* @js NA
* @lua NA
*/
virtual ~EGLView(); virtual ~EGLView();
/** /**

Some files were not shown because too many files have changed in this diff Show More