mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' into newRenderer
This commit is contained in:
commit
a70cad8c97
5
AUTHORS
5
AUTHORS
|
@ -10,6 +10,7 @@ Core Developers:
|
|||
Qingkui Hu (samuele3hu)
|
||||
Huabing Xu (dabingnn)
|
||||
Bo Yu (boyu0)
|
||||
Wenhai Lin(Dhilan007)
|
||||
|
||||
|
||||
Developers:
|
||||
|
@ -594,10 +595,12 @@ Developers:
|
|||
[Android] added EGL_RENDERABLE_TYPE to OpenGL attributes
|
||||
Android: add xlargeScreens="true" to supports-screens
|
||||
Trigger onKeyReleased only after the key has been released.
|
||||
Makes Colors are now comparable and explicit convertible
|
||||
|
||||
bmanGH
|
||||
Use gl caching functions in TexturePVR::createGLTexture()
|
||||
Configuration of VAO in runtime
|
||||
Add setUniformLocationWithMatrix2fv, setUniformLocationWithMatrix3fv mothed into GLProgram class
|
||||
|
||||
metadao
|
||||
make create_project.py more pythonic and fix some typoes
|
||||
|
@ -613,6 +616,7 @@ Developers:
|
|||
Added support of passing array to cc.Sequence.create and cc.Spawn.create.
|
||||
Fixed a bug that sys.localStorage.getItem() does not support non-ascii string.
|
||||
Fixed a memory leak in XMLHttpRequest.
|
||||
Fixed a bug that wrong convention to jsval in cccolor4f_to_jsval and cccolor3b_to_jsval.
|
||||
|
||||
Keita Obo (ktaobo)
|
||||
Avoid unnecessary object duplication for Scale9Sprite.
|
||||
|
@ -630,6 +634,7 @@ Developers:
|
|||
Fixed a bug that CCBReader can't play sequence automatically in JSB.
|
||||
Could not set next animation in CCBAnimationCompleted callback.
|
||||
Fixed missing to add JSAutoCompartment when invoking JS functions from C++.
|
||||
CCBReader: To set anchor point to 0,0 when created by loader
|
||||
|
||||
lite3
|
||||
Fixed a bug that Node's anchor point was changed after being added to ScrollView.
|
||||
|
|
|
@ -16,12 +16,17 @@ cocos2d-x-3.0alpha1 @??? 2013
|
|||
[FIX] Armature: many bug fixed, add more samples, add function to skip some frames when playing animation
|
||||
[FIX] Configuration of VAO in runtime
|
||||
[FIX] Webp Test Crashes.
|
||||
[FIX] TransitionScenePageTurn: z fighting
|
||||
[FIX] AssetsManager: Adding test whether the file directory exists when uncompressing file entry,if does not exist then create directory
|
||||
[FIX] CCBReader: To set anchor point to 0,0 when loading Scale9Sprite
|
||||
[NEW] Arm64 support.
|
||||
[NEW] Added Mouse Support For Desktop Platforms.
|
||||
[NEW] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc.
|
||||
[NEW] Sprite: Override setScale(float scaleX, float scaleY)
|
||||
[NEW] External: added | operator for Control::EventType
|
||||
[NEW] Android & iOS screen size change support
|
||||
[NEW] GLProgram: setUniformLocationWithMatrix2fv, setUniformLocationWithMatrix3fv
|
||||
[NEW] Color[3|4][B|F]: comparable and explicit convertible
|
||||
[Android]
|
||||
[FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes
|
||||
[FIX] Fixed application will crash when pause and resume.
|
||||
|
@ -45,6 +50,7 @@ cocos2d-x-3.0alpha1 @??? 2013
|
|||
[FIX] cc.Scheduler.schedule(target, func) without repeat argument couldn't repeat schedule forever on device.
|
||||
[FIX] CCBReader can't play sequence automatically in JSB.
|
||||
[NEW] main.js -> cocos2d-jsb.js
|
||||
[FIX] Wrong convention to jsval in cccolor4f_to_jsval and cccolor3b_to_jsval
|
||||
[Lua Binding]
|
||||
[NEW] Added Armature lua binding and added test samples.
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
d90317e96558b5bda3b3e122dd8c10034947c089
|
||||
8e37ed57dcba682ce34245eba76540512157a176
|
|
@ -1 +1 @@
|
|||
95c88dba8ecdd1d2b8c0c577725d40a64322150b
|
||||
fc62a687ea195f7070f35f85160a6c8361e63e08
|
|
@ -87,11 +87,11 @@ FT_Library FontFreeType::getFTLibrary()
|
|||
return _FTlibrary;
|
||||
}
|
||||
|
||||
FontFreeType::FontFreeType(bool dynamicGlyphCollection)
|
||||
: _letterPadding(5),
|
||||
_ttfData(nullptr),
|
||||
_dynamicGlyphCollection(dynamicGlyphCollection),
|
||||
_fontRef(nullptr)
|
||||
FontFreeType::FontFreeType(bool dynamicGlyphCollection)
|
||||
: _fontRef(nullptr),
|
||||
_letterPadding(5),
|
||||
_ttfData(nullptr),
|
||||
_dynamicGlyphCollection(dynamicGlyphCollection)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -515,6 +515,24 @@ void GLProgram::setUniformLocationWith4fv(GLint location, GLfloat* floats, unsig
|
|||
}
|
||||
}
|
||||
|
||||
void GLProgram::setUniformLocationWithMatrix2fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices) {
|
||||
bool updated = updateUniformLocation(location, matrixArray, sizeof(float)*4*numberOfMatrices);
|
||||
|
||||
if( updated )
|
||||
{
|
||||
glUniformMatrix2fv( (GLint)location, (GLsizei)numberOfMatrices, GL_FALSE, matrixArray);
|
||||
}
|
||||
}
|
||||
|
||||
void GLProgram::setUniformLocationWithMatrix3fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices) {
|
||||
bool updated = updateUniformLocation(location, matrixArray, sizeof(float)*9*numberOfMatrices);
|
||||
|
||||
if( updated )
|
||||
{
|
||||
glUniformMatrix3fv( (GLint)location, (GLsizei)numberOfMatrices, GL_FALSE, matrixArray);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GLProgram::setUniformLocationWithMatrix4fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices)
|
||||
{
|
||||
|
|
|
@ -198,6 +198,12 @@ public:
|
|||
/** calls glUniform4fv only if the values are different than the previous call for this same shader program. */
|
||||
void setUniformLocationWith4fv(GLint location, GLfloat* floats, unsigned int numberOfArrays);
|
||||
|
||||
/** calls glUniformMatrix2fv only if the values are different than the previous call for this same shader program. */
|
||||
void setUniformLocationWithMatrix2fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices);
|
||||
|
||||
/** calls glUniformMatrix3fv only if the values are different than the previous call for this same shader program. */
|
||||
void setUniformLocationWithMatrix3fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices);
|
||||
|
||||
/** calls glUniformMatrix4fv only if the values are different than the previous call for this same shader program. */
|
||||
void setUniformLocationWithMatrix4fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices);
|
||||
|
||||
|
|
|
@ -93,12 +93,13 @@ Label* Label::createWithAtlas(FontAtlas *atlas, TextHAlignment alignment, int li
|
|||
}
|
||||
|
||||
Label::Label(FontAtlas *atlas, TextHAlignment alignment)
|
||||
: _currentUTF16String(0)
|
||||
, _originalUTF16String(0)
|
||||
, _fontAtlas(atlas)
|
||||
, _alignment(alignment)
|
||||
: _reusedLetter(nullptr)
|
||||
, _lineBreakWithoutSpaces(false)
|
||||
, _alignment(alignment)
|
||||
, _currentUTF16String(0)
|
||||
, _originalUTF16String(0)
|
||||
, _advances(0)
|
||||
, _fontAtlas(atlas)
|
||||
, _displayedColor(Color3B::WHITE)
|
||||
, _realColor(Color3B::WHITE)
|
||||
, _cascadeColorEnabled(true)
|
||||
|
@ -106,7 +107,6 @@ Label::Label(FontAtlas *atlas, TextHAlignment alignment)
|
|||
, _displayedOpacity(255)
|
||||
, _realOpacity(255)
|
||||
, _isOpacityModifyRGB(true)
|
||||
,_reusedLetter(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -386,7 +386,7 @@ Sprite * Label::updateSpriteWithLetterDefinition(Sprite *spriteToUpdate, const F
|
|||
|
||||
bool Label::recordLetterInfo(const cocos2d::Point& point,unsigned short int theChar, int spriteIndex)
|
||||
{
|
||||
if (spriteIndex >= _lettersInfo.size())
|
||||
if (static_cast<std::size_t>(spriteIndex) >= _lettersInfo.size())
|
||||
{
|
||||
LetterInfo tmpInfo;
|
||||
_lettersInfo.push_back(tmpInfo);
|
||||
|
@ -402,7 +402,7 @@ bool Label::recordLetterInfo(const cocos2d::Point& point,unsigned short int theC
|
|||
|
||||
bool Label::recordPlaceholderInfo(int spriteIndex)
|
||||
{
|
||||
if (spriteIndex >= _lettersInfo.size())
|
||||
if (static_cast<std::size_t>(spriteIndex) >= _lettersInfo.size())
|
||||
{
|
||||
LetterInfo tmpInfo;
|
||||
_lettersInfo.push_back(tmpInfo);
|
||||
|
|
|
@ -127,9 +127,9 @@ void LabelAtlas::updateAtlasValues()
|
|||
itemHeightInPixels = _itemHeight;
|
||||
}
|
||||
|
||||
CCASSERT( n <= _textureAtlas->getCapacity(), "updateAtlasValues: Invalid String length");
|
||||
CCASSERT( static_cast<long>(n) <= _textureAtlas->getCapacity(), "updateAtlasValues: Invalid String length");
|
||||
V3F_C4B_T2F_Quad* quads = _textureAtlas->getQuads();
|
||||
for(int i = 0; i < n; i++) {
|
||||
for(long i = 0; i < static_cast<long>(n); i++) {
|
||||
|
||||
unsigned char a = s[i] - _mapStartChar;
|
||||
float row = (float) (a % _itemsPerRow);
|
||||
|
@ -177,8 +177,8 @@ void LabelAtlas::updateAtlasValues()
|
|||
}
|
||||
if (n > 0 ){
|
||||
_textureAtlas->setDirty(true);
|
||||
int totalQuads = _textureAtlas->getTotalQuads();
|
||||
if (n > totalQuads) {
|
||||
long totalQuads = _textureAtlas->getTotalQuads();
|
||||
if (static_cast<long>(n) > totalQuads) {
|
||||
_textureAtlas->increaseTotalQuadsWith(n - totalQuads);
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ void LabelAtlas::updateAtlasValues()
|
|||
void LabelAtlas::setString(const std::string &label)
|
||||
{
|
||||
size_t len = label.size();
|
||||
if (len > _textureAtlas->getTotalQuads())
|
||||
if (static_cast<long>(len) > _textureAtlas->getTotalQuads())
|
||||
{
|
||||
_textureAtlas->resizeCapacity(len);
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ std::set<unsigned int>* CCBMFontConfiguration::parseConfigFile(const std::string
|
|||
{
|
||||
size_t pos = strLeft.find('\n');
|
||||
|
||||
if (pos != (int)std::string::npos)
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
// the data is more than a line.get one line
|
||||
line = strLeft.substr(0, pos);
|
||||
|
|
|
@ -237,11 +237,13 @@ void Node::_setZOrder(int z)
|
|||
|
||||
void Node::setZOrder(int z)
|
||||
{
|
||||
_setZOrder(z);
|
||||
if (_parent)
|
||||
{
|
||||
_parent->reorderChild(this, z);
|
||||
}
|
||||
// should set "_ZOrder" after reorderChild, because the implementation of reorderChild subclass of Node, such as Sprite,
|
||||
// will return when _ZOrder value is not changed
|
||||
_setZOrder(z);
|
||||
|
||||
_eventDispatcher->setDirtyForNode(this);
|
||||
}
|
||||
|
|
|
@ -82,22 +82,22 @@ bool nodeComparisonLess(Object* p1, Object* p2);
|
|||
|
||||
class EventListener;
|
||||
|
||||
/** @brief Node is the main element. Anything that gets drawn or contains things that get drawn is a Node.
|
||||
The most popular Nodes are: Scene, Layer, Sprite, Menu.
|
||||
/** @brief Node is the base element of the Scene Graph. Element of the Scene Graph must be Node objects or subclasses of it.
|
||||
The most common Node objects are: Scene, Layer, Sprite, Menu.
|
||||
|
||||
The main features of a Node are:
|
||||
- They can contain other Node nodes (addChild, getChildByTag, removeChild, etc)
|
||||
- They can schedule periodic callback (schedule, unschedule, etc)
|
||||
- They can execute actions (runAction, stopAction, etc)
|
||||
- They can contain other Node objects (`addChild`, `getChildByTag`, `removeChild`, etc)
|
||||
- They can schedule periodic callback (`schedule`, `unschedule`, etc)
|
||||
- They can execute actions (`runAction`, `stopAction`, etc)
|
||||
|
||||
Some Node nodes provide extra functionality for them or their children.
|
||||
Some Node objects provide extra functionality for them or their children.
|
||||
|
||||
Subclassing a Node usually means (one/all) of:
|
||||
- overriding init to initialize resources and schedule callbacks
|
||||
- create callbacks to handle the advancement of time
|
||||
- overriding draw to render the node
|
||||
|
||||
Features of Node:
|
||||
Properties of Node:
|
||||
- position
|
||||
- scale (x, y)
|
||||
- rotation (in degrees, clockwise)
|
||||
|
@ -117,7 +117,7 @@ class EventListener;
|
|||
- anchorPoint: (x=0,y=0)
|
||||
|
||||
Limitations:
|
||||
- A Node is a "void" object. It doesn't have a texture
|
||||
- A Node is a "invisible" object. If you want to draw something on the screen, you should use a Sprite instead. Or subclass Node and override `draw`.
|
||||
|
||||
Order in transformations with grid disabled
|
||||
-# The node will be translated (position)
|
||||
|
@ -189,15 +189,15 @@ public:
|
|||
/**
|
||||
* Sets the Z order which stands for the drawing order, and reorder this node in its parent's children array.
|
||||
*
|
||||
* The Z order of node is relative to its "brothers": children of the same parent.
|
||||
* It's nothing to do with OpenGL's z vertex. This one only affects the draw order of nodes in cocos2d.
|
||||
* The larger number it is, the later this node will be drawn in each message loop.
|
||||
* Please refer to setVertexZ(float) for the difference.
|
||||
* The Z order of node is relative to its siblings.
|
||||
* It is not related to the OpenGL's z property. This one only affects the draw order of itself and its siblings.
|
||||
* Lower Z order number are drawn before higher numbers.
|
||||
* Please refer to `setVertexZ(float)` for the difference.
|
||||
*
|
||||
* @param zOrder Z order of this node.
|
||||
*/
|
||||
virtual void setZOrder(int zOrder);
|
||||
/**
|
||||
/*
|
||||
* Sets the z order which stands for the drawing order
|
||||
*
|
||||
* This is an internal method. Don't call it outside the framework.
|
||||
|
@ -209,7 +209,7 @@ public:
|
|||
/**
|
||||
* Gets the Z order of this node.
|
||||
*
|
||||
* @see setZOrder(int)
|
||||
* @see `setZOrder(int)`
|
||||
*
|
||||
* @return The Z order.
|
||||
*/
|
||||
|
@ -221,7 +221,7 @@ public:
|
|||
* Differences between openGL Z vertex and cocos2d Z order:
|
||||
* - OpenGL Z modifies the Z vertex, and not the Z order in the relation between parent-children
|
||||
* - OpenGL Z might require to set 2D projection
|
||||
* - cocos2d Z order works OK if all the nodes uses the same openGL Z vertex. eg: vertexZ = 0
|
||||
* - cocos2d Z order works OK if all the nodes uses the same openGL Z vertex. eg: `vertexZ = 0`
|
||||
*
|
||||
* @warning Use it at your own risk since it might break the cocos2d parent-children z order
|
||||
*
|
||||
|
@ -267,7 +267,7 @@ public:
|
|||
/**
|
||||
* Returns the scale factor on Y axis of this node
|
||||
*
|
||||
* @see setScaleY(float)
|
||||
* @see `setScaleY(float)`
|
||||
*
|
||||
* @return The scale factor on Y axis.
|
||||
*/
|
||||
|
@ -285,7 +285,7 @@ public:
|
|||
/**
|
||||
* Gets the scale factor of the node, when X and Y have the same scale factor.
|
||||
*
|
||||
* @warning Assert when _scaleX != _scaleY.
|
||||
* @warning Assert when `_scaleX != _scaleY`
|
||||
* @see setScale(float)
|
||||
*
|
||||
* @return The scale factor of the node.
|
||||
|
@ -305,13 +305,13 @@ public:
|
|||
/**
|
||||
* Changes the position (x,y) of the node in OpenGL coordinates
|
||||
*
|
||||
* Usually we use Point(x,y) to compose Point object.
|
||||
* Usually we use `Point(x,y)` to compose Point object.
|
||||
* The original point (0,0) is at the left-bottom corner of screen.
|
||||
* For example, this codesnip sets the node in the center of screen.
|
||||
* @code
|
||||
* Size size = Director::getInstance()->getWinSize();
|
||||
* node->setPosition( Point(size.width/2, size.height/2) )
|
||||
* @endcode
|
||||
@code
|
||||
Size size = Director::getInstance()->getWinSize();
|
||||
node->setPosition( Point(size.width/2, size.height/2) )
|
||||
@endcode
|
||||
*
|
||||
* @param position The position (x,y) of the node in OpenGL coordinates
|
||||
*/
|
||||
|
@ -334,11 +334,11 @@ public:
|
|||
* This method is binded to lua and javascript.
|
||||
* Passing a number is 10 times faster than passing a object from lua to c++
|
||||
*
|
||||
* @code
|
||||
* // sample code in lua
|
||||
* local pos = node::getPosition() -- returns Point object from C++
|
||||
* node:setPosition(x, y) -- pass x, y coordinate to C++
|
||||
* @endcode
|
||||
@code
|
||||
// sample code in lua
|
||||
local pos = node::getPosition() -- returns Point object from C++
|
||||
node:setPosition(x, y) -- pass x, y coordinate to C++
|
||||
@endcode
|
||||
*
|
||||
* @param x X coordinate for position
|
||||
* @param y Y coordinate for position
|
||||
|
@ -347,10 +347,8 @@ public:
|
|||
/**
|
||||
* Gets position in a more efficient way, returns two number instead of a Point object
|
||||
*
|
||||
* @see setPosition(float, float)
|
||||
* @code
|
||||
* @see `setPosition(float, float)`
|
||||
* In js,out value not return
|
||||
* @endcode
|
||||
*/
|
||||
virtual void getPosition(float* x, float* y) const;
|
||||
/**
|
||||
|
@ -376,7 +374,7 @@ public:
|
|||
/**
|
||||
* Returns the X skew angle of the node in degrees.
|
||||
*
|
||||
* @see setSkewX(float)
|
||||
* @see `setSkewX(float)`
|
||||
*
|
||||
* @return The X skew angle of the node in degrees.
|
||||
*/
|
||||
|
@ -396,7 +394,7 @@ public:
|
|||
/**
|
||||
* Returns the Y skew angle of the node in degrees.
|
||||
*
|
||||
* @see setSkewY(float)
|
||||
* @see `setSkewY(float)`
|
||||
*
|
||||
* @return The Y skew angle of the node in degrees.
|
||||
*/
|
||||
|
@ -418,7 +416,7 @@ public:
|
|||
/**
|
||||
* Returns the anchor point in percent.
|
||||
*
|
||||
* @see setAnchorPoint(const Point&)
|
||||
* @see `setAnchorPoint(const Point&)`
|
||||
*
|
||||
* @return The anchor point of node.
|
||||
*/
|
||||
|
@ -427,7 +425,7 @@ public:
|
|||
* Returns the anchorPoint in absolute pixels.
|
||||
*
|
||||
* @warning You can only read it. If you wish to modify it, use anchorPoint instead.
|
||||
* @see getAnchorPoint()
|
||||
* @see `getAnchorPoint()`
|
||||
*
|
||||
* @return The anchor point in absolute pixels.
|
||||
*/
|
||||
|
@ -446,7 +444,7 @@ public:
|
|||
/**
|
||||
* Returns the untransformed size of the node.
|
||||
*
|
||||
* @see setContentSize(const Size&)
|
||||
* @see `setContentSize(const Size&)`
|
||||
*
|
||||
* @return The untransformed size of the node.
|
||||
*/
|
||||
|
@ -464,7 +462,7 @@ public:
|
|||
/**
|
||||
* Determines if the node is visible
|
||||
*
|
||||
* @see setVisible(bool)
|
||||
* @see `setVisible(bool)`
|
||||
*
|
||||
* @return true if the node is visible, false if the node is hidden.
|
||||
*/
|
||||
|
@ -483,7 +481,7 @@ public:
|
|||
/**
|
||||
* Returns the rotation of the node in degrees.
|
||||
*
|
||||
* @see setRotation(float)
|
||||
* @see `setRotation(float)`
|
||||
*
|
||||
* @return The rotation of the node in degrees.
|
||||
*/
|
||||
|
@ -502,7 +500,7 @@ public:
|
|||
/**
|
||||
* Gets the X rotation (angle) of the node in degrees which performs a horizontal rotation skew.
|
||||
*
|
||||
* @see setRotationX(float)
|
||||
* @see `setRotationX(float)`
|
||||
*
|
||||
* @return The X rotation in degrees.
|
||||
*/
|
||||
|
@ -521,7 +519,7 @@ public:
|
|||
/**
|
||||
* Gets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew.
|
||||
*
|
||||
* @see setRotationY(float)
|
||||
* @see `setRotationY(float)`
|
||||
*
|
||||
* @return The Y rotation in degrees.
|
||||
*/
|
||||
|
@ -542,7 +540,7 @@ public:
|
|||
/**
|
||||
* Returns the arrival order, indecates which children is added previously.
|
||||
*
|
||||
* @see setOrderOfArrival(unsigned int)
|
||||
* @see `setOrderOfArrival(unsigned int)`
|
||||
*
|
||||
* @return The arrival order.
|
||||
*/
|
||||
|
@ -573,7 +571,7 @@ public:
|
|||
/**
|
||||
* Gets whether the anchor point will be (0,0) when you position this node.
|
||||
*
|
||||
* @see ignoreAnchorPointForPosition(bool)
|
||||
* @see `ignoreAnchorPointForPosition(bool)`
|
||||
*
|
||||
* @return true if the anchor point will be (0,0) when you position this node.
|
||||
*/
|
||||
|
@ -625,13 +623,13 @@ public:
|
|||
*
|
||||
* Composing a "tree" structure is a very important feature of Node
|
||||
* Here's a sample code of traversing children array:
|
||||
* @code
|
||||
* Node* node = NULL;
|
||||
* CCARRAY_FOREACH(parent->getChildren(), node)
|
||||
* {
|
||||
* node->setPosition(0,0);
|
||||
* }
|
||||
* @endcode
|
||||
@code
|
||||
Node* node = NULL;
|
||||
CCARRAY_FOREACH(parent->getChildren(), node)
|
||||
{
|
||||
node->setPosition(0,0);
|
||||
}
|
||||
@endcode
|
||||
* This sample code traverses all children nodes, and set their position to (0,0)
|
||||
*
|
||||
* @return An array of children
|
||||
|
@ -655,7 +653,7 @@ public:
|
|||
/**
|
||||
* Returns a pointer to the parent node
|
||||
*
|
||||
* @see setParent(Node*)
|
||||
* @see `setParent(Node*)`
|
||||
*
|
||||
* @returns A pointer to the parnet node
|
||||
*/
|
||||
|
@ -668,7 +666,7 @@ public:
|
|||
/**
|
||||
* Removes this node itself from its parent node with a cleanup.
|
||||
* If the node orphan, then nothing happens.
|
||||
* @see removeFromParentAndCleanup(bool)
|
||||
* @see `removeFromParentAndCleanup(bool)`
|
||||
*/
|
||||
virtual void removeFromParent();
|
||||
/**
|
||||
|
@ -698,7 +696,7 @@ public:
|
|||
/**
|
||||
* Removes all children from the container with a cleanup.
|
||||
*
|
||||
* @see removeAllChildrenWithCleanup(bool)
|
||||
* @see `removeAllChildrenWithCleanup(bool)`
|
||||
*/
|
||||
virtual void removeAllChildren();
|
||||
/**
|
||||
|
@ -761,32 +759,32 @@ public:
|
|||
* Returns a tag that is used to identify the node easily.
|
||||
*
|
||||
* You can set tags to node then identify them easily.
|
||||
* @code
|
||||
* #define TAG_PLAYER 1
|
||||
* #define TAG_MONSTER 2
|
||||
* #define TAG_BOSS 3
|
||||
* // set tags
|
||||
* node1->setTag(TAG_PLAYER);
|
||||
* node2->setTag(TAG_MONSTER);
|
||||
* node3->setTag(TAG_BOSS);
|
||||
* parent->addChild(node1);
|
||||
* parent->addChild(node2);
|
||||
* parent->addChild(node3);
|
||||
* // identify by tags
|
||||
* Node* node = NULL;
|
||||
* CCARRAY_FOREACH(parent->getChildren(), node)
|
||||
* {
|
||||
* switch(node->getTag())
|
||||
* {
|
||||
* case TAG_PLAYER:
|
||||
* break;
|
||||
* case TAG_MONSTER:
|
||||
* break;
|
||||
* case TAG_BOSS:
|
||||
* break;
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
@code
|
||||
#define TAG_PLAYER 1
|
||||
#define TAG_MONSTER 2
|
||||
#define TAG_BOSS 3
|
||||
// set tags
|
||||
node1->setTag(TAG_PLAYER);
|
||||
node2->setTag(TAG_MONSTER);
|
||||
node3->setTag(TAG_BOSS);
|
||||
parent->addChild(node1);
|
||||
parent->addChild(node2);
|
||||
parent->addChild(node3);
|
||||
// identify by tags
|
||||
Node* node = NULL;
|
||||
CCARRAY_FOREACH(parent->getChildren(), node)
|
||||
{
|
||||
switch(node->getTag())
|
||||
{
|
||||
case TAG_PLAYER:
|
||||
break;
|
||||
case TAG_MONSTER:
|
||||
break;
|
||||
case TAG_BOSS:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@endcode
|
||||
*
|
||||
* @return A interger that identifies the node.
|
||||
*/
|
||||
|
@ -820,7 +818,7 @@ public:
|
|||
* Sets a custom user data pointer
|
||||
*
|
||||
* You can set everything in UserData pointer, a data block, a structure or an object, etc.
|
||||
* @warning Don't forget to release the memroy manually,
|
||||
* @warning Don't forget to release the memory manually,
|
||||
* especially before you change this data pointer, and before this node is autoreleased.
|
||||
*
|
||||
* @param userData A custom user data pointer
|
||||
|
@ -875,9 +873,9 @@ public:
|
|||
*
|
||||
* Since v2.0, each rendering node must set its shader program.
|
||||
* It should be set in initialize phase.
|
||||
* @code
|
||||
* node->setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
* @endcode
|
||||
@code
|
||||
node->setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
@endcode
|
||||
*
|
||||
* @param shaderProgram The shader program which fetchs from ShaderCache.
|
||||
*/
|
||||
|
@ -888,11 +886,11 @@ public:
|
|||
/**
|
||||
* Returns a camera object that lets you move the node using a gluLookAt
|
||||
*
|
||||
* @code
|
||||
* Camera* camera = node->getCamera();
|
||||
* camera->setEye(0, 0, 415/2);
|
||||
* camera->setCenter(0, 0, 0);
|
||||
* @endcode
|
||||
@code
|
||||
Camera* camera = node->getCamera();
|
||||
camera->setEye(0, 0, 415/2);
|
||||
camera->setCenter(0, 0, 0);
|
||||
@endcode
|
||||
*
|
||||
* @return A Camera object that lets you move the node using a gluLookAt
|
||||
*/
|
||||
|
@ -966,10 +964,10 @@ public:
|
|||
/**
|
||||
* Override this method to draw your own node.
|
||||
* The following GL states will be enabled by default:
|
||||
* - glEnableClientState(GL_VERTEX_ARRAY);
|
||||
* - glEnableClientState(GL_COLOR_ARRAY);
|
||||
* - glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
* - glEnable(GL_TEXTURE_2D);
|
||||
* - `glEnableClientState(GL_VERTEX_ARRAY);`
|
||||
* - `glEnableClientState(GL_COLOR_ARRAY);`
|
||||
* - `glEnableClientState(GL_TEXTURE_COORD_ARRAY);`
|
||||
* - `glEnable(GL_TEXTURE_2D);`
|
||||
* AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE
|
||||
* But if you enable any other GL state, you should disable it after drawing your node.
|
||||
*/
|
||||
|
@ -986,7 +984,7 @@ public:
|
|||
* The returned box is relative only to its parent.
|
||||
*
|
||||
* @note This method returns a temporaty variable, so it can't returns const Rect&
|
||||
* @todo Rename to getBoundingBox() in the future versions.
|
||||
* @todo Rename to `getBoundingBox()` in the future versions.
|
||||
*
|
||||
* @return A "local" axis aligned boudning box of the node.
|
||||
*/
|
||||
|
@ -1049,7 +1047,7 @@ public:
|
|||
/**
|
||||
* Gets an action from the running action list by its tag.
|
||||
*
|
||||
* @see setTag(int), getTag().
|
||||
* @see `setTag(int)`, `getTag()`.
|
||||
*
|
||||
* @return The action object with the given tag.
|
||||
*/
|
||||
|
@ -1135,12 +1133,12 @@ public:
|
|||
* Schedules a custom selector.
|
||||
*
|
||||
* If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.
|
||||
* @code
|
||||
* // firstly, implement a schedule function
|
||||
* void MyNode::TickMe(float dt);
|
||||
* // wrap this function into a selector via schedule_selector marco.
|
||||
* this->schedule(schedule_selector(MyNode::TickMe), 0, 0, 0);
|
||||
* @endcode
|
||||
@code
|
||||
// firstly, implement a schedule function
|
||||
void MyNode::TickMe(float dt);
|
||||
// wrap this function into a selector via schedule_selector marco.
|
||||
this->schedule(schedule_selector(MyNode::TickMe), 0, 0, 0);
|
||||
@endcode
|
||||
*
|
||||
* @param selector The SEL_SCHEDULE selector to be scheduled.
|
||||
* @param interval Tick interval in seconds. 0 means tick every frame. If interval = 0, it's recommended to use scheduleUpdate() instead.
|
||||
|
@ -1152,7 +1150,7 @@ public:
|
|||
|
||||
/**
|
||||
* Schedules a custom selector with an interval time in seconds.
|
||||
* @see schedule(SEL_SCHEDULE, float, unsigned int, float)
|
||||
* @see `schedule(SEL_SCHEDULE, float, unsigned int, float)`
|
||||
*
|
||||
* @param selector The SEL_SCHEDULE selector to be scheduled.
|
||||
* @param interval Callback interval time in seconds. 0 means tick every frame,
|
||||
|
@ -1162,7 +1160,7 @@ public:
|
|||
|
||||
/**
|
||||
* Schedules a selector that runs only once, with a delay of 0 or larger
|
||||
* @see schedule(SEL_SCHEDULE, float, unsigned int, float)
|
||||
* @see `schedule(SEL_SCHEDULE, float, unsigned int, float)`
|
||||
*
|
||||
* @param selector The SEL_SCHEDULE selector to be scheduled.
|
||||
* @param delay The amount of time that the first tick will wait before execution.
|
||||
|
@ -1181,7 +1179,7 @@ public:
|
|||
|
||||
/**
|
||||
* Unschedules a custom selector.
|
||||
* @see schedule(SEL_SCHEDULE, float, unsigned int, float)
|
||||
* @see `schedule(SEL_SCHEDULE, float, unsigned int, float)`
|
||||
*
|
||||
* @param selector A function wrapped as a selector
|
||||
* @lua NA
|
||||
|
@ -1242,7 +1240,7 @@ public:
|
|||
*
|
||||
* This method is moved from Sprite, so it's no longer specific to Sprite.
|
||||
* As the result, you apply SpriteBatchNode's optimization on your customed Node.
|
||||
* e.g., batchNode->addChild(myCustomNode), while you can only addChild(sprite) before.
|
||||
* e.g., `batchNode->addChild(myCustomNode)`, while you can only addChild(sprite) before.
|
||||
*/
|
||||
virtual void updateTransform();
|
||||
|
||||
|
@ -1323,48 +1321,48 @@ public:
|
|||
*
|
||||
* @note The additional transform will be concatenated at the end of getNodeToParentTransform.
|
||||
* It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't).
|
||||
* @code
|
||||
// create a batchNode
|
||||
SpriteBatchNode* batch= SpriteBatchNode::create("Icon-114.png");
|
||||
this->addChild(batch);
|
||||
|
||||
// create two sprites, spriteA will be added to batchNode, they are using different textures.
|
||||
Sprite* spriteA = Sprite::createWithTexture(batch->getTexture());
|
||||
Sprite* spriteB = Sprite::create("Icon-72.png");
|
||||
@code
|
||||
// create a batchNode
|
||||
SpriteBatchNode* batch= SpriteBatchNode::create("Icon-114.png");
|
||||
this->addChild(batch);
|
||||
|
||||
batch->addChild(spriteA);
|
||||
|
||||
// We can't make spriteB as spriteA's child since they use different textures. So just add it to layer.
|
||||
// But we want to simulate `parent-child` relationship for these two node.
|
||||
this->addChild(spriteB);
|
||||
// create two sprites, spriteA will be added to batchNode, they are using different textures.
|
||||
Sprite* spriteA = Sprite::createWithTexture(batch->getTexture());
|
||||
Sprite* spriteB = Sprite::create("Icon-72.png");
|
||||
|
||||
//position
|
||||
spriteA->setPosition(Point(200, 200));
|
||||
|
||||
// Gets the spriteA's transform.
|
||||
AffineTransform t = spriteA->getNodeToParentTransform();
|
||||
|
||||
// Sets the additional transform to spriteB, spriteB's postion will based on its pseudo parent i.e. spriteA.
|
||||
spriteB->setAdditionalTransform(t);
|
||||
batch->addChild(spriteA);
|
||||
|
||||
//scale
|
||||
spriteA->setScale(2);
|
||||
|
||||
// Gets the spriteA's transform.
|
||||
t = spriteA->getNodeToParentTransform();
|
||||
|
||||
// Sets the additional transform to spriteB, spriteB's scale will based on its pseudo parent i.e. spriteA.
|
||||
spriteB->setAdditionalTransform(t);
|
||||
// We can't make spriteB as spriteA's child since they use different textures. So just add it to layer.
|
||||
// But we want to simulate `parent-child` relationship for these two node.
|
||||
this->addChild(spriteB);
|
||||
|
||||
//rotation
|
||||
spriteA->setRotation(20);
|
||||
|
||||
// Gets the spriteA's transform.
|
||||
t = spriteA->getNodeToParentTransform();
|
||||
|
||||
// Sets the additional transform to spriteB, spriteB's rotation will based on its pseudo parent i.e. spriteA.
|
||||
spriteB->setAdditionalTransform(t);
|
||||
* @endcode
|
||||
//position
|
||||
spriteA->setPosition(Point(200, 200));
|
||||
|
||||
// Gets the spriteA's transform.
|
||||
AffineTransform t = spriteA->getNodeToParentTransform();
|
||||
|
||||
// Sets the additional transform to spriteB, spriteB's postion will based on its pseudo parent i.e. spriteA.
|
||||
spriteB->setAdditionalTransform(t);
|
||||
|
||||
//scale
|
||||
spriteA->setScale(2);
|
||||
|
||||
// Gets the spriteA's transform.
|
||||
t = spriteA->getNodeToParentTransform();
|
||||
|
||||
// Sets the additional transform to spriteB, spriteB's scale will based on its pseudo parent i.e. spriteA.
|
||||
spriteB->setAdditionalTransform(t);
|
||||
|
||||
//rotation
|
||||
spriteA->setRotation(20);
|
||||
|
||||
// Gets the spriteA's transform.
|
||||
t = spriteA->getNodeToParentTransform();
|
||||
|
||||
// Sets the additional transform to spriteB, spriteB's rotation will based on its pseudo parent i.e. spriteA.
|
||||
spriteB->setAdditionalTransform(t);
|
||||
@endcode
|
||||
*/
|
||||
void setAdditionalTransform(const AffineTransform& additionalTransform);
|
||||
|
||||
|
|
|
@ -81,15 +81,15 @@ NS_CC_BEGIN
|
|||
//
|
||||
|
||||
ParticleSystem::ParticleSystem()
|
||||
: _configName("")
|
||||
, _isBlendAdditive(false)
|
||||
: _isBlendAdditive(false)
|
||||
, _isAutoRemoveOnFinish(false)
|
||||
, _plistFile("")
|
||||
, _elapsed(0)
|
||||
, _particles(NULL)
|
||||
, _particles(nullptr)
|
||||
, _configName("")
|
||||
, _emitCounter(0)
|
||||
, _particleIdx(0)
|
||||
, _batchNode(NULL)
|
||||
, _batchNode(nullptr)
|
||||
, _atlasIndex(0)
|
||||
, _transformSystemDirty(false)
|
||||
, _allocatedParticles(0)
|
||||
|
@ -113,11 +113,11 @@ ParticleSystem::ParticleSystem()
|
|||
, _endSpinVar(0)
|
||||
, _emissionRate(0)
|
||||
, _totalParticles(0)
|
||||
, _texture(NULL)
|
||||
, _texture(nullptr)
|
||||
, _blendFunc(BlendFunc::ALPHA_PREMULTIPLIED)
|
||||
, _opacityModifyRGB(false)
|
||||
, _positionType(PositionType::FREE)
|
||||
, _yCoordFlipped(0)
|
||||
, _positionType(PositionType::FREE)
|
||||
{
|
||||
modeA.gravity = Point::ZERO;
|
||||
modeA.speed = 0;
|
||||
|
|
|
@ -101,12 +101,12 @@ void Profiler::displayTimers()
|
|||
// implementation of ProfilingTimer
|
||||
|
||||
ProfilingTimer::ProfilingTimer()
|
||||
: numberOfCalls(0)
|
||||
, _averageTime1(0)
|
||||
: _averageTime1(0)
|
||||
, _averageTime2(0)
|
||||
, totalTime(0)
|
||||
, minTime(100000000)
|
||||
, maxTime(0)
|
||||
, totalTime(0)
|
||||
, numberOfCalls(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,11 @@ void Scene::update(float delta)
|
|||
{
|
||||
Node::update(delta);
|
||||
|
||||
_physicsWorld->update(delta);
|
||||
if (nullptr != _physicsWorld)
|
||||
{
|
||||
_physicsWorld->update(delta);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -212,6 +212,8 @@ enum ScriptEventType
|
|||
kCommonEvent,
|
||||
kTableViewEvent,//Now it's only used in LuaBinding
|
||||
kAssetsManagerEvent,//Now it's only used in Lua Binding
|
||||
kCocoStudioEventListener,//Now it's only used in Lua Binding
|
||||
kArmatureWrapper,//Now it's only used in Lua Binding
|
||||
};
|
||||
|
||||
struct BasicScriptData
|
||||
|
|
|
@ -130,7 +130,7 @@ TextFontPagesDef::~TextFontPagesDef()
|
|||
}
|
||||
}
|
||||
|
||||
TextImage::TextImage(): _font(0), _fontPages(0)
|
||||
TextImage::TextImage(): _fontPages(0), _font(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -622,8 +622,8 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat
|
|||
CHECK_GL_ERROR_DEBUG(); // clean possible GL error
|
||||
|
||||
// Specify OpenGL texture image
|
||||
int width = pixelsWide;
|
||||
int height = pixelsHigh;
|
||||
long width = pixelsWide;
|
||||
long height = pixelsHigh;
|
||||
|
||||
for (int i = 0; i < mipmapsNum; ++i)
|
||||
{
|
||||
|
@ -641,7 +641,7 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat
|
|||
|
||||
if (i > 0 && (width != height || ccNextPOT(width) != width ))
|
||||
{
|
||||
CCLOG("cocos2d: Texture2D. WARNING. Mipmap level %u is not squared. Texture won't render correctly. width=%u != height=%u", i, width, height);
|
||||
CCLOG("cocos2d: Texture2D. WARNING. Mipmap level %u is not squared. Texture won't render correctly. width=%ld != height=%ld", i, width, height);
|
||||
}
|
||||
|
||||
GLenum err = glGetError();
|
||||
|
@ -1243,7 +1243,7 @@ void Texture2D::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied)
|
|||
|
||||
void Texture2D::generateMipmap()
|
||||
{
|
||||
CCASSERT( _pixelsWide == ccNextPOT(_pixelsWide) && _pixelsHigh == ccNextPOT(_pixelsHigh), "Mipmap texture only works in POT textures");
|
||||
CCASSERT( static_cast<unsigned long>(_pixelsWide) == ccNextPOT(_pixelsWide) && static_cast<unsigned long>(_pixelsHigh) == ccNextPOT(_pixelsHigh), "Mipmap texture only works in POT textures");
|
||||
GL::bindTexture2D( _name );
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
_hasMipmaps = true;
|
||||
|
@ -1256,8 +1256,8 @@ bool Texture2D::hasMipmaps() const
|
|||
|
||||
void Texture2D::setTexParameters(const TexParams &texParams)
|
||||
{
|
||||
CCASSERT( (_pixelsWide == ccNextPOT(_pixelsWide) || texParams.wrapS == GL_CLAMP_TO_EDGE) &&
|
||||
(_pixelsHigh == ccNextPOT(_pixelsHigh) || texParams.wrapT == GL_CLAMP_TO_EDGE),
|
||||
CCASSERT( (static_cast<unsigned long>(_pixelsWide) == ccNextPOT(_pixelsWide) || texParams.wrapS == GL_CLAMP_TO_EDGE) &&
|
||||
(static_cast<unsigned long>(_pixelsHigh) == ccNextPOT(_pixelsHigh) || texParams.wrapT == GL_CLAMP_TO_EDGE),
|
||||
"GL_CLAMP_TO_EDGE should be used in NPOT dimensions");
|
||||
|
||||
GL::bindTexture2D( _name );
|
||||
|
|
|
@ -32,6 +32,9 @@ THE SOFTWARE.
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
float TransitionPageTurn::POLYGON_OFFSET_FACTOR = -20.f;
|
||||
float TransitionPageTurn::POLYGON_OFFSET_UNITS = -20.f;
|
||||
|
||||
TransitionPageTurn::TransitionPageTurn()
|
||||
{
|
||||
}
|
||||
|
@ -67,6 +70,27 @@ void TransitionPageTurn::sceneOrder()
|
|||
_isInSceneOnTop = _back;
|
||||
}
|
||||
|
||||
void TransitionPageTurn::draw()
|
||||
{
|
||||
Scene::draw();
|
||||
|
||||
if( _isInSceneOnTop ) {
|
||||
_outScene->visit();
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS);
|
||||
_inScene->visit();
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(0, 0);
|
||||
} else {
|
||||
_inScene->visit();
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS);
|
||||
_outScene->visit();
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void TransitionPageTurn::onEnter()
|
||||
{
|
||||
TransitionScene::onEnter();
|
||||
|
|
|
@ -64,6 +64,11 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
virtual ~TransitionPageTurn();
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
virtual void draw() override;
|
||||
|
||||
/**
|
||||
* Creates a base transition with duration and incoming scene.
|
||||
|
@ -83,8 +88,9 @@ protected:
|
|||
virtual void sceneOrder() override;
|
||||
|
||||
protected:
|
||||
bool _back;
|
||||
|
||||
bool _back;
|
||||
static float POLYGON_OFFSET_FACTOR;
|
||||
static float POLYGON_OFFSET_UNITS;
|
||||
};
|
||||
|
||||
// end of transition group
|
||||
|
|
|
@ -479,7 +479,7 @@ bool UserDefault::createXMLFile()
|
|||
{
|
||||
return false;
|
||||
}
|
||||
tinyxml2::XMLDeclaration *pDeclaration = pDoc->NewDeclaration("1.0");
|
||||
tinyxml2::XMLDeclaration *pDeclaration = pDoc->NewDeclaration(nullptr);
|
||||
if (NULL==pDeclaration)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -318,7 +318,7 @@ bool ZipUtils::ccIsCCZFile(const char *path)
|
|||
|
||||
bool ZipUtils::ccIsCCZBuffer(const unsigned char *buffer, long len)
|
||||
{
|
||||
if (len < sizeof(struct CCZHeader))
|
||||
if (static_cast<size_t>(len) < sizeof(struct CCZHeader))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -26,42 +26,221 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
Color4B::Color4B(const Color4F &color4F)
|
||||
: r((GLubyte)(color4F.r * 255.0f)),
|
||||
g((GLubyte)(color4F.g * 255.0f)),
|
||||
b((GLubyte)(color4F.b * 255.0f)),
|
||||
a((GLubyte)(color4F.a * 255.0f))
|
||||
/**
|
||||
* Color3B
|
||||
*/
|
||||
|
||||
Color3B::Color3B()
|
||||
: r(0)
|
||||
, g(0)
|
||||
, b(0)
|
||||
{}
|
||||
|
||||
const Color3B Color3B::WHITE(255,255,255);
|
||||
const Color3B Color3B::YELLOW(255,255,0);
|
||||
const Color3B Color3B::GREEN(0,255,0);
|
||||
const Color3B Color3B::BLUE(0,0,255);
|
||||
const Color3B Color3B::RED(255,0,0);
|
||||
const Color3B Color3B::MAGENTA(255,0,255);
|
||||
const Color3B Color3B::BLACK(0,0,0);
|
||||
const Color3B Color3B::ORANGE(255,127,0);
|
||||
const Color3B Color3B::GRAY(166,166,166);
|
||||
Color3B::Color3B(GLubyte _r, GLubyte _g, GLubyte _b)
|
||||
: r(_r)
|
||||
, g(_g)
|
||||
, b(_b)
|
||||
{}
|
||||
|
||||
const Color4B Color4B::WHITE(255,255,255,255);
|
||||
const Color4B Color4B::YELLOW(255,255,0,255);
|
||||
const Color4B Color4B::GREEN(0,255,0,255);
|
||||
const Color4B Color4B::BLUE(0,0,255,255);
|
||||
const Color4B Color4B::RED(255,0,0,255);
|
||||
const Color4B Color4B::MAGENTA(255,0,255,255);
|
||||
const Color4B Color4B::BLACK(0,0,0,255);
|
||||
const Color4B Color4B::ORANGE(255,127,0,255);
|
||||
const Color4B Color4B::GRAY(166,166,166,255);
|
||||
Color3B::Color3B(const Color4B& color)
|
||||
: r(color.r)
|
||||
, g(color.g)
|
||||
, b(color.b)
|
||||
{}
|
||||
|
||||
const Color4F Color4F::WHITE(1,1,1,1);
|
||||
const Color4F Color4F::YELLOW(1,1,0,1);
|
||||
const Color4F Color4F::GREEN(0,1,0,1);
|
||||
const Color4F Color4F::BLUE(0,0,1,1);
|
||||
const Color4F Color4F::RED(1,0,0,1);
|
||||
const Color4F Color4F::MAGENTA(1,0,1,1);
|
||||
const Color4F Color4F::BLACK(0,0,0,1);
|
||||
const Color4F Color4F::ORANGE(1,0.5f,0,1);
|
||||
const Color4F Color4F::GRAY(0.65f,0.65f,0.65f,1);
|
||||
Color3B::Color3B(const Color4F& color)
|
||||
: r(color.r * 255.0f)
|
||||
, g(color.g * 255.0f)
|
||||
, b(color.b * 255.0f)
|
||||
{}
|
||||
|
||||
bool Color3B::operator==(const Color3B& right) const
|
||||
{
|
||||
return (r == right.r && g == right.g && b == right.b);
|
||||
}
|
||||
|
||||
bool Color3B::operator==(const Color4B& right) const
|
||||
{
|
||||
return (r == right.r && g == right.g && b == right.b && 255 == right.a);
|
||||
}
|
||||
|
||||
bool Color3B::operator==(const Color4F& right) const
|
||||
{
|
||||
return (right.a == 1.0f && Color4F(*this) == right);
|
||||
}
|
||||
|
||||
bool Color3B::operator!=(const Color3B& right) const
|
||||
{
|
||||
return !(*this == right);
|
||||
}
|
||||
|
||||
bool Color3B::operator!=(const Color4B& right) const
|
||||
{
|
||||
return !(*this == right);
|
||||
}
|
||||
|
||||
bool Color3B::operator!=(const Color4F& right) const
|
||||
{
|
||||
return !(*this == right);
|
||||
}
|
||||
|
||||
/**
|
||||
* Color4B
|
||||
*/
|
||||
|
||||
Color4B::Color4B()
|
||||
: r(0)
|
||||
, g(0)
|
||||
, b(0)
|
||||
, a(0)
|
||||
{}
|
||||
|
||||
Color4B::Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a)
|
||||
: r(_r)
|
||||
, g(_g)
|
||||
, b(_b)
|
||||
, a(_a)
|
||||
{}
|
||||
|
||||
Color4B::Color4B(const Color3B& color)
|
||||
: r(color.r * 255)
|
||||
, g(color.g * 255)
|
||||
, b(color.b * 255)
|
||||
, a(255)
|
||||
{}
|
||||
|
||||
Color4B::Color4B(const Color4F& color)
|
||||
: r(color.r * 255)
|
||||
, g(color.g * 255)
|
||||
, b(color.b * 255)
|
||||
, a(color.a * 255)
|
||||
{}
|
||||
|
||||
bool Color4B::operator==(const Color4B& right) const
|
||||
{
|
||||
return (r == right.r && g == right.g && b == right.b && a == right.a);
|
||||
}
|
||||
|
||||
bool Color4B::operator==(const Color3B& right) const
|
||||
{
|
||||
return (r == right.r && g == right.g && b == right.b && a == 255);
|
||||
}
|
||||
|
||||
bool Color4B::operator==(const Color4F& right) const
|
||||
{
|
||||
return (*this == Color4B(right));
|
||||
}
|
||||
|
||||
bool Color4B::operator!=(const Color4B& right) const
|
||||
{
|
||||
return !(*this == right);
|
||||
}
|
||||
|
||||
bool Color4B::operator!=(const Color3B& right) const
|
||||
{
|
||||
return !(*this == right);
|
||||
}
|
||||
|
||||
bool Color4B::operator!=(const Color4F& right) const
|
||||
{
|
||||
return !(*this == right);
|
||||
}
|
||||
|
||||
/**
|
||||
* Color4F
|
||||
*/
|
||||
|
||||
Color4F::Color4F()
|
||||
: r(0.0f)
|
||||
, g(0.0f)
|
||||
, b(0.0f)
|
||||
, a(0.0f)
|
||||
{}
|
||||
|
||||
Color4F::Color4F(float _r, float _g, float _b, float _a)
|
||||
: r(_r)
|
||||
, g(_g)
|
||||
, b(_b)
|
||||
, a(_a)
|
||||
{}
|
||||
|
||||
Color4F::Color4F(const Color3B& color)
|
||||
: r(color.r / 255.0f)
|
||||
, g(color.g / 255.0f)
|
||||
, b(color.b / 255.0f)
|
||||
, a(1.0f)
|
||||
{}
|
||||
|
||||
Color4F::Color4F(const Color4B& color)
|
||||
: r(color.r / 255.0f)
|
||||
, g(color.g / 255.0f)
|
||||
, b(color.b / 255.0f)
|
||||
, a(color.a / 255.0f)
|
||||
{}
|
||||
|
||||
bool Color4F::operator==(const Color4F& right) const
|
||||
{
|
||||
return (r == right.r && g == right.g && b == right.b && a == right.a);
|
||||
}
|
||||
|
||||
bool Color4F::operator==(const Color3B& right) const
|
||||
{
|
||||
return (a == 1.0f && Color3B(*this) == right);
|
||||
}
|
||||
|
||||
bool Color4F::operator==(const Color4B& right) const
|
||||
{
|
||||
return (*this == Color4F(right));
|
||||
}
|
||||
|
||||
bool Color4F::operator!=(const Color4F& right) const
|
||||
{
|
||||
return !(*this == right);
|
||||
}
|
||||
|
||||
bool Color4F::operator!=(const Color3B& right) const
|
||||
{
|
||||
return !(*this == right);
|
||||
}
|
||||
|
||||
bool Color4F::operator!=(const Color4B& right) const
|
||||
{
|
||||
return !(*this == right);
|
||||
}
|
||||
|
||||
/**
|
||||
* Color constants
|
||||
*/
|
||||
|
||||
const Color3B Color3B::WHITE (255, 255, 255);
|
||||
const Color3B Color3B::YELLOW (255, 255, 0);
|
||||
const Color3B Color3B::GREEN ( 0, 255, 0);
|
||||
const Color3B Color3B::BLUE ( 0, 0, 255);
|
||||
const Color3B Color3B::RED (255, 0, 0);
|
||||
const Color3B Color3B::MAGENTA(255, 0, 255);
|
||||
const Color3B Color3B::BLACK ( 0, 0, 0);
|
||||
const Color3B Color3B::ORANGE (255, 127, 0);
|
||||
const Color3B Color3B::GRAY (166, 166, 166);
|
||||
|
||||
const Color4B Color4B::WHITE (255, 255, 255, 255);
|
||||
const Color4B Color4B::YELLOW (255, 255, 0, 255);
|
||||
const Color4B Color4B::GREEN ( 0, 255, 0, 255);
|
||||
const Color4B Color4B::BLUE ( 0, 0, 255, 255);
|
||||
const Color4B Color4B::RED (255, 0, 0, 255);
|
||||
const Color4B Color4B::MAGENTA(255, 0, 255, 255);
|
||||
const Color4B Color4B::BLACK ( 0, 0, 0, 255);
|
||||
const Color4B Color4B::ORANGE (255, 127, 0, 255);
|
||||
const Color4B Color4B::GRAY (166, 166, 166, 255);
|
||||
|
||||
const Color4F Color4F::WHITE ( 1, 1, 1, 1);
|
||||
const Color4F Color4F::YELLOW ( 1, 1, 0, 1);
|
||||
const Color4F Color4F::GREEN ( 0, 1, 0, 1);
|
||||
const Color4F Color4F::BLUE ( 0, 0, 1, 1);
|
||||
const Color4F Color4F::RED ( 1, 0, 0, 1);
|
||||
const Color4F Color4F::MAGENTA( 1, 0, 1, 1);
|
||||
const Color4F Color4F::BLACK ( 0, 0, 0, 1);
|
||||
const Color4F Color4F::ORANGE ( 1, 0.5f, 0, 1);
|
||||
const Color4F Color4F::GRAY (0.65f, 0.65f, 0.65f, 1);
|
||||
|
||||
const BlendFunc BlendFunc::DISABLE = {GL_ONE, GL_ZERO};
|
||||
const BlendFunc BlendFunc::ALPHA_PREMULTIPLIED = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA};
|
||||
|
|
|
@ -31,29 +31,33 @@ THE SOFTWARE.
|
|||
#include "CCGeometry.h"
|
||||
#include "CCGL.h"
|
||||
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
struct Color4B;
|
||||
struct Color4F;
|
||||
|
||||
/** RGB color composed of bytes 3 bytes
|
||||
@since v3.0
|
||||
*/
|
||||
struct Color3B
|
||||
{
|
||||
Color3B(): r(0), g(0), b(0) {}
|
||||
|
||||
Color3B(GLubyte _r, GLubyte _g, GLubyte _b)
|
||||
: r(_r)
|
||||
, g(_g)
|
||||
, b(_b)
|
||||
{}
|
||||
|
||||
bool equals(const Color3B &other)
|
||||
Color3B();
|
||||
Color3B(GLubyte _r, GLubyte _g, GLubyte _b);
|
||||
explicit Color3B(const Color4B& color);
|
||||
explicit Color3B(const Color4F& color);
|
||||
|
||||
bool operator==(const Color3B& right) const;
|
||||
bool operator==(const Color4B& right) const;
|
||||
bool operator==(const Color4F& right) const;
|
||||
bool operator!=(const Color3B& right) const;
|
||||
bool operator!=(const Color4B& right) const;
|
||||
bool operator!=(const Color4F& right) const;
|
||||
|
||||
bool equals(const Color3B& other)
|
||||
{
|
||||
return (this->r == other.r &&
|
||||
this->g == other.g &&
|
||||
this->b == other.b);
|
||||
return (*this == other);
|
||||
}
|
||||
|
||||
|
||||
GLubyte r;
|
||||
GLubyte g;
|
||||
GLubyte b;
|
||||
|
@ -69,24 +73,22 @@ struct Color3B
|
|||
const static Color3B GRAY;
|
||||
};
|
||||
|
||||
struct Color4F;
|
||||
|
||||
/** RGBA color composed of 4 bytes
|
||||
@since v3.0
|
||||
*/
|
||||
struct Color4B
|
||||
{
|
||||
Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a)
|
||||
: r(_r)
|
||||
, g(_g)
|
||||
, b(_b)
|
||||
, a(_a)
|
||||
{}
|
||||
|
||||
Color4B(): r(0), g(0), b(0), a(0) {}
|
||||
|
||||
// This function should use Color4F, so implement it in .cpp file.
|
||||
explicit Color4B(const Color4F &color4F);
|
||||
Color4B();
|
||||
Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a);
|
||||
explicit Color4B(const Color3B& color);
|
||||
explicit Color4B(const Color4F& color);
|
||||
|
||||
bool operator==(const Color4B& right) const;
|
||||
bool operator==(const Color3B& right) const;
|
||||
bool operator==(const Color4F& right) const;
|
||||
bool operator!=(const Color4B& right) const;
|
||||
bool operator!=(const Color3B& right) const;
|
||||
bool operator!=(const Color4F& right) const;
|
||||
|
||||
GLubyte r;
|
||||
GLubyte g;
|
||||
|
@ -110,35 +112,21 @@ struct Color4B
|
|||
*/
|
||||
struct Color4F
|
||||
{
|
||||
Color4F(float _r, float _g, float _b, float _a)
|
||||
: r(_r)
|
||||
, g(_g)
|
||||
, b(_b)
|
||||
, a(_a)
|
||||
{}
|
||||
|
||||
explicit Color4F(const Color3B &color3B)
|
||||
: r(color3B.r / 255.0f)
|
||||
, g(color3B.g / 255.0f)
|
||||
, b(color3B.b / 255.0f)
|
||||
, a(1.f)
|
||||
{}
|
||||
|
||||
explicit Color4F(const Color4B &color4B)
|
||||
: r(color4B.r / 255.0f)
|
||||
, g(color4B.g / 255.0f)
|
||||
, b(color4B.b / 255.0f)
|
||||
, a(color4B.a / 255.0f)
|
||||
{}
|
||||
|
||||
Color4F(): r(0.f), g(0.f), b(0.f), a(0.f) {}
|
||||
|
||||
Color4F();
|
||||
Color4F(float _r, float _g, float _b, float _a);
|
||||
explicit Color4F(const Color3B& color);
|
||||
explicit Color4F(const Color4B& color);
|
||||
|
||||
bool operator==(const Color4F& right) const;
|
||||
bool operator==(const Color3B& right) const;
|
||||
bool operator==(const Color4B& right) const;
|
||||
bool operator!=(const Color4F& right) const;
|
||||
bool operator!=(const Color3B& right) const;
|
||||
bool operator!=(const Color4B& right) const;
|
||||
|
||||
bool equals(const Color4F &other)
|
||||
{
|
||||
return (this->r == other.r &&
|
||||
this->g == other.g &&
|
||||
this->b == other.b &&
|
||||
this->a == other.a);
|
||||
return (*this == other);
|
||||
}
|
||||
|
||||
GLfloat r;
|
||||
|
|
|
@ -354,8 +354,8 @@ void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode
|
|||
|
||||
for (auto& touch : touchEvent._touches)
|
||||
{
|
||||
// delete the touch object.
|
||||
delete touch;
|
||||
// release the touch object.
|
||||
touch->release();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -380,8 +380,8 @@ Image::Image()
|
|||
, _fileType(Format::UNKOWN)
|
||||
, _renderFormat(Texture2D::PixelFormat::NONE)
|
||||
, _preMulti(false)
|
||||
, _hasPremultipliedAlpha(true)
|
||||
, _numberOfMipmaps(0)
|
||||
, _hasPremultipliedAlpha(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -602,7 +602,7 @@ bool Image::isWebp(const unsigned char * data, int dataLen)
|
|||
|
||||
bool Image::isPvr(const unsigned char * data, int dataLen)
|
||||
{
|
||||
if (dataLen < sizeof(PVRv2TexHeader) || dataLen < sizeof(PVRv3TexHeader))
|
||||
if (static_cast<size_t>(dataLen) < sizeof(PVRv2TexHeader) || static_cast<size_t>(dataLen) < sizeof(PVRv3TexHeader))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1283,7 +1283,7 @@ bool Image::initWithPVRv2Data(const unsigned char * data, int dataLen)
|
|||
|
||||
bool Image::initWithPVRv3Data(const unsigned char * data, int dataLen)
|
||||
{
|
||||
if (dataLen < sizeof(PVRv3TexHeader))
|
||||
if (static_cast<size_t>(dataLen) < sizeof(PVRv3TexHeader))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -153,16 +153,6 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char*
|
|||
|
||||
if (fullPath[0] != '/')
|
||||
{
|
||||
|
||||
// fullPathForFilename is not thread safe.
|
||||
if (forAsync) {
|
||||
LOGD("Async loading not supported. fullPathForFilename is not thread safe.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
string fullPath = fullPathForFilename(filename);
|
||||
LOGD("full path = %s", fullPath.c_str());
|
||||
|
||||
string relativePath = string();
|
||||
|
||||
size_t position = fullPath.find("assets/");
|
||||
|
|
|
@ -284,8 +284,8 @@ EGLView* EGLView::s_pEglView = nullptr;
|
|||
|
||||
EGLView::EGLView()
|
||||
: _captured(false)
|
||||
, _frameZoomFactor(1.0f)
|
||||
, _supportTouch(false)
|
||||
, _frameZoomFactor(1.0f)
|
||||
, _mainWindow(nullptr)
|
||||
{
|
||||
CCASSERT(nullptr == s_pEglView, "EGLView is singleton, Should be inited only one time\n");
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
|
||||
/**
|
||||
@brief Release the shared Engine object
|
||||
@warning It must be called before the application exit, or a memroy leak will be casued.
|
||||
@warning It must be called before the application exit, or a memory leak will be casued.
|
||||
*/
|
||||
static void end();
|
||||
|
||||
|
|
|
@ -387,7 +387,7 @@ bool CCBReader::readHeader()
|
|||
int magicBytes = *((int*)(this->_bytes + this->_currentByte));
|
||||
this->_currentByte += 4;
|
||||
|
||||
if(CC_SWAP_INT32_LITTLE_TO_HOST(magicBytes) != 'ccbi') {
|
||||
if(CC_SWAP_INT32_LITTLE_TO_HOST(magicBytes) != (*reinterpret_cast<const int*>("ccbi"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,11 @@ Dictionary* NodeLoader::getCustomProperties()
|
|||
Node * NodeLoader::loadNode(Node * pParent, CCBReader * ccbReader) {
|
||||
Node * ccNode = this->createNode(pParent, ccbReader);
|
||||
|
||||
//this->parseProperties(ccNode, pParent, ccbReader);
|
||||
//clear _customProperties, ready for load next node.
|
||||
if (_customProperties != nullptr)
|
||||
{
|
||||
_customProperties->removeAllObjects();
|
||||
}
|
||||
|
||||
return ccNode;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,13 @@ protected:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::extension::Scale9Sprite);
|
||||
virtual cocos2d::extension::Scale9Sprite * createNode(cocos2d::Node * pParent, cocosbuilder::CCBReader * ccbReader) {
|
||||
cocos2d::extension::Scale9Sprite* pNode = cocos2d::extension::Scale9Sprite::create();
|
||||
|
||||
pNode->setAnchorPoint(cocos2d::Point(0,0));
|
||||
|
||||
return pNode;
|
||||
};
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
|
|
|
@ -33,16 +33,16 @@ using namespace gui;
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
ActionNode::ActionNode()
|
||||
: _currentFrameIndex(0)
|
||||
, _destFrameIndex(0)
|
||||
, _fUnitTime(0.1f)
|
||||
, _actionTag(0)
|
||||
, _actionSpawn(NULL)
|
||||
, _action(NULL)
|
||||
, _object(NULL)
|
||||
, _frameArray(NULL)
|
||||
, _frameArrayNum(0)
|
||||
ActionNode::ActionNode()
|
||||
: _currentFrameIndex(0)
|
||||
, _destFrameIndex(0)
|
||||
, _fUnitTime(0.1f)
|
||||
, _actionTag(0)
|
||||
, _actionSpawn(NULL)
|
||||
, _action(NULL)
|
||||
, _object(NULL)
|
||||
, _frameArray(NULL)
|
||||
, _frameArrayNum(0)
|
||||
{
|
||||
_frameArray = Array::create();
|
||||
_frameArray->retain();
|
||||
|
@ -322,7 +322,7 @@ Spawn * ActionNode::refreshActionProperty()
|
|||
return _actionSpawn;
|
||||
}
|
||||
|
||||
void ActionNode::playAction(bool bloop)
|
||||
void ActionNode::playAction()
|
||||
{
|
||||
if ( _object == NULL || _actionSpawn == NULL)
|
||||
{
|
||||
|
@ -333,14 +333,8 @@ void ActionNode::playAction(bool bloop)
|
|||
{
|
||||
_action->release();
|
||||
}
|
||||
if (bloop)
|
||||
{
|
||||
_action = RepeatForever::create(_actionSpawn);
|
||||
}
|
||||
else
|
||||
{
|
||||
_action = Sequence::create(_actionSpawn, NULL);
|
||||
}
|
||||
|
||||
_action = Sequence::create(_actionSpawn, NULL);
|
||||
_action->retain();
|
||||
|
||||
this->runAction();
|
||||
|
@ -480,4 +474,14 @@ void ActionNode::easingToFrame(float duration,float delayTime,ActionFrame* destF
|
|||
cAction->update(delayTime);
|
||||
}
|
||||
|
||||
|
||||
bool ActionNode::isActionDoneOnce()
|
||||
{
|
||||
if (_action == nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return _action->isDone();
|
||||
}
|
||||
|
||||
}
|
|
@ -136,10 +136,8 @@ public:
|
|||
|
||||
/**
|
||||
* Play the action.
|
||||
*
|
||||
* @param bloop true the
|
||||
*/
|
||||
virtual void playAction(bool bloop);
|
||||
virtual void playAction();
|
||||
|
||||
/**
|
||||
* Stop the action.
|
||||
|
@ -148,6 +146,13 @@ public:
|
|||
|
||||
/*init properties with a json dictionary*/
|
||||
virtual void initWithDictionary(JsonDictionary* dic,cocos2d::Object* root);
|
||||
|
||||
/**
|
||||
* Gets if the action is done once time.
|
||||
*
|
||||
* @return that if the action is done once time
|
||||
*/
|
||||
virtual bool isActionDoneOnce();
|
||||
protected:
|
||||
int _currentFrameIndex;
|
||||
int _destFrameIndex;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "cocostudio/CCActionObject.h"
|
||||
#include "cocostudio/DictionaryHelper.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
using namespace cocos2d;
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
|
@ -37,15 +37,19 @@ ActionObject::ActionObject()
|
|||
, _bPlaying(false)
|
||||
, _fUnitTime(0.1f)
|
||||
, _currentTime(0.0f)
|
||||
, _pScheduler(NULL)
|
||||
{
|
||||
_actionNodeList = Array::create();
|
||||
_actionNodeList->retain();
|
||||
_pScheduler = new Scheduler();
|
||||
Director::sharedDirector()->getScheduler()->scheduleUpdateForTarget(_pScheduler, 0, false);
|
||||
}
|
||||
|
||||
ActionObject::~ActionObject()
|
||||
{
|
||||
_actionNodeList->removeAllObjects();
|
||||
_actionNodeList->release();
|
||||
CC_SAFE_DELETE(_pScheduler);
|
||||
}
|
||||
|
||||
void ActionObject::setName(const char* name)
|
||||
|
@ -134,11 +138,16 @@ void ActionObject::removeActionNode(ActionNode* node)
|
|||
void ActionObject::play()
|
||||
{
|
||||
stop();
|
||||
this->updateToFrameByTime(0.0f);
|
||||
int frameNum = _actionNodeList->count();
|
||||
for ( int i = 0; i < frameNum; i++ )
|
||||
{
|
||||
ActionNode* actionNode = (ActionNode*)_actionNodeList->getObjectAtIndex(i);
|
||||
actionNode->playAction( getLoop());
|
||||
actionNode->playAction();
|
||||
}
|
||||
if (_loop)
|
||||
{
|
||||
_pScheduler->scheduleSelector(schedule_selector(ActionObject::simulationActionUpdate), this, 0.0f , kRepeatForever, 0.0f, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,6 +166,7 @@ void ActionObject::stop()
|
|||
actionNode->stopAction();
|
||||
}
|
||||
|
||||
_pScheduler->unscheduleSelector(schedule_selector(ActionObject::simulationActionUpdate), this);
|
||||
_bPause = false;
|
||||
}
|
||||
|
||||
|
@ -174,4 +184,30 @@ void ActionObject::updateToFrameByTime(float fTime)
|
|||
}
|
||||
}
|
||||
|
||||
void ActionObject::simulationActionUpdate(float dt)
|
||||
{
|
||||
if (_loop)
|
||||
{
|
||||
bool isEnd = true;
|
||||
int nodeNum = _actionNodeList->count();
|
||||
|
||||
for ( int i = 0; i < nodeNum; i++ )
|
||||
{
|
||||
ActionNode* actionNode = (ActionNode*)_actionNodeList->objectAtIndex(i);
|
||||
|
||||
if (actionNode->isActionDoneOnce() == false)
|
||||
{
|
||||
isEnd = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isEnd)
|
||||
{
|
||||
this->play();
|
||||
}
|
||||
|
||||
CCLOG("ActionObject Update");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -142,7 +142,9 @@ public:
|
|||
|
||||
/*init properties with a json dictionary*/
|
||||
void initWithDictionary(JsonDictionary* dic,cocos2d::Object* root);
|
||||
|
||||
|
||||
/*scheduler update function*/
|
||||
void simulationActionUpdate(float dt);
|
||||
protected:
|
||||
cocos2d::Array* _actionNodeList;/*actionnode*/
|
||||
std::string _name;
|
||||
|
@ -151,6 +153,7 @@ protected:
|
|||
bool _bPlaying;
|
||||
float _fUnitTime;
|
||||
float _currentTime;
|
||||
cocos2d::Scheduler *_pScheduler;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class Bone;
|
|||
class ColliderFilter
|
||||
{
|
||||
public:
|
||||
~ColliderFilter() { }
|
||||
virtual ~ColliderFilter() { }
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
public:
|
||||
ColliderFilter(unsigned short categoryBits = 0x0001, unsigned short maskBits = 0xFFFF, signed short groupIndex = 0);
|
||||
|
|
|
@ -28,8 +28,7 @@ using namespace cocos2d;
|
|||
namespace cocostudio {
|
||||
|
||||
ComAttribute::ComAttribute(void)
|
||||
: _attributes(NULL)
|
||||
, _jsonDict(NULL)
|
||||
: _jsonDict(nullptr)
|
||||
{
|
||||
_name = "ComAttribute";
|
||||
}
|
||||
|
@ -37,14 +36,10 @@ ComAttribute::ComAttribute(void)
|
|||
ComAttribute::~ComAttribute(void)
|
||||
{
|
||||
CC_SAFE_DELETE(_jsonDict);
|
||||
CC_SAFE_RELEASE(_attributes);
|
||||
}
|
||||
|
||||
bool ComAttribute::init()
|
||||
{
|
||||
_attributes = Dictionary::create();
|
||||
_attributes->retain();
|
||||
|
||||
_jsonDict = new JsonDictionary();
|
||||
return true;
|
||||
}
|
||||
|
@ -66,123 +61,46 @@ ComAttribute* ComAttribute::create(void)
|
|||
void ComAttribute::setInt(const char *key, int value)
|
||||
{
|
||||
CCASSERT(key != NULL, "Argument must be non-nil");
|
||||
_attributes->setObject(Integer::create(value), key);
|
||||
}
|
||||
|
||||
void ComAttribute::setDouble(const char *key, double value)
|
||||
{
|
||||
CCASSERT(key != NULL, "Argument must be non-nil");
|
||||
_attributes->setObject(Double::create(value), key);
|
||||
_jsonDict->insertItem(key, value);
|
||||
}
|
||||
|
||||
void ComAttribute::setFloat(const char *key, float value)
|
||||
{
|
||||
CCASSERT(key != NULL, "Argument must be non-nil");
|
||||
_attributes->setObject(Float::create(value), key);
|
||||
_jsonDict->insertItem(key, value);
|
||||
}
|
||||
|
||||
void ComAttribute::setBool(const char *key, bool value)
|
||||
{
|
||||
CCASSERT(key != NULL, "Argument must be non-nil");
|
||||
_attributes->setObject(Bool::create(value), key);
|
||||
_jsonDict->insertItem(key, value);
|
||||
}
|
||||
|
||||
void ComAttribute::setCString(const char *key, const char *value)
|
||||
{
|
||||
CCASSERT(key != NULL, "Argument must be non-nil");
|
||||
_attributes->setObject(String::create(value), key);
|
||||
_jsonDict->insertItem(key, value);
|
||||
}
|
||||
|
||||
void ComAttribute::setObject(const char *key, Object *value)
|
||||
{
|
||||
CCASSERT(key != NULL, "Argument must be non-nil");
|
||||
_attributes->setObject(value, key);
|
||||
}
|
||||
|
||||
int ComAttribute::getInt(const char *key) const
|
||||
{
|
||||
Object *ret = _attributes->objectForKey(key);
|
||||
if( ret )
|
||||
{
|
||||
if( Integer *obj=dynamic_cast<Integer*>(ret) )
|
||||
return obj->getValue();
|
||||
|
||||
CCASSERT(false, "Key found, type is not integer");
|
||||
}
|
||||
|
||||
// XXX: Should it throw an exception ?
|
||||
CCLOG("Key not found: '%s'", key );
|
||||
return 0;
|
||||
}
|
||||
|
||||
double ComAttribute::getDouble(const char *key) const
|
||||
{
|
||||
Object *ret = _attributes->objectForKey(key);
|
||||
if( ret )
|
||||
{
|
||||
if( Double *obj=dynamic_cast<Double*>(ret) )
|
||||
return obj->getValue();
|
||||
|
||||
CCASSERT(false, "Key found, type is not double");
|
||||
}
|
||||
|
||||
// XXX: Should it throw an exception ?
|
||||
CCLOG("Key not found: '%s'", key );
|
||||
return 0.0;
|
||||
return _jsonDict->getItemIntValue(key, -1);
|
||||
}
|
||||
|
||||
float ComAttribute::getFloat(const char *key) const
|
||||
{
|
||||
Object *ret = _attributes->objectForKey(key);
|
||||
if( ret )
|
||||
{
|
||||
if( Float *obj=dynamic_cast<Float*>(ret) )
|
||||
return obj->getValue();
|
||||
|
||||
CCASSERT(false, "Key found, type is not float");
|
||||
}
|
||||
|
||||
// XXX: Should it throw an exception ?
|
||||
CCLOG("Key not found: '%s'", key );
|
||||
return 0.0;
|
||||
return _jsonDict->getItemFloatValue(key, -1.0f);
|
||||
}
|
||||
|
||||
bool ComAttribute::getBool(const char *key) const
|
||||
{
|
||||
Object *ret = _attributes->objectForKey(key);
|
||||
if( ret )
|
||||
{
|
||||
if( Bool *boolobj=dynamic_cast<Bool*>(ret) )
|
||||
return boolobj->getValue();
|
||||
if( String *strobj=dynamic_cast<String*>(ret) )
|
||||
return strobj->boolValue();
|
||||
CCASSERT(false, "Key found, type is not Bool");
|
||||
}
|
||||
|
||||
// XXX: Should it throw an exception ?
|
||||
CCLOG("Key not found: '%s'", key );
|
||||
return false;
|
||||
return _jsonDict->getItemBoolvalue(key, false);
|
||||
}
|
||||
|
||||
const char* ComAttribute::getCString(const char *key) const
|
||||
{
|
||||
Object *ret = _attributes->objectForKey(key);
|
||||
if( ret )
|
||||
{
|
||||
if( String *str=dynamic_cast<String*>(ret) )
|
||||
return str->getCString();
|
||||
|
||||
CCASSERT(false, "Key found, type is not CString");
|
||||
}
|
||||
|
||||
// XXX: Should it throw an exception ?
|
||||
CCLOG("Key not found: '%s'", key );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Object* ComAttribute::getObject(const char *key) const
|
||||
{
|
||||
return _attributes->objectForKey(key);
|
||||
return _jsonDict->getItemStringValue(key);
|
||||
}
|
||||
|
||||
JsonDictionary* ComAttribute::getDict() const
|
||||
|
|
|
@ -47,24 +47,20 @@ protected:
|
|||
public:
|
||||
virtual bool init();
|
||||
static ComAttribute* create(void);
|
||||
|
||||
|
||||
void setInt(const char *key, int value);
|
||||
void setDouble(const char *key, double value);
|
||||
void setFloat(const char *key, float value);
|
||||
void setBool(const char *key, bool value);
|
||||
void setCString(const char *key, const char *value);
|
||||
void setObject(const char *key, Object *value);
|
||||
|
||||
int getInt(const char *key) const;
|
||||
double getDouble(const char *key) const;
|
||||
float getFloat(const char *key) const;
|
||||
bool getBool(const char *key) const;
|
||||
const char* getCString(const char *key) const;
|
||||
cocos2d::Object* getObject(const char *key) const;
|
||||
|
||||
JsonDictionary* getDict() const;
|
||||
|
||||
private:
|
||||
cocos2d::Dictionary *_attributes;
|
||||
JsonDictionary *_jsonDict;
|
||||
|
||||
};
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace cocostudio {
|
|||
|
||||
class ComController : public cocos2d::Component, public InputDelegate
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
ComController(void);
|
||||
|
||||
public:
|
||||
|
@ -51,10 +51,10 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onExit();
|
||||
virtual void update(float delta);
|
||||
virtual bool isEnabled() const;
|
||||
virtual void setEnabled(bool b);
|
||||
virtual void onExit() override;
|
||||
virtual void update(float delta) override;
|
||||
virtual bool isEnabled() const override;
|
||||
virtual void setEnabled(bool b) override;
|
||||
|
||||
static ComController* create(void);
|
||||
};
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
namespace cocostudio {
|
||||
|
||||
ComRender::ComRender(void)
|
||||
: _render(NULL)
|
||||
: _render(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -242,11 +242,11 @@ void DataReaderHelper::purge()
|
|||
|
||||
DataReaderHelper::DataReaderHelper()
|
||||
: _loadingThread(nullptr)
|
||||
, _asyncStructQueue(nullptr)
|
||||
, _dataQueue(nullptr)
|
||||
, need_quit(false)
|
||||
, _asyncRefCount(0)
|
||||
, _asyncRefTotalCount(0)
|
||||
, need_quit(false)
|
||||
, _asyncStructQueue(nullptr)
|
||||
, _dataQueue(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
static GUIReader* sharedReader = NULL;
|
||||
static GUIReader* sharedReader = nullptr;
|
||||
|
||||
GUIReader::GUIReader():
|
||||
m_strFilePath("")
|
||||
|
@ -122,26 +122,26 @@ const cocos2d::Size GUIReader::getFileDesignSize(const char* fileName) const
|
|||
UIWidget* GUIReader::widgetFromJsonFile(const char *fileName)
|
||||
{
|
||||
DictionaryHelper* dicHelper = DICTOOL;
|
||||
const char *des = NULL;
|
||||
const char *des = nullptr;
|
||||
std::string jsonpath;
|
||||
JsonDictionary *jsonDict = NULL;
|
||||
JsonDictionary *jsonDict = nullptr;
|
||||
jsonpath = CCFileUtils::getInstance()->fullPathForFilename(fileName);
|
||||
int pos = jsonpath.find_last_of('/');
|
||||
m_strFilePath = jsonpath.substr(0,pos+1);
|
||||
long size = 0;
|
||||
des = (char*)(CCFileUtils::getInstance()->getFileData(jsonpath.c_str(),"r" , &size));
|
||||
if(NULL == des || strcmp(des, "") == 0)
|
||||
if(nullptr == des || strcmp(des, "") == 0)
|
||||
{
|
||||
printf("read json file[%s] error!\n", fileName);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
std::string strDes(des);
|
||||
jsonDict = new JsonDictionary();
|
||||
jsonDict->initWithDescription(strDes.c_str());
|
||||
|
||||
UIWidget* widget = NULL;
|
||||
UIWidget* widget = nullptr;
|
||||
const char* fileVersion = dicHelper->getStringValue_json(jsonDict, "version");
|
||||
WidgetPropertiesReader * pReader = NULL;
|
||||
WidgetPropertiesReader * pReader = nullptr;
|
||||
if (fileVersion)
|
||||
{
|
||||
int versionInteger = getVersionInteger(fileVersion);
|
||||
|
@ -221,7 +221,7 @@ UIWidget* WidgetPropertiesReader0250::createWidget(JsonDictionary* data, const c
|
|||
UIWidget* WidgetPropertiesReader0250::widgetFromJsonDictionary(JsonDictionary *data)
|
||||
{
|
||||
DictionaryHelper* dicHelper = DICTOOL;
|
||||
UIWidget* widget = NULL;
|
||||
UIWidget* widget = nullptr;
|
||||
const char* classname = dicHelper->getStringValue_json(data, "classname");
|
||||
JsonDictionary* uiOptions = dicHelper->getSubDictionary_json(data, "options");
|
||||
if (classname && strcmp(classname, "Button") == 0)
|
||||
|
@ -397,9 +397,9 @@ void WidgetPropertiesReader0250::setPropsForButtonFromJsonDictionary(UIWidget*wi
|
|||
const char* pressedFileName = dicHelper->getStringValue_json(options, "pressed");
|
||||
const char* disabledFileName = dicHelper->getStringValue_json(options, "disabled");
|
||||
|
||||
const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL;
|
||||
const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL;
|
||||
const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL;
|
||||
const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr;
|
||||
const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr;
|
||||
const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr;
|
||||
bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture");
|
||||
if (scale9Enable)
|
||||
{
|
||||
|
@ -484,11 +484,11 @@ void WidgetPropertiesReader0250::setPropsForCheckBoxFromJsonDictionary(UIWidget*
|
|||
std::string tp_bd = m_strFilePath;
|
||||
std::string tp_cd = m_strFilePath;
|
||||
|
||||
const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():NULL;
|
||||
const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():NULL;
|
||||
const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():NULL;
|
||||
const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():NULL;
|
||||
const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():NULL;
|
||||
const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():nullptr;
|
||||
const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():nullptr;
|
||||
const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():nullptr;
|
||||
const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():nullptr;
|
||||
const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():nullptr;
|
||||
bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture");
|
||||
|
||||
if (useMergedTexture)
|
||||
|
@ -519,7 +519,7 @@ void WidgetPropertiesReader0250::setPropsForImageViewFromJsonDictionary(UIWidget
|
|||
imageView->setScale9Enabled(scale9Enable);
|
||||
|
||||
std::string tp_i = m_strFilePath;
|
||||
const char* imageFileName_tp = NULL;
|
||||
const char* imageFileName_tp = nullptr;
|
||||
if (imageFileName && (strcmp(imageFileName, "") != 0))
|
||||
{
|
||||
imageFileName_tp = tp_i.append(imageFileName).c_str();
|
||||
|
@ -619,7 +619,7 @@ void WidgetPropertiesReader0250::setPropsForLabelAtlasFromJsonDictionary(UIWidge
|
|||
if (sv && cmf && iw && ih && scm && (strcmp(dicHelper->getStringValue_json(options, "charMapFile"), "") != 0))
|
||||
{
|
||||
std::string tp_c = m_strFilePath;
|
||||
const char* cmf_tp = NULL;
|
||||
const char* cmf_tp = nullptr;
|
||||
const char* cmft = dicHelper->getStringValue_json(options, "charMapFile");
|
||||
cmf_tp = tp_c.append(cmft).c_str();
|
||||
|
||||
|
@ -668,7 +668,7 @@ void WidgetPropertiesReader0250::setPropsForLayoutFromJsonDictionary(UIWidget*wi
|
|||
|
||||
std::string tp_b = m_strFilePath;
|
||||
const char* imageFileName = dicHelper->getStringValue_json(options, "backGroundImage");
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL;
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr;
|
||||
bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture");
|
||||
if (backGroundScale9Enable)
|
||||
{
|
||||
|
@ -732,7 +732,7 @@ void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(UIWidget*wi
|
|||
{
|
||||
std::string tp_b = m_strFilePath;
|
||||
const char* imageFileName = dicHelper->getStringValue_json(options, "barFileName");
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL;
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr;
|
||||
if (useMergedTexture)
|
||||
{
|
||||
slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST);
|
||||
|
@ -747,7 +747,7 @@ void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(UIWidget*wi
|
|||
{
|
||||
std::string tp_b = m_strFilePath;
|
||||
const char* imageFileName = dicHelper->getStringValue_json(options, "barFileName");
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL;
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr;
|
||||
if (useMergedTexture)
|
||||
{
|
||||
slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST);
|
||||
|
@ -766,9 +766,9 @@ void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(UIWidget*wi
|
|||
const char* pressedFileName = dicHelper->getStringValue_json(options, "ballPressed");
|
||||
const char* disabledFileName = dicHelper->getStringValue_json(options, "ballDisabled");
|
||||
|
||||
const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL;
|
||||
const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL;
|
||||
const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL;
|
||||
const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr;
|
||||
const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr;
|
||||
const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr;
|
||||
if (useMergedTexture)
|
||||
{
|
||||
slider->loadSlidBallTextures(normalFileName,pressedFileName,disabledFileName,UI_TEX_TYPE_PLIST);
|
||||
|
@ -781,7 +781,7 @@ void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(UIWidget*wi
|
|||
|
||||
std::string tp_b = m_strFilePath;
|
||||
const char* imageFileName = dicHelper->getStringValue_json(options, "progressBarFileName");
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL;
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr;
|
||||
if (useMergedTexture)
|
||||
{
|
||||
slider->loadProgressBarTexture(imageFileName, UI_TEX_TYPE_PLIST);
|
||||
|
@ -852,7 +852,7 @@ void WidgetPropertiesReader0250::setPropsForLoadingBarFromJsonDictionary(UIWidge
|
|||
bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture");
|
||||
std::string tp_b = m_strFilePath;
|
||||
const char*imageFileName = dicHelper->getStringValue_json(options, "texture");
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL;
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr;
|
||||
if (useMergedTexture)
|
||||
{
|
||||
loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST);
|
||||
|
@ -875,7 +875,7 @@ void WidgetPropertiesReader0250::setPropsForLabelBMFontFromJsonDictionary(UIWidg
|
|||
UILabelBMFont* labelBMFont = (UILabelBMFont*)widget;
|
||||
|
||||
std::string tp_c = m_strFilePath;
|
||||
const char* cmf_tp = NULL;
|
||||
const char* cmf_tp = nullptr;
|
||||
const char* cmft = dicHelper->getStringValue_json(options, "fileName");
|
||||
cmf_tp = tp_c.append(cmft).c_str();
|
||||
|
||||
|
@ -940,7 +940,7 @@ UIWidget* WidgetPropertiesReader0300::createWidget(JsonDictionary* data, const c
|
|||
UIWidget* WidgetPropertiesReader0300::widgetFromJsonDictionary(JsonDictionary *data)
|
||||
{
|
||||
DictionaryHelper* dicHelper = DICTOOL;
|
||||
UIWidget* widget = NULL;
|
||||
UIWidget* widget = nullptr;
|
||||
const char* classname = dicHelper->getStringValue_json(data, "classname");
|
||||
JsonDictionary* uiOptions = dicHelper->getSubDictionary_json(data, "options");
|
||||
if (classname && strcmp(classname, "Button") == 0)
|
||||
|
@ -1033,6 +1033,12 @@ UIWidget* WidgetPropertiesReader0300::widgetFromJsonDictionary(JsonDictionary *d
|
|||
}
|
||||
CC_SAFE_DELETE(subData);
|
||||
}
|
||||
|
||||
UILayout* layout = dynamic_cast<UILayout*>(widget);
|
||||
if (layout)
|
||||
{
|
||||
layout->doLayout();
|
||||
}
|
||||
|
||||
CC_SAFE_DELETE(uiOptions);
|
||||
return widget;
|
||||
|
@ -1047,6 +1053,12 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(UIWidget*wi
|
|||
widget->ignoreContentAdaptWithSize(dicHelper->getBooleanValue_json(options, "ignoreSize"));
|
||||
}
|
||||
|
||||
widget->setSizeType((SizeType)dicHelper->getIntValue_json(options, "sizeType"));
|
||||
widget->setPositionType((PositionType)dicHelper->getIntValue_json(options, "positionType"));
|
||||
|
||||
widget->setSizePercent(Point(dicHelper->getFloatValue_json(options, "sizePercentX"), dicHelper->getFloatValue_json(options, "sizePercentY")));
|
||||
widget->setPositionPercent(Point(dicHelper->getFloatValue_json(options, "positionPercentX"), dicHelper->getFloatValue_json(options, "positionPercentY")));
|
||||
|
||||
float w = dicHelper->getFloatValue_json(options, "width");
|
||||
float h = dicHelper->getFloatValue_json(options, "height");
|
||||
widget->setSize(Size(w, h));
|
||||
|
@ -1082,6 +1094,46 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(UIWidget*wi
|
|||
}
|
||||
int z = dicHelper->getIntValue_json(options, "ZOrder");
|
||||
widget->setZOrder(z);
|
||||
|
||||
JsonDictionary* layoutParameterDic = dicHelper->getSubDictionary_json(options, "layoutParameter");
|
||||
if (layoutParameterDic)
|
||||
{
|
||||
int paramType = dicHelper->getIntValue_json(layoutParameterDic, "type");
|
||||
UILayoutParameter* parameter = nullptr;
|
||||
switch (paramType)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
parameter = UILinearLayoutParameter::create();
|
||||
int gravity = dicHelper->getIntValue_json(layoutParameterDic, "gravity");
|
||||
((UILinearLayoutParameter*)parameter)->setGravity((UILinearGravity)gravity);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
parameter = UIRelativeLayoutParameter::create();
|
||||
UIRelativeLayoutParameter* rParameter = (UIRelativeLayoutParameter*)parameter;
|
||||
const char* relativeName = dicHelper->getStringValue_json(layoutParameterDic, "relativeName");
|
||||
rParameter->setRelativeName(relativeName);
|
||||
const char* relativeToName = dicHelper->getStringValue_json(layoutParameterDic, "relativeToName");
|
||||
rParameter->setRelativeToWidgetName(relativeToName);
|
||||
int align = dicHelper->getIntValue_json(layoutParameterDic, "align");
|
||||
rParameter->setAlign((UIRelativeAlign)align);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
float mgl = dicHelper->getFloatValue_json(layoutParameterDic, "marginLeft");
|
||||
float mgt = dicHelper->getFloatValue_json(layoutParameterDic, "marginTop");
|
||||
float mgr = dicHelper->getFloatValue_json(layoutParameterDic, "marginRight");
|
||||
float mgb = dicHelper->getFloatValue_json(layoutParameterDic, "marginDown");
|
||||
parameter->setMargin(UIMargin(mgl, mgt, mgr, mgb));
|
||||
widget->setLayoutParameter(parameter);
|
||||
}
|
||||
CC_SAFE_DELETE(layoutParameterDic);
|
||||
}
|
||||
|
||||
void WidgetPropertiesReader0300::setColorPropsForWidgetFromJsonDictionary(UIWidget *widget, JsonDictionary *options)
|
||||
|
@ -1126,7 +1178,7 @@ void WidgetPropertiesReader0300::setPropsForButtonFromJsonDictionary(UIWidget*wi
|
|||
{
|
||||
std::string tp_n = m_strFilePath;
|
||||
const char* normalFileName = dicHelper->getStringValue_json(normalDic, "path");
|
||||
const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL;
|
||||
const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr;
|
||||
button->loadTextureNormal(normalFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1148,7 +1200,7 @@ void WidgetPropertiesReader0300::setPropsForButtonFromJsonDictionary(UIWidget*wi
|
|||
{
|
||||
std::string tp_p = m_strFilePath;
|
||||
const char* pressedFileName = dicHelper->getStringValue_json(pressedDic, "path");
|
||||
const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL;
|
||||
const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr;
|
||||
button->loadTexturePressed(pressedFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1170,7 +1222,7 @@ void WidgetPropertiesReader0300::setPropsForButtonFromJsonDictionary(UIWidget*wi
|
|||
{
|
||||
std::string tp_d = m_strFilePath;
|
||||
const char* disabledFileName = dicHelper->getStringValue_json(disabledDic, "path");
|
||||
const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL;
|
||||
const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr;
|
||||
button->loadTextureDisabled(disabledFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1245,7 +1297,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(UIWidget*
|
|||
{
|
||||
std::string tp_b = m_strFilePath;
|
||||
const char* backGroundFileName = dicHelper->getStringValue_json(backGroundDic, "path");
|
||||
const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():NULL;
|
||||
const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():nullptr;
|
||||
checkBox->loadTextureBackGround(backGroundFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1268,7 +1320,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(UIWidget*
|
|||
{
|
||||
std::string tp_bs = m_strFilePath;
|
||||
const char* backGroundSelectedFileName = dicHelper->getStringValue_json(backGroundSelectedDic, "path");
|
||||
const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():NULL;
|
||||
const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():nullptr;
|
||||
checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1291,7 +1343,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(UIWidget*
|
|||
{
|
||||
std::string tp_c = m_strFilePath;
|
||||
const char* frontCrossFileName = dicHelper->getStringValue_json(frontCrossDic, "path");
|
||||
const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():NULL;
|
||||
const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():nullptr;
|
||||
checkBox->loadTextureFrontCross(frontCrossFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1314,7 +1366,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(UIWidget*
|
|||
{
|
||||
std::string tp_bd = m_strFilePath;
|
||||
const char* backGroundDisabledFileName = dicHelper->getStringValue_json(backGroundDisabledDic, "path");
|
||||
const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():NULL;
|
||||
const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():nullptr;
|
||||
checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1337,7 +1389,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(UIWidget*
|
|||
{
|
||||
std::string tp_cd = m_strFilePath;
|
||||
const char* frontCrossDisabledFileName = dicHelper->getStringValue_json(options, "path");
|
||||
const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():NULL;
|
||||
const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():nullptr;
|
||||
checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1370,7 +1422,7 @@ void WidgetPropertiesReader0300::setPropsForImageViewFromJsonDictionary(UIWidget
|
|||
{
|
||||
std::string tp_i = m_strFilePath;
|
||||
const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path");
|
||||
const char* imageFileName_tp = NULL;
|
||||
const char* imageFileName_tp = nullptr;
|
||||
if (imageFileName && (strcmp(imageFileName, "") != 0))
|
||||
{
|
||||
imageFileName_tp = tp_i.append(imageFileName).c_str();
|
||||
|
@ -1540,7 +1592,7 @@ void WidgetPropertiesReader0300::setPropsForLayoutFromJsonDictionary(UIWidget*wi
|
|||
{
|
||||
std::string tp_b = m_strFilePath;
|
||||
const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path");
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL;
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr;
|
||||
panel->setBackGroundImage(imageFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1563,6 +1615,7 @@ void WidgetPropertiesReader0300::setPropsForLayoutFromJsonDictionary(UIWidget*wi
|
|||
float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight");
|
||||
panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch));
|
||||
}
|
||||
panel->setLayoutType((LayoutType)dicHelper->getIntValue_json(options, "layoutType"));
|
||||
setColorPropsForWidgetFromJsonDictionary(widget,options);
|
||||
}
|
||||
|
||||
|
@ -1603,7 +1656,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(UIWidget*wi
|
|||
{
|
||||
std::string tp_b = m_strFilePath;
|
||||
const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path");
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL;
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr;
|
||||
slider->loadBarTexture(imageFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1630,7 +1683,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(UIWidget*wi
|
|||
{
|
||||
std::string tp_b = m_strFilePath;
|
||||
const char*imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path");
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL;
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr;
|
||||
slider->loadBarTexture(imageFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1655,7 +1708,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(UIWidget*wi
|
|||
{
|
||||
std::string tp_n = m_strFilePath;
|
||||
const char* normalFileName = dicHelper->getStringValue_json(normalDic, "path");
|
||||
const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL;
|
||||
const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr;
|
||||
slider->loadSlidBallTextureNormal(normalFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1678,7 +1731,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(UIWidget*wi
|
|||
{
|
||||
std::string tp_p = m_strFilePath;
|
||||
const char* pressedFileName = dicHelper->getStringValue_json(pressedDic, "path");
|
||||
const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL;
|
||||
const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr;
|
||||
slider->loadSlidBallTexturePressed(pressedFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1701,7 +1754,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(UIWidget*wi
|
|||
{
|
||||
std::string tp_d = m_strFilePath;
|
||||
const char* disabledFileName = dicHelper->getStringValue_json(disabledDic, "path");
|
||||
const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL;
|
||||
const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr;
|
||||
slider->loadSlidBallTextureDisabled(disabledFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1726,7 +1779,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(UIWidget*wi
|
|||
{
|
||||
std::string tp_b = m_strFilePath;
|
||||
const char* imageFileName = dicHelper->getStringValue_json(progressBarDic, "path");
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL;
|
||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr;
|
||||
slider->loadProgressBarTexture(imageFileName_tp);
|
||||
break;
|
||||
}
|
||||
|
@ -1807,7 +1860,7 @@ void WidgetPropertiesReader0300::setPropsForLoadingBarFromJsonDictionary(UIWidge
|
|||
{
|
||||
std::string tp_i = m_strFilePath;
|
||||
const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path");
|
||||
const char* imageFileName_tp = NULL;
|
||||
const char* imageFileName_tp = nullptr;
|
||||
if (imageFileName && (strcmp(imageFileName, "") != 0))
|
||||
{
|
||||
imageFileName_tp = tp_i.append(imageFileName).c_str();
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace gui;
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
SceneReader* SceneReader::s_sharedReader = NULL;
|
||||
SceneReader* SceneReader::s_sharedReader = nullptr;
|
||||
|
||||
SceneReader::SceneReader()
|
||||
{
|
||||
|
@ -49,14 +49,14 @@ namespace cocostudio {
|
|||
{
|
||||
long size = 0;
|
||||
const char* pData = 0;
|
||||
cocos2d::Node *pNode = NULL;
|
||||
cocos2d::Node *pNode = nullptr;
|
||||
do {
|
||||
CC_BREAK_IF(pszFileName == NULL);
|
||||
CC_BREAK_IF(pszFileName == nullptr);
|
||||
pData = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pszFileName, "r", &size));
|
||||
CC_BREAK_IF(pData == NULL || strcmp(pData, "") == 0);
|
||||
CC_BREAK_IF(pData == nullptr || strcmp(pData, "") == 0);
|
||||
JsonDictionary *jsonDict = new JsonDictionary();
|
||||
jsonDict->initWithDescription(pData);
|
||||
pNode = createObject(jsonDict,NULL);
|
||||
pNode = createObject(jsonDict,nullptr);
|
||||
CC_SAFE_DELETE(jsonDict);
|
||||
} while (0);
|
||||
|
||||
|
@ -68,8 +68,8 @@ namespace cocostudio {
|
|||
const char *className = inputFiles->getItemStringValue("classname");
|
||||
if(strcmp(className, "CCNode") == 0)
|
||||
{
|
||||
Node* gb = NULL;
|
||||
if(NULL == parenet)
|
||||
Node* gb = nullptr;
|
||||
if(nullptr == parenet)
|
||||
{
|
||||
gb = Node::create();
|
||||
}
|
||||
|
@ -97,26 +97,26 @@ namespace cocostudio {
|
|||
std::string pPath;
|
||||
std::string pPlistFile;
|
||||
int nResType = 0;
|
||||
if (fileData != NULL)
|
||||
if (fileData != nullptr)
|
||||
{
|
||||
const char *file = fileData->getItemStringValue("path");
|
||||
nResType = fileData->getItemIntValue("resourceType", -1);
|
||||
const char *plistFile = fileData->getItemStringValue("plistFile");
|
||||
if (file != NULL)
|
||||
if (file != nullptr)
|
||||
{
|
||||
pPath.append(cocos2d::FileUtils::getInstance()->fullPathForFilename(file));
|
||||
}
|
||||
|
||||
if (plistFile != NULL)
|
||||
if (plistFile != nullptr)
|
||||
{
|
||||
pPlistFile.append(cocos2d::FileUtils::getInstance()->fullPathForFilename(plistFile));
|
||||
}
|
||||
CC_SAFE_DELETE(fileData);
|
||||
}
|
||||
|
||||
if (comName != NULL && strcmp(comName, "CCSprite") == 0)
|
||||
if (comName != nullptr && strcmp(comName, "CCSprite") == 0)
|
||||
{
|
||||
cocos2d::Sprite *pSprite = NULL;
|
||||
cocos2d::Sprite *pSprite = nullptr;
|
||||
|
||||
if (nResType == 0)
|
||||
{
|
||||
|
@ -144,16 +144,16 @@ namespace cocostudio {
|
|||
}
|
||||
|
||||
ComRender *pRender = ComRender::create(pSprite, "CCSprite");
|
||||
if (pComName != NULL)
|
||||
if (pComName != nullptr)
|
||||
{
|
||||
pRender->setName(pComName);
|
||||
}
|
||||
|
||||
gb->addComponent(pRender);
|
||||
}
|
||||
else if(comName != NULL && strcmp(comName, "CCTMXTiledMap") == 0)
|
||||
else if(comName != nullptr && strcmp(comName, "CCTMXTiledMap") == 0)
|
||||
{
|
||||
cocos2d::TMXTiledMap *pTmx = NULL;
|
||||
cocos2d::TMXTiledMap *pTmx = nullptr;
|
||||
if (nResType == 0)
|
||||
{
|
||||
if (pPath.find(".tmx") == pPath.npos)
|
||||
|
@ -168,13 +168,13 @@ namespace cocostudio {
|
|||
}
|
||||
|
||||
ComRender *pRender = ComRender::create(pTmx, "CCTMXTiledMap");
|
||||
if (pComName != NULL)
|
||||
if (pComName != nullptr)
|
||||
{
|
||||
pRender->setName(pComName);
|
||||
}
|
||||
gb->addComponent(pRender);
|
||||
}
|
||||
else if(comName != NULL && strcmp(comName, "CCParticleSystemQuad") == 0)
|
||||
else if(comName != nullptr && strcmp(comName, "CCParticleSystemQuad") == 0)
|
||||
{
|
||||
std::string::size_type pos = pPath.find(".plist");
|
||||
if (pos == pPath.npos)
|
||||
|
@ -182,7 +182,7 @@ namespace cocostudio {
|
|||
continue;
|
||||
}
|
||||
|
||||
cocos2d::ParticleSystemQuad *pParticle = NULL;
|
||||
cocos2d::ParticleSystemQuad *pParticle = nullptr;
|
||||
if (nResType == 0)
|
||||
{
|
||||
pParticle = ParticleSystemQuad::create(pPath.c_str());
|
||||
|
@ -194,13 +194,13 @@ namespace cocostudio {
|
|||
|
||||
pParticle->setPosition(0, 0);
|
||||
ComRender *pRender = ComRender::create(pParticle, "CCParticleSystemQuad");
|
||||
if (pComName != NULL)
|
||||
if (pComName != nullptr)
|
||||
{
|
||||
pRender->setName(pComName);
|
||||
}
|
||||
gb->addComponent(pRender);
|
||||
}
|
||||
else if(comName != NULL && strcmp(comName, "CCArmature") == 0)
|
||||
else if(comName != nullptr && strcmp(comName, "CCArmature") == 0)
|
||||
{
|
||||
if (nResType != 0)
|
||||
{
|
||||
|
@ -217,7 +217,7 @@ namespace cocostudio {
|
|||
const char *des = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(),"r" , &size));
|
||||
JsonDictionary *jsonDict = new JsonDictionary();
|
||||
jsonDict->initWithDescription(des);
|
||||
if(NULL == des || strcmp(des, "") == 0)
|
||||
if(nullptr == des || strcmp(des, "") == 0)
|
||||
{
|
||||
CCLOG("read json file[%s] error!\n", pPath.c_str());
|
||||
}
|
||||
|
@ -247,14 +247,14 @@ namespace cocostudio {
|
|||
|
||||
Armature *pAr = Armature::create(name);
|
||||
ComRender *pRender = ComRender::create(pAr, "CCArmature");
|
||||
if (pComName != NULL)
|
||||
if (pComName != nullptr)
|
||||
{
|
||||
pRender->setName(pComName);
|
||||
}
|
||||
gb->addComponent(pRender);
|
||||
|
||||
const char *actionName = subDict->getItemStringValue("selectedactionname");
|
||||
if (actionName != NULL && pAr->getAnimation() != NULL)
|
||||
if (actionName != nullptr && pAr->getAnimation() != nullptr)
|
||||
{
|
||||
pAr->getAnimation()->play(actionName);
|
||||
}
|
||||
|
@ -263,9 +263,9 @@ namespace cocostudio {
|
|||
CC_SAFE_DELETE(subData);
|
||||
CC_SAFE_DELETE_ARRAY(des);
|
||||
}
|
||||
else if(comName != NULL && strcmp(comName, "CCComAudio") == 0)
|
||||
else if(comName != nullptr && strcmp(comName, "CCComAudio") == 0)
|
||||
{
|
||||
ComAudio *pAudio = NULL;
|
||||
ComAudio *pAudio = nullptr;
|
||||
if (nResType == 0)
|
||||
{
|
||||
pAudio = ComAudio::create();
|
||||
|
@ -277,16 +277,16 @@ namespace cocostudio {
|
|||
pAudio->preloadEffect(pPath.c_str());
|
||||
gb->addComponent(pAudio);
|
||||
}
|
||||
else if(comName != NULL && strcmp(comName, "CCComAttribute") == 0)
|
||||
else if(comName != nullptr && strcmp(comName, "CCComAttribute") == 0)
|
||||
{
|
||||
ComAttribute *pAttribute = NULL;
|
||||
ComAttribute *pAttribute = nullptr;
|
||||
if (nResType == 0)
|
||||
{
|
||||
pAttribute = ComAttribute::create();
|
||||
long size = 0;
|
||||
const char* pData = 0;
|
||||
pData = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(), "r", &size));
|
||||
if(pData != NULL && strcmp(pData, "") != 0)
|
||||
if(pData != nullptr && strcmp(pData, "") != 0)
|
||||
{
|
||||
pAttribute->getDict()->initWithDescription(pData);
|
||||
}
|
||||
|
@ -298,9 +298,9 @@ namespace cocostudio {
|
|||
}
|
||||
gb->addComponent(pAttribute);
|
||||
}
|
||||
else if (comName != NULL && strcmp(comName, "CCBackgroundAudio") == 0)
|
||||
else if (comName != nullptr && strcmp(comName, "CCBackgroundAudio") == 0)
|
||||
{
|
||||
ComAudio *pAudio = NULL;
|
||||
ComAudio *pAudio = nullptr;
|
||||
if (nResType == 0)
|
||||
{
|
||||
pAudio = ComAudio::create();
|
||||
|
@ -316,14 +316,14 @@ namespace cocostudio {
|
|||
gb->addComponent(pAudio);
|
||||
pAudio->playBackgroundMusic(pPath.c_str(), bLoop);
|
||||
}
|
||||
else if(comName != NULL && strcmp(comName, "GUIComponent") == 0)
|
||||
else if(comName != nullptr && strcmp(comName, "GUIComponent") == 0)
|
||||
{
|
||||
gui::UILayer *pLayer = gui::UILayer::create();
|
||||
pLayer->scheduleUpdate();
|
||||
// UIWidget* widget= gui::UIHelper::instance()->createWidgetFromJsonFile(pPath.c_str());
|
||||
// pLayer->addWidget(widget);
|
||||
UIWidget* widget= GUIReader::shareReader()->widgetFromJsonFile(pPath.c_str());
|
||||
pLayer->addWidget(widget);
|
||||
ComRender *pRender = ComRender::create(pLayer, "GUIComponent");
|
||||
if (pComName != NULL)
|
||||
if (pComName != nullptr)
|
||||
{
|
||||
pRender->setName(pComName);
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ namespace cocostudio {
|
|||
return gb;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -377,7 +377,7 @@ namespace cocostudio {
|
|||
|
||||
SceneReader* SceneReader::getInstance()
|
||||
{
|
||||
if (s_sharedReader == NULL)
|
||||
if (s_sharedReader == nullptr)
|
||||
{
|
||||
s_sharedReader = new SceneReader();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~SceneReader(void);
|
||||
virtual ~SceneReader(void);
|
||||
|
||||
public:
|
||||
static SceneReader* getInstance();
|
||||
|
|
|
@ -132,7 +132,7 @@ namespace cocostudio {
|
|||
const char * JsonDictionary::getItemStringValue(const char *pszKey)
|
||||
{
|
||||
if (!isKeyValidate(pszKey, m_cValue) || !m_cValue[pszKey].isString())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return m_cValue[pszKey].asCString();
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ namespace cocostudio {
|
|||
!m_cValue[pszKey].isConvertibleTo(Json::arrayValue) &&
|
||||
!m_cValue[pszKey].isConvertibleTo(Json::objectValue)))
|
||||
{
|
||||
pNewDictionary = NULL;
|
||||
pNewDictionary = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -336,7 +336,7 @@ namespace cocostudio {
|
|||
return (*arrayValue)[nIndex].asCString();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -353,7 +353,7 @@ namespace cocostudio {
|
|||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -379,9 +379,9 @@ namespace cocostudio {
|
|||
inline Json::Value * JsonDictionary::validateArrayItem(const char *pszArrayKey, int nIndex)
|
||||
{
|
||||
if (!isKeyValidate(pszArrayKey, m_cValue) && !m_cValue[pszArrayKey].isArray() && !m_cValue[pszArrayKey].isConvertibleTo(Json::arrayValue))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (!m_cValue[pszArrayKey].isValidIndex(nIndex))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return &m_cValue[pszArrayKey];
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace cocostudio {
|
|||
{
|
||||
public:
|
||||
JsonDictionary();
|
||||
~JsonDictionary();
|
||||
virtual ~JsonDictionary();
|
||||
|
||||
public:
|
||||
void initWithDescription(const char *pszDescription);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
static DictionaryHelper* sharedHelper = NULL;
|
||||
static DictionaryHelper* sharedHelper = nullptr;
|
||||
|
||||
DictionaryHelper::DictionaryHelper()
|
||||
{
|
||||
|
@ -54,11 +54,11 @@ void DictionaryHelper::purgeDictionaryHelper()
|
|||
cocos2d::Dictionary* DictionaryHelper::getSubDictionary(cocos2d::Dictionary* root,const char* key)
|
||||
{
|
||||
if (!root) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
cocos2d::Object* obj = root->objectForKey(key);
|
||||
if (!obj) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return (cocos2d::Dictionary*)(obj);
|
||||
}
|
||||
|
@ -93,11 +93,11 @@ float DictionaryHelper::getFloatValue(cocos2d::Dictionary* root,const char* key)
|
|||
const char* DictionaryHelper::getStringValue(cocos2d::Dictionary* root,const char* key)
|
||||
{
|
||||
if (!root) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
cocos2d::Object* obj = root->objectForKey(key);
|
||||
if (!obj) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
cocos2d::String* cstr = (cocos2d::String*)(obj);
|
||||
return cstr->_string.c_str();
|
||||
|
@ -111,11 +111,11 @@ bool DictionaryHelper::getBooleanValue(cocos2d::Dictionary* root,const char* key
|
|||
cocos2d::Array* DictionaryHelper::getArrayValue(cocos2d::Dictionary *root, const char *key)
|
||||
{
|
||||
if (!root) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
cocos2d::Object* obj = root->objectForKey(key);
|
||||
if (!obj) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
cocos2d::Array* array = (cocos2d::Array*)(obj);
|
||||
return array;
|
||||
|
@ -124,7 +124,7 @@ cocos2d::Array* DictionaryHelper::getArrayValue(cocos2d::Dictionary *root, const
|
|||
cocos2d::Object* DictionaryHelper::checkObjectExist(cocos2d::Dictionary *root, const char *key)
|
||||
{
|
||||
if (!root) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return root->objectForKey(key);
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ const char* DictionaryHelper::objectToStringValue(cocos2d::Object *obj)
|
|||
{
|
||||
if (!obj)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
cocos2d::String* cstr = (cocos2d::String*)(obj);
|
||||
return cstr->_string.c_str();
|
||||
|
@ -172,7 +172,7 @@ cocos2d::Array* DictionaryHelper::objectToCCArray(cocos2d::Object *obj)
|
|||
{
|
||||
if (!obj)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
cocos2d::Array* array = (cocos2d::Array*)(obj);
|
||||
return array;
|
||||
|
@ -182,7 +182,7 @@ JsonDictionary* DictionaryHelper::getSubDictionary_json(JsonDictionary* root,con
|
|||
{
|
||||
if (!root)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return root->getSubDictionary(key);
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ const char* DictionaryHelper::getStringValue_json(JsonDictionary* root,const cha
|
|||
{
|
||||
if (!root)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return root->getItemStringValue(key);
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ const char* DictionaryHelper::getStringValueFromArray_json(JsonDictionary *root,
|
|||
{
|
||||
if (!root)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return root->getStringValueFromArray(arrayKey, idx);
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ JsonDictionary* DictionaryHelper::getDictionaryFromArray_json(JsonDictionary* ro
|
|||
{
|
||||
if (!root)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return root->getSubItemFromArray(arrayKey, idx);
|
||||
}
|
||||
|
|
|
@ -63,26 +63,26 @@ void CCSkeleton::initialize () {
|
|||
scheduleUpdate();
|
||||
}
|
||||
|
||||
void CCSkeleton::setSkeletonData (SkeletonData *skeletonData, bool ownsSkeletonData) {
|
||||
void CCSkeleton::setSkeletonData (SkeletonData *skeletonData, bool isOwnsSkeletonData) {
|
||||
skeleton = Skeleton_create(skeletonData);
|
||||
rootBone = skeleton->bones[0];
|
||||
this->ownsSkeletonData = ownsSkeletonData;
|
||||
this->ownsSkeletonData = isOwnsSkeletonData;
|
||||
}
|
||||
|
||||
CCSkeleton::CCSkeleton () {
|
||||
initialize();
|
||||
}
|
||||
|
||||
CCSkeleton::CCSkeleton (SkeletonData *skeletonData, bool ownsSkeletonData) {
|
||||
CCSkeleton::CCSkeleton (SkeletonData *skeletonData, bool isOwnsSkeletonData) {
|
||||
initialize();
|
||||
|
||||
setSkeletonData(skeletonData, ownsSkeletonData);
|
||||
setSkeletonData(skeletonData, isOwnsSkeletonData);
|
||||
}
|
||||
|
||||
CCSkeleton::CCSkeleton (const char* skeletonDataFile, Atlas* atlas, float scale) {
|
||||
CCSkeleton::CCSkeleton (const char* skeletonDataFile, Atlas* aAtlas, float scale) {
|
||||
initialize();
|
||||
|
||||
SkeletonJson* json = SkeletonJson_create(atlas);
|
||||
SkeletonJson* json = SkeletonJson_create(aAtlas);
|
||||
json->scale = scale;
|
||||
SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
|
||||
CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data.");
|
||||
|
@ -164,16 +164,16 @@ void CCSkeleton::draw () {
|
|||
DrawPrimitives::setDrawColor4B(0, 0, 255, 255);
|
||||
glLineWidth(1);
|
||||
Point points[4];
|
||||
V3F_C4B_T2F_Quad quad;
|
||||
V3F_C4B_T2F_Quad tmpQuad;
|
||||
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
|
||||
Slot* slot = skeleton->slots[i];
|
||||
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
||||
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
|
||||
RegionAttachment_updateQuad(attachment, slot, &quad);
|
||||
points[0] = Point(quad.bl.vertices.x, quad.bl.vertices.y);
|
||||
points[1] = Point(quad.br.vertices.x, quad.br.vertices.y);
|
||||
points[2] = Point(quad.tr.vertices.x, quad.tr.vertices.y);
|
||||
points[3] = Point(quad.tl.vertices.x, quad.tl.vertices.y);
|
||||
RegionAttachment_updateQuad(attachment, slot, &tmpQuad);
|
||||
points[0] = Point(tmpQuad.bl.vertices.x, tmpQuad.bl.vertices.y);
|
||||
points[1] = Point(tmpQuad.br.vertices.x, tmpQuad.br.vertices.y);
|
||||
points[2] = Point(tmpQuad.tr.vertices.x, tmpQuad.tr.vertices.y);
|
||||
points[3] = Point(tmpQuad.tl.vertices.x, tmpQuad.tl.vertices.y);
|
||||
DrawPrimitives::drawPoly(points, 4, true);
|
||||
}
|
||||
}
|
||||
|
@ -275,8 +275,8 @@ const BlendFunc& CCSkeleton::getBlendFunc() const
|
|||
return blendFunc;
|
||||
}
|
||||
|
||||
void CCSkeleton::setBlendFunc( const BlendFunc &blendFunc) {
|
||||
this->blendFunc = blendFunc;
|
||||
void CCSkeleton::setBlendFunc( const BlendFunc &aBlendFunc) {
|
||||
this->blendFunc = aBlendFunc;
|
||||
}
|
||||
|
||||
void CCSkeleton::setOpacityModifyRGB (bool value) {
|
||||
|
|
|
@ -33,10 +33,10 @@ namespace gui {
|
|||
#define TITLERENDERERZ (1)
|
||||
|
||||
UIButton::UIButton():
|
||||
_buttonNormalRenderer(NULL),
|
||||
_buttonClickedRenderer(NULL),
|
||||
_buttonDisableRenderer(NULL),
|
||||
_titleRenderer(NULL),
|
||||
_buttonNormalRenderer(nullptr),
|
||||
_buttonClickedRenderer(nullptr),
|
||||
_buttonDisableRenderer(nullptr),
|
||||
_titleRenderer(nullptr),
|
||||
_normalFileName(""),
|
||||
_clickedFileName(""),
|
||||
_disabledFileName(""),
|
||||
|
@ -70,7 +70,7 @@ UIButton* UIButton::create()
|
|||
return widget;
|
||||
}
|
||||
CC_SAFE_DELETE(widget);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool UIButton::init()
|
||||
|
@ -109,9 +109,9 @@ void UIButton::setScale9Enabled(bool able)
|
|||
_renderer->removeChild(_buttonClickedRenderer, true);
|
||||
_renderer->removeChild(_buttonDisableRenderer, true);
|
||||
|
||||
_buttonNormalRenderer = NULL;
|
||||
_buttonClickedRenderer = NULL;
|
||||
_buttonDisableRenderer = NULL;
|
||||
_buttonNormalRenderer = nullptr;
|
||||
_buttonClickedRenderer = nullptr;
|
||||
_buttonDisableRenderer = nullptr;
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
_buttonNormalRenderer = cocos2d::extension::Scale9Sprite::create();
|
||||
|
@ -457,7 +457,7 @@ cocos2d::Node* UIButton::getVirtualRenderer()
|
|||
case BRIGHT_HIGHLIGHT:
|
||||
return _buttonClickedRenderer;
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -120,7 +120,7 @@ public:
|
|||
void setCapInsetsDisabledRenderer(const cocos2d::Rect &capInsets);
|
||||
|
||||
//override "setAnchorPoint" of widget.
|
||||
virtual void setAnchorPoint(const cocos2d::Point &pt);
|
||||
virtual void setAnchorPoint(const cocos2d::Point &pt) override;
|
||||
|
||||
/**
|
||||
* Sets if button is using scale9 renderer.
|
||||
|
@ -130,16 +130,16 @@ public:
|
|||
virtual void setScale9Enabled(bool able);
|
||||
|
||||
//override "setFlipX" of widget.
|
||||
virtual void setFlipX(bool flipX);
|
||||
virtual void setFlipX(bool flipX) override;
|
||||
|
||||
//override "setFlipY" of widget.
|
||||
virtual void setFlipY(bool flipY);
|
||||
virtual void setFlipY(bool flipY) override;
|
||||
|
||||
//override "isFlipX" of widget.
|
||||
virtual bool isFlipX();
|
||||
virtual bool isFlipX() override;
|
||||
|
||||
//override "isFlipY" of widget.
|
||||
virtual bool isFlipY();
|
||||
virtual bool isFlipY() override;
|
||||
|
||||
/**
|
||||
* Changes if button can be clicked zoom effect.
|
||||
|
@ -149,13 +149,13 @@ public:
|
|||
void setPressedActionEnabled(bool enabled);
|
||||
|
||||
//override "ignoreContentAdaptWithSize" method of widget.
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore);
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore) override;
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const cocos2d::Size& getContentSize() const;
|
||||
virtual const cocos2d::Size& getContentSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual cocos2d::Node* getVirtualRenderer();
|
||||
virtual cocos2d::Node* getVirtualRenderer() override;
|
||||
|
||||
/**
|
||||
* Sets color to widget
|
||||
|
@ -164,12 +164,12 @@ public:
|
|||
*
|
||||
* @param color
|
||||
*/
|
||||
virtual void setColor(const cocos2d::Color3B &color);
|
||||
virtual void setColor(const cocos2d::Color3B &color) override;
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual const char* getDescription() const;
|
||||
virtual const char* getDescription() const override;
|
||||
|
||||
void setTitleText(const std::string& text);
|
||||
const std::string& getTitleText() const;
|
||||
|
@ -181,18 +181,18 @@ public:
|
|||
const char* getTitleFontName() const;
|
||||
|
||||
protected:
|
||||
virtual bool init();
|
||||
virtual void initRenderer();
|
||||
virtual void onPressStateChangedToNormal();
|
||||
virtual void onPressStateChangedToPressed();
|
||||
virtual void onPressStateChangedToDisabled();
|
||||
virtual void onSizeChanged();
|
||||
virtual bool init() override;
|
||||
virtual void initRenderer() override;
|
||||
virtual void onPressStateChangedToNormal() override;
|
||||
virtual void onPressStateChangedToPressed() override;
|
||||
virtual void onPressStateChangedToDisabled() override;
|
||||
virtual void onSizeChanged() override;
|
||||
|
||||
void normalTextureScaleChangedWithSize();
|
||||
void pressedTextureScaleChangedWithSize();
|
||||
void disabledTextureScaleChangedWithSize();
|
||||
virtual UIWidget* createCloneInstance();
|
||||
virtual void copySpecialProperties(UIWidget* model);
|
||||
virtual UIWidget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(UIWidget* model) override;
|
||||
protected:
|
||||
cocos2d::Node* _buttonNormalRenderer;
|
||||
cocos2d::Node* _buttonClickedRenderer;
|
||||
|
|
|
@ -28,14 +28,14 @@ namespace gui {
|
|||
|
||||
|
||||
UICheckBox::UICheckBox():
|
||||
_backGroundBoxRenderer(NULL),
|
||||
_backGroundSelectedBoxRenderer(NULL),
|
||||
_frontCrossRenderer(NULL),
|
||||
_backGroundBoxDisabledRenderer(NULL),
|
||||
_frontCrossDisabledRenderer(NULL),
|
||||
_backGroundBoxRenderer(nullptr),
|
||||
_backGroundSelectedBoxRenderer(nullptr),
|
||||
_frontCrossRenderer(nullptr),
|
||||
_backGroundBoxDisabledRenderer(nullptr),
|
||||
_frontCrossDisabledRenderer(nullptr),
|
||||
_isSelected(true),
|
||||
_checkBoxEventListener(NULL),
|
||||
_checkBoxEventSelector(NULL),
|
||||
_checkBoxEventListener(nullptr),
|
||||
_checkBoxEventSelector(nullptr),
|
||||
_backGroundTexType(UI_TEX_TYPE_LOCAL),
|
||||
_backGroundSelectedTexType(UI_TEX_TYPE_LOCAL),
|
||||
_frontCrossTexType(UI_TEX_TYPE_LOCAL),
|
||||
|
@ -51,8 +51,8 @@ _frontCrossDisabledFileName("")
|
|||
|
||||
UICheckBox::~UICheckBox()
|
||||
{
|
||||
_checkBoxEventListener = NULL;
|
||||
_checkBoxEventSelector = NULL;
|
||||
_checkBoxEventListener = nullptr;
|
||||
_checkBoxEventSelector = nullptr;
|
||||
}
|
||||
|
||||
UICheckBox* UICheckBox::create()
|
||||
|
@ -64,7 +64,7 @@ UICheckBox* UICheckBox::create()
|
|||
return widget;
|
||||
}
|
||||
CC_SAFE_DELETE(widget);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool UICheckBox::init()
|
||||
|
|
|
@ -135,53 +135,53 @@ public:
|
|||
bool getSelectedState();
|
||||
|
||||
//override "setAnchorPoint" method of widget.
|
||||
virtual void setAnchorPoint(const cocos2d::Point &pt);
|
||||
virtual void setAnchorPoint(const cocos2d::Point &pt) override;
|
||||
|
||||
//add a call back function would called when checkbox is selected or unselected.
|
||||
void addEventListenerCheckBox(cocos2d::Object* target,SEL_SelectedStateEvent selector);
|
||||
|
||||
//override "setFlipX" method of widget.
|
||||
virtual void setFlipX(bool flipX);
|
||||
virtual void setFlipX(bool flipX) override;
|
||||
|
||||
//override "setFlipY" method of widget.
|
||||
virtual void setFlipY(bool flipY);
|
||||
virtual void setFlipY(bool flipY) override;
|
||||
|
||||
//override "isFlipX" method of widget.
|
||||
virtual bool isFlipX();
|
||||
virtual bool isFlipX() override;
|
||||
|
||||
//override "isFlipY" method of widget.
|
||||
virtual bool isFlipY();
|
||||
virtual bool isFlipY() override;
|
||||
|
||||
//override "onTouchEnded" method of widget.
|
||||
virtual void onTouchEnded(const cocos2d::Point &touchPoint);
|
||||
virtual void onTouchEnded(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const cocos2d::Size& getContentSize() const;
|
||||
virtual const cocos2d::Size& getContentSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual cocos2d::Node* getVirtualRenderer();
|
||||
virtual cocos2d::Node* getVirtualRenderer() override;
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual const char* getDescription() const;
|
||||
virtual const char* getDescription() const override;
|
||||
|
||||
protected:
|
||||
virtual bool init();
|
||||
virtual void initRenderer();
|
||||
virtual void onPressStateChangedToNormal();
|
||||
virtual void onPressStateChangedToPressed();
|
||||
virtual void onPressStateChangedToDisabled();
|
||||
virtual bool init() override;
|
||||
virtual void initRenderer() override;
|
||||
virtual void onPressStateChangedToNormal() override;
|
||||
virtual void onPressStateChangedToPressed() override;
|
||||
virtual void onPressStateChangedToDisabled() override;
|
||||
void selectedEvent();
|
||||
void unSelectedEvent();
|
||||
virtual void onSizeChanged();
|
||||
virtual void onSizeChanged() override;
|
||||
void backGroundTextureScaleChangedWithSize();
|
||||
void backGroundSelectedTextureScaleChangedWithSize();
|
||||
void frontCrossTextureScaleChangedWithSize();
|
||||
void backGroundDisabledTextureScaleChangedWithSize();
|
||||
void frontCrossDisabledTextureScaleChangedWithSize();
|
||||
virtual UIWidget* createCloneInstance();
|
||||
virtual void copySpecialProperties(UIWidget* model);
|
||||
virtual UIWidget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(UIWidget* model) override;
|
||||
protected:
|
||||
cocos2d::Sprite* _backGroundBoxRenderer;
|
||||
cocos2d::Sprite* _backGroundSelectedBoxRenderer;
|
||||
|
|
|
@ -30,7 +30,7 @@ UIWidget* UIHelper::seekWidgetByTag(UIWidget* root, int tag)
|
|||
{
|
||||
if (!root)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (root->getTag() == tag)
|
||||
{
|
||||
|
@ -42,19 +42,19 @@ UIWidget* UIHelper::seekWidgetByTag(UIWidget* root, int tag)
|
|||
{
|
||||
UIWidget* child = (UIWidget*)(arrayRootChildren->arr[i]);
|
||||
UIWidget* res = seekWidgetByTag(child,tag);
|
||||
if (res != NULL)
|
||||
if (res != nullptr)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UIWidget* UIHelper::seekWidgetByName(UIWidget* root, const char *name)
|
||||
{
|
||||
if (!root)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (strcmp(root->getName(), name) == 0)
|
||||
{
|
||||
|
@ -66,19 +66,19 @@ UIWidget* UIHelper::seekWidgetByName(UIWidget* root, const char *name)
|
|||
{
|
||||
UIWidget* child = (UIWidget*)(arrayRootChildren->arr[i]);
|
||||
UIWidget* res = seekWidgetByName(child,name);
|
||||
if (res != NULL)
|
||||
if (res != nullptr)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UIWidget* UIHelper::seekWidgetByRelativeName(UIWidget *root, const char *name)
|
||||
{
|
||||
if (!root)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
cocos2d::ccArray* arrayRootChildren = root->getChildren()->data;
|
||||
int length = arrayRootChildren->num;
|
||||
|
@ -91,7 +91,7 @@ UIWidget* UIHelper::seekWidgetByRelativeName(UIWidget *root, const char *name)
|
|||
return child;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*temp action*/
|
||||
|
@ -99,7 +99,7 @@ UIWidget* UIHelper::seekActionWidgetByActionTag(UIWidget* root, int tag)
|
|||
{
|
||||
if (!root)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (root->getActionTag() == tag)
|
||||
{
|
||||
|
@ -111,12 +111,12 @@ UIWidget* UIHelper::seekActionWidgetByActionTag(UIWidget* root, int tag)
|
|||
{
|
||||
UIWidget* child = (UIWidget*)(arrayRootChildren->arr[i]);
|
||||
UIWidget* res = seekActionWidgetByActionTag(child,tag);
|
||||
if (res != NULL)
|
||||
if (res != nullptr)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
|
@ -40,7 +40,7 @@ _doubleClickEnabled(false),
|
|||
_scale9Enabled(false),
|
||||
_prevIgnoreSize(true),
|
||||
_capInsets(cocos2d::Rect::ZERO),
|
||||
_imageRenderer(NULL),
|
||||
_imageRenderer(nullptr),
|
||||
_textureFile(""),
|
||||
_imageTexType(UI_TEX_TYPE_LOCAL),
|
||||
_imageTextureSize(_size)
|
||||
|
@ -62,7 +62,7 @@ UIImageView* UIImageView::create()
|
|||
return widget;
|
||||
}
|
||||
CC_SAFE_DELETE(widget);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UIImageView::initRenderer()
|
||||
|
@ -275,7 +275,7 @@ void UIImageView::setScale9Enabled(bool able)
|
|||
|
||||
_scale9Enabled = able;
|
||||
_renderer->removeChild(_imageRenderer, true);
|
||||
_imageRenderer = NULL;
|
||||
_imageRenderer = nullptr;
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
_imageRenderer = cocos2d::extension::Scale9Sprite::create();
|
||||
|
|
|
@ -81,45 +81,45 @@ public:
|
|||
void setCapInsets(const cocos2d::Rect &capInsets);
|
||||
|
||||
//override "setFlipX" method of widget.
|
||||
virtual void setFlipX(bool flipX);
|
||||
virtual void setFlipX(bool flipX) override;
|
||||
|
||||
//override "setFlipY" method of widget.
|
||||
virtual void setFlipY(bool flipY);
|
||||
virtual void setFlipY(bool flipY) override;
|
||||
|
||||
//override "isFlipX" method of widget.
|
||||
virtual bool isFlipX();
|
||||
virtual bool isFlipX() override;
|
||||
|
||||
//override "isFlipY" method of widget.
|
||||
virtual bool isFlipY();
|
||||
virtual bool isFlipY() override;
|
||||
|
||||
//override "setAnchorPoint" method of widget.
|
||||
virtual void setAnchorPoint(const cocos2d::Point &pt);
|
||||
virtual void setAnchorPoint(const cocos2d::Point &pt) override;
|
||||
|
||||
//override "onTouchBegan" method of widget.
|
||||
virtual bool onTouchBegan(const cocos2d::Point &touchPoint);
|
||||
virtual bool onTouchBegan(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "onTouchEnded" method of widget.
|
||||
virtual void onTouchEnded(const cocos2d::Point &touchPoint);
|
||||
virtual void onTouchEnded(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "ignoreContentAdaptWithSize" method of widget.
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore);
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore) override;
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual const char* getDescription() const;
|
||||
virtual const char* getDescription() const override;
|
||||
|
||||
void setDoubleClickEnabled(bool able);
|
||||
void doubleClickEvent();
|
||||
void checkDoubleClick(float dt);
|
||||
virtual const cocos2d::Size& getContentSize() const;
|
||||
virtual cocos2d::Node* getVirtualRenderer();
|
||||
virtual const cocos2d::Size& getContentSize() const override;
|
||||
virtual cocos2d::Node* getVirtualRenderer() override;
|
||||
protected:
|
||||
virtual void initRenderer();
|
||||
virtual void onSizeChanged();
|
||||
virtual void initRenderer() override;
|
||||
virtual void onSizeChanged() override;
|
||||
void imageTextureScaleChangedWithSize();
|
||||
virtual UIWidget* createCloneInstance();
|
||||
virtual void copySpecialProperties(UIWidget* model);
|
||||
virtual UIWidget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(UIWidget* model) override;
|
||||
protected:
|
||||
int _clickCount;
|
||||
float _clickTimeInterval;
|
||||
|
|
|
@ -30,12 +30,12 @@
|
|||
namespace gui {
|
||||
|
||||
UIInputManager::UIInputManager():
|
||||
_manageredWidget(NULL),
|
||||
_manageredWidget(nullptr),
|
||||
_touchDown(false),
|
||||
_longClickTime(0.0),
|
||||
_longClickRecordTime(0.0),
|
||||
_checkedDoubleClickWidget(NULL),
|
||||
_rootWidget(NULL)
|
||||
_checkedDoubleClickWidget(nullptr),
|
||||
_rootWidget(nullptr)
|
||||
{
|
||||
_manageredWidget = Array::create();
|
||||
_manageredWidget->retain();
|
||||
|
|
|
@ -29,11 +29,12 @@ namespace gui {
|
|||
|
||||
UILabel::UILabel():
|
||||
_touchScaleChangeEnabled(false),
|
||||
_normalScaleValue(1.0f),
|
||||
_normalScaleValueX(1.0f),
|
||||
_normalScaleValueY(1.0f),
|
||||
_fontName("Thonburi"),
|
||||
_fontSize(10),
|
||||
_onSelectedScaleOffset(0.5),
|
||||
_labelRenderer(NULL)
|
||||
_labelRenderer(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -51,7 +52,7 @@ UILabel* UILabel::create()
|
|||
return widget;
|
||||
}
|
||||
CC_SAFE_DELETE(widget);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool UILabel::init()
|
||||
|
@ -124,7 +125,26 @@ void UILabel::setTextVerticalAlignment(cocos2d::TextVAlignment alignment)
|
|||
void UILabel::setTouchScaleChangeEnabled(bool enable)
|
||||
{
|
||||
_touchScaleChangeEnabled = enable;
|
||||
_normalScaleValue = getScale();
|
||||
_normalScaleValueX = getScaleX();
|
||||
_normalScaleValueY = getScaleY();
|
||||
}
|
||||
|
||||
void UILabel::setScale(float fScale)
|
||||
{
|
||||
UIWidget::setScale(fScale);
|
||||
_normalScaleValueX = _normalScaleValueY = fScale;
|
||||
}
|
||||
|
||||
void UILabel::setScaleX(float fScaleX)
|
||||
{
|
||||
UIWidget::setScaleX(fScaleX);
|
||||
_normalScaleValueX = fScaleX;
|
||||
}
|
||||
|
||||
void UILabel::setScaleY(float fScaleY)
|
||||
{
|
||||
UIWidget::setScaleY(fScaleY);
|
||||
_normalScaleValueY = fScaleY;
|
||||
}
|
||||
|
||||
bool UILabel::isTouchScaleChangeEnabled()
|
||||
|
@ -138,7 +158,7 @@ void UILabel::onPressStateChangedToNormal()
|
|||
{
|
||||
return;
|
||||
}
|
||||
clickScale(_normalScaleValue);
|
||||
clickScale(_normalScaleValueX, _normalScaleValueY);
|
||||
}
|
||||
|
||||
void UILabel::onPressStateChangedToPressed()
|
||||
|
@ -147,7 +167,7 @@ void UILabel::onPressStateChangedToPressed()
|
|||
{
|
||||
return;
|
||||
}
|
||||
clickScale(_normalScaleValue + _onSelectedScaleOffset);
|
||||
clickScale(_normalScaleValueX + _onSelectedScaleOffset, _normalScaleValueY + _onSelectedScaleOffset);
|
||||
}
|
||||
|
||||
void UILabel::onPressStateChangedToDisabled()
|
||||
|
@ -155,9 +175,10 @@ void UILabel::onPressStateChangedToDisabled()
|
|||
|
||||
}
|
||||
|
||||
void UILabel::clickScale(float scale)
|
||||
void UILabel::clickScale(float scaleX, float scaleY)
|
||||
{
|
||||
_renderer->setScale(scale);
|
||||
_renderer->setScaleX(scaleX);
|
||||
_renderer->setScaleY(scaleY);
|
||||
}
|
||||
|
||||
void UILabel::setFlipX(bool flipX)
|
||||
|
|
|
@ -100,50 +100,79 @@ public:
|
|||
* @return touch scale enabled of label.
|
||||
*/
|
||||
bool isTouchScaleChangeEnabled();
|
||||
|
||||
/**
|
||||
* Changes both X and Y scale factor of the widget.
|
||||
*
|
||||
* 1.0 is the default scale factor. It modifies the X and Y scale at the same time.
|
||||
*
|
||||
* @param scale The scale factor for both X and Y axis.
|
||||
*/
|
||||
virtual void setScale(float fScale) override;
|
||||
|
||||
/**
|
||||
* Changes the scale factor on X axis of this widget
|
||||
*
|
||||
* The deafult value is 1.0 if you haven't changed it before
|
||||
*
|
||||
* @param fScaleX The scale factor on X axis.
|
||||
*/
|
||||
virtual void setScaleX(float fScaleX) override;
|
||||
|
||||
/**
|
||||
* Changes the scale factor on Y axis of this widget
|
||||
*
|
||||
* The Default value is 1.0 if you haven't changed it before.
|
||||
*
|
||||
* @param fScaleY The scale factor on Y axis.
|
||||
*/
|
||||
virtual void setScaleY(float fScaleY) override;
|
||||
|
||||
|
||||
//override "setFlipX" method of widget.
|
||||
virtual void setFlipX(bool flipX);
|
||||
virtual void setFlipX(bool flipX) override;
|
||||
|
||||
//override "setFlipY" method of widget.
|
||||
virtual void setFlipY(bool flipY);
|
||||
virtual void setFlipY(bool flipY) override;
|
||||
|
||||
//override "isFlipX" method of widget.
|
||||
virtual bool isFlipX();
|
||||
virtual bool isFlipX() override;
|
||||
|
||||
//override "isFlipY" method of widget.
|
||||
virtual bool isFlipY();
|
||||
virtual bool isFlipY() override;
|
||||
|
||||
//override "setAnchorPoint" method of widget.
|
||||
virtual void setAnchorPoint(const cocos2d::Point &pt);
|
||||
virtual void setAnchorPoint(const cocos2d::Point &pt) override;
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const cocos2d::Size& getContentSize() const;
|
||||
virtual const cocos2d::Size& getContentSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual cocos2d::Node* getVirtualRenderer();
|
||||
virtual cocos2d::Node* getVirtualRenderer() override;
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual const char* getDescription() const;
|
||||
virtual const char* getDescription() const override;
|
||||
|
||||
void setTextAreaSize(const cocos2d::Size &size);
|
||||
void setTextHorizontalAlignment(cocos2d::TextHAlignment alignment);
|
||||
void setTextVerticalAlignment(cocos2d::TextVAlignment alignment);
|
||||
protected:
|
||||
virtual bool init();
|
||||
virtual void initRenderer();
|
||||
virtual void onPressStateChangedToNormal();
|
||||
virtual void onPressStateChangedToPressed();
|
||||
virtual void onPressStateChangedToDisabled();
|
||||
virtual void onSizeChanged();
|
||||
void clickScale(float scale);
|
||||
virtual bool init() override;
|
||||
virtual void initRenderer() override;
|
||||
virtual void onPressStateChangedToNormal() override;
|
||||
virtual void onPressStateChangedToPressed() override;
|
||||
virtual void onPressStateChangedToDisabled() override;
|
||||
virtual void onSizeChanged() override;
|
||||
void clickScale(float scaleX, float scaleY);
|
||||
void labelScaleChangedWithSize();
|
||||
virtual UIWidget* createCloneInstance();
|
||||
virtual void copySpecialProperties(UIWidget* model);
|
||||
virtual UIWidget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(UIWidget* model) override;
|
||||
protected:
|
||||
bool _touchScaleChangeEnabled;
|
||||
float _normalScaleValue;
|
||||
float _normalScaleValueX;
|
||||
float _normalScaleValueY;
|
||||
std::string _fontName;
|
||||
int _fontSize;
|
||||
float _onSelectedScaleOffset;
|
||||
|
|
|
@ -47,7 +47,7 @@ UICCLabelAtlas* UICCLabelAtlas::create()
|
|||
}
|
||||
CC_SAFE_DELETE(pRet);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UICCLabelAtlas::setProperty(const std::string& string, const std::string& charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap)
|
||||
|
@ -79,7 +79,7 @@ void UICCLabelAtlas::updateDisplayedOpacity(GLubyte opacity)
|
|||
|
||||
|
||||
UILabelAtlas::UILabelAtlas():
|
||||
_laberAtlasRenderer(NULL),
|
||||
_laberAtlasRenderer(nullptr),
|
||||
_stringValue(""),
|
||||
_charMapFileName(""),
|
||||
_itemWidth(0),
|
||||
|
@ -103,7 +103,7 @@ UILabelAtlas* UILabelAtlas::create()
|
|||
return widget;
|
||||
}
|
||||
CC_SAFE_DELETE(widget);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UILabelAtlas::initRenderer()
|
||||
|
|
|
@ -52,8 +52,8 @@ public:
|
|||
static UICCLabelAtlas* create();
|
||||
void setProperty(const std::string& string, const std::string& charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap);
|
||||
void setProperty(const std::string& string, cocos2d::Texture2D *texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap);
|
||||
virtual void updateDisplayedOpacity(GLubyte opacity);
|
||||
virtual void draw(void);
|
||||
virtual void updateDisplayedOpacity(GLubyte opacity) override;
|
||||
virtual void draw(void) override;
|
||||
};
|
||||
/**
|
||||
* @js NA
|
||||
|
@ -87,25 +87,25 @@ public:
|
|||
const std::string& getStringValue() const;
|
||||
|
||||
//override "setAnchorPoint" method of widget.
|
||||
virtual void setAnchorPoint(const cocos2d::Point &pt);
|
||||
virtual void setAnchorPoint(const cocos2d::Point &pt) override;
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const cocos2d::Size& getContentSize() const;
|
||||
virtual const cocos2d::Size& getContentSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual cocos2d::Node* getVirtualRenderer();
|
||||
virtual cocos2d::Node* getVirtualRenderer() override;
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual const char* getDescription() const;
|
||||
virtual const char* getDescription() const override;
|
||||
|
||||
protected:
|
||||
virtual void initRenderer();
|
||||
virtual void onSizeChanged();
|
||||
virtual void initRenderer() override;
|
||||
virtual void onSizeChanged() override;
|
||||
void labelAtlasScaleChangedWithSize();
|
||||
virtual UIWidget* createCloneInstance();
|
||||
virtual void copySpecialProperties(UIWidget* model);
|
||||
virtual UIWidget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(UIWidget* model) override;
|
||||
protected:
|
||||
UICCLabelAtlas* _laberAtlasRenderer;
|
||||
std::string _stringValue;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
namespace gui {
|
||||
|
||||
UILabelBMFont::UILabelBMFont():
|
||||
_labelBMFontRenderer(NULL),
|
||||
_labelBMFontRenderer(nullptr),
|
||||
_fntFileHasInit(false),
|
||||
_fntFileName(""),
|
||||
_stringValue("")
|
||||
|
@ -48,7 +48,7 @@ UILabelBMFont* UILabelBMFont::create()
|
|||
return widget;
|
||||
}
|
||||
CC_SAFE_DELETE(widget);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UILabelBMFont::initRenderer()
|
||||
|
|
|
@ -59,19 +59,19 @@ public:
|
|||
|
||||
/** get string value for labelbmfont*/
|
||||
const char* getStringValue();
|
||||
virtual void setAnchorPoint(const cocos2d::Point &pt);
|
||||
virtual const cocos2d::Size& getContentSize() const;
|
||||
virtual cocos2d::Node* getVirtualRenderer();
|
||||
virtual void setAnchorPoint(const cocos2d::Point &pt) override;
|
||||
virtual const cocos2d::Size& getContentSize() const override;
|
||||
virtual cocos2d::Node* getVirtualRenderer() override;
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual const char* getDescription() const;
|
||||
virtual const char* getDescription() const override;
|
||||
protected:
|
||||
virtual void initRenderer();
|
||||
virtual void onSizeChanged();
|
||||
virtual void initRenderer() override;
|
||||
virtual void onSizeChanged() override;
|
||||
void labelBMFontScaleChangedWithSize();
|
||||
virtual UIWidget* createCloneInstance();
|
||||
virtual void copySpecialProperties(UIWidget* model);
|
||||
virtual UIWidget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(UIWidget* model) override;
|
||||
protected:
|
||||
cocos2d::LabelBMFont* _labelBMFontRenderer;
|
||||
bool _fntFileHasInit;
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
namespace gui {
|
||||
|
||||
UILayer::UILayer():
|
||||
_rootWidget(NULL),
|
||||
_inputManager(NULL)
|
||||
_rootWidget(nullptr),
|
||||
_inputManager(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -48,7 +48,6 @@ bool UILayer::init()
|
|||
{
|
||||
_rootWidget = UIRootWidget::create();
|
||||
_rootWidget->retain();
|
||||
_rootWidget->onEnter();
|
||||
addChild(_rootWidget->getRenderer());
|
||||
_inputManager = new UIInputManager();
|
||||
_inputManager->setRootWidget(_rootWidget);
|
||||
|
@ -68,7 +67,7 @@ UILayer* UILayer::create(void)
|
|||
else
|
||||
{
|
||||
CC_SAFE_DELETE(pRet);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,10 +84,12 @@ void UILayer::onEnter()
|
|||
listener->onTouchCancelled = CC_CALLBACK_2(UILayer::onTouchCancelled, this);
|
||||
|
||||
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
||||
_rootWidget->onEnter();
|
||||
}
|
||||
|
||||
void UILayer::onExit()
|
||||
{
|
||||
_rootWidget->onExit();
|
||||
CCLayer::onExit();
|
||||
}
|
||||
|
||||
|
@ -117,7 +118,7 @@ UIWidget* UILayer::getWidgetByTag(int tag)
|
|||
{
|
||||
if (!_rootWidget)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return UIHelper::seekWidgetByTag(_rootWidget, tag);
|
||||
}
|
||||
|
@ -126,7 +127,7 @@ UIWidget* UILayer::getWidgetByName(const char* name)
|
|||
{
|
||||
if (!_rootWidget)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return UIHelper::seekWidgetByName(_rootWidget, name);
|
||||
}
|
||||
|
|
|
@ -53,11 +53,11 @@ public:
|
|||
static UILayer *create(void);
|
||||
|
||||
//initializes state of uilayer.
|
||||
virtual bool init();
|
||||
virtual bool init() override;
|
||||
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
virtual void onEnterTransitionDidFinish();
|
||||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
virtual void onEnterTransitionDidFinish() override;
|
||||
|
||||
virtual bool onTouchBegan(cocos2d::Touch *pTouch, cocos2d::Event *pEvent);
|
||||
virtual void onTouchMoved(cocos2d::Touch *pTouch, cocos2d::Event *pEvent);
|
||||
|
@ -87,7 +87,7 @@ public:
|
|||
*
|
||||
* @param visible true if the UILayer is visible, false if the UILayer is hidden.
|
||||
*/
|
||||
virtual void setVisible(bool visible);
|
||||
virtual void setVisible(bool visible) override;
|
||||
|
||||
/**
|
||||
* Finds a widget whose tag is equal tag param from widget tree.
|
||||
|
|
|
@ -35,13 +35,13 @@ namespace gui {
|
|||
UILayout::UILayout():
|
||||
_clippingEnabled(false),
|
||||
_backGroundScale9Enabled(false),
|
||||
_backGroundImage(NULL),
|
||||
_backGroundImage(nullptr),
|
||||
_backGroundImageFileName(""),
|
||||
_backGroundImageCapInsets(cocos2d::Rect::ZERO),
|
||||
_colorType(LAYOUT_COLOR_NONE),
|
||||
_bgImageTexType(UI_TEX_TYPE_LOCAL),
|
||||
_colorRender(NULL),
|
||||
_gradientRender(NULL),
|
||||
_colorRender(nullptr),
|
||||
_gradientRender(nullptr),
|
||||
_cColor(cocos2d::Color3B::WHITE),
|
||||
_gStartColor(cocos2d::Color3B::WHITE),
|
||||
_gEndColor(cocos2d::Color3B::WHITE),
|
||||
|
@ -66,7 +66,7 @@ UILayout* UILayout::create()
|
|||
return layout;
|
||||
}
|
||||
CC_SAFE_DELETE(layout);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool UILayout::init()
|
||||
|
@ -165,7 +165,7 @@ void UILayout::setBackGroundImageScale9Enabled(bool able)
|
|||
return;
|
||||
}
|
||||
_renderer->removeChild(_backGroundImage, true);
|
||||
_backGroundImage = NULL;
|
||||
_backGroundImage = nullptr;
|
||||
_backGroundScale9Enabled = able;
|
||||
if (_backGroundScale9Enabled)
|
||||
{
|
||||
|
@ -188,7 +188,7 @@ void UILayout::setBackGroundImage(const char* fileName,TextureResType texType)
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (_backGroundImage == NULL)
|
||||
if (_backGroundImage == nullptr)
|
||||
{
|
||||
addBackGroundImage();
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ void UILayout::removeBackGroundImage()
|
|||
return;
|
||||
}
|
||||
_renderer->removeChild(_backGroundImage, true);
|
||||
_backGroundImage = NULL;
|
||||
_backGroundImage = nullptr;
|
||||
_backGroundImageFileName = "";
|
||||
_backGroundImageTextureSize = cocos2d::Size::ZERO;
|
||||
}
|
||||
|
@ -322,26 +322,26 @@ void UILayout::setBackGroundColorType(LayoutBackGroundColorType type)
|
|||
if (_colorRender)
|
||||
{
|
||||
_renderer->removeChild(_colorRender, true);
|
||||
_colorRender = NULL;
|
||||
_colorRender = nullptr;
|
||||
}
|
||||
if (_gradientRender)
|
||||
{
|
||||
_renderer->removeChild(_gradientRender, true);
|
||||
_gradientRender = NULL;
|
||||
_gradientRender = nullptr;
|
||||
}
|
||||
break;
|
||||
case LAYOUT_COLOR_SOLID:
|
||||
if (_colorRender)
|
||||
{
|
||||
_renderer->removeChild(_colorRender, true);
|
||||
_colorRender = NULL;
|
||||
_colorRender = nullptr;
|
||||
}
|
||||
break;
|
||||
case LAYOUT_COLOR_GRADIENT:
|
||||
if (_gradientRender)
|
||||
{
|
||||
_renderer->removeChild(_gradientRender, true);
|
||||
_gradientRender = NULL;
|
||||
_gradientRender = nullptr;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -596,8 +596,8 @@ void UILayout::doLayout()
|
|||
cocos2d::Size cs = child->getSize();
|
||||
UIRelativeAlign align = layoutParameter->getAlign();
|
||||
const char* relativeName = layoutParameter->getRelativeToWidgetName();
|
||||
UIWidget* relativeWidget = NULL;
|
||||
UIRelativeLayoutParameter* relativeWidgetLP = NULL;
|
||||
UIWidget* relativeWidget = nullptr;
|
||||
UIRelativeLayoutParameter* relativeWidgetLP = nullptr;
|
||||
float finalPosX = 0.0f;
|
||||
float finalPosY = 0.0f;
|
||||
if (relativeName && strcmp(relativeName, ""))
|
||||
|
@ -927,7 +927,7 @@ void UILayout::copySpecialProperties(UIWidget *widget)
|
|||
}
|
||||
|
||||
UIRectClippingNode::UIRectClippingNode():
|
||||
_innerStencil(NULL),
|
||||
_innerStencil(nullptr),
|
||||
_enabled(true),
|
||||
_clippingSize(cocos2d::Size(50.0f, 50.0f)),
|
||||
_clippingEnabled(false)
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
static UILayout* create();
|
||||
|
||||
//override "hitTest" method of widget.
|
||||
virtual bool hitTest(const cocos2d::Point &pt);
|
||||
virtual bool hitTest(const cocos2d::Point &pt) override;
|
||||
|
||||
//background
|
||||
/**
|
||||
|
@ -133,10 +133,10 @@ public:
|
|||
void setBackGroundColorVector(const cocos2d::Point &vector);
|
||||
|
||||
//override "setColor" method of widget.
|
||||
virtual void setColor(const cocos2d::Color3B &color);
|
||||
virtual void setColor(const cocos2d::Color3B &color) override;
|
||||
|
||||
//override "setOpacity" method of widget.
|
||||
virtual void setOpacity(int opacity);
|
||||
virtual void setOpacity(int opacity) override;
|
||||
|
||||
/**
|
||||
* Remove the background image of layout.
|
||||
|
@ -157,7 +157,7 @@ public:
|
|||
*
|
||||
* @param clipping enabled.
|
||||
*/
|
||||
virtual void setClippingEnabled(bool able);
|
||||
virtual void setClippingEnabled(bool enabled);
|
||||
|
||||
/**
|
||||
* Gets if layout is clipping enabled.
|
||||
|
@ -171,12 +171,12 @@ public:
|
|||
*
|
||||
* Content size is widget's texture size.
|
||||
*/
|
||||
virtual const cocos2d::Size& getContentSize() const;
|
||||
virtual const cocos2d::Size& getContentSize() const override;
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual const char* getDescription() const;
|
||||
virtual const char* getDescription() const override;
|
||||
|
||||
/**
|
||||
* Sets LayoutType.
|
||||
|
@ -203,25 +203,25 @@ public:
|
|||
*
|
||||
* @param child A child widget
|
||||
*/
|
||||
virtual bool addChild(UIWidget* child);
|
||||
virtual bool addChild(UIWidget* child) override;
|
||||
|
||||
protected:
|
||||
//override "init" method of widget.
|
||||
virtual bool init();
|
||||
virtual bool init() override;
|
||||
|
||||
//override "initRenderer" method of widget.
|
||||
virtual void initRenderer();
|
||||
virtual void initRenderer() override;
|
||||
|
||||
//override "onSizeChanged" method of widget.
|
||||
virtual void onSizeChanged();
|
||||
virtual void onSizeChanged() override;
|
||||
|
||||
//init background image renderer.
|
||||
void addBackGroundImage();
|
||||
|
||||
void supplyTheLayoutParameterLackToChild(UIWidget* child);
|
||||
virtual UIWidget* createCloneInstance();
|
||||
virtual void copySpecialProperties(UIWidget* model);
|
||||
virtual void copyClonedWidgetChildren(UIWidget* model);
|
||||
virtual UIWidget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(UIWidget* model) override;
|
||||
virtual void copyClonedWidgetChildren(UIWidget* model) override;
|
||||
protected:
|
||||
bool _clippingEnabled;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ UILayoutParameter* UILayoutParameter::create()
|
|||
return parameter;
|
||||
}
|
||||
CC_SAFE_DELETE(parameter);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UILayoutParameter::setMargin(const UIMargin &margin)
|
||||
|
@ -64,7 +64,7 @@ UILinearLayoutParameter* UILinearLayoutParameter::create()
|
|||
return parameter;
|
||||
}
|
||||
CC_SAFE_DELETE(parameter);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UILinearLayoutParameter::setGravity(UILinearGravity gravity)
|
||||
|
@ -86,7 +86,7 @@ UIRelativeLayoutParameter* UIRelativeLayoutParameter::create()
|
|||
return parameter;
|
||||
}
|
||||
CC_SAFE_DELETE(parameter);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UIRelativeLayoutParameter::setAlign(UIRelativeAlign align)
|
||||
|
|
|
@ -29,12 +29,12 @@
|
|||
namespace gui {
|
||||
|
||||
UIListView::UIListView():
|
||||
_model(NULL),
|
||||
_items(NULL),
|
||||
_model(nullptr),
|
||||
_items(nullptr),
|
||||
_gravity(LISTVIEW_GRAVITY_CENTER_HORIZONTAL),
|
||||
_itemsMargin(0.0f),
|
||||
_listViewEventListener(NULL),
|
||||
_listViewEventSelector(NULL),
|
||||
_listViewEventListener(nullptr),
|
||||
_listViewEventSelector(nullptr),
|
||||
_curSelectedIndex(0)
|
||||
{
|
||||
|
||||
|
@ -44,8 +44,8 @@ UIListView::~UIListView()
|
|||
{
|
||||
_items->removeAllObjects();
|
||||
CC_SAFE_RELEASE(_items);
|
||||
_listViewEventListener = NULL;
|
||||
_listViewEventSelector = NULL;
|
||||
_listViewEventListener = nullptr;
|
||||
_listViewEventSelector = nullptr;
|
||||
}
|
||||
|
||||
UIListView* UIListView::create()
|
||||
|
@ -57,7 +57,7 @@ UIListView* UIListView::create()
|
|||
return widget;
|
||||
}
|
||||
CC_SAFE_DELETE(widget);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool UIListView::init()
|
||||
|
@ -303,7 +303,7 @@ UIWidget* UIListView::getItem(unsigned int index)
|
|||
{
|
||||
if ((int)index < 0 || index >= _items->count())
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return (UIWidget*)(_items->data->arr[index]);
|
||||
}
|
||||
|
@ -393,7 +393,7 @@ void UIListView::selectedItemEvent()
|
|||
{
|
||||
if (_listViewEventListener && _listViewEventSelector)
|
||||
{
|
||||
(_listViewEventListener->*_listViewEventSelector)(this, LISTVIEW_ONSELECEDTITEM);
|
||||
(_listViewEventListener->*_listViewEventSelector)(this, LISTVIEW_ONSELECTEDITEM);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ typedef enum
|
|||
|
||||
typedef enum
|
||||
{
|
||||
LISTVIEW_ONSELECEDTITEM
|
||||
LISTVIEW_ONSELECTEDITEM
|
||||
}ListViewEventType;
|
||||
|
||||
typedef void (cocos2d::Object::*SEL_ListViewEvent)(cocos2d::Object*,ListViewEventType);
|
||||
|
@ -164,20 +164,24 @@ public:
|
|||
*
|
||||
* @param SCROLLVIEW_DIR
|
||||
*/
|
||||
virtual void setDirection(SCROLLVIEW_DIR dir);
|
||||
virtual void setDirection(SCROLLVIEW_DIR dir) override;
|
||||
|
||||
virtual const char* getDescription() const;
|
||||
virtual const char* getDescription() const override;
|
||||
|
||||
protected:
|
||||
virtual bool init();
|
||||
virtual bool addChild(UIWidget* widget) override{return UIScrollView::addChild(widget);};
|
||||
virtual bool removeChild(UIWidget* widget) override{return UIScrollView::removeChild(widget);};
|
||||
virtual void removeAllChildren() override{UIScrollView::removeAllChildren();};
|
||||
virtual cocos2d::Array* getChildren() override{return UIScrollView::getChildren();};
|
||||
virtual bool init() override;
|
||||
void updateInnerContainerSize();
|
||||
void remedyLayoutParameter(UIWidget* item);
|
||||
virtual void onSizeChanged();
|
||||
virtual UIWidget* createCloneInstance();
|
||||
virtual void copySpecialProperties(UIWidget* model);
|
||||
virtual void copyClonedWidgetChildren(UIWidget* model);
|
||||
virtual void onSizeChanged() override;
|
||||
virtual UIWidget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(UIWidget* model) override;
|
||||
virtual void copyClonedWidgetChildren(UIWidget* model) override;
|
||||
void selectedItemEvent();
|
||||
virtual void interceptTouchEvent(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint);
|
||||
virtual void interceptTouchEvent(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint) override;
|
||||
protected:
|
||||
|
||||
UIWidget* _model;
|
||||
|
|
|
@ -34,7 +34,7 @@ UILoadingBar::UILoadingBar():
|
|||
_barType(LoadingBarTypeLeft),
|
||||
_percent(100),
|
||||
_totalLength(0),
|
||||
_barRenderer(NULL),
|
||||
_barRenderer(nullptr),
|
||||
_renderBarTexType(UI_TEX_TYPE_LOCAL),
|
||||
_barRendererTextureSize(cocos2d::Size::ZERO),
|
||||
_scale9Enabled(false),
|
||||
|
@ -58,7 +58,7 @@ UILoadingBar* UILoadingBar::create()
|
|||
return widget;
|
||||
}
|
||||
CC_SAFE_DELETE(widget);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UILoadingBar::initRenderer()
|
||||
|
@ -179,7 +179,7 @@ void UILoadingBar::setScale9Enabled(bool enabled)
|
|||
}
|
||||
_scale9Enabled = enabled;
|
||||
_renderer->removeChild(_barRenderer, true);
|
||||
_barRenderer = NULL;
|
||||
_barRenderer = nullptr;
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
_barRenderer = cocos2d::extension::Scale9Sprite::create();
|
||||
|
|
|
@ -112,25 +112,25 @@ public:
|
|||
void setCapInsets(const cocos2d::Rect &capInsets);
|
||||
|
||||
//override "ignoreContentAdaptWithSize" method of widget.
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore);
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore) override;
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const cocos2d::Size& getContentSize() const;
|
||||
virtual const cocos2d::Size& getContentSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual cocos2d::Node* getVirtualRenderer();
|
||||
virtual cocos2d::Node* getVirtualRenderer() override;
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual const char* getDescription() const;
|
||||
virtual const char* getDescription() const override;
|
||||
protected:
|
||||
virtual void initRenderer();
|
||||
virtual void onSizeChanged();
|
||||
virtual void initRenderer() override;
|
||||
virtual void onSizeChanged() override;
|
||||
void setScale9Scale();
|
||||
void barRendererScaleChangedWithSize();
|
||||
virtual UIWidget* createCloneInstance();
|
||||
virtual void copySpecialProperties(UIWidget* model);
|
||||
virtual UIWidget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(UIWidget* model) override;
|
||||
protected:
|
||||
LoadingBarType _barType;
|
||||
int _percent;
|
||||
|
|
|
@ -28,13 +28,13 @@ namespace gui {
|
|||
|
||||
UIPageView::UIPageView():
|
||||
_curPageIdx(0),
|
||||
_pages(NULL),
|
||||
_pages(nullptr),
|
||||
_touchMoveDir(PAGEVIEW_TOUCHLEFT),
|
||||
_touchStartLocation(0.0f),
|
||||
_touchMoveStartLocation(0.0f),
|
||||
_movePagePoint(cocos2d::Point::ZERO),
|
||||
_leftChild(NULL),
|
||||
_rightChild(NULL),
|
||||
_leftChild(nullptr),
|
||||
_rightChild(nullptr),
|
||||
_leftBoundary(0.0f),
|
||||
_rightBoundary(0.0f),
|
||||
_isAutoScrolling(false),
|
||||
|
@ -42,8 +42,8 @@ _autoScrollDistance(0.0f),
|
|||
_autoScrollSpeed(0.0f),
|
||||
_autoScrollDir(0),
|
||||
_childFocusCancelOffset(5.0f),
|
||||
_pageViewEventListener(NULL),
|
||||
_pageViewEventSelector(NULL)
|
||||
_pageViewEventListener(nullptr),
|
||||
_pageViewEventSelector(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,8 @@ UIPageView::~UIPageView()
|
|||
{
|
||||
_pages->removeAllObjects();
|
||||
CC_SAFE_RELEASE(_pages);
|
||||
_pageViewEventListener = NULL;
|
||||
_pageViewEventSelector = NULL;
|
||||
_pageViewEventListener = nullptr;
|
||||
_pageViewEventSelector = nullptr;
|
||||
}
|
||||
|
||||
UIPageView* UIPageView::create()
|
||||
|
@ -64,7 +64,7 @@ UIPageView* UIPageView::create()
|
|||
return widget;
|
||||
}
|
||||
CC_SAFE_DELETE(widget);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool UIPageView::init()
|
||||
|
@ -219,13 +219,18 @@ void UIPageView::removePageAtIndex(int index)
|
|||
removePage(page);
|
||||
}
|
||||
}
|
||||
|
||||
void UIPageView::removeAllPages()
|
||||
{
|
||||
removeAllChildren();
|
||||
}
|
||||
|
||||
void UIPageView::updateBoundaryPages()
|
||||
{
|
||||
if (_pages->count() <= 0)
|
||||
{
|
||||
_leftChild = NULL;
|
||||
_rightChild = NULL;
|
||||
_leftChild = nullptr;
|
||||
_rightChild = nullptr;
|
||||
return;
|
||||
}
|
||||
_leftChild = dynamic_cast<UIWidget*>(_pages->getObjectAtIndex(0));
|
||||
|
@ -247,9 +252,8 @@ bool UIPageView::removeChild(UIWidget* widget)
|
|||
if (_pages->containsObject(widget))
|
||||
{
|
||||
_pages->removeObject(widget);
|
||||
return UILayout::removeChild(widget);
|
||||
}
|
||||
return false;
|
||||
return UILayout::removeChild(widget);
|
||||
}
|
||||
|
||||
void UIPageView::onSizeChanged()
|
||||
|
@ -586,6 +590,15 @@ cocos2d::Array* UIPageView::getPages()
|
|||
{
|
||||
return _pages;
|
||||
}
|
||||
|
||||
UILayout* UIPageView::getPage(int index)
|
||||
{
|
||||
if (index < 0 || index >= (int)(_pages->count()))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return (UILayout*)_pages->getObjectAtIndex(index);
|
||||
}
|
||||
|
||||
const char* UIPageView::getDescription() const
|
||||
{
|
||||
|
|
|
@ -101,6 +101,8 @@ public:
|
|||
*/
|
||||
void removePageAtIndex(int index);
|
||||
|
||||
void removeAllPages();
|
||||
|
||||
/**
|
||||
* scroll pageview to index.
|
||||
*
|
||||
|
@ -117,59 +119,78 @@ public:
|
|||
|
||||
cocos2d::Array* getPages();
|
||||
|
||||
UILayout* getPage(int index);
|
||||
|
||||
// event
|
||||
void addEventListenerPageView(cocos2d::Object *target, SEL_PageViewEvent selector);
|
||||
|
||||
|
||||
//override "removeChild" method of widget.
|
||||
virtual bool removeChild(UIWidget* widget);
|
||||
|
||||
//override "removeAllChildrenAndCleanUp" method of widget.
|
||||
virtual void removeAllChildren();
|
||||
|
||||
|
||||
//override "onTouchBegan" method of widget.
|
||||
virtual bool onTouchBegan(const cocos2d::Point &touchPoint);
|
||||
virtual bool onTouchBegan(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "onTouchMoved" method of widget.
|
||||
virtual void onTouchMoved(const cocos2d::Point &touchPoint);
|
||||
virtual void onTouchMoved(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "onTouchEnded" method of widget.
|
||||
virtual void onTouchEnded(const cocos2d::Point &touchPoint);
|
||||
virtual void onTouchEnded(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "onTouchCancelled" method of widget.
|
||||
virtual void onTouchCancelled(const cocos2d::Point &touchPoint);
|
||||
virtual void onTouchCancelled(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "update" method of widget.
|
||||
virtual void update(float dt);
|
||||
virtual void update(float dt) override;
|
||||
|
||||
virtual void doLayout(){};
|
||||
virtual void doLayout() override{};
|
||||
|
||||
/**
|
||||
* Sets LayoutType.
|
||||
*
|
||||
* @see LayoutType
|
||||
*
|
||||
* @param LayoutType
|
||||
*/
|
||||
virtual void setLayoutType(LayoutType type) override{};
|
||||
|
||||
/**
|
||||
* Gets LayoutType.
|
||||
*
|
||||
* @see LayoutType
|
||||
*
|
||||
* @return LayoutType
|
||||
*/
|
||||
virtual LayoutType getLayoutType() const override{return LAYOUT_ABSOLUTE;};
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual const char* getDescription() const;
|
||||
virtual const char* getDescription() const override;
|
||||
|
||||
protected:
|
||||
virtual bool addChild(UIWidget* widget);
|
||||
virtual bool init();
|
||||
virtual bool addChild(UIWidget* widget) override;
|
||||
virtual bool removeChild(UIWidget* widget) override;
|
||||
virtual void removeAllChildren() override;
|
||||
virtual cocos2d::Array* getChildren() override{return UIWidget::getChildren();};
|
||||
virtual bool init() override;
|
||||
UILayout* createPage();
|
||||
float getPositionXByIndex(int idx);
|
||||
void updateBoundaryPages();
|
||||
virtual void handlePressLogic(const cocos2d::Point &touchPoint);
|
||||
virtual void handleMoveLogic(const cocos2d::Point &touchPoint);
|
||||
virtual void handleReleaseLogic(const cocos2d::Point &touchPoint);
|
||||
virtual void interceptTouchEvent(int handleState, UIWidget* sender, const cocos2d::Point &touchPoint);
|
||||
virtual void checkChildInfo(int handleState, UIWidget* sender, const cocos2d::Point &touchPoint);
|
||||
virtual void handlePressLogic(const cocos2d::Point &touchPoint) override;
|
||||
virtual void handleMoveLogic(const cocos2d::Point &touchPoint) override;
|
||||
virtual void handleReleaseLogic(const cocos2d::Point &touchPoint) override;
|
||||
virtual void interceptTouchEvent(int handleState, UIWidget* sender, const cocos2d::Point &touchPoint) override;
|
||||
virtual void checkChildInfo(int handleState, UIWidget* sender, const cocos2d::Point &touchPoint) override;
|
||||
virtual bool scrollPages(float touchOffset);
|
||||
void movePages(float offset);
|
||||
void pageTurningEvent();
|
||||
void updateChildrenSize();
|
||||
void updateChildrenPosition();
|
||||
virtual void onSizeChanged();
|
||||
virtual UIWidget* createCloneInstance();
|
||||
virtual void copySpecialProperties(UIWidget* model);
|
||||
virtual void copyClonedWidgetChildren(UIWidget* model);
|
||||
virtual void setClippingEnabled(bool able){UILayout::setClippingEnabled(able);};
|
||||
virtual void onSizeChanged() override;
|
||||
virtual UIWidget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(UIWidget* model) override;
|
||||
virtual void copyClonedWidgetChildren(UIWidget* model) override;
|
||||
virtual void setClippingEnabled(bool enabled) override {UILayout::setClippingEnabled(enabled);};
|
||||
protected:
|
||||
int _curPageIdx;
|
||||
cocos2d::Array* _pages;
|
||||
|
|
|
@ -43,7 +43,7 @@ UIRootWidget* UIRootWidget::create()
|
|||
return widget;
|
||||
}
|
||||
CC_SAFE_DELETE(widget);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool UIRootWidget::init()
|
||||
|
|
|
@ -54,10 +54,10 @@ public:
|
|||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual const char* getDescription() const;
|
||||
virtual const char* getDescription() const override;
|
||||
protected:
|
||||
//initializes state of widget.
|
||||
virtual bool init();
|
||||
virtual bool init() override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ const cocos2d::Point SCROLLDIR_LEFT = cocos2d::Point(-1.0f, 0.0f);
|
|||
const cocos2d::Point SCROLLDIR_RIGHT = cocos2d::Point(1.0f, 0.0f);
|
||||
|
||||
UIScrollView::UIScrollView():
|
||||
_innerContainer(NULL),
|
||||
_innerContainer(nullptr),
|
||||
_direction(SCROLLVIEW_DIR_VERTICAL),
|
||||
_touchBeganPoint(cocos2d::Point::ZERO),
|
||||
_touchMovedPoint(cocos2d::Point::ZERO),
|
||||
|
@ -69,15 +69,15 @@ _bouncing(false),
|
|||
_bounceDir(cocos2d::Point::ZERO),
|
||||
_bounceOriginalSpeed(0.0f),
|
||||
_inertiaScrollEnabled(true),
|
||||
_scrollViewEventListener(NULL),
|
||||
_scrollViewEventSelector(NULL)
|
||||
_scrollViewEventListener(nullptr),
|
||||
_scrollViewEventSelector(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
UIScrollView::~UIScrollView()
|
||||
{
|
||||
_scrollViewEventListener = NULL;
|
||||
_scrollViewEventSelector = NULL;
|
||||
_scrollViewEventListener = nullptr;
|
||||
_scrollViewEventSelector = nullptr;
|
||||
}
|
||||
|
||||
UIScrollView* UIScrollView::create()
|
||||
|
@ -89,7 +89,7 @@ UIScrollView* UIScrollView::create()
|
|||
return widget;
|
||||
}
|
||||
CC_SAFE_DELETE(widget);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool UIScrollView::init()
|
||||
|
|
|
@ -234,33 +234,33 @@ public:
|
|||
void addEventListenerScrollView(cocos2d::Object* target, SEL_ScrollViewEvent selector);
|
||||
|
||||
//override "addChild" method of widget.
|
||||
virtual bool addChild(UIWidget* widget);
|
||||
virtual bool addChild(UIWidget* widget) override;
|
||||
|
||||
//override "removeAllChildrenAndCleanUp" method of widget.
|
||||
virtual void removeAllChildren();
|
||||
virtual void removeAllChildren() override;
|
||||
|
||||
//override "removeChild" method of widget.
|
||||
virtual bool removeChild(UIWidget* child);
|
||||
virtual bool removeChild(UIWidget* child) override;
|
||||
|
||||
//override "getChildren" method of widget.
|
||||
virtual cocos2d::Array* getChildren();
|
||||
virtual cocos2d::Array* getChildren() override;
|
||||
|
||||
//override "onTouchBegan" method of widget.
|
||||
virtual bool onTouchBegan(const cocos2d::Point &touchPoint);
|
||||
virtual bool onTouchBegan(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "onTouchMoved" method of widget.
|
||||
virtual void onTouchMoved(const cocos2d::Point &touchPoint);
|
||||
virtual void onTouchMoved(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "onTouchEnded" method of widget.
|
||||
virtual void onTouchEnded(const cocos2d::Point &touchPoint);
|
||||
virtual void onTouchEnded(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "onTouchCancelled" method of widget.
|
||||
virtual void onTouchCancelled(const cocos2d::Point &touchPoint);
|
||||
virtual void onTouchCancelled(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "onTouchLongClicked" method of widget.
|
||||
virtual void onTouchLongClicked(const cocos2d::Point &touchPoint);
|
||||
virtual void onTouchLongClicked(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
virtual void update(float dt);
|
||||
virtual void update(float dt) override;
|
||||
|
||||
void setBounceEnabled(bool enabled);
|
||||
|
||||
|
@ -277,7 +277,7 @@ public:
|
|||
*
|
||||
* @param LayoutType
|
||||
*/
|
||||
virtual void setLayoutType(LayoutType type);
|
||||
virtual void setLayoutType(LayoutType type) override;
|
||||
|
||||
/**
|
||||
* Gets LayoutType.
|
||||
|
@ -286,17 +286,17 @@ public:
|
|||
*
|
||||
* @return LayoutType
|
||||
*/
|
||||
virtual LayoutType getLayoutType() const;
|
||||
virtual LayoutType getLayoutType() const override;
|
||||
|
||||
virtual void doLayout();
|
||||
virtual void doLayout() override;
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual const char* getDescription() const;
|
||||
virtual const char* getDescription() const override;
|
||||
protected:
|
||||
virtual bool init();
|
||||
virtual void initRenderer();
|
||||
virtual bool init() override;
|
||||
virtual void initRenderer() override;
|
||||
void moveChildren(float offsetX, float offsetY);
|
||||
void autoScrollChildren(float dt);
|
||||
void bounceChildren(float dt);
|
||||
|
@ -313,11 +313,11 @@ protected:
|
|||
bool bounceScrollChildren(float touchOffsetX, float touchOffsetY);
|
||||
void startRecordSlidAction();
|
||||
virtual void endRecordSlidAction();
|
||||
virtual void handlePressLogic(const cocos2d::Point &touchPoint);
|
||||
virtual void handleMoveLogic(const cocos2d::Point &touchPoint);
|
||||
virtual void handleReleaseLogic(const cocos2d::Point &touchPoint);
|
||||
virtual void interceptTouchEvent(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint);
|
||||
virtual void checkChildInfo(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint);
|
||||
virtual void handlePressLogic(const cocos2d::Point &touchPoint) override;
|
||||
virtual void handleMoveLogic(const cocos2d::Point &touchPoint) override;
|
||||
virtual void handleReleaseLogic(const cocos2d::Point &touchPoint) override;
|
||||
virtual void interceptTouchEvent(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint) override;
|
||||
virtual void checkChildInfo(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint) override;
|
||||
void recordSlidTime(float dt);
|
||||
void scrollToTopEvent();
|
||||
void scrollToBottomEvent();
|
||||
|
@ -328,11 +328,11 @@ protected:
|
|||
void bounceBottomEvent();
|
||||
void bounceLeftEvent();
|
||||
void bounceRightEvent();
|
||||
virtual void onSizeChanged();
|
||||
virtual UIWidget* createCloneInstance();
|
||||
virtual void copySpecialProperties(UIWidget* model);
|
||||
virtual void copyClonedWidgetChildren(UIWidget* model);
|
||||
virtual void setClippingEnabled(bool able){UILayout::setClippingEnabled(able);};
|
||||
virtual void onSizeChanged() override;
|
||||
virtual UIWidget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(UIWidget* model) override;
|
||||
virtual void copyClonedWidgetChildren(UIWidget* model) override;
|
||||
virtual void setClippingEnabled(bool able) override{UILayout::setClippingEnabled(able);};
|
||||
protected:
|
||||
UILayout* _innerContainer;
|
||||
|
||||
|
|
|
@ -28,13 +28,13 @@
|
|||
namespace gui {
|
||||
|
||||
UISlider::UISlider():
|
||||
_barRenderer(NULL),
|
||||
_progressBarRenderer(NULL),
|
||||
_barRenderer(nullptr),
|
||||
_progressBarRenderer(nullptr),
|
||||
_progressBarTextureSize(cocos2d::Size::ZERO),
|
||||
_slidBallNormalRenderer(NULL),
|
||||
_slidBallPressedRenderer(NULL),
|
||||
_slidBallDisabledRenderer(NULL),
|
||||
_slidBallRenderer(NULL),
|
||||
_slidBallNormalRenderer(nullptr),
|
||||
_slidBallPressedRenderer(nullptr),
|
||||
_slidBallDisabledRenderer(nullptr),
|
||||
_slidBallRenderer(nullptr),
|
||||
_barLength(0.0),
|
||||
_percent(0),
|
||||
_scale9Enabled(false),
|
||||
|
@ -46,8 +46,8 @@ _slidBallPressedTextureFile(""),
|
|||
_slidBallDisabledTextureFile(""),
|
||||
_capInsetsBarRenderer(cocos2d::Rect::ZERO),
|
||||
_capInsetsProgressBarRenderer(cocos2d::Rect::ZERO),
|
||||
_sliderEventListener(NULL),
|
||||
_sliderEventSelector(NULL),
|
||||
_sliderEventListener(nullptr),
|
||||
_sliderEventSelector(nullptr),
|
||||
_barTexType(UI_TEX_TYPE_LOCAL),
|
||||
_progressBarTexType(UI_TEX_TYPE_LOCAL),
|
||||
_ballNTexType(UI_TEX_TYPE_LOCAL),
|
||||
|
@ -58,8 +58,8 @@ _ballDTexType(UI_TEX_TYPE_LOCAL)
|
|||
|
||||
UISlider::~UISlider()
|
||||
{
|
||||
_sliderEventListener = NULL;
|
||||
_sliderEventSelector = NULL;
|
||||
_sliderEventListener = nullptr;
|
||||
_sliderEventSelector = nullptr;
|
||||
}
|
||||
|
||||
UISlider* UISlider::create()
|
||||
|
@ -71,7 +71,7 @@ UISlider* UISlider::create()
|
|||
return widget;
|
||||
}
|
||||
CC_SAFE_DELETE(widget);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UISlider::initRenderer()
|
||||
|
@ -198,8 +198,8 @@ void UISlider::setScale9Enabled(bool able)
|
|||
_scale9Enabled = able;
|
||||
_renderer->removeChild(_barRenderer, true);
|
||||
_renderer->removeChild(_progressBarRenderer, true);
|
||||
_barRenderer = NULL;
|
||||
_progressBarRenderer = NULL;
|
||||
_barRenderer = nullptr;
|
||||
_progressBarRenderer = nullptr;
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
_barRenderer = cocos2d::extension::Scale9Sprite::create();
|
||||
|
|
|
@ -165,43 +165,43 @@ public:
|
|||
void addEventListenerSlider(cocos2d::Object* target,SEL_SlidPercentChangedEvent selector);
|
||||
|
||||
//override "onTouchBegan" method of widget.
|
||||
virtual bool onTouchBegan(const cocos2d::Point &touchPoint);
|
||||
virtual bool onTouchBegan(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "onTouchMoved" method of widget.
|
||||
virtual void onTouchMoved(const cocos2d::Point &touchPoint);
|
||||
virtual void onTouchMoved(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "onTouchEnded" method of widget.
|
||||
virtual void onTouchEnded(const cocos2d::Point &touchPoint);
|
||||
virtual void onTouchEnded(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "onTouchCancelled" method of widget.
|
||||
virtual void onTouchCancelled(const cocos2d::Point &touchPoint);
|
||||
virtual void onTouchCancelled(const cocos2d::Point &touchPoint) override;
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const cocos2d::Size& getContentSize() const;
|
||||
virtual const cocos2d::Size& getContentSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual cocos2d::Node* getVirtualRenderer();
|
||||
virtual cocos2d::Node* getVirtualRenderer() override;
|
||||
|
||||
//override "ignoreContentAdaptWithSize" method of widget.
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore);
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore) override;
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual const char* getDescription() const;
|
||||
virtual const char* getDescription() const override;
|
||||
|
||||
protected:
|
||||
virtual void initRenderer();
|
||||
virtual void initRenderer() override;
|
||||
float getPercentWithBallPos(float location);
|
||||
void percentChangedEvent();
|
||||
virtual void onPressStateChangedToNormal();
|
||||
virtual void onPressStateChangedToPressed();
|
||||
virtual void onPressStateChangedToDisabled();
|
||||
virtual void onSizeChanged();
|
||||
virtual void onPressStateChangedToNormal() override;
|
||||
virtual void onPressStateChangedToPressed() override;
|
||||
virtual void onPressStateChangedToDisabled() override;
|
||||
virtual void onSizeChanged() override;
|
||||
void barRendererScaleChangedWithSize();
|
||||
void progressBarRendererScaleChangedWithSize();
|
||||
virtual UIWidget* createCloneInstance();
|
||||
virtual void copySpecialProperties(UIWidget* model);
|
||||
virtual UIWidget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(UIWidget* model) override;
|
||||
protected:
|
||||
cocos2d::Node* _barRenderer;
|
||||
cocos2d::Node* _progressBarRenderer;
|
||||
|
|
|
@ -57,7 +57,7 @@ UICCTextField * UICCTextField::create(const char *placeholder, const char *fontN
|
|||
}
|
||||
CC_SAFE_DELETE(pRet);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UICCTextField::onEnter()
|
||||
|
@ -271,20 +271,20 @@ bool UICCTextField::getDeleteBackward()
|
|||
|
||||
|
||||
UITextField::UITextField():
|
||||
_textFieldRenderer(NULL),
|
||||
_textFieldRenderer(nullptr),
|
||||
_touchWidth(0.0f),
|
||||
_touchHeight(0.0f),
|
||||
_useTouchArea(false),
|
||||
_textFieldEventListener(NULL),
|
||||
_textFieldEventSelector(NULL),
|
||||
_textFieldEventListener(nullptr),
|
||||
_textFieldEventSelector(nullptr),
|
||||
_passwordStyleText("")
|
||||
{
|
||||
}
|
||||
|
||||
UITextField::~UITextField()
|
||||
{
|
||||
_textFieldEventListener = NULL;
|
||||
_textFieldEventSelector = NULL;
|
||||
_textFieldEventListener = nullptr;
|
||||
_textFieldEventSelector = nullptr;
|
||||
}
|
||||
|
||||
UITextField* UITextField::create()
|
||||
|
@ -296,7 +296,7 @@ UITextField* UITextField::create()
|
|||
return widget;
|
||||
}
|
||||
CC_SAFE_DELETE(widget);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool UITextField::init()
|
||||
|
|
|
@ -106,8 +106,8 @@ public:
|
|||
UITextField();
|
||||
virtual ~UITextField();
|
||||
static UITextField* create();
|
||||
virtual bool init();
|
||||
virtual void initRenderer();
|
||||
virtual bool init() override;
|
||||
virtual void initRenderer() override;
|
||||
void setTouchSize(const cocos2d::Size &size);
|
||||
void setText(const std::string& text);
|
||||
void setPlaceHolder(const std::string& value);
|
||||
|
@ -115,7 +115,7 @@ public:
|
|||
void setFontName(const std::string& name);
|
||||
virtual void didNotSelectSelf();
|
||||
const std::string& getStringValue();
|
||||
virtual bool onTouchBegan(const cocos2d::Point &touchPoint);
|
||||
virtual bool onTouchBegan(const cocos2d::Point &touchPoint) override;
|
||||
void setMaxLengthEnabled(bool enable);
|
||||
bool isMaxLengthEnabled();
|
||||
void setMaxLength(int length);
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
void setPasswordEnabled(bool enable);
|
||||
bool isPasswordEnabled();
|
||||
void setPasswordStyleText(const char* styleText);
|
||||
virtual void update(float dt);
|
||||
virtual void update(float dt) override;
|
||||
bool getAttachWithIME();
|
||||
void setAttachWithIME(bool attach);
|
||||
bool getDetachWithIME();
|
||||
|
@ -134,17 +134,17 @@ public:
|
|||
void setDeleteBackward(bool deleteBackward);
|
||||
void addEventListenerTextField(cocos2d::Object* target, SEL_TextFieldEvent selecor);
|
||||
|
||||
virtual void setAnchorPoint(const cocos2d::Point &pt);
|
||||
virtual void setColor(const cocos2d::Color3B &color);
|
||||
virtual void setOpacity(int opacity);
|
||||
virtual void setAnchorPoint(const cocos2d::Point &pt) override;
|
||||
virtual void setColor(const cocos2d::Color3B &color) override;
|
||||
virtual void setOpacity(int opacity) override;
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual const char* getDescription() const;
|
||||
virtual const char* getDescription() const override;
|
||||
|
||||
virtual const cocos2d::Size& getContentSize() const;
|
||||
virtual cocos2d::Node* getVirtualRenderer();
|
||||
virtual const cocos2d::Size& getContentSize() const override;
|
||||
virtual cocos2d::Node* getVirtualRenderer() override;
|
||||
void attachWithIME();
|
||||
protected:
|
||||
// event
|
||||
|
@ -152,10 +152,10 @@ protected:
|
|||
void detachWithIMEEvent();
|
||||
void insertTextEvent();
|
||||
void deleteBackwardEvent();
|
||||
virtual void onSizeChanged();
|
||||
virtual void onSizeChanged() override;
|
||||
void textfieldRendererScaleChangedWithSize();
|
||||
virtual UIWidget* createCloneInstance();
|
||||
virtual void copySpecialProperties(UIWidget* model);
|
||||
virtual UIWidget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(UIWidget* model) override;
|
||||
protected:
|
||||
UICCTextField* _textFieldRenderer;
|
||||
|
||||
|
|
|
@ -44,46 +44,46 @@ _touchPassedEnabled(false),
|
|||
_focus(false),
|
||||
_widgetZOrder(0),
|
||||
_anchorPoint(cocos2d::Point(0.5f, 0.5f)),
|
||||
_widgetParent(NULL),
|
||||
_widgetParent(nullptr),
|
||||
_brightStyle(BRIGHT_NONE),
|
||||
_updateEnabled(false),
|
||||
_renderer(NULL),
|
||||
_renderer(nullptr),
|
||||
_touchStartPos(cocos2d::Point::ZERO),
|
||||
_touchMovePos(cocos2d::Point::ZERO),
|
||||
_touchEndPos(cocos2d::Point::ZERO),
|
||||
_touchEventListener(NULL),
|
||||
_touchEventSelector(NULL),
|
||||
_touchEventListener(nullptr),
|
||||
_touchEventSelector(nullptr),
|
||||
_widgetTag(-1),
|
||||
_name("default"),
|
||||
_widgetType(WidgetTypeWidget),
|
||||
_actionTag(0),
|
||||
_size(cocos2d::Size::ZERO),
|
||||
_customSize(cocos2d::Size::ZERO),
|
||||
_layoutParameterDictionary(NULL),
|
||||
_layoutParameterDictionary(nullptr),
|
||||
_ignoreSize(false),
|
||||
_children(NULL),
|
||||
_children(nullptr),
|
||||
_affectByClipping(false),
|
||||
_scheduler(NULL),
|
||||
_scheduler(nullptr),
|
||||
_sizeType(SIZE_ABSOLUTE),
|
||||
_sizePercent(cocos2d::Point::ZERO),
|
||||
_positionType(POSITION_ABSOLUTE),
|
||||
_positionPercent(cocos2d::Point::ZERO),
|
||||
_isRunning(false),
|
||||
_userObject(NULL)
|
||||
_userObject(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
UIWidget::~UIWidget()
|
||||
{
|
||||
_touchEventListener = NULL;
|
||||
_touchEventSelector = NULL;
|
||||
_touchEventListener = nullptr;
|
||||
_touchEventSelector = nullptr;
|
||||
removeAllChildren();
|
||||
_children->release();
|
||||
_renderer->removeAllChildrenWithCleanup(true);
|
||||
_renderer->removeFromParentAndCleanup(true);
|
||||
_renderer->release();
|
||||
setParent(NULL);
|
||||
setParent(nullptr);
|
||||
_layoutParameterDictionary->removeAllObjects();
|
||||
CC_SAFE_RELEASE(_layoutParameterDictionary);
|
||||
CC_SAFE_RELEASE(_scheduler);
|
||||
|
@ -99,7 +99,7 @@ UIWidget* UIWidget::create()
|
|||
return widget;
|
||||
}
|
||||
CC_SAFE_DELETE(widget);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool UIWidget::init()
|
||||
|
@ -210,7 +210,7 @@ bool UIWidget::removeChild(UIWidget *child)
|
|||
child->onExit();
|
||||
}
|
||||
child->setUpdateEnabled(false);
|
||||
child->setParent(NULL);
|
||||
child->setParent(nullptr);
|
||||
_renderer->removeChild(child->getRenderer());
|
||||
_children->removeObject(child);
|
||||
return true;
|
||||
|
@ -332,21 +332,33 @@ void UIWidget::setSize(const cocos2d::Size &size)
|
|||
{
|
||||
_size = size;
|
||||
}
|
||||
if (_isRunning)
|
||||
if (_isRunning && _widgetParent)
|
||||
{
|
||||
_sizePercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(_customSize.width / _widgetParent->getSize().width, _customSize.height / _widgetParent->getSize().height);
|
||||
cocos2d::Size pSize = _widgetParent->getSize();
|
||||
float spx = 0.0f;
|
||||
float spy = 0.0f;
|
||||
if (pSize.width > 0.0f)
|
||||
{
|
||||
spx = _customSize.width / pSize.width;
|
||||
}
|
||||
if (pSize.height > 0.0f)
|
||||
{
|
||||
spy = _customSize.height / pSize.height;
|
||||
}
|
||||
_sizePercent = cocos2d::Point(spx, spy);
|
||||
}
|
||||
|
||||
onSizeChanged();
|
||||
}
|
||||
|
||||
void UIWidget::setSizePercent(const cocos2d::Point &percent)
|
||||
{
|
||||
_sizePercent = percent;
|
||||
if (!_isRunning)
|
||||
cocos2d::Size cSize = _customSize;
|
||||
if (_isRunning)
|
||||
{
|
||||
return;
|
||||
cSize = (_widgetParent == nullptr) ? cocos2d::Size::ZERO : cocos2d::Size(_widgetParent->getSize().width * percent.x , _widgetParent->getSize().height * percent.y);
|
||||
}
|
||||
cocos2d::Size cSize = (_widgetParent == NULL) ? cocos2d::Size::ZERO : cocos2d::Size(_widgetParent->getSize().width * percent.x , _widgetParent->getSize().height * percent.y);
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_size = getContentSize();
|
||||
|
@ -364,6 +376,7 @@ void UIWidget::updateSizeAndPosition()
|
|||
switch (_sizeType)
|
||||
{
|
||||
case SIZE_ABSOLUTE:
|
||||
{
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_size = getContentSize();
|
||||
|
@ -372,8 +385,23 @@ void UIWidget::updateSizeAndPosition()
|
|||
{
|
||||
_size = _customSize;
|
||||
}
|
||||
_sizePercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(_customSize.width / _widgetParent->getSize().width, _customSize.height / _widgetParent->getSize().height);
|
||||
if (_widgetParent)
|
||||
{
|
||||
cocos2d::Size pSize = _widgetParent->getSize();
|
||||
float spx = 0.0f;
|
||||
float spy = 0.0f;
|
||||
if (pSize.width > 0.0f)
|
||||
{
|
||||
spx = _customSize.width / pSize.width;
|
||||
}
|
||||
if (pSize.height > 0.0f)
|
||||
{
|
||||
spy = _customSize.height / pSize.height;
|
||||
}
|
||||
_sizePercent = cocos2d::Point(spx, spy);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SIZE_PERCENT:
|
||||
{
|
||||
cocos2d::Size cSize = (_widgetParent == NULL) ? cocos2d::Size::ZERO : cocos2d::Size(_widgetParent->getSize().width * _sizePercent.x , _widgetParent->getSize().height * _sizePercent.y);
|
||||
|
@ -396,14 +424,38 @@ void UIWidget::updateSizeAndPosition()
|
|||
switch (_positionType)
|
||||
{
|
||||
case POSITION_ABSOLUTE:
|
||||
_positionPercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(absPos.x / _widgetParent->getSize().width, absPos.y / _widgetParent->getSize().height);
|
||||
{
|
||||
if (_widgetParent)
|
||||
{
|
||||
cocos2d::Size pSize = _widgetParent->getSize();
|
||||
if (pSize.width <= 0.0f || pSize.height <= 0.0f)
|
||||
{
|
||||
_positionPercent = cocos2d::Point::ZERO;
|
||||
}
|
||||
else
|
||||
{
|
||||
_positionPercent = cocos2d::Point(absPos.x / pSize.width, absPos.y / pSize.height);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_positionPercent = cocos2d::Point::ZERO;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case POSITION_PERCENT:
|
||||
{
|
||||
cocos2d::Size parentSize = _widgetParent->getSize();
|
||||
absPos = cocos2d::Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y);
|
||||
}
|
||||
if (_widgetParent)
|
||||
{
|
||||
cocos2d::Size parentSize = _widgetParent->getSize();
|
||||
absPos = cocos2d::Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
absPos = cocos2d::Point::ZERO;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -740,7 +792,7 @@ bool UIWidget::clippingParentAreaContainPoint(const cocos2d::Point &pt)
|
|||
{
|
||||
_affectByClipping = false;
|
||||
UIWidget* parent = getParent();
|
||||
UIWidget* clippingParent = NULL;
|
||||
UIWidget* clippingParent = nullptr;
|
||||
while (parent)
|
||||
{
|
||||
UILayout* layoutParent = dynamic_cast<UILayout*>(parent);
|
||||
|
@ -788,9 +840,17 @@ void UIWidget::checkChildInfo(int handleState, UIWidget *sender, const cocos2d::
|
|||
|
||||
void UIWidget::setPosition(const cocos2d::Point &pos)
|
||||
{
|
||||
if (_isRunning)
|
||||
if (_isRunning && _widgetParent)
|
||||
{
|
||||
_positionPercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(pos.x / _widgetParent->getSize().width, pos.y / _widgetParent->getSize().height);
|
||||
cocos2d::Size pSize = _widgetParent->getSize();
|
||||
if (pSize.width <= 0.0f || pSize.height <= 0.0f)
|
||||
{
|
||||
_positionPercent = cocos2d::Point::ZERO;
|
||||
}
|
||||
else
|
||||
{
|
||||
_positionPercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(pos.x / pSize.width, pos.y / pSize.height);
|
||||
}
|
||||
}
|
||||
_renderer->setPosition(pos);
|
||||
}
|
||||
|
@ -798,7 +858,7 @@ void UIWidget::setPosition(const cocos2d::Point &pos)
|
|||
void UIWidget::setPositionPercent(const cocos2d::Point &percent)
|
||||
{
|
||||
_positionPercent = percent;
|
||||
if (_isRunning)
|
||||
if (_isRunning && _widgetParent)
|
||||
{
|
||||
cocos2d::Size parentSize = _widgetParent->getSize();
|
||||
cocos2d::Point absPos = cocos2d::Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y);
|
||||
|
@ -1115,6 +1175,10 @@ WidgetType UIWidget::getWidgetType() const
|
|||
|
||||
void UIWidget::setLayoutParameter(UILayoutParameter *parameter)
|
||||
{
|
||||
if (!parameter)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_layoutParameterDictionary->setObject(parameter, parameter->getLayoutType());
|
||||
}
|
||||
|
||||
|
|
|
@ -52,10 +52,10 @@ PhysicsContact::PhysicsContact()
|
|||
, _info(nullptr)
|
||||
, _notificationEnable(true)
|
||||
, _begin(false)
|
||||
, _result(true)
|
||||
, _data(nullptr)
|
||||
, _contactInfo(nullptr)
|
||||
, _contactData(nullptr)
|
||||
, _result(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ set(LUABINDING_SRC
|
|||
lua/bindings/LuaBasicConversions.cpp
|
||||
lua/bindings/lua_cocos2dx_manual.cpp
|
||||
lua/bindings/lua_cocos2dx_extension_manual.cpp
|
||||
lua/bindings/lua_cocos2dx_coco_studio_manual.cpp
|
||||
lua/bindings/lua_cocos2dx_deprecated.cpp
|
||||
lua/bindings/lua_xml_http_request.cpp
|
||||
)
|
||||
|
@ -23,6 +24,7 @@ include_directories(
|
|||
lua/bindings
|
||||
../../cocos/editor-support/cocosbuilder
|
||||
../../cocos/editor-support/cocostudio
|
||||
../../cocos/gui
|
||||
../../external/lua/lua
|
||||
../../external/lua/tolua
|
||||
)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 3fa10c3f8f9fe083ef05cb401924d31740da9719
|
||||
Subproject commit e76bd3683fd785d1b23d59d153641a7f5ae6e583
|
|
@ -1024,8 +1024,8 @@ jsval cccolor4b_to_jsval(JSContext* cx, const Color4B& v) {
|
|||
if (!tmp) return JSVAL_NULL;
|
||||
JSBool ok = JS_DefineProperty(cx, tmp, "r", INT_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
JS_DefineProperty(cx, tmp, "g", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
JS_DefineProperty(cx, tmp, "b", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
JS_DefineProperty(cx, tmp, "a", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
JS_DefineProperty(cx, tmp, "b", INT_TO_JSVAL(v.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
JS_DefineProperty(cx, tmp, "a", INT_TO_JSVAL(v.a), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
if (ok) {
|
||||
return OBJECT_TO_JSVAL(tmp);
|
||||
}
|
||||
|
@ -1037,8 +1037,8 @@ jsval cccolor4f_to_jsval(JSContext* cx, const Color4F& v) {
|
|||
if (!tmp) return JSVAL_NULL;
|
||||
JSBool ok = JS_DefineProperty(cx, tmp, "r", DOUBLE_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
JS_DefineProperty(cx, tmp, "g", DOUBLE_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
JS_DefineProperty(cx, tmp, "b", DOUBLE_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
JS_DefineProperty(cx, tmp, "a", DOUBLE_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
JS_DefineProperty(cx, tmp, "b", DOUBLE_TO_JSVAL(v.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
JS_DefineProperty(cx, tmp, "a", DOUBLE_TO_JSVAL(v.a), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
if (ok) {
|
||||
return OBJECT_TO_JSVAL(tmp);
|
||||
}
|
||||
|
@ -1050,7 +1050,7 @@ jsval cccolor3b_to_jsval(JSContext* cx, const Color3B& v) {
|
|||
if (!tmp) return JSVAL_NULL;
|
||||
JSBool ok = JS_DefineProperty(cx, tmp, "r", INT_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
JS_DefineProperty(cx, tmp, "g", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
JS_DefineProperty(cx, tmp, "b", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
JS_DefineProperty(cx, tmp, "b", INT_TO_JSVAL(v.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
if (ok) {
|
||||
return OBJECT_TO_JSVAL(tmp);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ LOCAL_SRC_FILES := CCLuaBridge.cpp \
|
|||
../../auto-generated/lua-bindings/lua_cocos2dx_studio_auto.cpp \
|
||||
lua_cocos2dx_manual.cpp \
|
||||
lua_cocos2dx_extension_manual.cpp \
|
||||
lua_cocos2dx_coco_studio_manual.cpp \
|
||||
lua_cocos2dx_deprecated.cpp \
|
||||
lua_xml_http_request.cpp \
|
||||
platform/android/CCLuaJavaBridge.cpp \
|
||||
|
@ -37,7 +38,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../external/lua/tolua \
|
|||
$(LOCAL_PATH)/platform/android/jni \
|
||||
$(LOCAL_PATH)/../../../../extensions \
|
||||
$(LOCAL_PATH)/../../../editor-support/cocosbuilder \
|
||||
$(LOCAL_PATH)/../../../editor-support/cocostudio
|
||||
$(LOCAL_PATH)/../../../editor-support/cocostudio \
|
||||
$(LOCAL_PATH)/../../../gui
|
||||
|
||||
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "extensions/GUI/CCControlExtension/CCControl.h"
|
||||
#include "LuaOpengl.h"
|
||||
#include "lua_cocos2dx_extension_manual.h"
|
||||
#include "lua_cocos2dx_coco_studio_manual.hpp"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -257,6 +258,16 @@ int LuaEngine::sendEvent(ScriptEvent* evt)
|
|||
return handleAssetsManagerEvent(evt->data);
|
||||
}
|
||||
break;
|
||||
case kCocoStudioEventListener:
|
||||
{
|
||||
return handleCocoStudioEventListener(evt->data);
|
||||
}
|
||||
break;
|
||||
case kArmatureWrapper:
|
||||
{
|
||||
return handleArmatureWrapper(evt->data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -818,4 +829,84 @@ int LuaEngine::handleAssetsManagerEvent(void* data)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int LuaEngine::handleCocoStudioEventListener(void* data)
|
||||
{
|
||||
|
||||
if (nullptr == data)
|
||||
return 0;
|
||||
|
||||
BasicScriptData* eventData = static_cast<BasicScriptData*>(data);
|
||||
if (nullptr == eventData->nativeObject || nullptr == eventData->value)
|
||||
return 0;
|
||||
|
||||
LuaCocoStudioEventListenerData* listenerData = static_cast<LuaCocoStudioEventListenerData*>(eventData->value);
|
||||
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
||||
|
||||
if (0 == handler)
|
||||
return 0;
|
||||
|
||||
_stack->pushObject(listenerData->objTarget, "Object");
|
||||
_stack->pushInt(listenerData->eventType);
|
||||
|
||||
_stack->executeFunctionByHandler(handler, 2);
|
||||
_stack->clean();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngine::handleArmatureWrapper(void* data)
|
||||
{
|
||||
if (nullptr == data)
|
||||
return 0;
|
||||
|
||||
BasicScriptData* eventData = static_cast<BasicScriptData*>(data);
|
||||
if (nullptr == eventData->nativeObject || nullptr == eventData->value)
|
||||
return 0;
|
||||
|
||||
LuaArmatureWrapperEventData* wrapperData = static_cast<LuaArmatureWrapperEventData*>(eventData->value);
|
||||
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT);
|
||||
|
||||
if (0 == handler)
|
||||
return 0;
|
||||
|
||||
switch (wrapperData->eventType)
|
||||
{
|
||||
case LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::MOVEMENT_EVENT:
|
||||
{
|
||||
LuaArmatureMovementEventData* movementData = static_cast<LuaArmatureMovementEventData*>(wrapperData->eventData);
|
||||
|
||||
_stack->pushObject(movementData->objTarget, "Armature");
|
||||
_stack->pushInt(movementData->movementType);
|
||||
_stack->pushString(movementData->movementID.c_str());
|
||||
_stack->executeFunctionByHandler(handler, 3);
|
||||
}
|
||||
break;
|
||||
case LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FRAME_EVENT:
|
||||
{
|
||||
LuaArmatureFrameEventData* frameData = static_cast<LuaArmatureFrameEventData*>(wrapperData->eventData);
|
||||
|
||||
_stack->pushObject(frameData->objTarget, "Bone");
|
||||
_stack->pushString(frameData->frameEventName.c_str());
|
||||
_stack->pushInt(frameData->originFrameIndex);
|
||||
_stack->pushInt(frameData->currentFrameIndex);
|
||||
_stack->executeFunctionByHandler(handler, 4);
|
||||
}
|
||||
break;
|
||||
case LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FILE_ASYNC:
|
||||
{
|
||||
_stack->pushFloat(*(float*)wrapperData->eventData);
|
||||
_stack->executeFunctionByHandler(handler, 1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
_stack->clean();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -142,6 +142,8 @@ private:
|
|||
int handleTableViewEvent(void* data);
|
||||
int handleTableViewEventReturnArray(void* data,int numResults,Array& resultArray);
|
||||
int handleAssetsManagerEvent(void* data);
|
||||
int handleCocoStudioEventListener(void* data);
|
||||
int handleArmatureWrapper(void* data);
|
||||
void extendWebsocket(lua_State* lua_S);
|
||||
void extendGLNode(lua_State* lua_S);
|
||||
private:
|
||||
|
|
|
@ -55,6 +55,7 @@ extern "C" {
|
|||
#include "lua_cocos2dx_deprecated.h"
|
||||
#include "lua_xml_http_request.h"
|
||||
#include "lua_cocos2dx_studio_auto.hpp"
|
||||
#include "lua_cocos2dx_coco_studio_manual.hpp"
|
||||
|
||||
namespace {
|
||||
int lua_print(lua_State * luastate)
|
||||
|
@ -140,6 +141,7 @@ bool LuaStack::init(void)
|
|||
register_all_cocos2dx_manual(_state);
|
||||
register_all_cocos2dx_extension_manual(_state);
|
||||
register_all_cocos2dx_manual_deprecated(_state);
|
||||
register_all_cocos2dx_coco_studio_manual(_state);
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
LuaObjcBridge::luaopen_luaoc(_state);
|
||||
#endif
|
||||
|
|
|
@ -101,6 +101,9 @@ public:
|
|||
ASSETSMANAGER_PROGRESS,
|
||||
ASSETSMANAGER_SUCCESS,
|
||||
ASSETSMANAGER_ERROR,
|
||||
|
||||
EVENT_LISTENER,
|
||||
ARMATURE_EVENT,
|
||||
};
|
||||
|
||||
typedef int Handler;
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\..\..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)extensions\network;$(EngineRoot)external;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\..\..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)extensions\network;$(EngineRoot)external;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\gui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
|
@ -96,7 +96,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$
|
|||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\..\..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)extensions\network;$(EngineRoot)external;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\..\..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)extensions\network;$(EngineRoot)external;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\gui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
|
@ -131,6 +131,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$
|
|||
<ClCompile Include="..\..\..\..\external\lua\tolua\tolua_to.c" />
|
||||
<ClCompile Include="..\..\auto-generated\lua-bindings\lua_cocos2dx_auto.cpp" />
|
||||
<ClCompile Include="..\..\auto-generated\lua-bindings\lua_cocos2dx_extension_auto.cpp" />
|
||||
<ClCompile Include="..\..\auto-generated\lua-bindings\lua_cocos2dx_studio_auto.cpp" />
|
||||
<ClCompile Include="CCBProxy.cpp" />
|
||||
<ClCompile Include="CCLuaBridge.cpp" />
|
||||
<ClCompile Include="CCLuaEngine.cpp" />
|
||||
|
@ -140,6 +141,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$
|
|||
<ClCompile Include="LuaBasicConversions.cpp" />
|
||||
<ClCompile Include="LuaOpengl.cpp" />
|
||||
<ClCompile Include="LuaScriptHandlerMgr.cpp" />
|
||||
<ClCompile Include="lua_cocos2dx_coco_studio_manual.cpp" />
|
||||
<ClCompile Include="lua_cocos2dx_deprecated.cpp" />
|
||||
<ClCompile Include="lua_cocos2dx_extension_manual.cpp" />
|
||||
<ClCompile Include="lua_cocos2dx_manual.cpp" />
|
||||
|
@ -156,6 +158,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$
|
|||
<ClInclude Include="..\..\..\..\external\lua\tolua\tolua_event.h" />
|
||||
<ClInclude Include="..\..\auto-generated\lua-bindings\lua_cocos2dx_auto.hpp" />
|
||||
<ClInclude Include="..\..\auto-generated\lua-bindings\lua_cocos2dx_extension_auto.hpp" />
|
||||
<ClInclude Include="..\..\auto-generated\lua-bindings\lua_cocos2dx_studio_auto.hpp" />
|
||||
<ClInclude Include="CCBProxy.h" />
|
||||
<ClInclude Include="CCLuaBridge.h" />
|
||||
<ClInclude Include="CCLuaEngine.h" />
|
||||
|
@ -165,6 +168,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$
|
|||
<ClInclude Include="LuaBasicConversions.h" />
|
||||
<ClInclude Include="LuaOpengl.h" />
|
||||
<ClInclude Include="LuaScriptHandlerMgr.h" />
|
||||
<ClInclude Include="lua_cocos2dx_coco_studio_manual.hpp" />
|
||||
<ClInclude Include="lua_cocos2dx_deprecated.h" />
|
||||
<ClInclude Include="lua_cocos2dx_extension_manual.h" />
|
||||
<ClInclude Include="lua_cocos2dx_manual.hpp" />
|
||||
|
|
|
@ -84,6 +84,12 @@
|
|||
<ClCompile Include="lua_xml_http_request.cpp">
|
||||
<Filter>cocos2dx_support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\auto-generated\lua-bindings\lua_cocos2dx_studio_auto.cpp">
|
||||
<Filter>cocos2dx_support\generated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="lua_cocos2dx_coco_studio_manual.cpp">
|
||||
<Filter>cocos2dx_support</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\auto-generated\lua-bindings\lua_cocos2dx_auto.hpp">
|
||||
|
@ -155,6 +161,12 @@
|
|||
<ClInclude Include="lua_xml_http_request.h">
|
||||
<Filter>cocos2dx_support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\auto-generated\lua-bindings\lua_cocos2dx_studio_auto.hpp">
|
||||
<Filter>cocos2dx_support\generated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lua_cocos2dx_coco_studio_manual.hpp">
|
||||
<Filter>cocos2dx_support</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\auto-generated\lua-bindings\lua_cocos2dx_auto_api.js">
|
||||
|
|
|
@ -0,0 +1,916 @@
|
|||
#include "lua_cocos2dx_coco_studio_manual.hpp"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "tolua_fix.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include "LuaBasicConversions.h"
|
||||
#include "LuaScriptHandlerMgr.h"
|
||||
#include "CCLuaValue.h"
|
||||
#include "CocosGUI.h"
|
||||
#include "CocoStudio.h"
|
||||
|
||||
using namespace gui;
|
||||
using namespace cocostudio;
|
||||
|
||||
class LuaCocoStudioEventListener:public Object
|
||||
{
|
||||
public:
|
||||
LuaCocoStudioEventListener();
|
||||
virtual ~LuaCocoStudioEventListener();
|
||||
|
||||
static LuaCocoStudioEventListener* create();
|
||||
|
||||
virtual void eventCallbackFunc(Object* sender,int eventType);
|
||||
};
|
||||
|
||||
LuaCocoStudioEventListener::LuaCocoStudioEventListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LuaCocoStudioEventListener::~LuaCocoStudioEventListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LuaCocoStudioEventListener* LuaCocoStudioEventListener::create()
|
||||
{
|
||||
LuaCocoStudioEventListener* listener = new LuaCocoStudioEventListener();
|
||||
if (nullptr == listener)
|
||||
return nullptr;
|
||||
|
||||
listener->autorelease();
|
||||
|
||||
return listener;
|
||||
}
|
||||
|
||||
void LuaCocoStudioEventListener::eventCallbackFunc(Object* sender,int eventType)
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
||||
|
||||
if (0 != handler)
|
||||
{
|
||||
LuaCocoStudioEventListenerData eventData(sender,eventType);
|
||||
BasicScriptData data(this,(void*)&eventData);
|
||||
ScriptEvent scriptEvent(kCocoStudioEventListener,(void*)&data);
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
|
||||
}
|
||||
}
|
||||
|
||||
static int lua_cocos2dx_UIWidget_addTouchEventListener(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
UIWidget* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"UIWidget",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<UIWidget*>(tolua_tousertype(L,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UIWidget_addTouchEventListener'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (1 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err))
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create();
|
||||
if (nullptr == listener)
|
||||
{
|
||||
tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
||||
|
||||
self->setUserObject(listener);
|
||||
self->addTouchEventListener(listener, toucheventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'addTouchEventListener' function of UIWidget has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'addTouchEventListener'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void extendUIWidget(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "UIWidget");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "addTouchEventListener", lua_cocos2dx_UIWidget_addTouchEventListener);
|
||||
}
|
||||
}
|
||||
|
||||
static int lua_cocos2dx_UICheckBox_addEventListenerCheckBox(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
UICheckBox* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"UICheckBox",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<UICheckBox*>(tolua_tousertype(L,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UICheckBox_addEventListenerCheckBox'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
argc = lua_gettop(L) - 1;
|
||||
if (1 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err))
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create();
|
||||
if (nullptr == listener)
|
||||
{
|
||||
tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
||||
|
||||
self->setUserObject(listener);
|
||||
self->addEventListenerCheckBox(listener, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'addEventListenerCheckBox' function of UICheckBox has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'addEventListenerCheckBox'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void extendUICheckBox(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "UICheckBox");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "addEventListenerCheckBox", lua_cocos2dx_UICheckBox_addEventListenerCheckBox);
|
||||
}
|
||||
}
|
||||
|
||||
static int lua_cocos2dx_UISlider_addEventListenerSlider(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
UISlider* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"UISlider",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<UISlider*>(tolua_tousertype(L,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UISlider_addEventListenerSlider'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
argc = lua_gettop(L) - 1;
|
||||
if (1 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) )
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create();
|
||||
if (nullptr == listener)
|
||||
{
|
||||
tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
||||
|
||||
self->setUserObject(listener);
|
||||
self->addEventListenerSlider(listener, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'addEventListenerSlider' function of UISlider has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'addEventListenerSlider'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void extendUISlider(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "UISlider");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "addEventListenerSlider", lua_cocos2dx_UISlider_addEventListenerSlider);
|
||||
}
|
||||
}
|
||||
|
||||
static int lua_cocos2dx_UITextField_addEventListenerTextField(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
UITextField* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"UITextField",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<UITextField*>(tolua_tousertype(L,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UITextField_addEventListenerTextField'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
argc = lua_gettop(L) - 1;
|
||||
if (1 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err))
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create();
|
||||
if (nullptr == listener)
|
||||
{
|
||||
tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
||||
|
||||
self->setUserObject(listener);
|
||||
self->addEventListenerTextField(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'addEventListenerTextField' function of UITextField has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'addEventListenerTextField'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void extendUITextField(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "UITextField");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "addEventListenerTextField", lua_cocos2dx_UITextField_addEventListenerTextField);
|
||||
}
|
||||
}
|
||||
|
||||
static int lua_cocos2dx_UIPageView_addEventListenerPageView(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
UIPageView* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"UIPageView",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<UIPageView*>(tolua_tousertype(L,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UIPageView_addEventListenerPageView'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
argc = lua_gettop(L) - 1;
|
||||
if (1 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) )
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create();
|
||||
if (nullptr == listener)
|
||||
{
|
||||
tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
||||
|
||||
self->setUserObject(listener);
|
||||
self->addEventListenerPageView(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'addEventListenerPageView' function of UIPageView has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'addEventListenerPageView'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void extendUIPageView(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "UIPageView");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "addEventListenerPageView", lua_cocos2dx_UIPageView_addEventListenerPageView);
|
||||
}
|
||||
}
|
||||
|
||||
static int lua_cocos2dx_UIListView_addEventListenerListView(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
UIListView* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"UIListView",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<UIListView*>(tolua_tousertype(L,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UIListView_addEventListenerListView'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
argc = lua_gettop(L) - 1;
|
||||
if (1 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err))
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create();
|
||||
if (nullptr == listern)
|
||||
{
|
||||
tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
||||
|
||||
self->setUserObject(listern);
|
||||
self->addEventListenerListView(listern, listvieweventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'addEventListenerListView' function of UIListView has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'addEventListenerListView'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void extendUIListView(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "UIListView");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "addEventListenerListView", lua_cocos2dx_UIListView_addEventListenerListView);
|
||||
}
|
||||
}
|
||||
|
||||
static int lua_cocos2dx_UILayoutParameter_setMargin(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
UILayoutParameter* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"UILayoutParameter",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<UILayoutParameter*>(tolua_tousertype(L,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UILayoutParameter_setMargin'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (1 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_istable(L, 2, 0, &tolua_err))
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
|
||||
UIMargin margin;
|
||||
lua_pushstring(L, "left");
|
||||
lua_gettable(L,2);
|
||||
margin.left = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1);
|
||||
lua_pop(L,1);
|
||||
|
||||
lua_pushstring(L, "top");
|
||||
lua_gettable(L,2);
|
||||
margin.top = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1);
|
||||
lua_pop(L,1);
|
||||
|
||||
lua_pushstring(L, "right");
|
||||
lua_gettable(L,2);
|
||||
margin.right = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1);
|
||||
lua_pop(L,1);
|
||||
|
||||
lua_pushstring(L, "bottom");
|
||||
lua_gettable(L,2);
|
||||
margin.bottom = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1);
|
||||
lua_pop(L,1);
|
||||
|
||||
self->setMargin(margin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'setMargin' function of UILayoutParameter has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'setMargin'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int lua_cocos2dx_UILayoutParameter_getMargin(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
UILayoutParameter* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"LayoutParameter",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<UILayoutParameter*>(tolua_tousertype(L,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_LayoutParameter_getMargin'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (0 == argc)
|
||||
{
|
||||
UIMargin margin = self->getMargin();
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
lua_pushstring(L, "left");
|
||||
lua_pushnumber(L, (lua_Number) margin.left);
|
||||
lua_rawset(L, -3);
|
||||
|
||||
lua_pushstring(L, "top");
|
||||
lua_pushnumber(L, (lua_Number) margin.top);
|
||||
lua_rawset(L, -3);
|
||||
|
||||
lua_pushstring(L, "right");
|
||||
lua_pushnumber(L, (lua_Number) margin.right);
|
||||
lua_rawset(L, -3);
|
||||
|
||||
lua_pushstring(L, "bottom");
|
||||
lua_pushnumber(L, (lua_Number) margin.bottom);
|
||||
lua_rawset(L, -3);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
CCLOG("'getMargin' function of LayoutParameter has wrong number of arguments: %d, was expecting %d\n", argc, 0);
|
||||
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'getMargin'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void extendLayoutParameter(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "UILayoutParameter");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "setMargin", lua_cocos2dx_UILayoutParameter_setMargin);
|
||||
tolua_function(L, "getMargin", lua_cocos2dx_UILayoutParameter_getMargin);
|
||||
}
|
||||
}
|
||||
|
||||
class LuaArmatureWrapper:public Object
|
||||
{
|
||||
public:
|
||||
LuaArmatureWrapper();
|
||||
virtual ~LuaArmatureWrapper();
|
||||
|
||||
virtual void movementEventCallback(Armature* armature, MovementEventType type,const char* movementID);
|
||||
virtual void frameEventCallback(Bone* bone, const char* frameEventName, int orginFrameIndex, int currentFrameIndex);
|
||||
virtual void addArmatureFileInfoAsyncCallback(float percent);
|
||||
};
|
||||
|
||||
LuaArmatureWrapper::LuaArmatureWrapper()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LuaArmatureWrapper::~LuaArmatureWrapper()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LuaArmatureWrapper::movementEventCallback(Armature* armature, MovementEventType type,const char* movementID)
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT);
|
||||
|
||||
if (0 != handler)
|
||||
{
|
||||
std::string strMovementID = movementID;
|
||||
LuaArmatureMovementEventData movementData(armature,(int)type, strMovementID);
|
||||
|
||||
LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::MOVEMENT_EVENT , (void*)&movementData);
|
||||
|
||||
BasicScriptData data(this,(void*)&wrapperData);
|
||||
|
||||
ScriptEvent scriptEvent(kArmatureWrapper,(void*)&data);
|
||||
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
|
||||
}
|
||||
}
|
||||
|
||||
void LuaArmatureWrapper::frameEventCallback(Bone* bone, const char* frameEventName, int orginFrameIndex, int currentFrameIndex)
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT);
|
||||
|
||||
if (0 != handler)
|
||||
{
|
||||
std::string strFrameEventName(frameEventName);
|
||||
|
||||
LuaArmatureFrameEventData frameData(bone,strFrameEventName,orginFrameIndex,currentFrameIndex);
|
||||
|
||||
LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FRAME_EVENT , (void*)&frameData);
|
||||
|
||||
BasicScriptData data(this,(void*)&wrapperData);
|
||||
|
||||
ScriptEvent scriptEvent(kArmatureWrapper,(void*)&data);
|
||||
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
|
||||
}
|
||||
}
|
||||
|
||||
void LuaArmatureWrapper::addArmatureFileInfoAsyncCallback(float percent)
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT);
|
||||
|
||||
if (0 != handler)
|
||||
{
|
||||
LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FILE_ASYNC , (void*)&percent);
|
||||
|
||||
BasicScriptData data(this,(void*)&wrapperData);
|
||||
|
||||
ScriptEvent scriptEvent(kArmatureWrapper,(void*)&data);
|
||||
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
|
||||
}
|
||||
}
|
||||
|
||||
static int lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
ArmatureAnimation* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"ArmatureAnimation",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<ArmatureAnimation*>(tolua_tousertype(L,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (1 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err))
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
|
||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||
|
||||
LuaArmatureWrapper* wrapper = new LuaArmatureWrapper();
|
||||
wrapper->autorelease();
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT);
|
||||
|
||||
self->setUserObject(wrapper);
|
||||
self->setMovementEventCallFunc(wrapper, movementEvent_selector(LuaArmatureWrapper::movementEventCallback));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'setMovementEventCallFunc' function of ArmatureAnimation has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'setMovementEventCallFunc'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
ArmatureAnimation* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"ArmatureAnimation",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<ArmatureAnimation*>(tolua_tousertype(L,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (1 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) )
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
|
||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||
|
||||
LuaArmatureWrapper* wrapper = new LuaArmatureWrapper();
|
||||
wrapper->autorelease();
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT);
|
||||
|
||||
self->setUserObject(wrapper);
|
||||
self->setFrameEventCallFunc(wrapper, frameEvent_selector(LuaArmatureWrapper::frameEventCallback));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
CCLOG("'setFrameEventCallFunc' function of ArmatureAnimation has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'setFrameEventCallFunc'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void extendArmatureAnimation(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "ArmatureAnimation");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "setMovementEventCallFunc", lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc);
|
||||
tolua_function(L, "setFrameEventCallFunc", lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc);
|
||||
}
|
||||
}
|
||||
|
||||
static int lua_cocos2dx_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0 ;
|
||||
|
||||
int argc = 0;
|
||||
ArmatureDataManager* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"ArmatureDataManager",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<ArmatureDataManager*>(tolua_tousertype(L,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (2 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isstring(L, 2, 0, &tolua_err) ||
|
||||
!toluafix_isfunction(L,3,"LUA_FUNCTION",0,&tolua_err))
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
const char* configFilePath = tolua_tostring(L, 2, "");
|
||||
LUA_FUNCTION handler = ( toluafix_ref_function(L, 3, 0));
|
||||
|
||||
LuaArmatureWrapper* wrapper = new LuaArmatureWrapper();
|
||||
wrapper->autorelease();
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT);
|
||||
|
||||
self->addArmatureFileInfoAsync(configFilePath, wrapper, schedule_selector(LuaArmatureWrapper::addArmatureFileInfoAsyncCallback));
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if (4 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if ( !tolua_isstring(L, 2, 0, &tolua_err) ||
|
||||
!tolua_isstring(L, 3, 0, &tolua_err) ||
|
||||
!tolua_isstring(L, 4, 0, &tolua_err) ||
|
||||
!toluafix_isfunction(L,5,"LUA_FUNCTION",0,&tolua_err))
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
const char* imagePath = tolua_tostring(L, 2, "");
|
||||
const char* plistPath = tolua_tostring(L, 3, "");
|
||||
const char* configFilePath = tolua_tostring(L, 4, "");
|
||||
|
||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,5,0));
|
||||
|
||||
LuaArmatureWrapper* wrapper = new LuaArmatureWrapper();
|
||||
wrapper->autorelease();
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT);
|
||||
|
||||
self->addArmatureFileInfoAsync(imagePath, plistPath,configFilePath,wrapper, schedule_selector(LuaArmatureWrapper::addArmatureFileInfoAsyncCallback));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'addArmatureFileInfoAsync' function of ArmatureDataManager has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'addArmatureFileInfoAsync'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void extendArmatureDataManager(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "ArmatureDataManager");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "addArmatureFileInfoAsync", lua_cocos2dx_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc);
|
||||
}
|
||||
}
|
||||
|
||||
int register_all_cocos2dx_coco_studio_manual(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
extendUIWidget(L);
|
||||
extendUICheckBox(L);
|
||||
extendUISlider(L);
|
||||
extendUITextField(L);
|
||||
extendUIPageView(L);
|
||||
extendUIListView(L);
|
||||
extendLayoutParameter(L);
|
||||
extendArmatureAnimation(L);
|
||||
extendArmatureDataManager(L);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_COCO_STUDIO_MANUAL_H
|
||||
#define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_COCO_STUDIO_MANUAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "tolua++.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "CCObject.h"
|
||||
|
||||
TOLUA_API int register_all_cocos2dx_coco_studio_manual(lua_State* L);
|
||||
|
||||
struct LuaCocoStudioEventListenerData
|
||||
{
|
||||
cocos2d::Object* objTarget;
|
||||
int eventType;
|
||||
|
||||
LuaCocoStudioEventListenerData(cocos2d::Object* _objTarget, int _eventType):objTarget(_objTarget),eventType(_eventType)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct LuaArmatureWrapperEventData
|
||||
{
|
||||
enum class LuaArmatureWrapperEventType
|
||||
{
|
||||
MOVEMENT_EVENT,
|
||||
FRAME_EVENT,
|
||||
FILE_ASYNC,
|
||||
};
|
||||
|
||||
LuaArmatureWrapperEventType eventType;
|
||||
void* eventData;
|
||||
|
||||
LuaArmatureWrapperEventData(LuaArmatureWrapperEventType _eventType, void* _eventData):eventType(_eventType),eventData(_eventData)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct LuaArmatureMovementEventData
|
||||
{
|
||||
cocos2d::Object* objTarget;
|
||||
int movementType;
|
||||
std::string movementID;
|
||||
|
||||
LuaArmatureMovementEventData(cocos2d::Object* _objTarget, int _movementType,const std::string& _movementID):objTarget(_objTarget),movementType(_movementType),movementID(_movementID)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct LuaArmatureFrameEventData
|
||||
{
|
||||
cocos2d::Object* objTarget;
|
||||
std::string frameEventName;
|
||||
int originFrameIndex;
|
||||
int currentFrameIndex;
|
||||
|
||||
LuaArmatureFrameEventData( cocos2d::Object* _objTarget, const std::string& _frameEventName, int _originFrameIndex, int _currentFrameIndex):objTarget(_objTarget), frameEventName(_frameEventName),originFrameIndex(_originFrameIndex), currentFrameIndex(_currentFrameIndex)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif // #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_COCO_STUDIO_MANUAL_H
|
|
@ -186,7 +186,7 @@ static int tolua_cocos2d_ScrollView_unregisterScriptHandler(lua_State* tolua_S)
|
|||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'unregisterScriptHandler' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 0);
|
||||
CCLOG("'unregisterScriptHandler' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
|
@ -313,7 +313,7 @@ static int tolua_cocos2d_control_unregisterControlEventHandler(lua_State* tolua_
|
|||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'unregisterControlEventHandler' function of Control has wrong number of arguments: %d, was expecting %d\n", argc, 0);
|
||||
CCLOG("'unregisterControlEventHandler' function of Control has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
|
@ -1190,7 +1190,7 @@ static int lua_cocos2dx_TableView_create(lua_State* L)
|
|||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(L,3,"Node",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
Node* node = static_cast<Node*>(tolua_tousertype(L, 2, nullptr));
|
||||
Node* node = static_cast<Node*>(tolua_tousertype(L, 3, nullptr));
|
||||
ret = TableView::create(dataSource, size, node);
|
||||
}
|
||||
|
||||
|
@ -1495,7 +1495,14 @@ static int lua_cocos2dx_AssetsManager_setDelegate(lua_State* L)
|
|||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (2 == argc)
|
||||
{
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err) ||
|
||||
!tolua_isnumber(L, 3, 0, &tolua_err) )
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
LuaAssetsManagerDelegateProtocol* delegate = dynamic_cast<LuaAssetsManagerDelegateProtocol*>( self->getDelegate());
|
||||
if (nullptr == delegate)
|
||||
{
|
||||
|
@ -1508,21 +1515,11 @@ static int lua_cocos2dx_AssetsManager_setDelegate(lua_State* L)
|
|||
delegate->release();
|
||||
}
|
||||
|
||||
if (2 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err) ||
|
||||
!tolua_isnumber(L, 3, 0, &tolua_err) )
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
LUA_FUNCTION handler = toluafix_ref_function(L, 2, 0);
|
||||
ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,3,0) + (int)ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS);
|
||||
LUA_FUNCTION handler = toluafix_ref_function(L, 2, 0);
|
||||
ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,3,0) + (int)ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS);
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)delegate, handler, handlerType);
|
||||
return 0;
|
||||
}
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)delegate, handler, handlerType);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'setDelegate' function of AssetsManager has wrong number of arguments: %d, was expecting %d\n", argc, 2);
|
||||
|
|
|
@ -16,6 +16,19 @@ rawset(CCDirector,"sharedDirector",CCDirectorDeprecated.sharedDirector)
|
|||
|
||||
|
||||
--functions of CCTextureCache will be deprecated begin
|
||||
local TextureCacheDeprecated = {}
|
||||
function TextureCacheDeprecated.getInstance(self)
|
||||
deprecatedTip("cc.TextureCache:getInstance","cc.Director:getInstance():getTextureCache")
|
||||
return cc.Director:getInstance():getTextureCache()
|
||||
end
|
||||
rawset(cc.TextureCache,"getInstance",TextureCacheDeprecated.getInstance)
|
||||
|
||||
function TextureCacheDeprecated.destroyInstance(self)
|
||||
deprecatedTip("cc.TextureCache:destroyInstance","cc.Director:getInstance():destroyTextureCache")
|
||||
return cc.Director:getInstance():destroyTextureCache()
|
||||
end
|
||||
rawset(cc.TextureCache,"destroyInstance",TextureCacheDeprecated.destroyInstance)
|
||||
|
||||
local CCTextureCacheDeprecated = { }
|
||||
function CCTextureCacheDeprecated.sharedTextureCache()
|
||||
deprecatedTip("CCTextureCache:sharedTextureCache","CCTextureCache:getInstance")
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
ccs = ccs or {}
|
||||
|
||||
|
||||
ccs.MovementEventType = {
|
||||
START = 0,
|
||||
COMPLETE = 1,
|
||||
LOOP_COMPLETE = 2,
|
||||
}
|
||||
|
||||
ccs.BrightStyle =
|
||||
{
|
||||
none = -1,
|
||||
normal = 0,
|
||||
highlight = 1,
|
||||
}
|
||||
|
||||
ccs.WidgetType =
|
||||
{
|
||||
widget = 0, --control
|
||||
container = 1, --container
|
||||
}
|
||||
|
||||
-- ccs.TextureResType =
|
||||
-- {
|
||||
-- "local" = 0,
|
||||
-- "plist" = 1,
|
||||
-- }
|
||||
|
||||
ccs.TouchEventType =
|
||||
{
|
||||
began = 0,
|
||||
moved = 1,
|
||||
ended = 2,
|
||||
canceled = 3,
|
||||
}
|
||||
|
||||
ccs.SizeType =
|
||||
{
|
||||
absolute = 0,
|
||||
percent = 1,
|
||||
}
|
||||
|
||||
ccs.PositionType = {
|
||||
absolute = 0,
|
||||
percent = 1,
|
||||
}
|
||||
|
||||
ccs.CheckBoxEventType =
|
||||
{
|
||||
selected = 0,
|
||||
unselected = 1,
|
||||
}
|
||||
|
||||
ccs.TextFiledEventType =
|
||||
{
|
||||
attach_with_ime = 0,
|
||||
detach_with_ime = 1,
|
||||
insert_text = 2,
|
||||
delete_backward = 3,
|
||||
}
|
||||
|
||||
ccs.LayoutBackGroundColorType =
|
||||
{
|
||||
none = 0,
|
||||
solid = 1,
|
||||
gradient = 2,
|
||||
}
|
||||
|
||||
ccs.LayoutType =
|
||||
{
|
||||
absolute = 0,
|
||||
linearVertical = 1,
|
||||
linearHorizontal = 2,
|
||||
relative = 3,
|
||||
}
|
||||
|
||||
ccs.UILayoutParameterType =
|
||||
{
|
||||
none = 0,
|
||||
linear = 1,
|
||||
relative = 2,
|
||||
}
|
||||
|
||||
ccs.UILinearGravity =
|
||||
{
|
||||
none = 0,
|
||||
left = 1,
|
||||
top = 2,
|
||||
right = 3,
|
||||
bottom = 4,
|
||||
centerVertical = 5,
|
||||
centerHorizontal = 6,
|
||||
}
|
||||
|
||||
ccs.UIRelativeAlign =
|
||||
{
|
||||
alignNone = 0,
|
||||
alignParentTopLeft = 1,
|
||||
alignParentTopCenterHorizontal = 2,
|
||||
alignParentTopRight = 3,
|
||||
alignParentLeftCenterVertical = 4,
|
||||
centerInParent = 5,
|
||||
alignParentRightCenterVertical = 6,
|
||||
alignParentLeftBottom = 7,
|
||||
alignParentBottomCenterHorizontal = 8,
|
||||
alignParentRightBottom = 9,
|
||||
locationAboveLeftAlign = 10,
|
||||
locationAboveCenter = 11,
|
||||
locationAboveRightAlign = 12,
|
||||
locationLeftOfTopAlign = 13,
|
||||
locationLeftOfCenter = 14,
|
||||
locationLeftOfBottomAlign = 15,
|
||||
locationRightOfTopAlign = 16,
|
||||
locationRightOfCenter = 17,
|
||||
locationRightOfBottomAlign = 18,
|
||||
locationBelowLeftAlign = 19,
|
||||
locationBelowCenter = 20,
|
||||
locationBelowRightAlign = 21,
|
||||
}
|
||||
|
||||
ccs.SliderEventType = {percent_changed = 0}
|
||||
|
||||
ccs.LoadingBarType = { left = 0, right = 1}
|
||||
|
||||
ccs.SCROLLVIEW_DIR = {
|
||||
none = 0,
|
||||
vertical = 1,
|
||||
horizontal = 2,
|
||||
both = 3,
|
||||
}
|
||||
|
||||
ccs.SCROLLVIEW_MOVE_DIR = {
|
||||
none = 0,
|
||||
up = 1,
|
||||
down = 2,
|
||||
left = 3,
|
||||
right = 4,
|
||||
}
|
||||
|
||||
ccs.ScrollviewEventType = {
|
||||
top = 0,
|
||||
bottom = 1,
|
||||
left = 2,
|
||||
right = 3,
|
||||
}
|
||||
|
||||
ccs.ListViewDirection = {
|
||||
none = 0,
|
||||
vertical = 1,
|
||||
horizontal = 2,
|
||||
}
|
||||
|
||||
ccs.ListViewMoveDirection = {
|
||||
none = 0,
|
||||
up = 1,
|
||||
down = 2,
|
||||
left = 3,
|
||||
right = 4,
|
||||
}
|
||||
|
||||
ccs.ListViewEventType = {
|
||||
init_child = 0,
|
||||
update_child = 1,
|
||||
}
|
||||
|
||||
ccs.PageViewEventType = {
|
||||
turning = 0,
|
||||
}
|
||||
|
||||
ccs.PVTouchDir = {
|
||||
touch_left = 0,
|
||||
touch_right = 1,
|
||||
}
|
||||
|
||||
ccs.ListViewGravity = {
|
||||
left = 0,
|
||||
right = 1,
|
||||
center_horizontal = 2,
|
||||
top = 3,
|
||||
bottom = 4 ,
|
||||
center_vertical = 5,
|
||||
}
|
1839
docs/doxygen.config
1839
docs/doxygen.config
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue