mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into Bridge
This commit is contained in:
commit
85ca0136f0
|
@ -56,6 +56,10 @@ public:
|
|||
@brief Get the shared Engine object,it will new one when first time be called
|
||||
*/
|
||||
static SimpleAudioEngine* getInstance();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE static SimpleAudioEngine* sharedEngine() { return SimpleAudioEngine::getInstance(); }
|
||||
|
||||
/**
|
||||
|
@ -73,47 +77,63 @@ public:
|
|||
/**
|
||||
@brief Preload background music
|
||||
@param pszFilePath The path of the background music file.
|
||||
* @js preloadMusic
|
||||
* @lua preloadMusic
|
||||
*/
|
||||
virtual void preloadBackgroundMusic(const char* pszFilePath);
|
||||
|
||||
/**
|
||||
@brief Play background music
|
||||
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
||||
@param bLoop Whether the background music loop or not
|
||||
*/
|
||||
@brief Play background music
|
||||
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
||||
@param bLoop Whether the background music loop or not
|
||||
* @js playMusic
|
||||
* @lua playMusic
|
||||
*/
|
||||
virtual void playBackgroundMusic(const char* pszFilePath, bool bLoop = false);
|
||||
|
||||
/**
|
||||
@brief Stop playing background music
|
||||
@param bReleaseData If release the background music data or not.As default value is false
|
||||
*/
|
||||
@brief Stop playing background music
|
||||
@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);
|
||||
|
||||
/**
|
||||
@brief Pause playing background music
|
||||
@brief Pause playing background music
|
||||
* @js pauseMusic
|
||||
* @lua pauseMusic
|
||||
*/
|
||||
virtual void pauseBackgroundMusic();
|
||||
|
||||
/**
|
||||
@brief Resume playing background music
|
||||
@brief Resume playing background music
|
||||
* @js resumeMusic
|
||||
* @lua resumeMusic
|
||||
*/
|
||||
virtual void resumeBackgroundMusic();
|
||||
|
||||
/**
|
||||
@brief Rewind playing background music
|
||||
@brief Rewind playing background music
|
||||
* @js rewindMusic
|
||||
* @lua rewindMusic
|
||||
*/
|
||||
virtual void rewindBackgroundMusic();
|
||||
|
||||
/**
|
||||
@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>.
|
||||
* @js willPlayMusic
|
||||
* @lua willPlayMusic
|
||||
*/
|
||||
virtual bool willPlayBackgroundMusic();
|
||||
|
||||
/**
|
||||
@brief Indicates whether the background music is playing
|
||||
@return <i>true</i> if the background music is playing, otherwise <i>false</i>
|
||||
*/
|
||||
@brief Indicates whether the background music is playing
|
||||
@return <i>true</i> if the background music is playing, otherwise <i>false</i>
|
||||
* @js isMusicPlaying
|
||||
* @lua isMusicPlaying
|
||||
*/
|
||||
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();
|
||||
|
||||
/**
|
||||
@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.
|
||||
*/
|
||||
@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.
|
||||
* @js setMusicVolume
|
||||
* @lua setMusicVolume
|
||||
*/
|
||||
virtual void setBackgroundMusicVolume(float volume);
|
||||
|
||||
/**
|
||||
|
|
|
@ -92,7 +92,7 @@ float Camera::getZEye(void)
|
|||
return FLT_EPSILON;
|
||||
}
|
||||
|
||||
void Camera::setEyeXYZ(float fEyeX, float fEyeY, float fEyeZ)
|
||||
void Camera::setEye(float fEyeX, float fEyeY, float fEyeZ)
|
||||
{
|
||||
_eyeX = fEyeX;
|
||||
_eyeY = fEyeY;
|
||||
|
@ -101,7 +101,7 @@ void Camera::setEyeXYZ(float fEyeX, float fEyeY, float fEyeZ)
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void Camera::setCenterXYZ(float fCenterX, float fCenterY, float fCenterZ)
|
||||
void Camera::setCenter(float fCenterX, float fCenterY, float fCenterZ)
|
||||
{
|
||||
_centerX = fCenterX;
|
||||
_centerY = fCenterY;
|
||||
|
@ -110,7 +110,7 @@ void Camera::setCenterXYZ(float fCenterX, float fCenterY, float fCenterZ)
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void Camera::setUpXYZ(float fUpX, float fUpY, float fUpZ)
|
||||
void Camera::setUp(float fUpX, float fUpY, float fUpZ)
|
||||
{
|
||||
_upX = fUpX;
|
||||
_upY = fUpY;
|
||||
|
@ -119,21 +119,21 @@ void Camera::setUpXYZ(float fUpX, float fUpY, float fUpZ)
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void Camera::getEyeXYZ(float *pEyeX, float *pEyeY, float *pEyeZ) const
|
||||
void Camera::getEye(float *pEyeX, float *pEyeY, float *pEyeZ) const
|
||||
{
|
||||
*pEyeX = _eyeX;
|
||||
*pEyeY = _eyeY;
|
||||
*pEyeZ = _eyeZ;
|
||||
}
|
||||
|
||||
void Camera::getCenterXYZ(float *pCenterX, float *pCenterY, float *pCenterZ) const
|
||||
void Camera::getCenter(float *pCenterX, float *pCenterY, float *pCenterZ) const
|
||||
{
|
||||
*pCenterX = _centerX;
|
||||
*pCenterY = _centerY;
|
||||
*pCenterZ = _centerZ;
|
||||
}
|
||||
|
||||
void Camera::getUpXYZ(float *pUpX, float *pUpY, float *pUpZ) const
|
||||
void Camera::getUp(float *pUpX, float *pUpY, float *pUpZ) const
|
||||
{
|
||||
*pUpX = _upX;
|
||||
*pUpY = _upY;
|
||||
|
|
|
@ -68,12 +68,21 @@ class CC_DLL Camera : public Object
|
|||
public:
|
||||
/** returns the Z eye */
|
||||
static float getZEye();
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Camera(void);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Camera(void);
|
||||
|
||||
void init(void);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
const char* description(void) const;
|
||||
|
||||
/** sets the dirty value */
|
||||
|
@ -86,18 +95,68 @@ public:
|
|||
/** Sets the camera using gluLookAt using its eye, center and up_vector */
|
||||
void locate(void);
|
||||
/** 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 */
|
||||
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 */
|
||||
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 */
|
||||
void getEyeXYZ(float *pEyeX, float *pEyeY, float *pEyeZ) const;
|
||||
/** get the center vector values int points */
|
||||
void getCenterXYZ(float *pCenterX, float *pCenterY, float *pCenterZ) const;
|
||||
/** get the up vector values */
|
||||
void getUpXYZ(float *pUpX, float *pUpY, float *pUpZ) const;
|
||||
/** get the eye vector values in points
|
||||
* @code
|
||||
* when this function bound to js or lua,the input params are changed
|
||||
* in js: var getEye()
|
||||
* in lua:local getEye()
|
||||
* @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:
|
||||
float _eyeX;
|
||||
|
|
|
@ -60,7 +60,10 @@ public:
|
|||
CC_DEPRECATED_ATTRIBUTE static void purgeConfiguration();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Configuration();
|
||||
|
||||
/** OpenGL Max texture size. */
|
||||
|
|
|
@ -104,8 +104,14 @@ public:
|
|||
|
||||
/** @deprecated Use getInstance() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE static Director* sharedDirector() { return Director::getInstance(); }
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Director(void);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Director(void);
|
||||
virtual bool init(void);
|
||||
|
||||
|
@ -127,7 +133,10 @@ public:
|
|||
/** seconds per frame */
|
||||
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; }
|
||||
void setOpenGLView(EGLView *pobOpenGLView);
|
||||
|
||||
|
@ -142,6 +151,8 @@ public:
|
|||
|
||||
/** Sets an OpenGL projection
|
||||
@since v0.8.2
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline Projection getProjection() { return _projection; }
|
||||
void setProjection(Projection projection);
|
||||
|
@ -169,8 +180,14 @@ public:
|
|||
|
||||
/** Director delegate. It shall implemente the DirectorDelegate protocol
|
||||
@since v0.99.5
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
DirectorDelegate* getDelegate() const;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setDelegate(DirectorDelegate* delegate);
|
||||
|
||||
// window size
|
||||
|
@ -250,6 +267,7 @@ public:
|
|||
|
||||
/** Ends the execution, releases the running scene.
|
||||
It doesn't remove the OpenGL view from its parent. You have to do it manually.
|
||||
* @lua endToLua
|
||||
*/
|
||||
void end();
|
||||
|
||||
|
@ -336,38 +354,52 @@ public:
|
|||
|
||||
/** Gets the TouchDispatcher associated with this director
|
||||
@since v2.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
TouchDispatcher* getTouchDispatcher() const;
|
||||
|
||||
/** Sets the TouchDispatcher associated with this director
|
||||
@since v2.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setTouchDispatcher(TouchDispatcher* touchDispatcher);
|
||||
|
||||
/** Gets the KeyboardDispatcher associated with this director
|
||||
@note Supported on Mac and Linux only now.
|
||||
@since v3.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
KeyboardDispatcher* getKeyboardDispatcher() const;
|
||||
|
||||
/** Sets the KeyboardDispatcher associated with this director
|
||||
@note Supported on Mac and Linux only now.
|
||||
@since v3.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setKeyboardDispatcher(KeyboardDispatcher* keyboardDispatcher);
|
||||
|
||||
/** Gets the KeypadDispatcher associated with this director
|
||||
@since v2.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
KeypadDispatcher* getKeypadDispatcher() const;
|
||||
|
||||
/** Sets the KeypadDispatcher associated with this director
|
||||
@since v2.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setKeypadDispatcher(KeypadDispatcher* keypadDispatcher);
|
||||
|
||||
/** Gets Accelerometer associated with this director
|
||||
@since v2.0
|
||||
*@js NA
|
||||
*@lua NA
|
||||
*/
|
||||
Accelerometer* getAccelerometer() const;
|
||||
|
||||
|
|
|
@ -50,7 +50,10 @@ public:
|
|||
static Timer* create(Object *target, SEL_SCHEDULE selector);
|
||||
/** Allocates a timer with a target, a selector and an interval in 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);
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE static Timer* timerWithTarget(Object *target, SEL_SCHEDULE selector) { return Timer::create(target, selector); }
|
||||
|
@ -70,7 +73,10 @@ public:
|
|||
float getInterval() const;
|
||||
/** set interval in seconds */
|
||||
void setInterval(float interval);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
SEL_SCHEDULE getSelector() const;
|
||||
|
||||
/** triggers the timer */
|
||||
|
@ -120,8 +126,14 @@ public:
|
|||
|
||||
// Minimum priority level for user scheduling.
|
||||
static const int PRIORITY_NON_SYSTEM_MIN;
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Scheduler();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Scheduler(void);
|
||||
|
||||
inline float getTimeScale(void) { return _timeScale; }
|
||||
|
@ -136,6 +148,8 @@ public:
|
|||
|
||||
/** 'update' the scheduler.
|
||||
You should NEVER call this method, unless you know what you are doing.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void update(float dt);
|
||||
|
||||
|
@ -220,6 +234,8 @@ public:
|
|||
|
||||
/** Returns whether or not the target is paused
|
||||
@since v1.0.0
|
||||
* In js: var isTargetPaused(var jsObject)
|
||||
* @lua NA
|
||||
*/
|
||||
bool isTargetPaused(Object *target);
|
||||
|
||||
|
|
|
@ -46,11 +46,19 @@ class CC_DLL Action : public Object, public Clonable
|
|||
public:
|
||||
/// Default tag used for all the actions
|
||||
static const int INVALID_TAG = -1;
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Action(void);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Action(void);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
const char* description() const;
|
||||
|
||||
/** returns a clone of action */
|
||||
|
@ -123,9 +131,16 @@ protected:
|
|||
class CC_DLL FiniteTimeAction : public Action
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
FiniteTimeAction()
|
||||
: _duration(0)
|
||||
{}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~FiniteTimeAction(){}
|
||||
//! get duration in seconds of the action
|
||||
inline float getDuration(void) const { return _duration; }
|
||||
|
@ -157,8 +172,14 @@ class CC_DLL Speed : public Action
|
|||
public:
|
||||
/** create the action */
|
||||
static Speed* create(ActionInterval* pAction, float fSpeed);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Speed();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Speed(void);
|
||||
|
||||
inline float getSpeed(void) const { return _speed; }
|
||||
|
@ -209,7 +230,9 @@ public:
|
|||
* with no boundary.
|
||||
*/
|
||||
static Follow* create(Node *followedNode, const Rect& rect = Rect::ZERO);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Follow()
|
||||
: _followedNode(NULL)
|
||||
, _boundarySet(false)
|
||||
|
@ -220,6 +243,10 @@ public:
|
|||
, _bottomBoundary(0.0)
|
||||
, _worldRect(Rect::ZERO)
|
||||
{}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Follow(void);
|
||||
|
||||
inline bool isBoundarySet(void) const { return _boundarySet; }
|
||||
|
|
|
@ -44,6 +44,9 @@ class Camera;
|
|||
class CC_DLL ActionCamera : public ActionInterval //<NSCopying>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ActionCamera()
|
||||
:_centerXOrig(0)
|
||||
,_centerYOrig(0)
|
||||
|
@ -55,6 +58,10 @@ public:
|
|||
,_upYOrig(0)
|
||||
,_upZOrig(0)
|
||||
{}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ActionCamera(){}
|
||||
|
||||
// Overrides
|
||||
|
@ -86,7 +93,9 @@ class CC_DLL OrbitCamera : public ActionCamera //<NSCopying>
|
|||
public:
|
||||
/** 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);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
OrbitCamera()
|
||||
: _radius(0.0)
|
||||
, _deltaRadius(0.0)
|
||||
|
@ -99,6 +108,10 @@ public:
|
|||
, _radX(0.0)
|
||||
, _radDeltaX(0.0)
|
||||
{}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~OrbitCamera(){}
|
||||
|
||||
/** initializes a OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */
|
||||
|
|
|
@ -58,43 +58,78 @@ class CC_DLL PointArray : public Object, public Clonable
|
|||
{
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~PointArray();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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);
|
||||
|
||||
/** appends a control point */
|
||||
/** appends a control point
|
||||
* @js NA
|
||||
*/
|
||||
void addControlPoint(Point controlPoint);
|
||||
|
||||
/** inserts a controlPoint at index */
|
||||
/** inserts a controlPoint at index
|
||||
* @js NA
|
||||
*/
|
||||
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);
|
||||
|
||||
/** 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);
|
||||
|
||||
/** deletes a control point at a given index */
|
||||
/** deletes a control point at a given index
|
||||
* @js NA
|
||||
*/
|
||||
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;
|
||||
|
||||
/** 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;
|
||||
|
||||
/** 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();
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual PointArray* clone() const;
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
const std::vector<Point*>* getControlPoints() const;
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
void setControlPoints(std::vector<Point*> *controlPoints);
|
||||
private:
|
||||
/** Array that contains the control points */
|
||||
|
@ -109,10 +144,23 @@ class CC_DLL CardinalSplineTo : public ActionInterval
|
|||
{
|
||||
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);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~CardinalSplineTo();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CardinalSplineTo();
|
||||
|
||||
/** initializes the action with a duration and an array of points */
|
||||
|
@ -121,6 +169,10 @@ public:
|
|||
virtual void updatePosition(Point &newPos);
|
||||
|
||||
inline PointArray* getPoints() { return _points; }
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline void setPoints(PointArray* points)
|
||||
{
|
||||
CC_SAFE_RETAIN(points);
|
||||
|
@ -151,7 +203,13 @@ class CC_DLL CardinalSplineBy : public CardinalSplineTo
|
|||
{
|
||||
public:
|
||||
|
||||
/** creates an action with a Cardinal Spline array of points and tension */
|
||||
/** creates an action with a Cardinal Spline array of points and tension
|
||||
* @code
|
||||
* when this function bound to js or lua,the input params are changed
|
||||
* in js: var create(var t,var table)
|
||||
* in lua: lcaol create(local t, local table)
|
||||
* @endcode
|
||||
*/
|
||||
static CardinalSplineBy* create(float duration, PointArray* points, float tension);
|
||||
|
||||
CardinalSplineBy();
|
||||
|
@ -175,7 +233,13 @@ class CC_DLL CatmullRomTo : public CardinalSplineTo
|
|||
{
|
||||
public:
|
||||
|
||||
/** creates an action with a Cardinal Spline array of points and tension */
|
||||
/** creates an action with a Cardinal Spline array of points and tension
|
||||
* @code
|
||||
* when this function bound to js or lua,the input params are changed
|
||||
* in js: var create(var dt,var table)
|
||||
* in lua: lcaol create(local dt, local table)
|
||||
* @endcode
|
||||
*/
|
||||
static CatmullRomTo* create(float dt, PointArray* points);
|
||||
|
||||
/** initializes the action with a duration and an array of points */
|
||||
|
@ -194,7 +258,13 @@ public:
|
|||
class CC_DLL CatmullRomBy : public CardinalSplineBy
|
||||
{
|
||||
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);
|
||||
|
||||
/** initializes the action with a duration and an array of points */
|
||||
|
|
|
@ -44,6 +44,10 @@ class Object;
|
|||
class CC_DLL ActionEase : public ActionInterval
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ActionEase(void);
|
||||
|
||||
/** initializes the action */
|
||||
|
@ -72,6 +76,10 @@ protected:
|
|||
class CC_DLL EaseRateAction : public ActionEase
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~EaseRateAction(void);
|
||||
|
||||
/** Initializes the action with the inner action and the rate parameter */
|
||||
|
|
|
@ -66,19 +66,34 @@ public:
|
|||
|
||||
/** returns the grid */
|
||||
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;
|
||||
|
||||
/** @deprecated Use getVertex() instead */
|
||||
/** @deprecated Use getVertex() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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;
|
||||
|
||||
/** @deprecated Use getOriginalVertex() instead */
|
||||
/** @deprecated Use getOriginalVertex() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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);
|
||||
|
||||
// Overrides
|
||||
|
@ -89,22 +104,40 @@ public:
|
|||
class CC_DLL TiledGrid3DAction : public GridAction
|
||||
{
|
||||
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);
|
||||
|
||||
/** 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;
|
||||
|
||||
/** @deprecated Use getTile() instead */
|
||||
/** @deprecated Use getTile() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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;
|
||||
|
||||
/** @deprecated Use getOriginalTile() instead */
|
||||
/** @deprecated Use getOriginalTile() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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);
|
||||
|
||||
/** returns the grid */
|
||||
|
@ -120,7 +153,10 @@ class CC_DLL AccelDeccelAmplitude : public ActionInterval
|
|||
public:
|
||||
/** creates the action with an inner action that has the amplitude property, and a duration time */
|
||||
static AccelDeccelAmplitude* create(Action *pAction, float duration);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~AccelDeccelAmplitude(void);
|
||||
/** initializes the action with an inner action that has the amplitude property, and a duration time */
|
||||
bool initWithAction(Action *pAction, float duration);
|
||||
|
@ -150,7 +186,10 @@ class CC_DLL AccelAmplitude : public ActionInterval
|
|||
public:
|
||||
/** creates the action with an inner action that has the amplitude property, and a duration time */
|
||||
static AccelAmplitude* create(Action *pAction, float duration);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~AccelAmplitude(void);
|
||||
|
||||
/** 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:
|
||||
/** creates the action with an inner action that has the amplitude property, and a duration time */
|
||||
static DeccelAmplitude* create(Action *pAction, float duration);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~DeccelAmplitude();
|
||||
/** initializes the action with an inner action that has the amplitude property, and a duration time */
|
||||
bool initWithAction(Action *pAction, float duration);
|
||||
|
|
|
@ -225,6 +225,9 @@ class CC_DLL CallFunc : public ActionInstant //<NSCopying>
|
|||
public:
|
||||
/** creates the action with the callback of type std::function<void()>.
|
||||
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);
|
||||
|
||||
|
@ -232,16 +235,25 @@ public:
|
|||
|
||||
typedef void (Object::*SEL_CallFunc)();
|
||||
@deprecated Use the std::function API instead.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE static CallFunc * create(Object* pSelectorTarget, SEL_CallFunc selector);
|
||||
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
CallFunc()
|
||||
: _selectorTarget(NULL)
|
||||
, _callFunc(NULL)
|
||||
, _function(nullptr)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~CallFunc();
|
||||
|
||||
/** initializes the action with the callback
|
||||
|
@ -251,6 +263,8 @@ public:
|
|||
CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* pSelectorTarget);
|
||||
|
||||
/** initializes the action with the std::function<void()>
|
||||
* @js NK
|
||||
* @lua NK
|
||||
*/
|
||||
bool initWithFunction(const std::function<void()>& func);
|
||||
|
||||
|
@ -379,8 +393,14 @@ public:
|
|||
typedef void (Object::*SEL_CallFuncO)(Object*);
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE static __CCCallFuncO * create(Object* selectorTarget, SEL_CallFuncO selector, Object* object);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
__CCCallFuncO();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~__CCCallFuncO();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -93,13 +93,22 @@ class CC_DLL Sequence : public ActionInterval
|
|||
public:
|
||||
/** helper constructor to create an array of sequenceable actions */
|
||||
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);
|
||||
/** helper constructor to create an array of sequence-able actions */
|
||||
static Sequence* createWithVariableList(FiniteTimeAction *pAction1, va_list args);
|
||||
/** creates the action */
|
||||
static Sequence* createWithTwoActions(FiniteTimeAction *pActionOne, FiniteTimeAction *pActionTwo);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Sequence(void);
|
||||
|
||||
/** initializes the action */
|
||||
|
@ -128,7 +137,10 @@ class CC_DLL Repeat : public ActionInterval
|
|||
public:
|
||||
/** creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) */
|
||||
static Repeat* create(FiniteTimeAction *pAction, unsigned int times);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Repeat(void);
|
||||
|
||||
/** 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:
|
||||
/** creates the action */
|
||||
static RepeatForever* create(ActionInterval *pAction);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
RepeatForever()
|
||||
: _innerAction(NULL)
|
||||
{}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~RepeatForever();
|
||||
|
||||
/** initializes the action */
|
||||
|
@ -220,7 +238,13 @@ protected:
|
|||
class CC_DLL Spawn : public ActionInterval
|
||||
{
|
||||
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;
|
||||
|
||||
/** helper constructor to create an array of spawned actions */
|
||||
|
@ -231,7 +255,10 @@ public:
|
|||
|
||||
/** creates the Spawn action */
|
||||
static Spawn* createWithTwoActions(FiniteTimeAction *pAction1, FiniteTimeAction *pAction2);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Spawn(void);
|
||||
|
||||
/** initializes the Spawn action with the 2 actions to spawn */
|
||||
|
@ -477,7 +504,13 @@ typedef struct _ccBezierConfig {
|
|||
class CC_DLL BezierBy : public ActionInterval
|
||||
{
|
||||
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);
|
||||
|
||||
/** initializes the action with a duration and a bezier configuration */
|
||||
|
@ -503,7 +536,13 @@ protected:
|
|||
class CC_DLL BezierTo : public BezierBy
|
||||
{
|
||||
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);
|
||||
bool initWithDuration(float t, const ccBezierConfig &c);
|
||||
|
||||
|
@ -742,8 +781,14 @@ class CC_DLL ReverseTime : public ActionInterval
|
|||
public:
|
||||
/** creates the action */
|
||||
static ReverseTime* create(FiniteTimeAction *pAction);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ReverseTime(void);
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ReverseTime();
|
||||
|
||||
/** initializes the action */
|
||||
|
@ -769,8 +814,14 @@ class CC_DLL Animate : public ActionInterval
|
|||
public:
|
||||
/** creates the action with an Animation and will restore the original frame when the animation is over */
|
||||
static Animate* create(Animation *pAnimation);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Animate();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Animate();
|
||||
|
||||
/** 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
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TargetedAction();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TargetedAction();
|
||||
|
||||
/** Create an action with the specified action and forced target */
|
||||
|
|
|
@ -57,7 +57,14 @@ struct _hashElement;
|
|||
class CC_DLL ActionManager : public Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ActionManager(void);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~ActionManager(void);
|
||||
|
||||
// actions
|
||||
|
|
|
@ -82,7 +82,10 @@ class CC_DLL ShuffleTiles : public TiledGrid3DAction
|
|||
public:
|
||||
/** creates the action with a random seed, the grid size and the duration */
|
||||
static ShuffleTiles* create(float duration, const Size& gridSize, unsigned int seed);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ShuffleTiles(void);
|
||||
/** initializes the action with a random seed, the grid size and the duration */
|
||||
bool initWithDuration(float duration, const Size& gridSize, unsigned int seed);
|
||||
|
@ -176,7 +179,10 @@ public:
|
|||
static TurnOffTiles* create(float duration, const Size& gridSize);
|
||||
/** creates the action with a random seed, the grid size and the duration */
|
||||
static TurnOffTiles* create(float duration, const Size& gridSize, unsigned int seed);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~TurnOffTiles(void);
|
||||
/** initializes the action with a random seed, the grid size and the duration */
|
||||
bool initWithDuration(float duration, const Size& gridSize, unsigned int seed);
|
||||
|
|
|
@ -37,6 +37,10 @@ NS_CC_BEGIN
|
|||
class CC_DLL ActionTweenDelegate
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ActionTweenDelegate() {}
|
||||
virtual void updateTweenAction(float value, const char* key) = 0;
|
||||
};
|
||||
|
|
|
@ -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*/
|
||||
static AtlasNode * create(const char* tile,unsigned int tileWidth, unsigned int tileHeight,
|
||||
unsigned int itemsToRender);
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
AtlasNode();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~AtlasNode();
|
||||
|
||||
/** 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 void setColor(const Color3B& color) 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;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual const BlendFunc& getBlendFunc() const override;
|
||||
|
||||
private :
|
||||
|
|
|
@ -29,7 +29,14 @@ THE SOFTWARE.
|
|||
class GLBufferedNode
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
GLBufferedNode();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~GLBufferedNode();
|
||||
|
||||
/**
|
||||
|
|
|
@ -144,11 +144,14 @@ public:
|
|||
|
||||
/**
|
||||
* Default constructor
|
||||
* @js ctor
|
||||
*/
|
||||
Node(void);
|
||||
|
||||
/**
|
||||
* Default destructor
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Node(void);
|
||||
|
||||
|
@ -161,6 +164,8 @@ public:
|
|||
/**
|
||||
* Gets the description string. It makes debugging easier.
|
||||
* @return A string terminated with '\0'
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
const char* description(void) const;
|
||||
|
||||
|
@ -299,6 +304,9 @@ public:
|
|||
* @see setPosition(const Point&)
|
||||
*
|
||||
* @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;
|
||||
/**
|
||||
|
@ -322,6 +330,9 @@ public:
|
|||
* Gets position in a more efficient way, returns two number instead of a Point object
|
||||
*
|
||||
* @see setPosition(float, float)
|
||||
* @code
|
||||
* In js,out value not return
|
||||
* @endcode
|
||||
*/
|
||||
virtual void getPosition(float* x, float* y) const;
|
||||
/**
|
||||
|
@ -520,9 +531,15 @@ public:
|
|||
virtual int getOrderOfArrival() const;
|
||||
|
||||
|
||||
/** @deprecated No longer needed */
|
||||
/** @deprecated No longer needed
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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; }
|
||||
|
||||
/**
|
||||
|
@ -640,6 +657,8 @@ public:
|
|||
* Removes this node itself from its parent node.
|
||||
* If the node orphan, then nothing happens.
|
||||
* @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);
|
||||
|
||||
|
@ -668,6 +687,8 @@ public:
|
|||
* 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.
|
||||
* @js removeAllChildren
|
||||
* @lua removeAllChildren
|
||||
*/
|
||||
virtual void removeAllChildrenWithCleanup(bool cleanup);
|
||||
|
||||
|
@ -697,8 +718,12 @@ public:
|
|||
* Returns 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; }
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return A custom user data pointer
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void* getUserData() { return _userData; }
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param userData A custom user data pointer
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setUserData(void *userData);
|
||||
|
||||
|
@ -784,8 +817,14 @@ public:
|
|||
* Similar to userData, but instead of holding a void* it holds an object
|
||||
*
|
||||
* @return A user assigned Object
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual Object* getUserObject() { return _userObject; }
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual const Object* getUserObject() const { return _userObject; }
|
||||
|
||||
/**
|
||||
|
@ -852,6 +891,7 @@ public:
|
|||
|
||||
/**
|
||||
* Schedules for lua script.
|
||||
* @js NA
|
||||
*/
|
||||
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.
|
||||
* 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().
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter();
|
||||
|
||||
/** 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 you override onEnterTransitionDidFinish, you shall call its parent's one, e.g. Node::onEnterTransitionDidFinish()
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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.
|
||||
* During onExit you can't access a sibling node.
|
||||
* If you override onExit, you shall call its parent's one, e.g., Node::onExit().
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onExit();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onExitTransitionDidStart();
|
||||
|
||||
|
@ -1029,6 +1077,8 @@ public:
|
|||
*
|
||||
* @param selector A function selector
|
||||
* @return Whether the funcion selector is scheduled.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool isScheduled(SEL_SCHEDULE selector);
|
||||
|
||||
|
@ -1038,6 +1088,8 @@ public:
|
|||
* 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.
|
||||
* Only one "update" method could be scheduled per node.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void scheduleUpdate(void);
|
||||
|
||||
|
@ -1047,6 +1099,8 @@ public:
|
|||
* This selector will be called every frame.
|
||||
* 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).
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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 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.
|
||||
* @lua NA
|
||||
*/
|
||||
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 interval Callback interval time in seconds. 0 means tick every frame,
|
||||
* @lua NA
|
||||
*/
|
||||
void schedule(SEL_SCHEDULE selector, float interval);
|
||||
|
||||
|
@ -1089,6 +1145,7 @@ public:
|
|||
*
|
||||
* @param selector The SEL_SCHEDULE selector to be scheduled.
|
||||
* @param delay The amount of time that the first tick will wait before execution.
|
||||
* @lua NA
|
||||
*/
|
||||
void scheduleOnce(SEL_SCHEDULE selector, float delay);
|
||||
|
||||
|
@ -1097,6 +1154,7 @@ public:
|
|||
* @see schedule(SEL_SCHEDULE, float, unsigned int, float)
|
||||
*
|
||||
* @param selector A function wrapped as a selector
|
||||
* @lua NA
|
||||
*/
|
||||
void schedule(SEL_SCHEDULE selector);
|
||||
|
||||
|
@ -1105,12 +1163,14 @@ public:
|
|||
* @see schedule(SEL_SCHEDULE, float, unsigned int, float)
|
||||
*
|
||||
* @param selector A function wrapped as a selector
|
||||
* @lua NA
|
||||
*/
|
||||
void unschedule(SEL_SCHEDULE selector);
|
||||
|
||||
/**
|
||||
* Unschedule all scheduled selectors: custom selectors, and the 'update' selector.
|
||||
* Actions are not affected by this method.
|
||||
* @lua NA
|
||||
*/
|
||||
void unscheduleAllSelectors(void);
|
||||
|
||||
|
@ -1395,7 +1455,14 @@ protected:
|
|||
class CC_DLL NodeRGBA : public Node, public RGBAProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
NodeRGBA();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~NodeRGBA();
|
||||
|
||||
virtual bool init();
|
||||
|
|
|
@ -234,45 +234,79 @@ class CC_DLL Array : public Object, public Clonable
|
|||
{
|
||||
public:
|
||||
|
||||
/** Creates an empty array. Default capacity is 10 */
|
||||
/** Creates an empty array. Default capacity is 10
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static Array* create();
|
||||
/** Create an array with objects */
|
||||
/** Create an array with objects
|
||||
* @js NA
|
||||
*/
|
||||
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);
|
||||
/** Create an array with a default capacity */
|
||||
/** Create an array with a default capacity
|
||||
* @js NA
|
||||
*/
|
||||
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);
|
||||
/**
|
||||
@brief Generate a Array pointer by file
|
||||
@param pFileName The file name of *.plist file
|
||||
@return The Array pointer generated from the file
|
||||
* @js NA
|
||||
*/
|
||||
static Array* createWithContentsOfFile(const char* pFileName);
|
||||
|
||||
/*
|
||||
@brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the
|
||||
invoker should call release().
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static Array* createWithContentsOfFileThreadSafe(const char* pFileName);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Array();
|
||||
|
||||
/** Initializes an array */
|
||||
/** Initializes an array
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool init();
|
||||
/** Initializes an array with one object */
|
||||
/** Initializes an array with one object
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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;
|
||||
/** Initializes an array with capacity */
|
||||
/** Initializes an array with capacity
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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);
|
||||
|
||||
// Querying an Array
|
||||
|
||||
/** Returns element count of the array */
|
||||
/** Returns element count of the array
|
||||
* @js NA
|
||||
*/
|
||||
int count() const
|
||||
{
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
|
@ -281,7 +315,9 @@ public:
|
|||
return data->num;
|
||||
#endif
|
||||
}
|
||||
/** Returns capacity of the array */
|
||||
/** Returns capacity of the array
|
||||
* @js NA
|
||||
*/
|
||||
int capacity() const
|
||||
{
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
|
@ -290,11 +326,20 @@ public:
|
|||
return data->max;
|
||||
#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;
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
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)
|
||||
{
|
||||
CCASSERT(index>=0 && index < count(), "index out of range in getObjectAtIndex()");
|
||||
|
@ -305,7 +350,9 @@ public:
|
|||
#endif
|
||||
}
|
||||
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()
|
||||
{
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
|
@ -317,25 +364,53 @@ public:
|
|||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE Object* lastObject() { return getLastObject(); }
|
||||
/** Returns a random element */
|
||||
/** Returns a random element
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Object* getRandomObject();
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
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;
|
||||
/** @since 1.1 */
|
||||
/** @since 1.1
|
||||
* @js NA
|
||||
*/
|
||||
bool isEqualToArray(Array* otherArray);
|
||||
// Adding Objects
|
||||
|
||||
/** Add a certain object */
|
||||
/** Add a certain object
|
||||
* @js NA
|
||||
*/
|
||||
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);
|
||||
/** Insert a certain object at a certain index */
|
||||
/** Insert a certain object at a certain index
|
||||
* @js NA
|
||||
*/
|
||||
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);
|
||||
/** 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)
|
||||
{
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
|
@ -345,7 +420,10 @@ public:
|
|||
data->arr[index] = object;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void swap( int indexOne, int indexTwo )
|
||||
{
|
||||
CCASSERT(indexOne >=0 && indexOne < count() && indexTwo >= 0 && indexTwo < count(), "Invalid indices");
|
||||
|
@ -358,38 +436,68 @@ public:
|
|||
|
||||
// Removing Objects
|
||||
|
||||
/** Remove last object */
|
||||
/** Remove last object
|
||||
* @js NA
|
||||
*/
|
||||
void removeLastObject(bool releaseObj = true);
|
||||
/** Remove a certain object */
|
||||
/** Remove a certain object
|
||||
* @js NA
|
||||
*/
|
||||
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);
|
||||
/** Remove all elements */
|
||||
/** Remove all elements
|
||||
* @js NA
|
||||
*/
|
||||
void removeObjectsInArray(Array* otherArray);
|
||||
/** Remove all objects */
|
||||
/** Remove all objects
|
||||
* @js NA
|
||||
*/
|
||||
void removeAllObjects();
|
||||
/** Fast way to remove a certain object */
|
||||
/** Fast way to remove a certain object
|
||||
* @js NA
|
||||
*/
|
||||
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);
|
||||
|
||||
// Rearranging Content
|
||||
|
||||
/** Swap two elements */
|
||||
/** Swap two elements
|
||||
* @js NA
|
||||
*/
|
||||
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);
|
||||
|
||||
/** 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);
|
||||
|
||||
/** Revers the array */
|
||||
/** Revers the array
|
||||
* @js NA
|
||||
*/
|
||||
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();
|
||||
|
||||
/* override functions */
|
||||
/* override functions
|
||||
* @js NA
|
||||
*/
|
||||
virtual void acceptVisitor(DataVisitor &visitor);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual Array* clone() const;
|
||||
|
||||
// ------------------------------------------
|
||||
|
@ -398,16 +506,35 @@ public:
|
|||
#if CC_USE_ARRAY_VECTOR
|
||||
typedef std::vector<RCPtr<Object>>::iterator iterator;
|
||||
typedef std::vector<RCPtr<Object>>::const_iterator const_iterator;
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
iterator begin() { return data.begin(); }
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
iterator end() { return data.end(); }
|
||||
const_iterator cbegin() { return data.cbegin(); }
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
const_iterator cend() { return data.cend(); }
|
||||
|
||||
std::vector<RCPtr<Object>> data;
|
||||
|
||||
#else
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Object** begin() { return &data->arr[0]; }
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Object** end() { return &data->arr[data->num]; }
|
||||
|
||||
ccArray* data;
|
||||
|
@ -415,6 +542,10 @@ public:
|
|||
#endif
|
||||
|
||||
//protected:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Array();
|
||||
};
|
||||
|
||||
|
|
|
@ -47,7 +47,15 @@ class CC_DLL AutoreleasePool : public Object
|
|||
*/
|
||||
Array *_managedObjectArray;
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
AutoreleasePool();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~AutoreleasePool();
|
||||
|
||||
/**
|
||||
|
@ -58,6 +66,8 @@ public:
|
|||
* for each time it was added.
|
||||
*
|
||||
* @param object The object to add to the pool.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void addObject(Object *object);
|
||||
|
||||
|
@ -65,6 +75,8 @@ public:
|
|||
* Remove a given object from this pool.
|
||||
*
|
||||
* @param object The object to be removed from the pool.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void removeObject(Object *object);
|
||||
|
||||
|
@ -73,6 +85,8 @@ public:
|
|||
*
|
||||
* Object::release() will be called for each time the managed object is
|
||||
* added to the pool.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void clear();
|
||||
};
|
||||
|
@ -84,19 +98,38 @@ class CC_DLL PoolManager
|
|||
|
||||
AutoreleasePool *getCurReleasePool();
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static PoolManager* sharedPoolManager();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static void purgePoolManager();
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
PoolManager();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~PoolManager();
|
||||
|
||||
/**
|
||||
* Clear all the AutoreleasePool on the pool stack.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void finalize();
|
||||
|
||||
/**
|
||||
* Push a new AutoreleasePool to the pool stack.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void push();
|
||||
|
||||
|
@ -107,6 +140,8 @@ public:
|
|||
* the stack.
|
||||
*
|
||||
* The AutoreleasePool being poped is destructed.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void pop();
|
||||
|
||||
|
@ -116,6 +151,8 @@ public:
|
|||
* @param object The object to be removed.
|
||||
*
|
||||
* @see AutoreleasePool::removeObject
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void removeObject(Object *object);
|
||||
|
||||
|
@ -125,9 +162,14 @@ public:
|
|||
* @param object The object to add.
|
||||
*
|
||||
* @see AutoreleasePool::addObject
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void addObject(Object *object);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
friend class AutoreleasePool;
|
||||
};
|
||||
|
||||
|
|
|
@ -33,10 +33,25 @@ NS_CC_BEGIN
|
|||
class CC_DLL Data : public Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Data(unsigned char *pBytes, const unsigned long nSize);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Data(Data *pData);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Data();
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static Data* create(unsigned char *pBytes, const unsigned long nSize)
|
||||
{
|
||||
Data* pRet = new Data(pBytes, nSize);
|
||||
|
@ -46,11 +61,21 @@ public:
|
|||
}
|
||||
return pRet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
unsigned char* getBytes() const;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
unsigned long getSize() const;
|
||||
|
||||
/* override functions */
|
||||
/** override functions
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void acceptVisitor(DataVisitor &visitor) { visitor.visit(this); }
|
||||
|
||||
private:
|
||||
|
|
|
@ -63,6 +63,10 @@ class Data;
|
|||
class CC_DLL DataVisitor
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~DataVisitor() {}
|
||||
|
||||
/** default method, called from non-overloaded methods and for unrecognized objects */
|
||||
|
|
|
@ -81,6 +81,8 @@ private:
|
|||
public:
|
||||
/**
|
||||
* The destructor of DictElement.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~DictElement();
|
||||
|
||||
|
@ -174,20 +176,28 @@ class CC_DLL Dictionary : public Object, public Clonable
|
|||
public:
|
||||
/**
|
||||
* The constructor of Dictionary.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Dictionary();
|
||||
|
||||
/**
|
||||
* The destructor of Dictionary
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~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();
|
||||
/**
|
||||
* Get the count of elements in Dictionary.
|
||||
*
|
||||
* @return The count of elements.
|
||||
* @js NA
|
||||
*/
|
||||
unsigned int count();
|
||||
|
||||
|
@ -195,6 +205,7 @@ public:
|
|||
* Return all keys of elements.
|
||||
*
|
||||
* @return The array contains all keys of elements. It's an autorelease object yet.
|
||||
* @js NA
|
||||
*/
|
||||
Array* allKeys();
|
||||
|
||||
|
@ -202,6 +213,7 @@ public:
|
|||
* Get all keys according to the specified object.
|
||||
* @warning We use '==' to compare two objects
|
||||
* @return The array contains all keys for the specified object. It's an autorelease object yet.
|
||||
* @js NA
|
||||
*/
|
||||
Array* allKeysForObject(Object* object);
|
||||
|
||||
|
@ -222,6 +234,7 @@ public:
|
|||
* }
|
||||
* @endcode
|
||||
* @see objectForKey(intptr_t)
|
||||
* @js NA
|
||||
*/
|
||||
Object* objectForKey(const std::string& key);
|
||||
|
||||
|
@ -232,6 +245,7 @@ public:
|
|||
* @param key The integer key for searching.
|
||||
* @return The object matches the key.
|
||||
* @see objectForKey(const std::string&)
|
||||
* @js NA
|
||||
*/
|
||||
Object* objectForKey(intptr_t key);
|
||||
|
||||
|
@ -242,6 +256,7 @@ public:
|
|||
* @return An instance of String.
|
||||
* It will return an empty string if the objects aren't String pointer or the key wasn't found.
|
||||
* @see valueForKey(intptr_t)
|
||||
* @js NA
|
||||
*/
|
||||
const String* valueForKey(const std::string& key);
|
||||
|
||||
|
@ -252,6 +267,7 @@ public:
|
|||
* @return An instance of String.
|
||||
* It will return an empty string if the objects aren't String pointer or the key wasn't found.
|
||||
* @see valueForKey(intptr_t)
|
||||
* @js NA
|
||||
*/
|
||||
const String* valueForKey(intptr_t key);
|
||||
|
||||
|
@ -265,6 +281,7 @@ public:
|
|||
* @param pObject The Object to be inserted.
|
||||
* @param key The string key for searching.
|
||||
* @see setObject(Object*, intptr_t)
|
||||
* @js NA
|
||||
*/
|
||||
void setObject(Object* pObject, const std::string& key);
|
||||
|
||||
|
@ -277,6 +294,7 @@ public:
|
|||
* @param pObject The Object to be inserted.
|
||||
* @param key The string key for searching.
|
||||
* @see setObject(Object*, const std::string&)
|
||||
* @js NA
|
||||
*/
|
||||
void setObject(Object* pObject, intptr_t key);
|
||||
|
||||
|
@ -286,6 +304,7 @@ public:
|
|||
* @param key The string key for searching.
|
||||
* @see removeObjectForKey(intptr_t), removeObjectsForKeys(Array*),
|
||||
* removeObjectForElememt(DictElement*), removeAllObjects().
|
||||
* @js NA
|
||||
*/
|
||||
void removeObjectForKey(const std::string& key);
|
||||
|
||||
|
@ -295,6 +314,7 @@ public:
|
|||
* @param key The integer key for searching.
|
||||
* @see removeObjectForKey(const std::string&), removeObjectsForKeys(Array*),
|
||||
* removeObjectForElememt(DictElement*), removeAllObjects().
|
||||
* @js NA
|
||||
*/
|
||||
void removeObjectForKey(intptr_t key);
|
||||
|
||||
|
@ -304,6 +324,7 @@ public:
|
|||
* @param pKeyArray The array contains keys to be removed.
|
||||
* @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t),
|
||||
* removeObjectForElememt(DictElement*), removeAllObjects().
|
||||
* @js NA
|
||||
*/
|
||||
void removeObjectsForKeys(Array* pKeyArray);
|
||||
|
||||
|
@ -313,6 +334,8 @@ public:
|
|||
* @param pElement The element need to be removed.
|
||||
* @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t),
|
||||
* removeObjectsForKeys(Array*), removeAllObjects().
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void removeObjectForElememt(DictElement* pElement);
|
||||
|
||||
|
@ -321,6 +344,7 @@ public:
|
|||
*
|
||||
* @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t),
|
||||
* removeObjectsForKeys(Array*), removeObjectForElememt(DictElement*).
|
||||
* @js NA
|
||||
*/
|
||||
void removeAllObjects();
|
||||
|
||||
|
@ -329,6 +353,8 @@ public:
|
|||
*
|
||||
* @return The random object.
|
||||
* @see objectForKey(intptr_t), objectForKey(const std::string&)
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Object* randomObject();
|
||||
|
||||
|
@ -336,6 +362,7 @@ public:
|
|||
* Create a dictionary.
|
||||
* @return A dictionary which is an autorelease object.
|
||||
* @see createWithDictionary(Dictionary*), createWithContentsOfFile(const char*), createWithContentsOfFileThreadSafe(const char*).
|
||||
* @js NA
|
||||
*/
|
||||
static Dictionary* create();
|
||||
|
||||
|
@ -345,6 +372,7 @@ public:
|
|||
* @param srcDict The exist dictionary.
|
||||
* @return A dictionary which is an autorelease object.
|
||||
* @see create(), createWithContentsOfFile(const char*), createWithContentsOfFileThreadSafe(const char*).
|
||||
* @js NA
|
||||
*/
|
||||
static Dictionary* createWithDictionary(Dictionary* srcDict);
|
||||
|
||||
|
@ -353,6 +381,7 @@ public:
|
|||
* @param pFileName The name of the plist file.
|
||||
* @return A dictionary which is an autorelease object.
|
||||
* @see create(), createWithDictionary(Dictionary*), createWithContentsOfFileThreadSafe(const char*).
|
||||
* @js NA
|
||||
*/
|
||||
static Dictionary* createWithContentsOfFile(const char *pFileName);
|
||||
|
||||
|
@ -360,6 +389,8 @@ public:
|
|||
* Write a dictionary to a plist file.
|
||||
* @param fullPath The full path of the plist file. You can get writeable path by getWritablePath()
|
||||
* @return true if successed, false if failed
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool writeToFile(const char *fullPath);
|
||||
|
||||
|
@ -373,11 +404,20 @@ public:
|
|||
*
|
||||
* @param pFileName The name of the plist file.
|
||||
* @return A dictionary which isn't an autorelease object.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static Dictionary* createWithContentsOfFileThreadSafe(const char *pFileName);
|
||||
|
||||
/* override functions */
|
||||
/* override functions
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void acceptVisitor(DataVisitor &visitor);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual Dictionary* clone() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -24,6 +24,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCGeometry.h"
|
||||
#include "ccMacros.h"
|
||||
#include <algorithm>
|
||||
|
||||
// implementation of Point
|
||||
NS_CC_BEGIN
|
||||
|
|
|
@ -60,28 +60,81 @@ public:
|
|||
float y;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
Point();
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
Point(float x, float y);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Point(const Point& other);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
explicit Point(const Size& size);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Point& operator= (const Point& other);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Point& operator= (const Size& size);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Point operator+(const Point& right) const;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Point operator-(const Point& right) const;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Point operator-() const;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Point operator*(float a) const;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Point operator/(float a) const;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setPoint(float x, float y);
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
bool equals(const Point& target) const;
|
||||
|
||||
/** @returns if points have fuzzy equality which means equal with some degree of variance.
|
||||
@since v2.1.4
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool fuzzyEquals(const Point& target, float variance) const;
|
||||
|
||||
/** Calculates distance between point an origin
|
||||
@return float
|
||||
@since v2.1.4
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline float getLength() const {
|
||||
return sqrtf(x*x + y*y);
|
||||
|
@ -90,6 +143,8 @@ public:
|
|||
/** Calculates the square length of a Point (not calling sqrt() )
|
||||
@return float
|
||||
@since v2.1.4
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline float getLengthSq() const {
|
||||
return dot(*this); //x*x + y*y;
|
||||
|
@ -98,7 +153,9 @@ public:
|
|||
/** Calculates the square distance between two points (not calling sqrt() )
|
||||
@return float
|
||||
@since v2.1.4
|
||||
*/
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline float getDistanceSq(const Point& other) const {
|
||||
return (*this - other).getLengthSq();
|
||||
};
|
||||
|
@ -106,6 +163,8 @@ public:
|
|||
/** Calculates the distance between two points
|
||||
@return float
|
||||
@since v2.1.4
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline float getDistance(const Point& other) const {
|
||||
return (*this - other).getLength();
|
||||
|
@ -113,19 +172,25 @@ public:
|
|||
|
||||
/** @returns the angle in radians between this vector and the x axis
|
||||
@since v2.1.4
|
||||
*/
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline float getAngle() const {
|
||||
return atan2f(y, x);
|
||||
};
|
||||
|
||||
/** @returns the angle in radians between two vector directions
|
||||
@since v2.1.4
|
||||
*/
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
float getAngle(const Point& other) const;
|
||||
|
||||
/** Calculates dot product of two points.
|
||||
@return float
|
||||
@since v2.1.4
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline float dot(const Point& other) const {
|
||||
return x*other.x + y*other.y;
|
||||
|
@ -134,6 +199,8 @@ public:
|
|||
/** Calculates cross product of two points.
|
||||
@return float
|
||||
@since v2.1.4
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline float cross(const Point& other) const {
|
||||
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
|
||||
@return Point
|
||||
@since v2.1.4
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline Point getPerp() const {
|
||||
return Point(-y, x);
|
||||
|
@ -150,6 +219,8 @@ public:
|
|||
/** Calculates midpoint between two points.
|
||||
@return Point
|
||||
@since v3.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline Point getMidpoint(const Point& other) const
|
||||
{
|
||||
|
@ -158,6 +229,8 @@ public:
|
|||
|
||||
/** Clamp a point between from and to.
|
||||
@since v3.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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
|
||||
* p.compOp(floorf);
|
||||
@since v3.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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
|
||||
@return Point
|
||||
@since v2.1.4
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline Point getRPerp() const {
|
||||
return Point(y, -x);
|
||||
|
@ -187,6 +264,8 @@ public:
|
|||
/** Calculates the projection of this over other.
|
||||
@return Point
|
||||
@since v2.1.4
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline Point project(const Point& other) const {
|
||||
return other * (dot(other)/other.dot(other));
|
||||
|
@ -196,6 +275,8 @@ public:
|
|||
@return Point vector with an angle of this.getAngle() + other.getAngle(),
|
||||
and a length of this.getLength() * other.getLength().
|
||||
@since v2.1.4
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline Point rotate(const Point& other) const {
|
||||
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(),
|
||||
and a length of this.getLength() * other.getLength().
|
||||
@since v2.1.4
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline Point unrotate(const Point& other) const {
|
||||
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)
|
||||
@return Point
|
||||
@since v2.1.4
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline Point normalize() const {
|
||||
float length = getLength();
|
||||
|
@ -227,6 +312,8 @@ public:
|
|||
alpha == 1 ? b
|
||||
otherwise a value between a..b
|
||||
@since v2.1.4
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline Point lerp(const Point& other, float alpha) const {
|
||||
return *this * (1.f - alpha) + other * alpha;
|
||||
|
@ -237,9 +324,15 @@ public:
|
|||
@param angle is the angle of rotation ccw in radians
|
||||
@returns the rotated point
|
||||
@since v2.1.4
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Point rotateByAngle(const Point& pivot, float angle) const;
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static inline Point forAngle(const float a)
|
||||
{
|
||||
return Point(cosf(a), sinf(a));
|
||||
|
@ -259,42 +352,54 @@ public:
|
|||
the hit point is C + T * (D - C);
|
||||
the hit point also is A + S * (B - A);
|
||||
@since 3.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static bool isLineIntersect(const Point& A, const Point& B,
|
||||
const Point& C, const Point& D,
|
||||
float *S = nullptr, float *T = nullptr);
|
||||
|
||||
/*
|
||||
/**
|
||||
returns true if Line A-B overlap with segment C-D
|
||||
@since v3.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static bool isLineOverlap(const Point& A, const Point& B,
|
||||
const Point& C, const Point& D);
|
||||
|
||||
/*
|
||||
/**
|
||||
returns true if Line A-B parallel with segment C-D
|
||||
@since v3.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static bool isLineParallel(const Point& A, const Point& B,
|
||||
const Point& C, const Point& D);
|
||||
|
||||
/*
|
||||
/**
|
||||
returns true if Segment A-B overlap with segment C-D
|
||||
@since v3.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static bool isSegmentOverlap(const Point& A, const Point& B,
|
||||
const Point& C, const Point& D,
|
||||
Point* S = nullptr, Point* E = nullptr);
|
||||
|
||||
/*
|
||||
/**
|
||||
returns true if Segment A-B intersects with segment C-D
|
||||
@since v3.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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
|
||||
@since v3.0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static Point getIntersectPoint(const Point& A, const Point& B, const Point& C, const Point& D);
|
||||
|
||||
|
@ -315,17 +420,62 @@ public:
|
|||
float height;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
Size();
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
Size(float width, float height);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Size(const Size& other);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
explicit Size(const Point& point);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Size& operator= (const Size& other);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Size& operator= (const Point& point);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Size operator+(const Size& right) const;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Size operator-(const Size& right) const;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Size operator*(float a) const;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Size operator/(float a) const;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setSize(float width, float height);
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
bool equals(const Size& target) const;
|
||||
|
||||
static const Size ZERO;
|
||||
|
@ -338,20 +488,69 @@ public:
|
|||
Size size;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
Rect();
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
Rect(float x, float y, float width, float height);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Rect(const Rect& other);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Rect& operator= (const Rect& other);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setRect(float x, float y, float width, float height);
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
float getMinX() const; /// return the leftmost x-value of current rect
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
float getMidX() const; /// return the midpoint x-value of current rect
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
float getMaxX() const; /// return the rightmost x-value of current rect
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
float getMinY() const; /// return the bottommost y-value of current rect
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
float getMidY() const; /// return the midpoint y-value of current rect
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
bool intersectsRect(const Rect& rect) const;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Rect unionWithRect(const Rect & rect) const;
|
||||
|
||||
static const Rect ZERO;
|
||||
|
|
|
@ -44,11 +44,16 @@ public:
|
|||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
Integer(int v)
|
||||
: _value(v) {}
|
||||
int getValue() const {return _value;}
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Integer() {
|
||||
CCLOGINFO("deallocing ~Integer: %p", this);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,10 @@ class CC_DLL Clonable
|
|||
public:
|
||||
/** returns a copy of the object */
|
||||
virtual Clonable* clone() const = 0;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Clonable() {};
|
||||
|
||||
/** returns a copy of the object.
|
||||
|
@ -79,9 +83,14 @@ public:
|
|||
* Constructor
|
||||
*
|
||||
* The object's reference count is 1 after construction.
|
||||
* @js NA
|
||||
*/
|
||||
Object();
|
||||
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Object();
|
||||
|
||||
/**
|
||||
|
@ -93,6 +102,7 @@ public:
|
|||
* destructed.
|
||||
*
|
||||
* @see retain, autorelease
|
||||
* @js NA
|
||||
*/
|
||||
inline void release()
|
||||
{
|
||||
|
@ -109,6 +119,7 @@ public:
|
|||
* This increases the object's reference count.
|
||||
*
|
||||
* @see release, autorelease
|
||||
* @js NA
|
||||
*/
|
||||
inline void retain()
|
||||
{
|
||||
|
@ -128,6 +139,8 @@ public:
|
|||
* @returns The object itself.
|
||||
*
|
||||
* @see AutoreleasePool, retain, release
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Object* autorelease();
|
||||
|
||||
|
@ -136,6 +149,7 @@ public:
|
|||
* reference to the object. That is, whether the reference count is 1.
|
||||
*
|
||||
* @returns Whether the object's reference count is 1.
|
||||
* @js NA
|
||||
*/
|
||||
bool isSingleReference() const;
|
||||
|
||||
|
@ -143,6 +157,7 @@ public:
|
|||
* Returns the object's current reference count.
|
||||
*
|
||||
* @returns The object's reference count.
|
||||
* @js NA
|
||||
*/
|
||||
unsigned int retainCount() const;
|
||||
|
||||
|
@ -153,11 +168,19 @@ public:
|
|||
* @param object The object to be compared to this object.
|
||||
*
|
||||
* @returns True if this object and @p object are equal, otherwise false.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual bool isEqual(const Object* object);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void acceptVisitor(DataVisitor &visitor);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void update(float dt) {CC_UNUSED_PARAM(dt);};
|
||||
|
||||
friend class AutoreleasePool;
|
||||
|
|
|
@ -40,8 +40,15 @@ typedef std::set<Object *>::iterator SetIterator;
|
|||
class CC_DLL Set : public Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Set(void);
|
||||
Set(const Set &rSetObject);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Set(void);
|
||||
|
||||
/**
|
||||
|
@ -79,17 +86,24 @@ public:
|
|||
bool containsObject(Object *pObject);
|
||||
/**
|
||||
*@brief Return the iterator that points to the first element.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
SetIterator begin();
|
||||
/**
|
||||
*@brief Return the iterator that points to the position after the last element.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
SetIterator end();
|
||||
/**
|
||||
*@brief Return the first element if it contains elements, or null if it doesn't contain any element.
|
||||
*/
|
||||
Object* anyObject();
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void acceptVisitor(DataVisitor &visitor);
|
||||
|
||||
private:
|
||||
|
|
|
@ -43,58 +43,111 @@ NS_CC_BEGIN
|
|||
class CC_DLL String : public Object, public Clonable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
String();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
String(const char* str);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
String(const std::string& str);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
String(const String& str);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~String();
|
||||
|
||||
/* override assignment operator */
|
||||
/* override assignment operator
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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);
|
||||
|
||||
/** convert to int value */
|
||||
/** convert to int value
|
||||
* @js NA
|
||||
*/
|
||||
int intValue() const;
|
||||
|
||||
/** convert to unsigned int value */
|
||||
/** convert to unsigned int value
|
||||
* @js NA
|
||||
*/
|
||||
unsigned int uintValue() const;
|
||||
|
||||
/** convert to float value */
|
||||
/** convert to float value
|
||||
* @js NA
|
||||
*/
|
||||
float floatValue() const;
|
||||
|
||||
/** convert to double value */
|
||||
/** convert to double value
|
||||
* @js NA
|
||||
*/
|
||||
double doubleValue() const;
|
||||
|
||||
/** convert to bool value */
|
||||
/** convert to bool value
|
||||
* @js NA
|
||||
*/
|
||||
bool boolValue() const;
|
||||
|
||||
/** get the C string */
|
||||
/** get the C string
|
||||
* @js NA
|
||||
*/
|
||||
const char* getCString() const;
|
||||
|
||||
/** get the length of string */
|
||||
/** get the length of string
|
||||
* @js NA
|
||||
*/
|
||||
unsigned int length() const;
|
||||
|
||||
/** compare to a c string */
|
||||
/** compare to a c string
|
||||
* @js NA
|
||||
*/
|
||||
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);
|
||||
|
||||
/** 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, ...);
|
||||
|
||||
/** split a string */
|
||||
/** split a string
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Array* componentsSeparatedByString(const char *delimiter);
|
||||
|
||||
/* override functions */
|
||||
/* override functions
|
||||
* @js NA
|
||||
*/
|
||||
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.
|
||||
* @return A String pointer which is an autorelease object pointer,
|
||||
* it means that you needn't do a release operation unless you retain it.
|
||||
* @js NA
|
||||
*/
|
||||
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.
|
||||
* @return A String pointer which is an autorelease object pointer,
|
||||
* 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);
|
||||
|
||||
/** create a string with binary data
|
||||
* @return A String pointer which is an autorelease object pointer,
|
||||
* 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);
|
||||
|
||||
/** create a string with a file,
|
||||
* @return A String pointer which is an autorelease object pointer,
|
||||
* it means that you needn't do a release operation unless you retain it.
|
||||
* @js NA
|
||||
*/
|
||||
static String* createWithContentsOfFile(const char* filename);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void acceptVisitor(DataVisitor &visitor);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual String* clone() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -46,7 +46,14 @@ class CC_DLL DrawNode : public Node
|
|||
public:
|
||||
/** creates and initialize a DrawNode node */
|
||||
static DrawNode* create();
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
DrawNode();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~DrawNode();
|
||||
|
||||
virtual bool init();
|
||||
|
@ -57,17 +64,35 @@ public:
|
|||
/** draw a segment with a radius and 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);
|
||||
|
||||
/** Clear the geometry in the node's buffer. */
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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);
|
||||
|
||||
/** listen the event that coming to foreground on Android
|
||||
*/
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void listenBackToForeground(Object *obj);
|
||||
|
||||
// Overrides
|
||||
|
|
|
@ -42,7 +42,14 @@ class Texture2D;
|
|||
class Grabber : public Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Grabber(void);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Grabber(void);
|
||||
|
||||
void grab(Texture2D *texture);
|
||||
|
|
|
@ -56,7 +56,10 @@ public:
|
|||
static GridBase* create(const Size& gridSize, Texture2D *texture, bool flipped);
|
||||
/** create one Grid */
|
||||
static GridBase* create(const Size& gridSize);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~GridBase(void);
|
||||
|
||||
bool initWithSize(const Size& gridSize, Texture2D *texture, bool bFlipped);
|
||||
|
@ -115,20 +118,41 @@ public:
|
|||
static Grid3D* create(const Size& gridSize, Texture2D *texture, bool bFlipped);
|
||||
/** create one Grid */
|
||||
static Grid3D* create(const Size& gridSize);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Grid3D();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~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;
|
||||
/** @deprecated Use getVertex() instead */
|
||||
/** @deprecated Use getVertex() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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;
|
||||
/** @deprecated Use getOriginalVertex() instead */
|
||||
/** @deprecated Use getOriginalVertex() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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);
|
||||
|
||||
// Overrides
|
||||
|
@ -157,20 +181,41 @@ public:
|
|||
static TiledGrid3D* create(const Size& gridSize, Texture2D *texture, bool bFlipped);
|
||||
/** create one Grid */
|
||||
static TiledGrid3D* create(const Size& gridSize);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TiledGrid3D();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~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;
|
||||
/** 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); }
|
||||
/** 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;
|
||||
/** 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); }
|
||||
|
||||
/** sets a new tile */
|
||||
/** sets a new tile
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setTile(const Point& pos, const Quad3& coords);
|
||||
|
||||
// Overrides
|
||||
|
|
|
@ -42,6 +42,8 @@ public:
|
|||
* Changes the color with R,G,B bytes
|
||||
*
|
||||
* @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;
|
||||
|
||||
|
@ -49,6 +51,8 @@ public:
|
|||
* Returns color that is currently used.
|
||||
*
|
||||
* @return The Color3B contains R,G,B bytes.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual const Color3B& getColor() const = 0;
|
||||
|
||||
|
@ -56,6 +60,8 @@ public:
|
|||
* Returns the displayed color.
|
||||
*
|
||||
* @return The Color3B contains R,G,B bytes.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual const Color3B& getDisplayedColor() const = 0;
|
||||
|
||||
|
@ -63,6 +69,8 @@ public:
|
|||
* Returns the displayed opacity.
|
||||
*
|
||||
* @return The opacity of sprite, from 0 ~ 255
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual GLubyte getDisplayedOpacity() const = 0;
|
||||
/**
|
||||
|
@ -72,6 +80,8 @@ public:
|
|||
* 0 indicates fully transparent and 255 is fully opaque.
|
||||
*
|
||||
* @return The opacity of sprite, from 0 ~ 255
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual GLubyte getOpacity() const = 0;
|
||||
|
||||
|
@ -79,6 +89,8 @@ public:
|
|||
* Changes the opacity.
|
||||
*
|
||||
* @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;
|
||||
|
||||
|
@ -91,6 +103,8 @@ public:
|
|||
*
|
||||
* @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);
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setOpacityModifyRGB(bool value) = 0;
|
||||
|
||||
|
@ -99,28 +113,46 @@ public:
|
|||
* or glColor(opacity, opacity, opacity, opacity)
|
||||
*
|
||||
* @return Returns opacity modify flag.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual bool isOpacityModifyRGB() const = 0;
|
||||
|
||||
/**
|
||||
* whether or not color should be propagated to its children.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual bool isCascadeColorEnabled() const = 0;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) = 0;
|
||||
|
||||
/**
|
||||
* recursive method that updates display color
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void updateDisplayedColor(const Color3B& color) = 0;
|
||||
|
||||
/**
|
||||
* whether or not opacity should be propagated to its children.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual bool isCascadeOpacityEnabled() const = 0;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) = 0;
|
||||
|
||||
/**
|
||||
* recursive method that updates the displayed opacity.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void updateDisplayedOpacity(GLubyte opacity) = 0;
|
||||
};
|
||||
|
@ -138,7 +170,8 @@ public:
|
|||
*
|
||||
* @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}.
|
||||
*
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setBlendFunc(const BlendFunc &blendFunc) = 0;
|
||||
|
||||
|
@ -146,6 +179,8 @@ public:
|
|||
* Returns the blending function that is currently being used.
|
||||
*
|
||||
* @return A BlendFunc structure with source and destination factor which specified pixel arithmetic.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual const BlendFunc &getBlendFunc() const = 0;
|
||||
};
|
||||
|
@ -166,6 +201,8 @@ public:
|
|||
* Returns the currently used texture
|
||||
*
|
||||
* @return The texture that is currenlty being used.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual Texture2D* getTexture() const = 0;
|
||||
|
||||
|
@ -173,6 +210,8 @@ public:
|
|||
* Sets a new texuture. It will be retained.
|
||||
*
|
||||
* @param texture A valid Texture2D object, which will be applied to this sprite object.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setTexture(Texture2D *texture) = 0;
|
||||
};
|
||||
|
@ -187,6 +226,8 @@ public:
|
|||
* Sets a new label using an string
|
||||
*
|
||||
* @param label A null terminated string
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setString(const char *label) = 0;
|
||||
|
||||
|
@ -194,6 +235,8 @@ public:
|
|||
* Returns 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;
|
||||
};
|
||||
|
@ -206,6 +249,8 @@ class CC_DLL DirectorDelegate
|
|||
public:
|
||||
/**
|
||||
* Will be called by Director when the projection is updated, and "custom" projection is used
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void updateProjection() = 0;
|
||||
};
|
||||
|
|
|
@ -427,7 +427,10 @@ public:
|
|||
struct FontDefinition
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
FontDefinition()
|
||||
: _fontSize(0)
|
||||
, _alignment(TextHAlignment::CENTER)
|
||||
|
|
|
@ -45,7 +45,14 @@ typedef std::function<void(int)> KeyboardDelegate;
|
|||
class CC_DLL KeyboardDispatcher : public Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
KeyboardDispatcher();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~KeyboardDispatcher();
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,10 +38,17 @@ NS_CC_BEGIN
|
|||
class CC_DLL KeypadDelegate
|
||||
{
|
||||
public:
|
||||
// The back key clicked
|
||||
/** The back key clicked
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
|
||||
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() {};
|
||||
};
|
||||
|
||||
|
@ -53,17 +60,34 @@ Object than contains the KeypadDelegate.
|
|||
class CC_DLL KeypadHandler : public Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~KeypadHandler(void);
|
||||
|
||||
/** delegate */
|
||||
/** delegate
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
KeypadDelegate* getDelegate();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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);
|
||||
|
||||
public:
|
||||
/** allocates a KeypadHandler with a delegate */
|
||||
/** allocates a KeypadHandler with a delegate
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static KeypadHandler* handlerWithDelegate(KeypadDelegate *pDelegate);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -49,7 +49,14 @@ struct _ccCArray;
|
|||
class CC_DLL KeypadDispatcher : public Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
KeypadDispatcher();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~KeypadDispatcher();
|
||||
|
||||
/**
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ void Font::setCurrentGlyphCollection(GlyphCollection glyphs, const char *customG
|
|||
}
|
||||
}
|
||||
|
||||
const char * Font::getCurrentGlyphCollection()
|
||||
const char * Font::getCurrentGlyphCollection() const
|
||||
{
|
||||
if (_customGlyphs)
|
||||
{
|
||||
|
@ -107,9 +107,9 @@ Font* Font::createWithFNT(const char* 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)
|
||||
return 0;
|
||||
|
@ -118,28 +118,28 @@ unsigned short int * Font::getUTF16Text(const char *pText, int &outNumLetters)
|
|||
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;
|
||||
|
||||
if ( newBegin>=newEnd )
|
||||
if ( newBegin >= newEnd )
|
||||
return 0;
|
||||
|
||||
if (newEnd >= cc_wcslen(pText))
|
||||
if (newEnd >= cc_wcslen(text))
|
||||
return 0;
|
||||
|
||||
int newLenght = newEnd - newBegin + 2;
|
||||
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
|
||||
|
@ -149,15 +149,9 @@ unsigned short int * Font::trimUTF16Text(unsigned short int *pText, int newBegi
|
|||
return trimmedString;
|
||||
}
|
||||
|
||||
Rect Font::getRectForChar(unsigned short theChar)
|
||||
Rect Font::getRectForChar(unsigned short theChar) const
|
||||
{
|
||||
Rect temp;
|
||||
temp.size.width = 0;
|
||||
temp.size.height = 0;
|
||||
temp.origin.x = 0;
|
||||
temp.origin.y = 0;
|
||||
|
||||
return temp;
|
||||
return Rect::ZERO;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -47,25 +47,29 @@ public:
|
|||
|
||||
virtual FontAtlas *createFontAtlas() = 0;
|
||||
|
||||
virtual Size * getAdvancesForTextUTF16(unsigned short *pText, int &outNumLetters) = 0;
|
||||
virtual const char * getCurrentGlyphCollection();
|
||||
virtual Size * getAdvancesForTextUTF16(unsigned short *text, int &outNumLetters) const = 0;
|
||||
virtual const char * getCurrentGlyphCollection() const;
|
||||
|
||||
virtual int getLetterPadding() { return 0; }
|
||||
virtual unsigned char * getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) { return 0; }
|
||||
virtual GlyphDef * getGlyphDefintionsForText(const char *pText, int &outNumGlyphs, bool UTF16text = false) { return 0; }
|
||||
virtual int getFontMaxHeight() { return 0; }
|
||||
virtual Rect getRectForChar(unsigned short theChar);
|
||||
virtual int getLetterPadding() const { return 0; }
|
||||
virtual unsigned char * getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) const { return 0; }
|
||||
virtual GlyphDef * getGlyphDefintionsForText(const char *text, int &outNumGlyphs, bool UTF16text = false) const { return 0; }
|
||||
virtual int getFontMaxHeight() const { return 0; }
|
||||
virtual Rect getRectForChar(unsigned short theChar) const;
|
||||
|
||||
virtual int getUTF16TextLenght(unsigned short int *pText);
|
||||
virtual unsigned short int * getUTF16Text(const char *pText, int &outNumLetters);
|
||||
virtual unsigned short int * trimUTF16Text(unsigned short int *pText, int newBegin, int newEnd);
|
||||
virtual int getUTF16TextLenght(unsigned short int *text) const;
|
||||
virtual unsigned short int * getUTF16Text(const char *text, int &outNumLetters) const;
|
||||
virtual unsigned short int * trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const;
|
||||
|
||||
protected:
|
||||
|
||||
Font();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Font() {}
|
||||
void setCurrentGlyphCollection(GlyphCollection glyphs, const char *customGlyphs = 0);
|
||||
const char * getGlyphCollection(GlyphCollection glyphs);
|
||||
const char * getGlyphCollection(GlyphCollection glyphs) const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ Texture2D & FontAtlas::getTexture(int slot)
|
|||
return *(_atlasTextures[slot]);
|
||||
}
|
||||
|
||||
float FontAtlas::getCommonLineHeight()
|
||||
float FontAtlas::getCommonLineHeight() const
|
||||
{
|
||||
return _commonLineHeight;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ void FontAtlas::setCommonLineHeight(float newHeight)
|
|||
_commonLineHeight = newHeight;
|
||||
}
|
||||
|
||||
Font & FontAtlas::getFont()
|
||||
Font & FontAtlas::getFont() const
|
||||
{
|
||||
return _font;
|
||||
}
|
||||
|
|
|
@ -50,19 +50,25 @@ struct FontLetterDefinition
|
|||
class CC_DLL FontAtlas : public Object
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
FontAtlas(Font &theFont);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~FontAtlas();
|
||||
|
||||
void addLetterDefinition(const FontLetterDefinition &letterDefinition);
|
||||
bool getLetterDefinitionForChar(unsigned short letteCharUTF16, FontLetterDefinition &outDefinition);
|
||||
|
||||
void addTexture(Texture2D &texture, int slot);
|
||||
float getCommonLineHeight();
|
||||
float getCommonLineHeight() const;
|
||||
void setCommonLineHeight(float newHeight);
|
||||
|
||||
Texture2D & getTexture(int slot);
|
||||
Font & getFont();
|
||||
Texture2D & getTexture(int slot);
|
||||
Font & getFont() const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -31,10 +31,10 @@ FontAtlas * FontAtlasFactory::createAtlasFromTTF(const char* fntFilePath, int fo
|
|||
|
||||
FontAtlas * FontAtlasFactory::createAtlasFromFNT(const char* fntFilePath)
|
||||
{
|
||||
Font *pFont = Font::createWithFNT(fntFilePath);
|
||||
Font *font = Font::createWithFNT(fntFilePath);
|
||||
|
||||
if(pFont)
|
||||
return pFont->createFontAtlas();
|
||||
if(font)
|
||||
return font->createFontAtlas();
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
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)
|
||||
{
|
||||
|
@ -36,18 +36,18 @@ FontDefinitionTTF::FontDefinitionTTF():_textImages(0), _commonLineHeight(0)
|
|||
FontDefinitionTTF* FontDefinitionTTF::create(Font *font, int textureSize)
|
||||
{
|
||||
if (textureSize == 0)
|
||||
textureSize = _DEFAUL_ATALS_TEXTURE_SIZE;
|
||||
textureSize = DEFAUL_ATALS_TEXTURE_SIZE;
|
||||
|
||||
FontDefinitionTTF *ret = new FontDefinitionTTF;
|
||||
|
||||
if(!ret)
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
||||
const char *pGlyph = font->getCurrentGlyphCollection();
|
||||
if (!pGlyph)
|
||||
const char *glyph = font->getCurrentGlyphCollection();
|
||||
if (!glyph)
|
||||
return nullptr;
|
||||
|
||||
if ( ret->initDefinition(font, pGlyph, textureSize ) )
|
||||
if (ret->initDefinition(font, glyph, textureSize))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
@ -69,34 +69,33 @@ FontDefinitionTTF::~FontDefinitionTTF()
|
|||
bool FontDefinitionTTF::prepareLetterDefinitions(TextFontPagesDef *pageDefs)
|
||||
{
|
||||
// get all the pages
|
||||
TextFontPagesDef *pPages = pageDefs;
|
||||
if (!pPages)
|
||||
TextFontPagesDef *pages = pageDefs;
|
||||
if (!pages)
|
||||
return (false);
|
||||
|
||||
float maxLineHeight = -1;
|
||||
|
||||
// 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
|
||||
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 posYUV = pPages->getPageAt(cPages)->getLineAt(cLines)->getY();
|
||||
float posYUV = pages->getPageAt(cPages)->getLineAt(cLines)->getY();
|
||||
|
||||
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
|
||||
GlyphDef currentGlyph = pPages->getPageAt(cPages)->getLineAt(cLines)->getGlyphAt(c);
|
||||
GlyphDef currentGlyph = pages->getPageAt(cPages)->getLineAt(cLines)->getGlyphAt(c);
|
||||
|
||||
// letter width
|
||||
float letterWidth = currentGlyph.getRect().size.width;
|
||||
|
||||
// letter height
|
||||
float letterHeight = pPages->getPageAt(cPages)->getLineAt(cLines)->getHeight();
|
||||
float letterHeight = pages->getPageAt(cPages)->getLineAt(cLines)->getHeight();
|
||||
|
||||
// add this letter definition
|
||||
FontLetterDefinition tempDef;
|
||||
|
@ -180,7 +179,7 @@ bool FontDefinitionTTF::initDefinition(cocos2d::Font *font, const char *letters,
|
|||
return prepareLetterDefinitions(_textImages->getPages());
|
||||
}
|
||||
|
||||
void FontDefinitionTTF::addLetterDefinition(FontLetterDefinition &defToAdd)
|
||||
void FontDefinitionTTF::addLetterDefinition(const FontLetterDefinition &defToAdd)
|
||||
{
|
||||
if (_fontLettersDefinitionUTF16.find(defToAdd.letteCharUTF16) == _fontLettersDefinitionUTF16.end())
|
||||
{
|
||||
|
@ -191,10 +190,10 @@ void FontDefinitionTTF::addLetterDefinition(FontLetterDefinition &defToAdd)
|
|||
FontAtlas * FontDefinitionTTF::createFontAtlas()
|
||||
{
|
||||
int numTextures = 0;
|
||||
TextFontPagesDef *pPages = _textImages->getPages();
|
||||
TextFontPagesDef *pages = _textImages->getPages();
|
||||
|
||||
if (pPages)
|
||||
numTextures = pPages->getNumPages();
|
||||
if (pages)
|
||||
numTextures = pages->getNumPages();
|
||||
else
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -41,18 +41,24 @@ public:
|
|||
FontAtlas * createFontAtlas();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
FontDefinitionTTF();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~FontDefinitionTTF();
|
||||
|
||||
bool initDefinition(Font *font, const char *letters, int textureSize);
|
||||
bool prepareLetterDefinitions(TextFontPagesDef *pageDefs);
|
||||
void addLetterDefinition(FontLetterDefinition &defToAdd);
|
||||
void addLetterDefinition(const FontLetterDefinition &defToAdd);
|
||||
|
||||
TextImage * _textImages;
|
||||
std::map<unsigned short, FontLetterDefinition> _fontLettersDefinitionUTF16;
|
||||
float _commonLineHeight;
|
||||
static const int _DEFAUL_ATALS_TEXTURE_SIZE;
|
||||
static const int DEFAUL_ATALS_TEXTURE_SIZE;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ FontFNT * FontFNT::create(const char* fntFilePath)
|
|||
|
||||
// add the texture
|
||||
Texture2D *tempTexture = TextureCache::getInstance()->addImage(newConf->getAtlasName());
|
||||
if ( !tempTexture )
|
||||
if (!tempTexture)
|
||||
{
|
||||
delete newConf;
|
||||
return nullptr;
|
||||
|
@ -42,39 +42,39 @@ FontFNT::~FontFNT()
|
|||
_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;
|
||||
|
||||
outNumLetters = cc_wcslen(pText);
|
||||
outNumLetters = cc_wcslen(text);
|
||||
|
||||
if (!outNumLetters)
|
||||
return 0;
|
||||
|
||||
Size *pSizes = new Size[outNumLetters];
|
||||
if (!pSizes)
|
||||
Size *sizes = new Size[outNumLetters];
|
||||
if (!sizes)
|
||||
return 0;
|
||||
|
||||
for (int c = 0; c<outNumLetters; ++c)
|
||||
for (int c = 0; c < outNumLetters; ++c)
|
||||
{
|
||||
int advance = 0;
|
||||
int kerning = 0;
|
||||
|
||||
advance = getAdvanceForChar(pText[c]);
|
||||
advance = getAdvanceForChar(text[c]);
|
||||
|
||||
if ( c < (outNumLetters-1) )
|
||||
kerning = getHorizontalKerningForChars(pText[c], pText[c+1]);
|
||||
if (c < (outNumLetters-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
|
||||
unsigned int key = theChar;
|
||||
|
@ -85,28 +85,28 @@ int FontFNT::getAdvanceForChar(unsigned short theChar)
|
|||
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;
|
||||
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);
|
||||
|
||||
if(element)
|
||||
if (element)
|
||||
ret = element->amount;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Rect FontFNT::getRectForCharInternal(unsigned short theChar)
|
||||
Rect FontFNT::getRectForCharInternal(unsigned short theChar) const
|
||||
{
|
||||
Rect retRect;
|
||||
ccBMFontDef fontDef;
|
||||
tFontDefHashElement *element = NULL;
|
||||
tFontDefHashElement *element = nullptr;
|
||||
unsigned int key = theChar;
|
||||
|
||||
HASH_FIND_INT(_configuration->_fontDefDictionary, &key, element);
|
||||
|
@ -119,7 +119,7 @@ Rect FontFNT::getRectForCharInternal(unsigned short theChar)
|
|||
return retRect;
|
||||
}
|
||||
|
||||
Rect FontFNT::getRectForChar(unsigned short theChar)
|
||||
Rect FontFNT::getRectForChar(unsigned short theChar) const
|
||||
{
|
||||
return getRectForCharInternal(theChar);
|
||||
}
|
||||
|
@ -146,15 +146,15 @@ FontAtlas * FontFNT::createFontAtlas()
|
|||
|
||||
|
||||
ccBMFontDef fontDef;
|
||||
tFontDefHashElement *current_element, *tmp;
|
||||
tFontDefHashElement *currentElement, *tmp;
|
||||
|
||||
// Purge uniform hash
|
||||
HASH_ITER(hh, _configuration->_fontDefDictionary, current_element, tmp)
|
||||
HASH_ITER(hh, _configuration->_fontDefDictionary, currentElement, tmp)
|
||||
{
|
||||
|
||||
FontLetterDefinition tempDefinition;
|
||||
|
||||
fontDef = current_element->fontDef;
|
||||
fontDef = currentElement->fontDef;
|
||||
Rect tempRect;
|
||||
|
||||
tempRect = fontDef.rect;
|
||||
|
|
|
@ -37,20 +37,24 @@ public:
|
|||
|
||||
static FontFNT * create(const char* fntFilePath);
|
||||
|
||||
virtual Size* getAdvancesForTextUTF16(unsigned short *pText, int &outNumLetters) override;
|
||||
virtual Rect getRectForChar(unsigned short theChar) override;
|
||||
virtual Size* getAdvancesForTextUTF16(unsigned short *text, int &outNumLetters) const override;
|
||||
virtual Rect getRectForChar(unsigned short theChar) const override;
|
||||
virtual FontAtlas *createFontAtlas() override;
|
||||
|
||||
protected:
|
||||
|
||||
FontFNT(CCBMFontConfiguration *theContfig) : _configuration(theContfig) {}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~FontFNT();
|
||||
|
||||
private:
|
||||
|
||||
int getAdvanceForChar(unsigned short theChar);
|
||||
int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar);
|
||||
Rect getRectForCharInternal(unsigned short theChar);
|
||||
int getAdvanceForChar(unsigned short theChar) const;
|
||||
int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const;
|
||||
Rect getRectForCharInternal(unsigned short theChar) const;
|
||||
|
||||
CCBMFontConfiguration * _configuration;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ FontFreeType * FontFreeType::create(const std::string &fontName, int fontSize, G
|
|||
|
||||
tempFont->setCurrentGlyphCollection(glyphs, customGlyphs);
|
||||
|
||||
if( !tempFont->createFontObject(fontName, fontSize))
|
||||
if (!tempFont->createFontObject(fontName, fontSize))
|
||||
{
|
||||
delete tempFont;
|
||||
return nullptr;
|
||||
|
@ -94,11 +94,10 @@ FontFreeType::FontFreeType() : _letterPadding(5)
|
|||
|
||||
bool FontFreeType::createFontObject(const std::string &fontName, int fontSize)
|
||||
{
|
||||
unsigned char* data = NULL;
|
||||
int dpi = 72;
|
||||
int dpi = 72;
|
||||
|
||||
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)
|
||||
return false;
|
||||
|
@ -107,16 +106,16 @@ bool FontFreeType::createFontObject(const std::string &fontName, int fontSize)
|
|||
FT_Face face;
|
||||
|
||||
// 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;
|
||||
|
||||
//we want to use unicode
|
||||
if( FT_Select_Charmap(face, FT_ENCODING_UNICODE) )
|
||||
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE))
|
||||
return false;
|
||||
|
||||
// set the requested font size
|
||||
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;
|
||||
|
||||
// store the face globally
|
||||
|
@ -137,10 +136,9 @@ FontFreeType::~FontFreeType()
|
|||
|
||||
FontAtlas * FontFreeType::createFontAtlas()
|
||||
{
|
||||
FontDefinitionTTF *def = 0;
|
||||
def = FontDefinitionTTF::create(this);
|
||||
FontDefinitionTTF *def = FontDefinitionTTF::create(this);
|
||||
|
||||
if(!def)
|
||||
if (!def)
|
||||
return nullptr;
|
||||
|
||||
FontAtlas *atlas = def->createFontAtlas();
|
||||
|
@ -150,7 +148,7 @@ FontAtlas * FontFreeType::createFontAtlas()
|
|||
return atlas;
|
||||
}
|
||||
|
||||
bool FontFreeType::getBBOXFotChar(unsigned short theChar, Rect &outRect)
|
||||
bool FontFreeType::getBBOXFotChar(unsigned short theChar, Rect &outRect) const
|
||||
{
|
||||
if (!_fontRef)
|
||||
return false;
|
||||
|
@ -174,17 +172,17 @@ bool FontFreeType::getBBOXFotChar(unsigned short theChar, Rect &outRect)
|
|||
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;
|
||||
|
||||
if (UTF16text)
|
||||
{
|
||||
utf16String = (unsigned short*) pText;
|
||||
utf16String = (unsigned short*) text;
|
||||
}
|
||||
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;
|
||||
|
||||
// allocate the needed Glyphs
|
||||
GlyphDef *pGlyphs = new GlyphDef[numChar];
|
||||
assert( pGlyphs != NULL );
|
||||
if (!pGlyphs)
|
||||
GlyphDef *glyphs = new GlyphDef[numChar];
|
||||
assert(glyphs != nullptr);
|
||||
if (!glyphs)
|
||||
return 0;
|
||||
|
||||
// sore result as CCRect
|
||||
for (int c=0; c<numChar; ++c)
|
||||
for (int c = 0; c < numChar; ++c)
|
||||
{
|
||||
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());
|
||||
|
||||
|
@ -215,20 +213,17 @@ GlyphDef * FontFreeType::getGlyphDefintionsForText(const char *pText, int &outNu
|
|||
tempRect.size.width = 0;
|
||||
tempRect.size.height = 0;
|
||||
|
||||
pGlyphs[c].setRect(tempRect);
|
||||
pGlyphs[c].setUTF16Letter(utf16String[c]);
|
||||
pGlyphs[c].setValid(false);
|
||||
pGlyphs[c].setPadding(_letterPadding);
|
||||
|
||||
glyphs[c].setRect(tempRect);
|
||||
glyphs[c].setUTF16Letter(utf16String[c]);
|
||||
glyphs[c].setValid(false);
|
||||
glyphs[c].setPadding(_letterPadding);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
pGlyphs[c].setRect(tempRect);
|
||||
pGlyphs[c].setUTF16Letter(utf16String[c]);
|
||||
pGlyphs[c].setPadding(_letterPadding);
|
||||
pGlyphs[c].setValid(true);
|
||||
|
||||
glyphs[c].setRect(tempRect);
|
||||
glyphs[c].setUTF16Letter(utf16String[c]);
|
||||
glyphs[c].setPadding(_letterPadding);
|
||||
glyphs[c].setValid(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,40 +234,40 @@ GlyphDef * FontFreeType::getGlyphDefintionsForText(const char *pText, int &outNu
|
|||
delete [] utf16String;
|
||||
|
||||
// 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;
|
||||
|
||||
outNumLetters = cc_wcslen(pText);
|
||||
outNumLetters = cc_wcslen(text);
|
||||
|
||||
if (!outNumLetters)
|
||||
return 0;
|
||||
|
||||
Size *pSizes = new Size[outNumLetters];
|
||||
if (!pSizes)
|
||||
Size *sizes = new Size[outNumLetters];
|
||||
if (!sizes)
|
||||
return 0;
|
||||
|
||||
for (int c = 0; c<outNumLetters; ++c)
|
||||
for (int c = 0; c < outNumLetters; ++c)
|
||||
{
|
||||
int advance = 0;
|
||||
int kerning = 0;
|
||||
|
||||
advance = getAdvanceForChar(pText[c]) - getBearingXForChar(pText[c]);
|
||||
advance = getAdvanceForChar(text[c]) - getBearingXForChar(text[c]);
|
||||
|
||||
if ( c < (outNumLetters-1) )
|
||||
kerning = getHorizontalKerningForChars(pText[c], pText[c+1]);
|
||||
if (c < (outNumLetters-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)
|
||||
return 0;
|
||||
|
@ -291,26 +286,26 @@ int FontFreeType::getAdvanceForChar(unsigned short theChar)
|
|||
return (_fontRef->glyph->advance.x >> 6);
|
||||
}
|
||||
|
||||
int FontFreeType::getBearingXForChar(unsigned short theChar)
|
||||
int FontFreeType::getBearingXForChar(unsigned short theChar) const
|
||||
{
|
||||
|
||||
if (!_fontRef)
|
||||
return 0;
|
||||
|
||||
// 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;
|
||||
|
||||
// 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 (_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)
|
||||
return 0;
|
||||
|
@ -321,43 +316,43 @@ int FontFreeType::getHorizontalKerningForChars(unsigned short firstChar, unsign
|
|||
return 0;
|
||||
|
||||
// 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;
|
||||
|
||||
// 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;
|
||||
|
||||
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 ( kerning.x >> 6 );
|
||||
return (kerning.x >> 6);
|
||||
}
|
||||
|
||||
int FontFreeType::getFontMaxHeight()
|
||||
int FontFreeType::getFontMaxHeight() const
|
||||
{
|
||||
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)
|
||||
return 0;
|
||||
|
||||
// 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;
|
||||
|
||||
// load glyph infos
|
||||
if (FT_Load_Glyph(_fontRef, glyph_index, FT_LOAD_DEFAULT))
|
||||
if (FT_Load_Glyph(_fontRef, glyphIndex, FT_LOAD_DEFAULT))
|
||||
return 0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int FontFreeType::getLetterPadding()
|
||||
int FontFreeType::getLetterPadding() const
|
||||
{
|
||||
return _letterPadding;
|
||||
}
|
||||
|
|
|
@ -41,11 +41,11 @@ public:
|
|||
static FontFreeType * create(const std::string &fontName, int fontSize, GlyphCollection glyphs, const char *customGlyphs);
|
||||
|
||||
virtual FontAtlas * createFontAtlas() override;
|
||||
virtual Size * getAdvancesForTextUTF16(unsigned short *pText, int &outNumLetters) override;
|
||||
virtual GlyphDef * getGlyphDefintionsForText(const char *pText, int &outNumGlyphs, bool UTF16text = false) override;
|
||||
unsigned char * getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) override;
|
||||
virtual int getFontMaxHeight() override;
|
||||
virtual int getLetterPadding() override;
|
||||
virtual Size * getAdvancesForTextUTF16(unsigned short *text, int &outNumLetters) const override;
|
||||
virtual GlyphDef * getGlyphDefintionsForText(const char *text, int &outNumGlyphs, bool UTF16text = false) const override;
|
||||
unsigned char * getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) const override;
|
||||
virtual int getFontMaxHeight() const override;
|
||||
virtual int getLetterPadding() const override;
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -60,10 +60,10 @@ private:
|
|||
void shutdownFreeType();
|
||||
FT_Library getFTLibrary();
|
||||
|
||||
bool getBBOXFotChar(unsigned short theChar, Rect &outRect);
|
||||
int getAdvanceForChar(unsigned short theChar);
|
||||
int getBearingXForChar(unsigned short theChar);
|
||||
int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar);
|
||||
bool getBBOXFotChar(unsigned short theChar, Rect &outRect) const;
|
||||
int getAdvanceForChar(unsigned short theChar) const;
|
||||
int getBearingXForChar(unsigned short theChar) const;
|
||||
int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const;
|
||||
|
||||
static FT_Library _FTlibrary;
|
||||
static bool _FTInitialized;
|
||||
|
|
|
@ -343,7 +343,7 @@ void Label::resetCurrentString()
|
|||
|
||||
}
|
||||
|
||||
Sprite * Label::createNewSpriteFromLetterDefinition(FontLetterDefinition &theDefinition, Texture2D *theTexture)
|
||||
Sprite * Label::createNewSpriteFromLetterDefinition(const FontLetterDefinition &theDefinition, Texture2D *theTexture)
|
||||
{
|
||||
Rect uvRect;
|
||||
uvRect.size.height = theDefinition.height;
|
||||
|
@ -372,7 +372,7 @@ Sprite * Label::createNewSpriteFromLetterDefinition(FontLetterDefinition &theDef
|
|||
return tempSprite;
|
||||
}
|
||||
|
||||
Sprite * Label::updateSpriteWithLetterDefinition(Sprite *spriteToUpdate, FontLetterDefinition &theDefinition, Texture2D *theTexture)
|
||||
Sprite * Label::updateSpriteWithLetterDefinition(Sprite *spriteToUpdate, const FontLetterDefinition &theDefinition, Texture2D *theTexture)
|
||||
{
|
||||
if (!spriteToUpdate)
|
||||
{
|
||||
|
@ -454,7 +454,7 @@ Sprite * Label::getSprite()
|
|||
{
|
||||
if (_spriteArrayCache->count())
|
||||
{
|
||||
Sprite *retSprite = static_cast<Sprite *>( _spriteArrayCache->getLastObject() );
|
||||
Sprite *retSprite = static_cast<Sprite *>(_spriteArrayCache->getLastObject());
|
||||
_spriteArrayCache->removeLastObject();
|
||||
return retSprite;
|
||||
}
|
||||
|
@ -467,7 +467,7 @@ Sprite * Label::getSprite()
|
|||
|
||||
///// PROTOCOL STUFF
|
||||
|
||||
Sprite * Label::getSpriteChild(int ID)
|
||||
Sprite * Label::getSpriteChild(int ID) const
|
||||
{
|
||||
Object* pObj = NULL;
|
||||
CCARRAY_FOREACH(_spriteArray, pObj)
|
||||
|
@ -481,7 +481,7 @@ Sprite * Label::getSpriteChild(int ID)
|
|||
return 0;
|
||||
}
|
||||
|
||||
Array* Label::getChildrenLetters()
|
||||
Array* Label::getChildrenLetters() const
|
||||
{
|
||||
return _spriteArray;
|
||||
}
|
||||
|
@ -516,29 +516,29 @@ Sprite * Label::getSpriteForChar(unsigned short int theChar, int spriteIndexHint
|
|||
return retSprite;
|
||||
}
|
||||
|
||||
float Label::getLetterPosXLeft( Sprite* sp )
|
||||
float Label::getLetterPosXLeft( Sprite* sp ) const
|
||||
{
|
||||
float scaleX = _scaleX;
|
||||
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;
|
||||
return sp->getPosition().x * scaleX + (sp->getContentSize().width * scaleX * sp->getAnchorPoint().x);
|
||||
}
|
||||
|
||||
int Label::getCommonLineHeight()
|
||||
int Label::getCommonLineHeight() const
|
||||
{
|
||||
return _commonLineHeight;
|
||||
}
|
||||
|
||||
int Label::getKerningForCharsPair(unsigned short first, unsigned short second)
|
||||
int Label::getKerningForCharsPair(unsigned short first, unsigned short second) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Label::getXOffsetForChar(unsigned short c)
|
||||
int Label::getXOffsetForChar(unsigned short c) const
|
||||
{
|
||||
FontLetterDefinition tempDefinition;
|
||||
bool validDefinition = _fontAtlas->getLetterDefinitionForChar(c, tempDefinition);
|
||||
|
@ -548,7 +548,7 @@ int Label::getXOffsetForChar(unsigned short c)
|
|||
return (tempDefinition.offsetX);
|
||||
}
|
||||
|
||||
int Label::getYOffsetForChar(unsigned short c)
|
||||
int Label::getYOffsetForChar(unsigned short c) const
|
||||
{
|
||||
FontLetterDefinition tempDefinition;
|
||||
bool validDefinition = _fontAtlas->getLetterDefinitionForChar(c, tempDefinition);
|
||||
|
@ -558,7 +558,7 @@ int Label::getYOffsetForChar(unsigned short c)
|
|||
return (tempDefinition.offsetY);
|
||||
}
|
||||
|
||||
int Label::getAdvanceForChar(unsigned short c, int hintPositionInString)
|
||||
int Label::getAdvanceForChar(unsigned short c, int hintPositionInString) const
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
// string related stuff
|
||||
int Label::getStringNumLines()
|
||||
int Label::getStringNumLines() const
|
||||
{
|
||||
int quantityOfLines = 1;
|
||||
|
||||
|
@ -603,17 +603,17 @@ int Label::getStringNumLines()
|
|||
return quantityOfLines;
|
||||
}
|
||||
|
||||
int Label::getStringLenght()
|
||||
int Label::getStringLenght() const
|
||||
{
|
||||
return _currentUTF8String ? cc_wcslen(_currentUTF8String) : 0;
|
||||
}
|
||||
|
||||
unsigned short Label::getCharAtStringPosition(int position)
|
||||
unsigned short Label::getCharAtStringPosition(int position) const
|
||||
{
|
||||
return _currentUTF8String[position];
|
||||
}
|
||||
|
||||
unsigned short * Label::getUTF8String()
|
||||
unsigned short * Label::getUTF8String() const
|
||||
{
|
||||
return _currentUTF8String;
|
||||
}
|
||||
|
@ -623,23 +623,23 @@ void Label::assignNewUTF8String(unsigned short *newString)
|
|||
setCurrentString(newString);
|
||||
}
|
||||
|
||||
TextHAlignment Label::getTextAlignment()
|
||||
TextHAlignment Label::getTextAlignment() const
|
||||
{
|
||||
return _alignment;
|
||||
}
|
||||
|
||||
// label related stuff
|
||||
float Label::getMaxLineWidth()
|
||||
float Label::getMaxLineWidth() const
|
||||
{
|
||||
return _width;
|
||||
}
|
||||
|
||||
bool Label::breakLineWithoutSpace()
|
||||
bool Label::breakLineWithoutSpace() const
|
||||
{
|
||||
return _lineBreakWithoutSpaces;
|
||||
}
|
||||
|
||||
Size Label::getLabelContentSize()
|
||||
Size Label::getLabelContentSize() const
|
||||
{
|
||||
return getContentSize();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ enum class GlyphCollection {
|
|||
NEHE,
|
||||
ASCII,
|
||||
CUSTOM
|
||||
|
||||
};
|
||||
|
||||
//fwd
|
||||
|
@ -52,75 +51,81 @@ class CC_DLL Label : public SpriteBatchNode, public LabelProtocol, public RGBAPr
|
|||
public:
|
||||
|
||||
// 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);
|
||||
|
||||
virtual void setString(const char *stringToRender);
|
||||
virtual void setString(const char *stringToRender) override;
|
||||
virtual void setAlignment(TextHAlignment alignment);
|
||||
virtual void setWidth(float width);
|
||||
virtual void setLineBreakWithoutSpace(bool breakWithoutSpace);
|
||||
virtual void setScale(float scale);
|
||||
virtual void setScaleX(float scaleX);
|
||||
virtual void setScaleY(float scaleY);
|
||||
virtual void setScale(float scale) override;
|
||||
virtual void setScaleX(float scaleX) override;
|
||||
virtual void setScaleY(float scaleY) override;
|
||||
|
||||
// RGBAProtocol
|
||||
virtual bool isOpacityModifyRGB() const;
|
||||
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB);
|
||||
virtual void setOpacity(GLubyte opacity);
|
||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity);
|
||||
virtual bool isCascadeOpacityEnabled() const;
|
||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
|
||||
virtual void setColor(const Color3B& color);
|
||||
virtual void updateDisplayedColor(const Color3B& parentColor);
|
||||
virtual bool isCascadeColorEnabled() const;
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
|
||||
virtual const Color3B& getColor(void) const;
|
||||
virtual const Color3B& getDisplayedColor() const;
|
||||
virtual unsigned char getOpacity() const;
|
||||
virtual unsigned char getDisplayedOpacity() const;
|
||||
virtual bool isOpacityModifyRGB() const override;
|
||||
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override;
|
||||
virtual void setOpacity(GLubyte opacity) override;
|
||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
||||
virtual bool isCascadeOpacityEnabled() const override;
|
||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override;
|
||||
virtual void setColor(const Color3B& color) override;
|
||||
virtual void updateDisplayedColor(const Color3B& parentColor) override;
|
||||
virtual bool isCascadeColorEnabled() const override;
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override;
|
||||
virtual const Color3B& getColor(void) const override;
|
||||
virtual const Color3B& getDisplayedColor() const override;
|
||||
virtual unsigned char getOpacity() const override;
|
||||
virtual unsigned char getDisplayedOpacity() const override;
|
||||
|
||||
// CCLabelTextFormat protocol implementation
|
||||
virtual Sprite * getSpriteChild(int ID);
|
||||
virtual Array * getChildrenLetters();
|
||||
virtual Sprite * getSpriteForChar(unsigned short int theChar, int spriteIndexHint);
|
||||
virtual float getLetterPosXLeft( Sprite* sp );
|
||||
virtual float getLetterPosXRight( Sprite* sp );
|
||||
virtual Sprite * getSpriteChild(int ID) const override;
|
||||
virtual Array * getChildrenLetters() const override;
|
||||
virtual Sprite * getSpriteForChar(unsigned short int theChar, int spriteIndexHint) override;
|
||||
virtual float getLetterPosXLeft( Sprite* sp ) const override;
|
||||
virtual float getLetterPosXRight( Sprite* sp ) const override;
|
||||
|
||||
|
||||
// font related stuff
|
||||
virtual int getCommonLineHeight();
|
||||
virtual int getKerningForCharsPair(unsigned short first, unsigned short second);
|
||||
virtual int getXOffsetForChar(unsigned short c);
|
||||
virtual int getYOffsetForChar(unsigned short c);
|
||||
virtual int getAdvanceForChar(unsigned short c, int hintPositionInString);
|
||||
virtual Rect getRectForChar(unsigned short c) ;
|
||||
virtual int getCommonLineHeight() const override;
|
||||
virtual int getKerningForCharsPair(unsigned short first, unsigned short second) const override;
|
||||
virtual int getXOffsetForChar(unsigned short c) const override;
|
||||
virtual int getYOffsetForChar(unsigned short c) const override;
|
||||
virtual int getAdvanceForChar(unsigned short c, int hintPositionInString) const override;
|
||||
virtual Rect getRectForChar(unsigned short c) const override;
|
||||
|
||||
// string related stuff
|
||||
virtual int getStringNumLines();
|
||||
virtual int getStringLenght();
|
||||
virtual unsigned short getCharAtStringPosition(int position);
|
||||
virtual unsigned short * getUTF8String();
|
||||
virtual void assignNewUTF8String(unsigned short *newString);
|
||||
virtual TextHAlignment getTextAlignment();
|
||||
virtual int getStringNumLines() const override;
|
||||
virtual int getStringLenght() const override;
|
||||
virtual unsigned short getCharAtStringPosition(int position) const override;
|
||||
virtual unsigned short * getUTF8String() const override;
|
||||
virtual void assignNewUTF8String(unsigned short *newString) override;
|
||||
virtual TextHAlignment getTextAlignment() const override;
|
||||
|
||||
// label related stuff
|
||||
virtual float getMaxLineWidth() ;
|
||||
virtual bool breakLineWithoutSpace();
|
||||
virtual Size getLabelContentSize();
|
||||
virtual void setLabelContentSize(const Size &newSize);
|
||||
virtual float getMaxLineWidth() const override;
|
||||
virtual bool breakLineWithoutSpace() const override;
|
||||
virtual Size getLabelContentSize() const override;
|
||||
virtual void setLabelContentSize(const Size &newSize) override;
|
||||
|
||||
// carloX
|
||||
const char * getString() const { return "not implemented"; }
|
||||
|
||||
private:
|
||||
|
||||
Label(FontAtlas *pAtlas, TextHAlignment alignment);
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
Label(FontAtlas *atlas, TextHAlignment alignment);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~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();
|
||||
|
||||
|
@ -134,8 +139,8 @@ private:
|
|||
void resetCurrentString();
|
||||
|
||||
Sprite * getSprite();
|
||||
Sprite * createNewSpriteFromLetterDefinition(FontLetterDefinition &theDefinition, Texture2D *theTexture);
|
||||
Sprite * updateSpriteWithLetterDefinition(Sprite *spriteToUpdate, FontLetterDefinition &theDefinition, Texture2D *theTexture);
|
||||
Sprite * createNewSpriteFromLetterDefinition(const FontLetterDefinition &theDefinition, Texture2D *theTexture);
|
||||
Sprite * updateSpriteWithLetterDefinition(Sprite *spriteToUpdate, const FontLetterDefinition &theDefinition, Texture2D *theTexture);
|
||||
Sprite * getSpriteForLetter(unsigned short int newLetter);
|
||||
Sprite * updateSpriteForLetter(Sprite *spriteToUpdate, unsigned short int newLetter);
|
||||
|
||||
|
|
|
@ -51,9 +51,16 @@ A more flexible class is LabelBMFont. It supports variable width characters and
|
|||
class CC_DLL LabelAtlas : public AtlasNode, public LabelProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
LabelAtlas()
|
||||
:_string("")
|
||||
{}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~LabelAtlas()
|
||||
{
|
||||
_string.clear();
|
||||
|
|
|
@ -124,8 +124,19 @@ public://@public
|
|||
// Character Set defines the letters that actually exist in the font
|
||||
std::set<unsigned int> *_characterSet;
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
CCBMFontConfiguration();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~CCBMFontConfiguration();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
const char * description() const;
|
||||
|
||||
/** 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
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
LabelBMFont();
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~LabelBMFont();
|
||||
/** Purges the cached data.
|
||||
Removes from memory the cached configurations and the atlas name dictionary.
|
||||
|
|
|
@ -57,8 +57,19 @@ NS_CC_BEGIN
|
|||
class CC_DLL LabelTTF : public Sprite, public LabelProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
LabelTTF();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~LabelTTF();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
const char* description() const;
|
||||
|
||||
/** creates a LabelTTF with a font name and font size in points
|
||||
|
|
|
@ -32,33 +32,33 @@ class CC_DLL LabelTextFormatProtocol
|
|||
public:
|
||||
|
||||
// sprite related stuff
|
||||
virtual cocos2d::Sprite *getSpriteChild(int ID) = 0;
|
||||
virtual cocos2d::Array *getChildrenLetters() = 0;
|
||||
virtual cocos2d::Sprite *getSpriteForChar(unsigned short int theChar, int spriteIndexHint) = 0;
|
||||
virtual float getLetterPosXLeft( cocos2d::Sprite* sp ) = 0;
|
||||
virtual float getLetterPosXRight( cocos2d::Sprite* sp ) = 0;
|
||||
virtual cocos2d::Sprite *getSpriteChild(int ID) const = 0;
|
||||
virtual cocos2d::Array *getChildrenLetters() const = 0;
|
||||
virtual cocos2d::Sprite *getSpriteForChar(unsigned short int theChar, int spriteIndexHint) = 0;
|
||||
virtual float getLetterPosXLeft(cocos2d::Sprite* sp) const = 0;
|
||||
virtual float getLetterPosXRight(cocos2d::Sprite* sp) const = 0;
|
||||
|
||||
// font related stuff
|
||||
virtual int getCommonLineHeight() = 0;
|
||||
virtual int getKerningForCharsPair(unsigned short first, unsigned short second) = 0;
|
||||
virtual int getXOffsetForChar(unsigned short c) = 0;
|
||||
virtual int getYOffsetForChar(unsigned short c) = 0;
|
||||
virtual int getAdvanceForChar(unsigned short c, int hintPositionInString) = 0;
|
||||
virtual cocos2d::Rect getRectForChar(unsigned short c) = 0;
|
||||
virtual int getCommonLineHeight() const = 0;
|
||||
virtual int getKerningForCharsPair(unsigned short first, unsigned short second) const = 0;
|
||||
virtual int getXOffsetForChar(unsigned short c) const = 0;
|
||||
virtual int getYOffsetForChar(unsigned short c) const = 0;
|
||||
virtual int getAdvanceForChar(unsigned short c, int hintPositionInString) const = 0;
|
||||
virtual cocos2d::Rect getRectForChar(unsigned short c) const = 0;
|
||||
|
||||
// string related stuff
|
||||
virtual int getStringNumLines() = 0;
|
||||
virtual int getStringLenght() = 0;
|
||||
virtual unsigned short getCharAtStringPosition(int position) = 0;
|
||||
virtual unsigned short * getUTF8String() = 0;
|
||||
virtual void assignNewUTF8String(unsigned short *newString) = 0;
|
||||
virtual TextHAlignment getTextAlignment() = 0;
|
||||
virtual int getStringNumLines() const = 0;
|
||||
virtual int getStringLenght() const = 0;
|
||||
virtual unsigned short getCharAtStringPosition(int position) const = 0;
|
||||
virtual unsigned short * getUTF8String() const = 0;
|
||||
virtual void assignNewUTF8String(unsigned short *newString) = 0;
|
||||
virtual TextHAlignment getTextAlignment() const = 0;
|
||||
|
||||
// label related stuff
|
||||
virtual float getMaxLineWidth() = 0;
|
||||
virtual bool breakLineWithoutSpace() = 0;
|
||||
virtual cocos2d::Size getLabelContentSize() = 0;
|
||||
virtual void setLabelContentSize(const Size &newSize) = 0;
|
||||
virtual float getMaxLineWidth() const = 0;
|
||||
virtual bool breakLineWithoutSpace() const = 0;
|
||||
virtual cocos2d::Size getLabelContentSize() const = 0;
|
||||
virtual void setLabelContentSize(const Size &newSize) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
|
|||
|
||||
unsigned int line = 1, i = 0;
|
||||
|
||||
bool start_line = false, start_word = false;
|
||||
bool isStartOfLine = false, isStartOfWord = false;
|
||||
float startOfLine = -1, startOfWord = -1;
|
||||
|
||||
int skip = 0;
|
||||
|
@ -76,16 +76,16 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
|
|||
|
||||
unsigned short character = strWhole[i];
|
||||
|
||||
if (!start_word)
|
||||
if (!isStartOfWord)
|
||||
{
|
||||
startOfWord = theLabel->getLetterPosXLeft( characterSprite );
|
||||
start_word = true;
|
||||
isStartOfWord = true;
|
||||
}
|
||||
|
||||
if (!start_line)
|
||||
if (!isStartOfLine)
|
||||
{
|
||||
startOfLine = startOfWord;
|
||||
start_line = true;
|
||||
isStartOfLine = true;
|
||||
}
|
||||
|
||||
// Newline.
|
||||
|
@ -96,12 +96,12 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
|
|||
last_word.push_back('\n');
|
||||
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
|
||||
last_word.clear();
|
||||
start_word = false;
|
||||
start_line = false;
|
||||
isStartOfWord = false;
|
||||
isStartOfLine = false;
|
||||
startOfWord = -1;
|
||||
startOfLine = -1;
|
||||
i+=justSkipped;
|
||||
line++;
|
||||
i += justSkipped;
|
||||
++line;
|
||||
|
||||
if (i >= stringLength)
|
||||
break;
|
||||
|
@ -111,12 +111,12 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
|
|||
if (!startOfWord)
|
||||
{
|
||||
startOfWord = theLabel->getLetterPosXLeft( characterSprite );
|
||||
start_word = true;
|
||||
isStartOfWord = true;
|
||||
}
|
||||
if (!startOfLine)
|
||||
{
|
||||
startOfLine = startOfWord;
|
||||
start_line = true;
|
||||
isStartOfLine = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,14 +126,14 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
|
|||
last_word.push_back(character);
|
||||
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
|
||||
last_word.clear();
|
||||
start_word = false;
|
||||
isStartOfWord = false;
|
||||
startOfWord = -1;
|
||||
i++;
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Out of bounds.
|
||||
if ( theLabel->getLetterPosXRight( characterSprite ) - startOfLine > theLabel->getMaxLineWidth() )
|
||||
if (theLabel->getLetterPosXRight( characterSprite ) - startOfLine > theLabel->getMaxLineWidth())
|
||||
{
|
||||
if (!theLabel->breakLineWithoutSpace())
|
||||
{
|
||||
|
@ -148,10 +148,10 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
|
|||
if (multiline_string.size() > 0)
|
||||
multiline_string.push_back('\n');
|
||||
|
||||
line++;
|
||||
start_line = false;
|
||||
++line;
|
||||
isStartOfLine = false;
|
||||
startOfLine = -1;
|
||||
i++;
|
||||
++i;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -160,11 +160,11 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
|
|||
last_word.push_back('\n');
|
||||
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
|
||||
last_word.clear();
|
||||
start_word = false;
|
||||
start_line = false;
|
||||
isStartOfWord = false;
|
||||
isStartOfLine = false;
|
||||
startOfWord = -1;
|
||||
startOfLine = -1;
|
||||
line++;
|
||||
++line;
|
||||
|
||||
if (i >= stringLength)
|
||||
break;
|
||||
|
@ -172,15 +172,15 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
|
|||
if (!startOfWord)
|
||||
{
|
||||
startOfWord = theLabel->getLetterPosXLeft( characterSprite );
|
||||
start_word = true;
|
||||
isStartOfWord = true;
|
||||
}
|
||||
if (!startOfLine)
|
||||
{
|
||||
startOfLine = startOfWord;
|
||||
start_line = true;
|
||||
isStartOfLine = true;
|
||||
}
|
||||
|
||||
j--;
|
||||
--j;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
@ -189,7 +189,7 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
|
|||
{
|
||||
// Character is normal.
|
||||
last_word.push_back(character);
|
||||
i++;
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -197,15 +197,15 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
|
|||
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
|
||||
|
||||
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)
|
||||
{
|
||||
str_new[i] = multiline_string[i];
|
||||
strNew[i] = multiline_string[i];
|
||||
}
|
||||
|
||||
str_new[size] = 0;
|
||||
theLabel->assignNewUTF8String(str_new);
|
||||
strNew[size] = 0;
|
||||
theLabel->assignNewUTF8String(strNew);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -220,28 +220,28 @@ bool LabelTextFormatter::alignText(LabelTextFormatProtocol *theLabel)
|
|||
int i = 0;
|
||||
|
||||
int lineNumber = 0;
|
||||
int str_len = cc_wcslen(theLabel->getUTF8String());
|
||||
vector<unsigned short> last_line;
|
||||
for (int ctr = 0; ctr <= str_len; ++ctr)
|
||||
int strLen = cc_wcslen(theLabel->getUTF8String());
|
||||
vector<unsigned short> lastLine;
|
||||
for (int ctr = 0; ctr <= strLen; ++ctr)
|
||||
{
|
||||
unsigned short int currentChar = theLabel->getCharAtStringPosition(ctr);
|
||||
|
||||
if (currentChar == '\n' || currentChar == 0)
|
||||
{
|
||||
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 (line_length == 0)
|
||||
if (lineLength == 0)
|
||||
{
|
||||
lineNumber++;
|
||||
continue;
|
||||
}
|
||||
int index = i + line_length - 1 + lineNumber;
|
||||
int index = i + lineLength - 1 + lineNumber;
|
||||
if (index < 0) continue;
|
||||
|
||||
Sprite* lastChar = theLabel->getSpriteChild(index);
|
||||
if ( lastChar == NULL )
|
||||
if (lastChar == nullptr)
|
||||
continue;
|
||||
|
||||
lineWidth = lastChar->getPosition().x + lastChar->getContentSize().width / 2.0f;
|
||||
|
@ -261,7 +261,7 @@ bool LabelTextFormatter::alignText(LabelTextFormatProtocol *theLabel)
|
|||
|
||||
if (shift != 0)
|
||||
{
|
||||
for (unsigned j = 0; j < line_length; j++)
|
||||
for (unsigned j = 0; j < lineLength; ++j)
|
||||
{
|
||||
index = i + j + lineNumber;
|
||||
if (index < 0) continue;
|
||||
|
@ -273,14 +273,14 @@ bool LabelTextFormatter::alignText(LabelTextFormatProtocol *theLabel)
|
|||
}
|
||||
}
|
||||
|
||||
i += line_length;
|
||||
lineNumber++;
|
||||
i += lineLength;
|
||||
++lineNumber;
|
||||
|
||||
last_line.clear();
|
||||
lastLine.clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
last_line.push_back(currentChar);
|
||||
lastLine.push_back(currentChar);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -311,7 +311,7 @@ bool LabelTextFormatter::createStringSprites(LabelTextFormatProtocol *theLabel)
|
|||
int commonLineHeight = theLabel->getCommonLineHeight();
|
||||
|
||||
totalHeight = commonLineHeight * quantityOfLines;
|
||||
nextFontPositionY = 0 - ( commonLineHeight - totalHeight );
|
||||
nextFontPositionY = 0 - (commonLineHeight - totalHeight);
|
||||
|
||||
Rect rect;
|
||||
|
||||
|
@ -340,9 +340,9 @@ bool LabelTextFormatter::createStringSprites(LabelTextFormatProtocol *theLabel)
|
|||
}
|
||||
|
||||
// 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);
|
||||
continue;
|
||||
|
@ -352,11 +352,11 @@ bool LabelTextFormatter::createStringSprites(LabelTextFormatProtocol *theLabel)
|
|||
int yOffset = commonLineHeight - charYOffset;
|
||||
|
||||
|
||||
Point fontPos = Point( (float)nextFontPositionX + charXOffset + charRect.size.width * 0.5f + kerningAmount,
|
||||
(float)nextFontPositionY + yOffset - charRect.size.height * 0.5f );
|
||||
Point fontPos = Point((float)nextFontPositionX + charXOffset + charRect.size.width * 0.5f + kerningAmount,
|
||||
(float)nextFontPositionY + yOffset - charRect.size.height * 0.5f);
|
||||
|
||||
// set the sprite position
|
||||
pLetterSprite->setPosition(CC_POINT_PIXELS_TO_POINTS(fontPos));
|
||||
letterSprite->setPosition(CC_POINT_PIXELS_TO_POINTS(fontPos));
|
||||
|
||||
// update kerning
|
||||
nextFontPositionX += charAdvance + kerningAmount;
|
||||
|
|
|
@ -81,7 +81,7 @@ bool TextPageDef::generatePageTexture(bool releasePageData)
|
|||
}
|
||||
|
||||
Size imageSize = Size((float)(_width), (float)(_height));
|
||||
if( (imageSize.width <=0) || (imageSize.height<=0) )
|
||||
if((imageSize.width <= 0) || (imageSize.height <= 0))
|
||||
return false;
|
||||
|
||||
_pageTexture = new Texture2D();
|
||||
|
@ -92,7 +92,7 @@ bool TextPageDef::generatePageTexture(bool releasePageData)
|
|||
bool textureCreated = _pageTexture->initWithData(_pageData, dataLenght, Texture2D::PixelFormat::RGBA8888, _width, _height, imageSize);
|
||||
|
||||
// release the page data if requested
|
||||
if ( releasePageData && textureCreated )
|
||||
if (releasePageData && textureCreated)
|
||||
{
|
||||
delete [] _pageData;
|
||||
_pageData = 0;
|
||||
|
@ -123,7 +123,7 @@ TextFontPagesDef::TextFontPagesDef()
|
|||
TextFontPagesDef::~TextFontPagesDef()
|
||||
{
|
||||
int numPages = _pages.size();
|
||||
for( int c = 0; c<numPages; ++c )
|
||||
for( int c = 0; c < numPages; ++c )
|
||||
{
|
||||
if (_pages[c])
|
||||
delete _pages[c];
|
||||
|
@ -143,7 +143,7 @@ TextImage::~TextImage()
|
|||
_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;
|
||||
|
||||
|
@ -157,14 +157,14 @@ bool TextImage::initWithString(const char *text, int nWidth, int nHeight, cocos2
|
|||
_font = font;
|
||||
|
||||
// generate the glyphs for the requested text (glyphs are latter's bounding boxes)
|
||||
if ( !generateTextGlyphs(text) )
|
||||
if (!generateTextGlyphs(text))
|
||||
return false;
|
||||
|
||||
Size constrainSize;
|
||||
unsigned short int *strUTF16 = 0;
|
||||
|
||||
int stringNumChars;
|
||||
if ( textIsUTF16 )
|
||||
if (textIsUTF16)
|
||||
{
|
||||
strUTF16 = (unsigned short int *)text;
|
||||
stringNumChars = cc_wcslen(strUTF16);
|
||||
|
@ -179,11 +179,11 @@ bool TextImage::initWithString(const char *text, int nWidth, int nHeight, cocos2
|
|||
return false;
|
||||
|
||||
// create all the needed pages
|
||||
if (!createPageDefinitions(strUTF16, nWidth, nHeight, _font->getFontMaxHeight()))
|
||||
if (!createPageDefinitions(strUTF16, width, height, _font->getFontMaxHeight()))
|
||||
return false;
|
||||
|
||||
// release the original string if needed
|
||||
if ( !textIsUTF16 )
|
||||
if (!textIsUTF16)
|
||||
delete [] strUTF16;
|
||||
|
||||
// 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)
|
||||
TextPageDef *currentPageDef = new TextPageDef(currentPage, imageWidth, imageHeight);
|
||||
if ( !currentPageDef )
|
||||
if (!currentPageDef)
|
||||
return false;
|
||||
|
||||
// add the current page
|
||||
|
@ -223,14 +223,14 @@ bool TextImage::createPageDefinitions(unsigned short int *inText, int imageWidth
|
|||
do {
|
||||
|
||||
// choose texture page
|
||||
if ( ( currentY + lineHeight ) > imageHeight )
|
||||
if ((currentY + lineHeight) > imageHeight)
|
||||
{
|
||||
currentY = 0;
|
||||
currentPage += 1;
|
||||
|
||||
// create a new page and add
|
||||
currentPageDef = new TextPageDef(currentPage, imageWidth, imageHeight);
|
||||
if ( !currentPageDef )
|
||||
if (!currentPageDef)
|
||||
return false;
|
||||
|
||||
_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
|
||||
TextLineDef *newLine = new TextLineDef(0.0, currentY, newLineSize, lineHeight);
|
||||
if ( !newLine )
|
||||
if (!newLine)
|
||||
return false;
|
||||
|
||||
// add all the glyphs to this line
|
||||
|
@ -268,7 +268,7 @@ bool TextImage::createPageDefinitions(unsigned short int *inText, int imageWidth
|
|||
delta = (stringLenght - numFittingChar);
|
||||
|
||||
// there is still some leftover, need to work on it
|
||||
if ( delta )
|
||||
if (delta)
|
||||
{
|
||||
// create the new string
|
||||
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
|
||||
currentY += lineHeight;
|
||||
|
||||
} while( delta );
|
||||
} while(delta);
|
||||
|
||||
if (needToReleaseText)
|
||||
delete [] strUTF16;
|
||||
|
@ -305,7 +305,7 @@ int TextImage::getNumGlyphsFittingInSize(std::map<unsigned short int, GlyphDef>
|
|||
// get the string to UTF8
|
||||
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());
|
||||
|
||||
|
@ -332,7 +332,7 @@ bool TextImage::addGlyphsToLine(TextLineDef *line, const char *lineText, bool te
|
|||
|
||||
if (textIsUTF16)
|
||||
{
|
||||
UTF16string = (unsigned short int *) lineText;
|
||||
UTF16string = (unsigned short int *)lineText;
|
||||
numLetters = cc_wcslen(UTF16string);
|
||||
}
|
||||
else
|
||||
|
@ -340,7 +340,7 @@ bool TextImage::addGlyphsToLine(TextLineDef *line, const char *lineText, bool te
|
|||
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());
|
||||
line->addGlyph(_textGlyphs[UTF16string[c]] );
|
||||
|
@ -352,24 +352,24 @@ bool TextImage::addGlyphsToLine(TextLineDef *line, const char *lineText, bool te
|
|||
return true;
|
||||
}
|
||||
|
||||
bool TextImage::generateTextGlyphs(const char * pText)
|
||||
bool TextImage::generateTextGlyphs(const char * text)
|
||||
{
|
||||
if (!_font)
|
||||
return false;
|
||||
|
||||
int numGlyphs = 0;
|
||||
GlyphDef *pNewGlyphs = _font->getGlyphDefintionsForText(pText, numGlyphs);
|
||||
GlyphDef *newGlyphs = _font->getGlyphDefintionsForText(text, numGlyphs);
|
||||
|
||||
if (!pNewGlyphs)
|
||||
if (!newGlyphs)
|
||||
return false;
|
||||
|
||||
if (!_textGlyphs.empty())
|
||||
_textGlyphs.clear();
|
||||
|
||||
for (int c=0; c < numGlyphs; ++c)
|
||||
_textGlyphs[pNewGlyphs[c].getUTF8Letter()] = pNewGlyphs[c];
|
||||
for (int c = 0; c < numGlyphs; ++c)
|
||||
_textGlyphs[newGlyphs[c].getUTF8Letter()] = newGlyphs[c];
|
||||
|
||||
delete [] pNewGlyphs;
|
||||
delete [] newGlyphs;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -381,13 +381,13 @@ bool TextImage::createImageDataFromPages(TextFontPagesDef *thePages, bool releas
|
|||
|
||||
for (int c = 0; c < numPages; ++c)
|
||||
{
|
||||
unsigned char *pPageData = 0;
|
||||
pPageData = preparePageGlyphData(thePages->getPageAt(c));
|
||||
unsigned char *pageData = 0;
|
||||
pageData = preparePageGlyphData(thePages->getPageAt(c));
|
||||
|
||||
if (pPageData)
|
||||
if (pageData)
|
||||
{
|
||||
// set the page data
|
||||
thePages->getPageAt(c)->setPageData(pPageData);
|
||||
thePages->getPageAt(c)->setPageData(pageData);
|
||||
|
||||
// crete page texture and relase RAW data
|
||||
thePages->getPageAt(c)->preparePageTexture(releaseRAWData);
|
||||
|
@ -396,7 +396,6 @@ bool TextImage::createImageDataFromPages(TextFontPagesDef *thePages, bool releas
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -432,18 +431,18 @@ unsigned char * TextImage::renderGlyphData(TextPageDef *thePage)
|
|||
|
||||
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 origY = pCurrentLine->getY();
|
||||
float origY = currentLine->getY();
|
||||
|
||||
int numGlyphToRender = pCurrentLine->getNumGlyph();
|
||||
int numGlyphToRender = currentLine->getNumGlyph();
|
||||
|
||||
for (int cglyph = 0; cglyph < numGlyphToRender; ++cglyph)
|
||||
{
|
||||
GlyphDef currGlyph = pCurrentLine->getGlyphAt(cglyph);
|
||||
GlyphDef currGlyph = currentLine->getGlyphAt(cglyph);
|
||||
renderCharAt(currGlyph.getUTF8Letter(), origX, origY, data, pageWidth);
|
||||
origX += (currGlyph.getRect().size.width + _font->getLetterPadding());
|
||||
}
|
||||
|
@ -454,9 +453,9 @@ unsigned char * TextImage::renderGlyphData(TextPageDef *thePage)
|
|||
char outFilename[512];
|
||||
sprintf(outFilename,"testIMG%d", counter);
|
||||
++counter;
|
||||
Image *pImage = new Image;
|
||||
pImage->initWithRawData(data, (pageWidth * pageWidth * 4), 1024, 1024, 8, false);
|
||||
pImage->saveToFile(outFilename);
|
||||
Image *image = new Image;
|
||||
image->initWithRawData(data, (pageWidth * pageWidth * 4), 1024, 1024, 8, false);
|
||||
image->saveToFile(outFilename);
|
||||
#endif
|
||||
|
||||
// we are done here
|
||||
|
@ -475,7 +474,7 @@ bool TextImage::renderCharAt(unsigned short int charToRender, int posX, int posY
|
|||
// get the glyph's bitmap
|
||||
sourceBitmap = _font->getGlyphBitmap(charToRender, sourceWidth, sourceHeight);
|
||||
|
||||
if(!sourceBitmap)
|
||||
if (!sourceBitmap)
|
||||
return false;
|
||||
|
||||
int iX = posX;
|
||||
|
|
|
@ -43,12 +43,12 @@ class CC_DLL GlyphDef
|
|||
public:
|
||||
|
||||
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 setRect(Rect & theRect) { _gliphRect = theRect; }
|
||||
void setRect(const Rect & theRect) { _gliphRect = theRect; }
|
||||
unsigned short int getUTF8Letter() { return _uTF16Letter; }
|
||||
Rect & getRect() { return _gliphRect; }
|
||||
const Rect & getRect() const { return _gliphRect; }
|
||||
void setPadding(float padding) { _padding = padding; }
|
||||
float getPadding() { return _padding; }
|
||||
void setCommonHeight(float commonHeight) { _commonHeight = commonHeight; }
|
||||
|
@ -77,14 +77,14 @@ public:
|
|||
|
||||
TextLineDef(float x, float y, float width, float height);
|
||||
|
||||
float getX() { return _x; }
|
||||
float getY() { return _y; }
|
||||
float getWidth() { return _width; }
|
||||
float getHeight() { return _height; }
|
||||
float getX() const { return _x; }
|
||||
float getY() const { return _y; }
|
||||
float getWidth() const { return _width; }
|
||||
float getHeight() const { return _height; }
|
||||
|
||||
void addGlyph(GlyphDef theGlyph) { _glyphs.push_back(theGlyph); }
|
||||
int getNumGlyph() { return _glyphs.size(); }
|
||||
GlyphDef & getGlyphAt(int index) { return _glyphs[index]; }
|
||||
void addGlyph(GlyphDef theGlyph) { _glyphs.push_back(theGlyph); }
|
||||
int getNumGlyph() const { return _glyphs.size(); }
|
||||
const GlyphDef & getGlyphAt(int index) const { return _glyphs[index]; }
|
||||
|
||||
private:
|
||||
|
||||
|
@ -104,18 +104,24 @@ private:
|
|||
class CC_DLL TextPageDef
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
TextPageDef(int pageNum, int width, int height);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~TextPageDef();
|
||||
|
||||
void addLine(TextLineDef *theLine) { _lines.push_back(theLine); }
|
||||
int getNumLines() { return _lines.size(); }
|
||||
TextLineDef * getLineAt(int index) { return _lines[index]; }
|
||||
int getWidth() { return _width; }
|
||||
int getHeight() { return _height; }
|
||||
int getPageNumber() { return _pageNum; }
|
||||
void setPageData(unsigned char *pData) { _pageData = pData; }
|
||||
unsigned char * getPageData() { return _pageData; }
|
||||
int getNumLines() const { return _lines.size(); }
|
||||
TextLineDef * getLineAt(int index) const { return _lines[index]; }
|
||||
int getWidth() const { return _width; }
|
||||
int getHeight() const { return _height; }
|
||||
int getPageNumber() const { return _pageNum; }
|
||||
void setPageData(unsigned char *data) { _pageData = data; }
|
||||
const unsigned char * getPageData() const { return _pageData; }
|
||||
Texture2D *getPageTexture();
|
||||
void preparePageTexture(bool releaseRAWData = true);
|
||||
|
||||
|
@ -139,13 +145,19 @@ private:
|
|||
class CC_DLL TextFontPagesDef
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TextFontPagesDef();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~TextFontPagesDef();
|
||||
|
||||
void addPage(TextPageDef *newPage) { _pages.push_back(newPage); }
|
||||
int getNumPages() { return _pages.size(); }
|
||||
TextPageDef* getPageAt(int index) { return _pages[index]; }
|
||||
void addPage(TextPageDef *newPage) { _pages.push_back(newPage); }
|
||||
int getNumPages() const { return _pages.size(); }
|
||||
TextPageDef* getPageAt(int index) const { return _pages[index]; }
|
||||
|
||||
private:
|
||||
|
||||
|
@ -159,20 +171,26 @@ private:
|
|||
class CC_DLL TextImage
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TextImage();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~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; }
|
||||
Font * getFont() { return _font; }
|
||||
TextFontPagesDef * getPages() const { return _fontPages; }
|
||||
Font * getFont() const { return _font; }
|
||||
|
||||
private:
|
||||
|
||||
bool createImageDataFromPages(TextFontPagesDef *thePages, bool releaseRAWData = true);
|
||||
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);
|
||||
bool createPageDefinitions(unsigned short int *inText, int imageWidth, int imageHeight, int lineHeight);
|
||||
unsigned char * preparePageGlyphData(TextPageDef *thePage);
|
||||
|
|
|
@ -60,7 +60,14 @@ class CC_DLL Layer : public Node, public TouchDelegate, public KeypadDelegate
|
|||
public:
|
||||
/** creates a fullscreen black layer */
|
||||
static Layer *create(void);
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Layer();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Layer();
|
||||
virtual bool init();
|
||||
|
||||
|
@ -75,7 +82,10 @@ public:
|
|||
virtual void ccTouchesMoved(Set *touches, Event *event);
|
||||
virtual void ccTouchesEnded(Set *touches, Event *event);
|
||||
virtual void ccTouchesCancelled(Set *touches, Event *event);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void didAccelerate(Acceleration* accelerationValue);
|
||||
|
||||
/** If isTouchEnabled, this method is called onEnter. Override it to change the
|
||||
|
@ -124,7 +134,15 @@ public:
|
|||
|
||||
virtual bool isKeyboardEnabled() const;
|
||||
virtual void setKeyboardEnabled(bool value);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void keyPressed(int keyCode) {};
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void keyReleased(int keyCode) {};
|
||||
|
||||
virtual bool isKeypadEnabled() const;
|
||||
|
@ -135,8 +153,20 @@ public:
|
|||
//
|
||||
// Overrides
|
||||
//
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onExit() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnterTransitionDidFinish() override;
|
||||
|
||||
protected:
|
||||
|
@ -170,8 +200,14 @@ class CC_DLL LayerRGBA : public Layer, public RGBAProtocol
|
|||
{
|
||||
public:
|
||||
CREATE_FUNC(LayerRGBA);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
LayerRGBA();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~LayerRGBA();
|
||||
|
||||
virtual bool init();
|
||||
|
@ -222,14 +258,26 @@ public:
|
|||
static LayerColor * create(const Color4B& color, GLfloat width, GLfloat height);
|
||||
/** creates a Layer with color. Width and height are the window size. */
|
||||
static LayerColor * create(const Color4B& color);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
LayerColor();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~LayerColor();
|
||||
|
||||
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);
|
||||
/** 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);
|
||||
|
||||
/** change width in Points*/
|
||||
|
@ -249,7 +297,18 @@ public:
|
|||
virtual void setOpacity(GLubyte opacity) override;
|
||||
virtual void setContentSize(const Size & var) override;
|
||||
/** BlendFunction. Conforms to BlendProtocol protocol */
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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;
|
||||
|
||||
protected:
|
||||
|
@ -295,10 +354,16 @@ public:
|
|||
static LayerGradient* create(const Color4B& start, const Color4B& end, const Point& v);
|
||||
|
||||
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);
|
||||
|
||||
/** 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);
|
||||
|
||||
/** 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
|
||||
{
|
||||
public:
|
||||
/** creates and initializes a LayerMultiplex object */
|
||||
/** creates and initializes a LayerMultiplex object
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static LayerMultiplex* create();
|
||||
|
||||
/** creates a LayerMultiplex with an array of layers.
|
||||
@since v2.1
|
||||
* @js NA
|
||||
*/
|
||||
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, ... );
|
||||
|
||||
/**
|
||||
* lua script can not init with undetermined number of variables
|
||||
* so add these functions to be used with lua.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static LayerMultiplex * createWithLayer(Layer* layer);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
LayerMultiplex();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~LayerMultiplex();
|
||||
|
||||
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);
|
||||
|
||||
/** initializes a MultiplexLayer with an array of layers
|
||||
|
|
|
@ -53,6 +53,10 @@ public:
|
|||
static Scene *create(void);
|
||||
|
||||
Scene();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Scene();
|
||||
|
||||
bool init();
|
||||
|
|
|
@ -77,8 +77,14 @@ public:
|
|||
|
||||
/** creates a base transition with duration and incoming scene */
|
||||
static TransitionScene * create(float t, Scene *scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionScene();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionScene();
|
||||
|
||||
/** initializes a transition with duration and incoming scene */
|
||||
|
@ -94,7 +100,15 @@ public:
|
|||
// Overrides
|
||||
//
|
||||
virtual void draw() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onExit() override;
|
||||
virtual void cleanup() override;
|
||||
|
||||
|
@ -120,8 +134,14 @@ class CC_DLL TransitionSceneOriented : public TransitionScene
|
|||
public:
|
||||
/** creates a base transition with duration and incoming scene */
|
||||
static TransitionSceneOriented * create(float t,Scene* scene, Orientation orientation);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionSceneOriented();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionSceneOriented();
|
||||
|
||||
/** initializes a transition with duration and incoming scene */
|
||||
|
@ -140,11 +160,19 @@ public:
|
|||
static TransitionRotoZoom* create(float t, Scene* scene);
|
||||
|
||||
TransitionRotoZoom();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionRotoZoom();
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
};
|
||||
|
||||
|
@ -155,13 +183,23 @@ class CC_DLL TransitionJumpZoom : public TransitionScene
|
|||
{
|
||||
public:
|
||||
static TransitionJumpZoom* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionJumpZoom();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionJumpZoom();
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
};
|
||||
|
||||
|
@ -172,8 +210,14 @@ class CC_DLL TransitionMoveInL : public TransitionScene, public TransitionEaseSc
|
|||
{
|
||||
public:
|
||||
static TransitionMoveInL* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionMoveInL();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionMoveInL();
|
||||
/** initializes the scenes */
|
||||
virtual void initScenes(void);
|
||||
|
@ -185,6 +229,10 @@ public:
|
|||
//
|
||||
// Overrides
|
||||
//
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
};
|
||||
|
||||
|
@ -195,8 +243,14 @@ class CC_DLL TransitionMoveInR : public TransitionMoveInL
|
|||
{
|
||||
public:
|
||||
static TransitionMoveInR* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionMoveInR();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionMoveInR();
|
||||
virtual void initScenes();
|
||||
};
|
||||
|
@ -208,8 +262,14 @@ class CC_DLL TransitionMoveInT : public TransitionMoveInL
|
|||
{
|
||||
public:
|
||||
static TransitionMoveInT* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionMoveInT();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionMoveInT();
|
||||
virtual void initScenes();
|
||||
};
|
||||
|
@ -221,8 +281,14 @@ class CC_DLL TransitionMoveInB : public TransitionMoveInL
|
|||
{
|
||||
public:
|
||||
static TransitionMoveInB* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionMoveInB();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionMoveInB();
|
||||
virtual void initScenes();
|
||||
};
|
||||
|
@ -234,8 +300,14 @@ class CC_DLL TransitionSlideInL : public TransitionScene, public TransitionEaseS
|
|||
{
|
||||
public:
|
||||
static TransitionSlideInL* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionSlideInL();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionSlideInL();
|
||||
|
||||
virtual ActionInterval* easeActionWithAction(ActionInterval * action);
|
||||
|
@ -248,6 +320,10 @@ public:
|
|||
//
|
||||
// Overrides
|
||||
//
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
|
||||
protected:
|
||||
|
@ -261,8 +337,14 @@ class CC_DLL TransitionSlideInR : public TransitionSlideInL
|
|||
{
|
||||
public:
|
||||
static TransitionSlideInR* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionSlideInR();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionSlideInR();
|
||||
|
||||
/** initializes the scenes */
|
||||
|
@ -281,8 +363,14 @@ class CC_DLL TransitionSlideInB : public TransitionSlideInL
|
|||
{
|
||||
public:
|
||||
static TransitionSlideInB* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionSlideInB();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionSlideInB();
|
||||
|
||||
/** initializes the scenes */
|
||||
|
@ -301,8 +389,14 @@ class CC_DLL TransitionSlideInT : public TransitionSlideInL
|
|||
{
|
||||
public:
|
||||
static TransitionSlideInT* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionSlideInT();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionSlideInT();
|
||||
|
||||
/** initializes the scenes */
|
||||
|
@ -321,8 +415,14 @@ class CC_DLL TransitionShrinkGrow : public TransitionScene , public TransitionEa
|
|||
{
|
||||
public:
|
||||
static TransitionShrinkGrow* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionShrinkGrow();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionShrinkGrow();
|
||||
|
||||
//
|
||||
|
@ -341,13 +441,23 @@ class CC_DLL TransitionFlipX : public TransitionSceneOriented
|
|||
public:
|
||||
static TransitionFlipX* create(float t, Scene* s, Orientation o);
|
||||
static TransitionFlipX* create(float t, Scene* s);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionFlipX();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionFlipX();
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
};
|
||||
|
||||
|
@ -360,13 +470,23 @@ class CC_DLL TransitionFlipY : public TransitionSceneOriented
|
|||
public:
|
||||
static TransitionFlipY* create(float t, Scene* s, Orientation o);
|
||||
static TransitionFlipY* create(float t, Scene* s);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionFlipY();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionFlipY();
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
};
|
||||
|
||||
|
@ -379,13 +499,23 @@ class CC_DLL TransitionFlipAngular : public TransitionSceneOriented
|
|||
public:
|
||||
static TransitionFlipAngular* create(float t, Scene* s, Orientation o);
|
||||
static TransitionFlipAngular* create(float t, Scene* s);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionFlipAngular();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionFlipAngular();
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
};
|
||||
|
||||
|
@ -398,13 +528,23 @@ class CC_DLL TransitionZoomFlipX : public TransitionSceneOriented
|
|||
public:
|
||||
static TransitionZoomFlipX* create(float t, Scene* s, Orientation o);
|
||||
static TransitionZoomFlipX* create(float t, Scene* s);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionZoomFlipX();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionZoomFlipX();
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
};
|
||||
|
||||
|
@ -417,13 +557,23 @@ class CC_DLL TransitionZoomFlipY : public TransitionSceneOriented
|
|||
public:
|
||||
static TransitionZoomFlipY* create(float t, Scene* s, Orientation o);
|
||||
static TransitionZoomFlipY* create(float t, Scene* s);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionZoomFlipY();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionZoomFlipY();
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
};
|
||||
|
||||
|
@ -436,13 +586,23 @@ class CC_DLL TransitionZoomFlipAngular : public TransitionSceneOriented
|
|||
public:
|
||||
static TransitionZoomFlipAngular* create(float t, Scene* s, Orientation o);
|
||||
static TransitionZoomFlipAngular* create(float t, Scene* s);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionZoomFlipAngular();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionZoomFlipAngular();
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionFade();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionFade();
|
||||
|
||||
/** initializes the transition with a duration and with an RGB color */
|
||||
|
@ -468,7 +634,15 @@ public:
|
|||
// Overrides
|
||||
//
|
||||
bool initWithDuration(float t,Scene* scene);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onExit();
|
||||
|
||||
protected:
|
||||
|
@ -484,15 +658,29 @@ class CC_DLL TransitionCrossFade : public TransitionScene
|
|||
{
|
||||
public :
|
||||
static TransitionCrossFade* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionCrossFade();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionCrossFade();
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
virtual void draw() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onExit() override;
|
||||
|
||||
};
|
||||
|
@ -504,13 +692,23 @@ class CC_DLL TransitionTurnOffTiles : public TransitionScene ,public TransitionE
|
|||
{
|
||||
public :
|
||||
static TransitionTurnOffTiles* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionTurnOffTiles();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionTurnOffTiles();
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
|
||||
|
||||
|
@ -525,8 +723,14 @@ class CC_DLL TransitionSplitCols : public TransitionScene , public TransitionEas
|
|||
{
|
||||
public:
|
||||
static TransitionSplitCols* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionSplitCols();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionSplitCols();
|
||||
|
||||
virtual ActionInterval* action(void);
|
||||
|
@ -534,6 +738,10 @@ public:
|
|||
//
|
||||
// Overrides
|
||||
//
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
|
||||
};
|
||||
|
@ -545,8 +753,14 @@ class CC_DLL TransitionSplitRows : public TransitionSplitCols
|
|||
{
|
||||
public:
|
||||
static TransitionSplitRows* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionSplitRows();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionSplitRows();
|
||||
|
||||
//
|
||||
|
@ -562,14 +776,24 @@ class CC_DLL TransitionFadeTR : public TransitionScene , public TransitionEaseSc
|
|||
{
|
||||
public:
|
||||
static TransitionFadeTR* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionFadeTR();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionFadeTR();
|
||||
virtual ActionInterval* actionWithSize(const Size& size);
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
|
||||
|
||||
|
@ -584,8 +808,14 @@ class CC_DLL TransitionFadeBL : public TransitionFadeTR
|
|||
{
|
||||
public:
|
||||
static TransitionFadeBL* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionFadeBL();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionFadeBL();
|
||||
|
||||
//
|
||||
|
@ -602,8 +832,14 @@ class CC_DLL TransitionFadeUp : public TransitionFadeTR
|
|||
{
|
||||
public:
|
||||
static TransitionFadeUp* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionFadeUp();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionFadeUp();
|
||||
|
||||
//
|
||||
|
@ -619,8 +855,14 @@ class CC_DLL TransitionFadeDown : public TransitionFadeTR
|
|||
{
|
||||
public:
|
||||
static TransitionFadeDown* create(float t, Scene* scene);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionFadeDown();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionFadeDown();
|
||||
|
||||
//
|
||||
|
|
|
@ -55,8 +55,14 @@ public:
|
|||
* scene is being turned from left over the outgoing scene.
|
||||
*/
|
||||
static TransitionPageTurn* create(float t,Scene* scene,bool backwards);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TransitionPageTurn();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionPageTurn();
|
||||
|
||||
/**
|
||||
|
|
|
@ -76,8 +76,14 @@ public:
|
|||
|
||||
/** creates a Menu with MenuItem objects */
|
||||
static Menu* createWithItems(MenuItem *firstItem, va_list args);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Menu() : _selectedItem(NULL) {}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Menu(){}
|
||||
|
||||
/** initializes an empty Menu */
|
||||
|
|
|
@ -65,18 +65,30 @@ public:
|
|||
CC_DEPRECATED_ATTRIBUTE static MenuItem* create(Object *rec, SEL_MenuHandler selector);
|
||||
/** Creates a MenuItem with a target/selector */
|
||||
static MenuItem* create(const ccMenuCallback& callback);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
MenuItem()
|
||||
: _selected(false)
|
||||
, _enabled(false)
|
||||
, _callback(nullptr)
|
||||
, _target(NULL)
|
||||
{}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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);
|
||||
/** 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);
|
||||
|
||||
/** Returns the outside box */
|
||||
|
@ -94,9 +106,17 @@ public:
|
|||
/** returns whether or not the item is selected */
|
||||
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);
|
||||
/** 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);
|
||||
|
||||
protected:
|
||||
|
@ -126,11 +146,17 @@ public:
|
|||
|
||||
/** creates a MenuItemLabel with a Label. Target and selector will be nil */
|
||||
static MenuItemLabel* create(Node *label);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
MenuItemLabel()
|
||||
: _originalScale(0.0)
|
||||
, _label(NULL)
|
||||
{}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~MenuItemLabel();
|
||||
|
||||
/** 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);
|
||||
/** 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);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
MenuItemAtlasFont(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~MenuItemAtlasFont(){}
|
||||
|
||||
/** 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);
|
||||
/** creates a menu item from a string with a target/selector */
|
||||
static MenuItemFont * create(const char *value, const ccMenuCallback& callback);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
MenuItemFont() : _fontSize(0), _fontName(""){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~MenuItemFont(){}
|
||||
|
||||
/** initializes a menu item from a string with a target/selector */
|
||||
|
@ -229,20 +267,26 @@ public:
|
|||
/** set font size
|
||||
* c++ can not overload static and non-static member functions with the same parameter types
|
||||
* so change the name to setFontSizeObj
|
||||
* @js setFontSize
|
||||
*/
|
||||
void setFontSizeObj(unsigned int s);
|
||||
|
||||
/** get font size */
|
||||
/** get font size
|
||||
* @js getFontSize
|
||||
*/
|
||||
unsigned int getFontSizeObj() const;
|
||||
CC_DEPRECATED_ATTRIBUTE unsigned int fontSizeObj() const { return getFontSizeObj(); };
|
||||
|
||||
/** set the font name
|
||||
* c++ can not overload static and non-static member functions with the same parameter types
|
||||
* so change the name to setFontNameObj
|
||||
* @js setFontName
|
||||
*/
|
||||
void setFontNameObj(const char* name);
|
||||
|
||||
/** returns the name of the Font */
|
||||
/** returns the name of the Font
|
||||
* @js getFontNameObj
|
||||
*/
|
||||
const char* getFontNameObj() const;
|
||||
|
||||
/** 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);
|
||||
/** 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);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
MenuItemImage(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~MenuItemImage(){}
|
||||
|
||||
bool init();
|
||||
|
@ -386,18 +436,33 @@ public:
|
|||
static MenuItemToggle* create();
|
||||
/** creates a menu item with a 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);
|
||||
/** 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;
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
MenuItemToggle()
|
||||
: _selectedIndex(0)
|
||||
, _subItems(NULL)
|
||||
{}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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);
|
||||
/** initializes a menu item from a list of items with a callable object */
|
||||
bool initWithCallback(const ccMenuCallback& callback, MenuItem* item, va_list args);
|
||||
|
@ -421,6 +486,8 @@ public:
|
|||
/** Gets the array that contains the subitems.
|
||||
You can add/remove items in runtime, and you can replace the array with a new one.
|
||||
@since v0.7.2
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
|
||||
inline Array* getSubItems() const { return _subItems; };
|
||||
|
|
|
@ -49,7 +49,10 @@ public:
|
|||
The stencil node will be retained.
|
||||
*/
|
||||
static ClippingNode* create(Node *pStencil);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ClippingNode();
|
||||
|
||||
/** Initializes a clipping node without a stencil.
|
||||
|
@ -84,9 +87,25 @@ public:
|
|||
void setInverted(bool bInverted);
|
||||
|
||||
// Overrides
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnterTransitionDidFinish() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onExitTransitionDidStart() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onExit() override;
|
||||
virtual void visit() override;
|
||||
|
||||
|
|
|
@ -53,8 +53,14 @@ public:
|
|||
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 */
|
||||
static MotionStreak* create(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
MotionStreak();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~MotionStreak();
|
||||
|
||||
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture filename */
|
||||
|
@ -80,11 +86,27 @@ public:
|
|||
|
||||
// Overrides
|
||||
virtual void setPosition(const Point& position) override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void draw() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void update(float delta) override;
|
||||
virtual Texture2D* getTexture() const override;
|
||||
virtual void setTexture(Texture2D *texture) override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual const BlendFunc& getBlendFunc() const override;
|
||||
virtual GLubyte getOpacity() const override;
|
||||
virtual void setOpacity(GLubyte opacity) override;
|
||||
|
|
|
@ -62,8 +62,14 @@ public:
|
|||
|
||||
/** Creates a progress timer with the sprite as the shape the timer goes through */
|
||||
static ProgressTimer* create(Sprite* sp);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ProgressTimer();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ProgressTimer();
|
||||
|
||||
/** Initializes a progress timer with the sprite as the shape the timer goes through */
|
||||
|
@ -81,6 +87,10 @@ public:
|
|||
void setPercentage(float fPercentage);
|
||||
void setSprite(Sprite *pSprite);
|
||||
void setType(Type type);
|
||||
/**
|
||||
* @js setReverseDirection
|
||||
* @lua setReverseDirection
|
||||
*/
|
||||
void setReverseProgress(bool reverse);
|
||||
|
||||
inline bool isReverseDirection() { return _reverseDirection; };
|
||||
|
|
|
@ -58,8 +58,14 @@ public:
|
|||
|
||||
/** creates a RenderTexture object with width and height in Points, pixel format is RGBA8888 */
|
||||
static RenderTexture * create(int w, int h);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
RenderTexture();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~RenderTexture();
|
||||
|
||||
/** initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */
|
||||
|
|
|
@ -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 */
|
||||
static ParticleBatchNode* create(const char* fileImage, unsigned int capacity = kParticleDefaultCapacity);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ParticleBatchNode();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ParticleBatchNode();
|
||||
|
||||
/** initializes the particle system with Texture2D, a capacity of particles */
|
||||
|
@ -107,7 +113,18 @@ public:
|
|||
virtual void draw(void) override;
|
||||
virtual Texture2D* getTexture(void) const 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;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual const BlendFunc& getBlendFunc(void) const override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -39,7 +39,14 @@ NS_CC_BEGIN
|
|||
class CC_DLL ParticleFire : public ParticleSystemQuad
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ParticleFire(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ParticleFire(){}
|
||||
bool init(){ return initWithTotalParticles(250); }
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
@ -52,7 +59,14 @@ public:
|
|||
class CC_DLL ParticleFireworks : public ParticleSystemQuad
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ParticleFireworks(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ParticleFireworks(){}
|
||||
bool init(){ return initWithTotalParticles(1500); }
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
@ -65,7 +79,14 @@ public:
|
|||
class CC_DLL ParticleSun : public ParticleSystemQuad
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ParticleSun(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ParticleSun(){}
|
||||
bool init(){ return initWithTotalParticles(350); }
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
@ -78,7 +99,14 @@ public:
|
|||
class CC_DLL ParticleGalaxy : public ParticleSystemQuad
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ParticleGalaxy(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ParticleGalaxy(){}
|
||||
bool init(){ return initWithTotalParticles(200); }
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
@ -91,7 +119,14 @@ public:
|
|||
class CC_DLL ParticleFlower : public ParticleSystemQuad
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ParticleFlower(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ParticleFlower(){}
|
||||
bool init(){ return initWithTotalParticles(250); }
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
@ -104,7 +139,14 @@ public:
|
|||
class CC_DLL ParticleMeteor : public ParticleSystemQuad
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ParticleMeteor(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ParticleMeteor(){}
|
||||
bool init(){ return initWithTotalParticles(150); }
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
@ -117,7 +159,14 @@ public:
|
|||
class CC_DLL ParticleSpiral : public ParticleSystemQuad
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ParticleSpiral(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ParticleSpiral(){}
|
||||
bool init(){ return initWithTotalParticles(500); }
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
@ -130,7 +179,14 @@ public:
|
|||
class CC_DLL ParticleExplosion : public ParticleSystemQuad
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ParticleExplosion(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ParticleExplosion(){}
|
||||
bool init(){ return initWithTotalParticles(700); }
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
@ -143,7 +199,14 @@ public:
|
|||
class CC_DLL ParticleSmoke : public ParticleSystemQuad
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ParticleSmoke(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ParticleSmoke(){}
|
||||
bool init(){ return initWithTotalParticles(200); }
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
@ -156,7 +219,14 @@ public:
|
|||
class CC_DLL ParticleSnow : public ParticleSystemQuad
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ParticleSnow(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ParticleSnow(){}
|
||||
bool init(){ return initWithTotalParticles(700); }
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
@ -169,7 +239,14 @@ public:
|
|||
class CC_DLL ParticleRain : public ParticleSystemQuad
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ParticleRain(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ParticleRain(){}
|
||||
bool init(){ return initWithTotalParticles(1000); }
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
|
|
@ -171,8 +171,14 @@ public:
|
|||
|
||||
//! create a system with a fixed number of particles
|
||||
static ParticleSystem* createWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ParticleSystem();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ParticleSystem();
|
||||
|
||||
/** initializes a ParticleSystem*/
|
||||
|
@ -374,7 +380,18 @@ public:
|
|||
virtual void update(float dt) override;
|
||||
virtual Texture2D* getTexture() const 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;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual const BlendFunc &getBlendFunc() const override;
|
||||
protected:
|
||||
virtual void updateBlendFunc();
|
||||
|
|
|
@ -62,8 +62,14 @@ public:
|
|||
This plist files can be created manually or with Particle Designer:
|
||||
*/
|
||||
static ParticleSystemQuad * create(const char *plistFile);
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
ParticleSystemQuad();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ParticleSystemQuad();
|
||||
|
||||
/** initializes the indices for the vertices*/
|
||||
|
@ -79,21 +85,53 @@ public:
|
|||
void setDisplayFrame(SpriteFrame *spriteFrame);
|
||||
|
||||
/** 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);
|
||||
|
||||
/** listen the event that coming to foreground on Android
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void listenBackToForeground(Object *obj);
|
||||
|
||||
// Overrides
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles) override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setTexture(Texture2D* texture) override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void updateQuadWithParticle(tParticle* particle, const Point& newPosition) override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void postStep() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void draw() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setBatchNode(ParticleBatchNode* batchNode) override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setTotalParticles(int tp) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -39,7 +39,10 @@ public:
|
|||
double z;
|
||||
|
||||
double timestamp;
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Acceleration(): x(0), y(0), z(0), timestamp(0) {}
|
||||
};
|
||||
|
||||
|
|
|
@ -28,40 +28,55 @@ public:
|
|||
OS_TIZEN
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ApplicationProtocol() {}
|
||||
|
||||
/**
|
||||
@brief Implement Director and Scene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
@return false Initialize failed, app terminate.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual bool applicationDidFinishLaunching() = 0;
|
||||
|
||||
/**
|
||||
@brief This function will be called when the application enters background.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void applicationDidEnterBackground() = 0;
|
||||
|
||||
/**
|
||||
@brief This function will be called when the application enters foreground.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void applicationWillEnterForeground() = 0;
|
||||
|
||||
/**
|
||||
@brief Callback by Director for limit FPS.
|
||||
@param interval The time, expressed in seconds, between current frame and next.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setAnimationInterval(double interval) = 0;
|
||||
|
||||
/**
|
||||
@brief Get current language config
|
||||
@return Current language config
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual LanguageType getCurrentLanguage() = 0;
|
||||
|
||||
/**
|
||||
@brief Get target platform
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual Platform getTargetPlatform() = 0;
|
||||
};
|
||||
|
|
|
@ -43,7 +43,14 @@ class Set;
|
|||
class CC_DLL EGLViewProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
EGLViewProtocol();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~EGLViewProtocol();
|
||||
|
||||
/** Force destroying EGL view, subclass must implement this method. */
|
||||
|
|
|
@ -64,6 +64,8 @@ public:
|
|||
|
||||
/**
|
||||
* The destructor of FileUtils.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~FileUtils();
|
||||
|
||||
|
@ -176,6 +178,8 @@ public:
|
|||
* @param filename The plist file name.
|
||||
*
|
||||
@since v2.1
|
||||
* @js loadFilenameLookup
|
||||
* @lua loadFilenameLookup
|
||||
*/
|
||||
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.
|
||||
* @see getSearchResolutionsOrder(void), fullPathForFilename(const char*).
|
||||
* @since v2.1
|
||||
* In js:var setSearchResolutionsOrder(var jsval)
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setSearchResolutionsOrder(const std::vector<std::string>& searchResolutionsOrder);
|
||||
|
||||
|
@ -220,6 +226,7 @@ public:
|
|||
*
|
||||
* @see setSearchResolutionsOrder(const std::vector<std::string>&), fullPathForFilename(const char*).
|
||||
* @since v2.1
|
||||
* @lua NA
|
||||
*/
|
||||
virtual const std::vector<std::string>& getSearchResolutionsOrder();
|
||||
|
||||
|
@ -239,6 +246,8 @@ public:
|
|||
* @param searchPaths The array contains search paths.
|
||||
* @see fullPathForFilename(const char*)
|
||||
* @since v2.1
|
||||
* In js:var setSearchPaths(var jsval);
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setSearchPaths(const std::vector<std::string>& searchPaths);
|
||||
|
||||
|
@ -254,6 +263,7 @@ public:
|
|||
*
|
||||
* @return The array of search paths.
|
||||
* @see fullPathForFilename(const char*).
|
||||
* @lua NA
|
||||
*/
|
||||
virtual const std::vector<std::string>& getSearchPaths() const;
|
||||
|
||||
|
|
|
@ -56,8 +56,14 @@ class CC_DLL Image : public Object
|
|||
{
|
||||
public:
|
||||
friend class TextureCache;
|
||||
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Image();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Image();
|
||||
|
||||
/** Supported formats for Image */
|
||||
|
@ -110,6 +116,8 @@ public:
|
|||
@param data stream buffer which holds the image data.
|
||||
@param dataLen data length expressed in (number of) bytes.
|
||||
@return true if loaded correctly.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool initWithImageData(const unsigned char * data, int dataLen);
|
||||
|
||||
|
@ -124,6 +132,8 @@ public:
|
|||
@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 size the font size, if 0, use the system default size.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool initWithString(
|
||||
const char * text,
|
||||
|
|
|
@ -39,8 +39,20 @@ typedef unsigned char CC_XML_CHAR;
|
|||
class CC_DLL SAXDelegator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void textHandler(void *ctx, const char *s, int len) = 0;
|
||||
};
|
||||
|
||||
|
@ -48,17 +60,50 @@ class CC_DLL SAXParser
|
|||
{
|
||||
SAXDelegator* _delegator;
|
||||
public:
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
SAXParser();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~SAXParser(void);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool init(const char *pszEncoding);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool parse(const char* pXMLData, unsigned int uDataLength);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool parse(const char *pszFile);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setDelegator(SAXDelegator* pDelegator);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static void textHandler(void *ctx, const CC_XML_CHAR *name, int len);
|
||||
};
|
||||
|
||||
|
|
|
@ -42,9 +42,20 @@ NS_CC_BEGIN
|
|||
class CC_DLL Thread
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Thread() : _autoReleasePool(nullptr) {}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Thread();
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void createAutoreleasePool();
|
||||
|
||||
private:
|
||||
|
|
|
@ -34,7 +34,14 @@ namespace cocos2d {
|
|||
class Accelerometer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Accelerometer();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Accelerometer();
|
||||
|
||||
void setDelegate(std::function<void(Acceleration*)> function);
|
||||
|
|
|
@ -9,7 +9,14 @@ NS_CC_BEGIN
|
|||
class CC_DLL Application : public ApplicationProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Application();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Application();
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,14 @@ NS_CC_BEGIN
|
|||
class CC_DLL EGLView : public EGLViewProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
EGLView();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~EGLView();
|
||||
|
||||
bool isOpenGLReady();
|
||||
|
|
|
@ -45,6 +45,10 @@ class CC_DLL FileUtilsAndroid : public FileUtils
|
|||
friend class FileUtils;
|
||||
FileUtilsAndroid();
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~FileUtilsAndroid();
|
||||
|
||||
static void setassetmanager(AAssetManager* a);
|
||||
|
|
|
@ -32,7 +32,14 @@ NS_CC_BEGIN
|
|||
class Lock
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Lock(void);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Lock(void);
|
||||
|
||||
void lock(void);
|
||||
|
|
|
@ -16,7 +16,14 @@ namespace cocos2d {
|
|||
class Accelerometer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Accelerometer(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Accelerometer(){}
|
||||
|
||||
static Accelerometer* sharedAccelerometer() { return NULL; };
|
||||
|
|
|
@ -11,7 +11,14 @@ class Rect;
|
|||
class CC_DLL Application : public ApplicationProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Application();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Application();
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,7 +36,14 @@ NS_CC_BEGIN
|
|||
class CC_DLL EGLView : public EGLViewProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
EGLView();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~EGLView();
|
||||
|
||||
bool isOpenGLReady();
|
||||
|
|
|
@ -32,7 +32,14 @@ NS_CC_BEGIN
|
|||
class CC_DLL TextureCacheEmscripten : public TextureCache
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
TextureCacheEmscripten();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~TextureCacheEmscripten();
|
||||
|
||||
void addImageAsync(const char *path, Object *target, SEL_CallFuncO selector);
|
||||
|
|
|
@ -33,7 +33,14 @@ NS_CC_BEGIN
|
|||
class Accelerometer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Accelerometer();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Accelerometer();
|
||||
|
||||
void setDelegate(std::function<void(Acceleration*)> function);
|
||||
|
|
|
@ -35,7 +35,14 @@ class Rect;
|
|||
class CC_DLL Application : public ApplicationProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Application();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Application();
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,22 +35,53 @@ NS_CC_BEGIN
|
|||
class CC_DLL EGLView : public EGLViewProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
EGLView();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~EGLView();
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual bool isOpenGLReady();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual bool setContentScaleFactor(float contentScaleFactor);
|
||||
|
||||
// keep compatible
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void end();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void swapBuffers();
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setIMEKeyboardState(bool bOpen);
|
||||
|
||||
/** returns the singleton */
|
||||
/** returns the singleton
|
||||
* @js NA
|
||||
*/
|
||||
static EGLView* getInstance();
|
||||
|
||||
/** @deprecated Use getInstance() instead */
|
||||
/** @deprecated Use getInstance() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
|
||||
|
||||
};
|
||||
|
|
|
@ -16,7 +16,14 @@ namespace cocos2d {
|
|||
class Accelerometer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Accelerometer(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Accelerometer(){}
|
||||
|
||||
static Accelerometer* sharedAccelerometer() { return NULL; };
|
||||
|
|
|
@ -18,7 +18,14 @@ class Rect;
|
|||
class Application : public ApplicationProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Application();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Application();
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,14 @@ NS_CC_BEGIN
|
|||
class CC_DLL EGLView : public EGLViewProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
EGLView();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~EGLView();
|
||||
|
||||
/* override functions */
|
||||
|
|
|
@ -34,6 +34,10 @@ class CC_DLL Accelerometer
|
|||
{
|
||||
public:
|
||||
Accelerometer() {}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Accelerometer() {}
|
||||
|
||||
void setDelegate(std::function<void(Acceleration*)> function) { CC_UNUSED_PARAM(function); }
|
||||
|
|
|
@ -34,7 +34,14 @@ NS_CC_BEGIN
|
|||
class CC_DLL Application : public ApplicationProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Application();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Application();
|
||||
|
||||
/**
|
||||
|
@ -49,6 +56,8 @@ public:
|
|||
|
||||
/**
|
||||
@brief Run the message loop.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
int run();
|
||||
|
||||
|
|
|
@ -34,7 +34,14 @@ NS_CC_BEGIN
|
|||
class CC_DLL EGLView : public EGLViewProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
EGLView();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~EGLView();
|
||||
|
||||
/* override functions */
|
||||
|
|
|
@ -33,7 +33,14 @@ namespace cocos2d {
|
|||
class Accelerometer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Accelerometer(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Accelerometer(){}
|
||||
|
||||
static Accelerometer* sharedAccelerometer() { return NULL; };
|
||||
|
|
|
@ -34,7 +34,14 @@ class Rect;
|
|||
class Application : public ApplicationProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Application();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~Application();
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,7 +43,14 @@ NS_CC_BEGIN
|
|||
class EGLView : public EGLViewProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
EGLView();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~EGLView();
|
||||
|
||||
/**
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue