mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' into develop_nutty_modify_framework_addlayoutparameterclone
This commit is contained in:
commit
a3f9a636e2
3
AUTHORS
3
AUTHORS
|
@ -721,6 +721,9 @@ Developers:
|
|||
|
||||
hbbalfred
|
||||
Fixed a bug that crash if file doesn't exist when using FileUtils::getStringFromFile.
|
||||
|
||||
liang8305
|
||||
Use multiple processes according the number of cores to build android project
|
||||
|
||||
Retired Core Developers:
|
||||
WenSheng Yang
|
||||
|
|
14
CHANGELOG
14
CHANGELOG
|
@ -1,12 +1,14 @@
|
|||
cocos2d-x-3.0final ?.? ?
|
||||
cocos2d-x-3.0beta2 ?.? ?
|
||||
[All]
|
||||
[NEW] DrawNode supports to draw triangle, quad bezier, cubic bezier.
|
||||
[NEW] Console: added the 'textures', 'fileutils dump' and 'config' commands
|
||||
[NEW] GLCache: glActiveTexture() is cached with GL::activeTexture(). All code MUST call the cached version in order to work correctly
|
||||
[NEW] Label: Uses a struct of TTF configuration for Label::createWithTTF to reduce parameters and make this interface more easily to use.
|
||||
[NEW] Label: Integrates LabelAtlas into new Label.
|
||||
[NEW] Node: Added `setGlobalZOrder()`. Useful to change the Node's render order. Node::setZOrder() -> Node::setLocalZOrder()
|
||||
[NEW] Renderer: Added BatchCommand. This command is not "batchable" with other commands, but improves performance in about 10%
|
||||
|
||||
[NEW] LuaBindings: Bindings-generator supports to bind namespace for lua.
|
||||
|
||||
[FIX] CocoStudio: TestColliderDetector in ArmatureTest can't work.
|
||||
[FIX] Crash if file doesn't exist when using FileUtils::getStringFromFile.
|
||||
[FIX] If setting a shorter string than before while using LabelAtlas, the effect will be wrong.
|
||||
|
@ -16,9 +18,11 @@ cocos2d-x-3.0final ?.? ?
|
|||
[FIX] ControlSlider doesn't support to set selected thumb sprite.
|
||||
[FIX] ControlButton doesn't support to set scale ratio of touchdown state.
|
||||
[FIX] Particles: Crash was triggered if there is not `textureFileName`section in particle plist file.
|
||||
[FIX] Renderer: QuadCommand::init() does not copy the Quads, it only store a reference making the code faster
|
||||
[FIX] Renderer: Performance improved in Sprite and SpriteBatchNode (and subclasses) sprites in about 20%
|
||||
[FIX] Renderer: When note using VAO, call glBufferData() instead of glBufferSubData().
|
||||
[FIX] Renderer: Uses a float as key with only the depth. Viewport, opaque are not needed now
|
||||
[FIX] Renderer Performance Fix: QuadCommand::init() does not copy the Quads, it only store a reference making the code faster
|
||||
[FIX] Renderer Performance Fix: Sprite and SpriteBatchNode (and subclasses) has much better performance
|
||||
[FIX] Renderer Performance Fix: When note using VAO, call glBufferData() instead of glBufferSubData().
|
||||
[FIX] Renderer Performance Fix: Doesn't sort z=0 elements. It also uses sort() instead of stable_sort() for z!=0.
|
||||
[FIX] Sprite: removed _hasChildren optimization. It uses !_children.empty() now which is super fast as well
|
||||
[FIX] Tests: TestCpp works with CMake on Windows.
|
||||
[FIX] Tests: Sprites Performance Test has 4 new tests
|
||||
|
|
|
@ -12,6 +12,16 @@ LUA_SAMPLES = ['hellolua', 'testlua']
|
|||
JSB_SAMPLES = ['cocosdragon', 'crystalcraze', 'moonwarriors', 'testjavascript', 'watermelonwithme']
|
||||
ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES + JSB_SAMPLES
|
||||
|
||||
def get_num_of_cpu():
|
||||
''' The build process can be accelerated by running multiple concurrent job processes using the -j-option.
|
||||
'''
|
||||
try:
|
||||
from numpy.distutils import cpuinfo
|
||||
return cpuinfo.cpu._getNCPUs()
|
||||
except Exception:
|
||||
print "Can't know cpuinfo, use default 1 cpu"
|
||||
return 1
|
||||
|
||||
def check_environment_variables():
|
||||
''' Checking the environment NDK_ROOT, which will be used for building
|
||||
'''
|
||||
|
@ -94,10 +104,12 @@ def do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,an
|
|||
else:
|
||||
ndk_module_path = 'NDK_MODULE_PATH=%s:%s/external:%s/cocos' % (cocos_root, cocos_root, cocos_root)
|
||||
|
||||
num_of_cpu = get_num_of_cpu()
|
||||
if ndk_build_param == None:
|
||||
command = '%s -C %s %s' % (ndk_path, app_android_root, ndk_module_path)
|
||||
command = '%s -j%d -C %s %s' % (ndk_path, num_of_cpu, app_android_root, ndk_module_path)
|
||||
else:
|
||||
command = '%s -C %s %s %s' % (ndk_path, app_android_root, ndk_build_param, ndk_module_path)
|
||||
command = '%s -j%d -C %s %s %s' % (ndk_path, num_of_cpu, app_android_root, ndk_build_param, ndk_module_path)
|
||||
print command
|
||||
if os.system(command) != 0:
|
||||
raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!")
|
||||
elif android_platform is not None:
|
||||
|
|
|
@ -1 +1 @@
|
|||
e1e5a1169e92834330092c45165660c6cbd03609
|
||||
63e6598ea5798bf42bbd22c2295e65f7c739695a
|
|
@ -1 +1 @@
|
|||
1fa58d8cba77ef923c83d2860d5511d28dad6c27
|
||||
447e7ba37294e6da0df2e02f5a62f30fb15e3272
|
|
@ -152,8 +152,8 @@ void AtlasNode::draw(void)
|
|||
|
||||
auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP);
|
||||
|
||||
_quadCommand.init(0,
|
||||
_vertexZ,
|
||||
_quadCommand.init(
|
||||
_globalZOrder,
|
||||
_textureAtlas->getTexture()->getName(),
|
||||
shader,
|
||||
_blendFunc,
|
||||
|
|
|
@ -210,12 +210,12 @@ void ClippingNode::visit()
|
|||
|
||||
Renderer* renderer = Director::getInstance()->getRenderer();
|
||||
|
||||
_groupCommand.init(0,_vertexZ);
|
||||
_groupCommand.init(_globalZOrder);
|
||||
renderer->addCommand(&_groupCommand);
|
||||
|
||||
renderer->pushGroup(_groupCommand.getRenderQueueID());
|
||||
|
||||
_beforeVisitCmd.init(0,_vertexZ);
|
||||
_beforeVisitCmd.init(_globalZOrder);
|
||||
_beforeVisitCmd.func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this);
|
||||
renderer->addCommand(&_beforeVisitCmd);
|
||||
if (_alphaThreshold < 1)
|
||||
|
@ -238,7 +238,7 @@ void ClippingNode::visit()
|
|||
}
|
||||
_stencil->visit();
|
||||
|
||||
_afterDrawStencilCmd.init(0,_vertexZ);
|
||||
_afterDrawStencilCmd.init(_globalZOrder);
|
||||
_afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this);
|
||||
renderer->addCommand(&_afterDrawStencilCmd);
|
||||
|
||||
|
@ -268,7 +268,7 @@ void ClippingNode::visit()
|
|||
this->draw();
|
||||
}
|
||||
|
||||
_afterVisitCmd.init(0,_vertexZ);
|
||||
_afterVisitCmd.init(_globalZOrder);
|
||||
_afterVisitCmd.func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this);
|
||||
renderer->addCommand(&_afterVisitCmd);
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ void DrawNode::render()
|
|||
|
||||
void DrawNode::draw()
|
||||
{
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -666,7 +666,7 @@ void Label::onDraw()
|
|||
|
||||
void Label::draw()
|
||||
{
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -565,7 +565,7 @@ void LayerColor::updateColor()
|
|||
|
||||
void LayerColor::draw()
|
||||
{
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
|
||||
|
|
|
@ -359,7 +359,7 @@ void MotionStreak::draw()
|
|||
if(_nuPoints <= 1)
|
||||
return;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW,&_cachedMV);
|
||||
_customCommand.init(0,_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
|
||||
|
|
|
@ -108,7 +108,8 @@ Node::Node(void)
|
|||
, _inverseDirty(true)
|
||||
// children (lazy allocs)
|
||||
// lazy alloc
|
||||
, _ZOrder(0)
|
||||
, _localZOrder(0)
|
||||
, _globalZOrder(0)
|
||||
, _parent(nullptr)
|
||||
// "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true
|
||||
, _tag(Node::INVALID_TAG)
|
||||
|
@ -212,29 +213,22 @@ void Node::setSkewY(float newSkewY)
|
|||
_transformDirty = _inverseDirty = true;
|
||||
}
|
||||
|
||||
/// zOrder getter
|
||||
int Node::getZOrder() const
|
||||
{
|
||||
return _ZOrder;
|
||||
}
|
||||
|
||||
/// zOrder setter : private method
|
||||
/// used internally to alter the zOrder variable. DON'T call this method manually
|
||||
void Node::_setZOrder(int z)
|
||||
void Node::_setLocalZOrder(int z)
|
||||
{
|
||||
_ZOrder = z;
|
||||
_localZOrder = z;
|
||||
}
|
||||
|
||||
void Node::setZOrder(int z)
|
||||
void Node::setLocalZOrder(int z)
|
||||
{
|
||||
_localZOrder = 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);
|
||||
}
|
||||
|
||||
|
@ -246,9 +240,10 @@ float Node::getVertexZ() const
|
|||
|
||||
|
||||
/// vertexZ setter
|
||||
void Node::setVertexZ(float var)
|
||||
void Node::setVertexZ(float zOrder)
|
||||
{
|
||||
_vertexZ = var;
|
||||
_vertexZ = zOrder;
|
||||
setGlobalZOrder(zOrder);
|
||||
}
|
||||
|
||||
|
||||
|
@ -650,7 +645,7 @@ void Node::addChild(Node *child, int zOrder)
|
|||
void Node::addChild(Node *child)
|
||||
{
|
||||
CCASSERT( child != nullptr, "Argument must be non-nil");
|
||||
this->addChild(child, child->_ZOrder, child->_tag);
|
||||
this->addChild(child, child->_localZOrder, child->_tag);
|
||||
}
|
||||
|
||||
void Node::removeFromParent()
|
||||
|
@ -767,7 +762,7 @@ void Node::insertChild(Node* child, int z)
|
|||
{
|
||||
_reorderChildDirty = true;
|
||||
_children.pushBack(child);
|
||||
child->_setZOrder(z);
|
||||
child->_setLocalZOrder(z);
|
||||
}
|
||||
|
||||
void Node::reorderChild(Node *child, int zOrder)
|
||||
|
@ -775,7 +770,7 @@ void Node::reorderChild(Node *child, int zOrder)
|
|||
CCASSERT( child != nullptr, "Child must be non-nil");
|
||||
_reorderChildDirty = true;
|
||||
child->setOrderOfArrival(s_globalOrderOfArrival++);
|
||||
child->_setZOrder(zOrder);
|
||||
child->_setLocalZOrder(zOrder);
|
||||
}
|
||||
|
||||
void Node::sortAllChildren()
|
||||
|
@ -816,7 +811,7 @@ void Node::visit()
|
|||
{
|
||||
auto node = _children.at(i);
|
||||
|
||||
if ( node && node->_ZOrder < 0 )
|
||||
if ( node && node->_localZOrder < 0 )
|
||||
node->visit();
|
||||
else
|
||||
break;
|
||||
|
|
|
@ -161,43 +161,72 @@ public:
|
|||
/// @name Setters & Getters for Graphic Peroperties
|
||||
|
||||
/**
|
||||
* 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 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.
|
||||
LocalZOrder is the 'key' used to sort the node relative to its siblings.
|
||||
|
||||
The Node's parent will sort all its children based ont the LocalZOrder value.
|
||||
If two nodes have the same LocalZOrder, then the node that was added first to the children's array will be in front of the other node in the array.
|
||||
|
||||
Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order )
|
||||
And Nodes that have LocalZOder values < 0 are the "left" subtree
|
||||
While Nodes with LocalZOder >=0 are the "right" subtree.
|
||||
|
||||
@see `setGlobalZOrder`
|
||||
@see `setVertexZ`
|
||||
*/
|
||||
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.
|
||||
* The difference between setZOrder(int) and _setOrder(int) is:
|
||||
* - _setZOrder(int) is a pure setter for _ZOrder memeber variable
|
||||
* - setZOrder(int) firstly changes _ZOrder, then recorder this node in its parent's chilren array.
|
||||
virtual void setLocalZOrder(int zOrder);
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE virtual void setZOrder(int zOrder) { setLocalZOrder(zOrder); }
|
||||
/* Helper function used by `setLocalZOrder`. Don't use it unless you know what you are doing.
|
||||
*/
|
||||
virtual void _setZOrder(int z);
|
||||
virtual void _setLocalZOrder(int z);
|
||||
/**
|
||||
* Gets the Z order of this node.
|
||||
* Gets the local Z order of this node.
|
||||
*
|
||||
* @see `setZOrder(int)`
|
||||
* @see `setLocalZOrder(int)`
|
||||
*
|
||||
* @return The Z order.
|
||||
* @return The local (relative to its siblings) Z order.
|
||||
*/
|
||||
virtual int getZOrder() const;
|
||||
virtual int getLocalZOrder() const { return _localZOrder; }
|
||||
CC_DEPRECATED_ATTRIBUTE virtual int getZOrder() const { return getLocalZOrder(); }
|
||||
|
||||
/**
|
||||
* Sets the real OpenGL Z vertex.
|
||||
Defines the oder in which the nodes are renderer.
|
||||
Nodes that have a Global Z Order lower, are renderer first.
|
||||
|
||||
In case two or more nodes have the same Global Z Order, the oder is not guaranteed.
|
||||
The only exception if the Nodes have a Global Z Order == 0. In that case, the Scene Graph order is used.
|
||||
|
||||
By default, all nodes have a Global Z Order = 0. That means that by default, the Scene Graph order is used to render the nodes.
|
||||
|
||||
Global Z Order is useful when you need to render nodes in an order different than the Scene Graph order.
|
||||
|
||||
Limitations: Global Z Order can't be used used by Nodes that have SpriteBatchNode as one of their acenstors.
|
||||
And if ClippingNode is one of the ancestors, then "global Z order" will be relative to the ClippingNode.
|
||||
|
||||
@see `setLocalZOrder()`
|
||||
@see `setVertexZ()`
|
||||
|
||||
@since v3.0
|
||||
*/
|
||||
virtual void setGlobalZOrder(float zOrder) { _globalZOrder = zOrder; }
|
||||
/**
|
||||
* Returns the Node's Global Z Order.
|
||||
*
|
||||
* 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`
|
||||
* @see `setGlobalZOrder(int)`
|
||||
*
|
||||
* @warning Use it at your own risk since it might break the cocos2d parent-children z order
|
||||
* @return The node's global Z order
|
||||
*/
|
||||
virtual float getGlobalZOrder() const { return _globalZOrder; }
|
||||
|
||||
/**
|
||||
* Sets the 'z' value in the OpenGL Depth Buffer.
|
||||
*
|
||||
* The OpenGL depth buffer and depth testing are disabled by default. You need to turn them on
|
||||
* in order to use this property correctly.
|
||||
*
|
||||
* `setVertexZ()` also sets the `setGlobalZValue()` with the vertexZ value.
|
||||
*
|
||||
* @see `setGlobalZValue()`
|
||||
*
|
||||
* @param vertexZ OpenGL Z vertex of this node.
|
||||
*/
|
||||
|
@ -1411,7 +1440,6 @@ protected:
|
|||
float _scaleX; ///< scaling factor on x-axis
|
||||
float _scaleY; ///< scaling factor on y-axis
|
||||
|
||||
float _vertexZ; ///< OpenGL real Z vertex
|
||||
|
||||
Point _position; ///< position of the node
|
||||
|
||||
|
@ -1433,8 +1461,12 @@ protected:
|
|||
mutable bool _transformDirty; ///< transform dirty flag
|
||||
mutable bool _inverseDirty; ///< inverse transform dirty flag
|
||||
|
||||
int _ZOrder; ///< z-order value that affects the draw order
|
||||
|
||||
|
||||
int _localZOrder; ///< Local order (relative to its siblings) used to sort the node
|
||||
float _globalZOrder; ///< Global order used to sort the node
|
||||
float _vertexZ; ///< OpenGL real Z vertex
|
||||
|
||||
|
||||
Vector<Node*> _children; ///< array of children nodes
|
||||
Node *_parent; ///< weak reference to parent node
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ void NodeGrid::visit()
|
|||
|
||||
Renderer* renderer = Director::getInstance()->getRenderer();
|
||||
|
||||
_groupCommand.init(0,_vertexZ);
|
||||
_groupCommand.init(_globalZOrder);
|
||||
renderer->addCommand(&_groupCommand);
|
||||
renderer->pushGroup(_groupCommand.getRenderQueueID());
|
||||
|
||||
|
@ -104,7 +104,7 @@ void NodeGrid::visit()
|
|||
_nodeGrid->set2DProjection();
|
||||
}
|
||||
|
||||
_gridBeginCommand.init(0,_vertexZ);
|
||||
_gridBeginCommand.init(_globalZOrder);
|
||||
_gridBeginCommand.func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this);
|
||||
renderer->addCommand(&_gridBeginCommand);
|
||||
|
||||
|
@ -152,7 +152,7 @@ void NodeGrid::visit()
|
|||
director->setProjection(beforeProjectionType);
|
||||
}
|
||||
|
||||
_gridEndCommand.init(0,_vertexZ);
|
||||
_gridEndCommand.init(_globalZOrder);
|
||||
_gridEndCommand.func = CC_CALLBACK_0(NodeGrid::onGridEndDraw, this);
|
||||
renderer->addCommand(&_gridEndCommand);
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ int ParticleBatchNode::addChildHelper(ParticleSystem* child, int z, int aTag)
|
|||
_children.insert(pos, child);
|
||||
|
||||
child->setTag(aTag);
|
||||
child->_setZOrder(z);
|
||||
child->_setLocalZOrder(z);
|
||||
|
||||
child->setParent(this);
|
||||
|
||||
|
@ -264,7 +264,7 @@ void ParticleBatchNode::reorderChild(Node * aChild, int zOrder)
|
|||
}
|
||||
}
|
||||
|
||||
child->_setZOrder(zOrder);
|
||||
child->_setLocalZOrder(zOrder);
|
||||
}
|
||||
|
||||
void ParticleBatchNode::getCurrentIndex(int* oldIndex, int* newIndex, Node* child, int z)
|
||||
|
@ -382,8 +382,8 @@ void ParticleBatchNode::draw(void)
|
|||
return;
|
||||
}
|
||||
|
||||
_batchCommand.init(0,
|
||||
_vertexZ,
|
||||
_batchCommand.init(
|
||||
_globalZOrder,
|
||||
_textureAtlas->getTexture()->getName(),
|
||||
_shaderProgram,
|
||||
_blendFunc,
|
||||
|
|
|
@ -439,7 +439,7 @@ void ParticleSystemQuad::draw()
|
|||
|
||||
auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP);
|
||||
|
||||
_quadCommand.init(0, _vertexZ, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform);
|
||||
_quadCommand.init(_globalZOrder, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
|
||||
}
|
||||
|
||||
|
|
|
@ -555,7 +555,7 @@ void ProgressTimer::draw()
|
|||
if( ! _vertexData || ! _sprite)
|
||||
return;
|
||||
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -322,7 +322,7 @@ void RenderTexture::beginWithClear(float r, float g, float b, float a, float dep
|
|||
this->begin();
|
||||
|
||||
//clear screen
|
||||
_beginWithClearCommand.init(0, _vertexZ);
|
||||
_beginWithClearCommand.init(_globalZOrder);
|
||||
_beginWithClearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_beginWithClearCommand);
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ void RenderTexture::clearDepth(float depthValue)
|
|||
|
||||
this->begin();
|
||||
|
||||
_clearDepthCommand.init(0, _vertexZ);
|
||||
_clearDepthCommand.init(_globalZOrder);
|
||||
_clearDepthCommand.func = CC_CALLBACK_0(RenderTexture::onClearDepth, this);
|
||||
|
||||
Director::getInstance()->getRenderer()->addCommand(&_clearDepthCommand);
|
||||
|
@ -605,7 +605,7 @@ void RenderTexture::draw()
|
|||
begin();
|
||||
|
||||
//clear screen
|
||||
_clearCommand.init(0, _vertexZ);
|
||||
_clearCommand.init(_globalZOrder);
|
||||
_clearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_clearCommand);
|
||||
|
||||
|
@ -648,13 +648,13 @@ void RenderTexture::begin()
|
|||
(float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 );
|
||||
kmGLMultMatrix(&orthoMatrix);
|
||||
|
||||
_groupCommand.init(0, _vertexZ);
|
||||
_groupCommand.init(_globalZOrder);
|
||||
|
||||
Renderer *renderer = Director::getInstance()->getRenderer();
|
||||
renderer->addCommand(&_groupCommand);
|
||||
renderer->pushGroup(_groupCommand.getRenderQueueID());
|
||||
|
||||
_beginCommand.init(0, _vertexZ);
|
||||
_beginCommand.init(_globalZOrder);
|
||||
_beginCommand.func = CC_CALLBACK_0(RenderTexture::onBegin, this);
|
||||
|
||||
Director::getInstance()->getRenderer()->addCommand(&_beginCommand);
|
||||
|
@ -662,7 +662,7 @@ void RenderTexture::begin()
|
|||
|
||||
void RenderTexture::end()
|
||||
{
|
||||
_endCommand.init(0, _vertexZ);
|
||||
_endCommand.init(_globalZOrder);
|
||||
_endCommand.func = CC_CALLBACK_0(RenderTexture::onEnd, this);
|
||||
|
||||
Renderer *renderer = Director::getInstance()->getRenderer();
|
||||
|
|
|
@ -670,7 +670,7 @@ void Sprite::updateTransform(void)
|
|||
void Sprite::draw(void)
|
||||
{
|
||||
//TODO implement z order
|
||||
_quadCommand.init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform);
|
||||
_quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform);
|
||||
|
||||
// if(culling())
|
||||
{
|
||||
|
@ -769,13 +769,8 @@ void Sprite::addChild(Node *child, int zOrder, int tag)
|
|||
|
||||
void Sprite::reorderChild(Node *child, int zOrder)
|
||||
{
|
||||
CCASSERT(child != nullptr, "");
|
||||
CCASSERT(_children.contains(child), "");
|
||||
|
||||
if (zOrder == child->getZOrder())
|
||||
{
|
||||
return;
|
||||
}
|
||||
CCASSERT(child != nullptr, "child must be non null");
|
||||
CCASSERT(_children.contains(child), "child does not belong to this");
|
||||
|
||||
if( _batchNode && ! _reorderChildDirty)
|
||||
{
|
||||
|
|
|
@ -356,8 +356,8 @@ void SpriteBatchNode::draw()
|
|||
for(const auto &child: _children)
|
||||
child->updateTransform();
|
||||
|
||||
_batchCommand.init(0,
|
||||
_vertexZ,
|
||||
_batchCommand.init(
|
||||
_globalZOrder,
|
||||
_textureAtlas->getTexture()->getName(),
|
||||
_shaderProgram,
|
||||
_blendFunc,
|
||||
|
|
|
@ -174,7 +174,7 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
|
|||
if (layerInfo->_visible)
|
||||
{
|
||||
TMXLayer *child = parseLayer(layerInfo, mapInfo);
|
||||
addChild((Node*)child, idx, idx);
|
||||
addChild(child, idx, idx);
|
||||
|
||||
// update content size with the max size
|
||||
const Size& childSize = child->getContentSize();
|
||||
|
|
|
@ -98,23 +98,23 @@ void TransitionPageTurn::draw()
|
|||
|
||||
if( _isInSceneOnTop ) {
|
||||
_outSceneProxy->visit();
|
||||
_enableOffsetCmd.init(0, _vertexZ);
|
||||
_enableOffsetCmd.init(_globalZOrder);
|
||||
_enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd);
|
||||
_inSceneProxy->visit();
|
||||
_disableOffsetCmd.init(0, _vertexZ);
|
||||
_disableOffsetCmd.init(_globalZOrder);
|
||||
_disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd);
|
||||
} else {
|
||||
_inSceneProxy->visit();
|
||||
|
||||
_enableOffsetCmd.init(0, _vertexZ);
|
||||
_enableOffsetCmd.init(_globalZOrder);
|
||||
_enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd);
|
||||
|
||||
_outSceneProxy->visit();
|
||||
|
||||
_disableOffsetCmd.init(0, _vertexZ);
|
||||
_disableOffsetCmd.init(_globalZOrder);
|
||||
_disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd);
|
||||
}
|
||||
|
|
|
@ -30,9 +30,7 @@
|
|||
NS_CC_BEGIN
|
||||
|
||||
BatchCommand::BatchCommand()
|
||||
: _viewport(0)
|
||||
, _depth(0)
|
||||
, _textureID(0)
|
||||
: _textureID(0)
|
||||
, _blendType(BlendFunc::DISABLE)
|
||||
, _textureAtlas(nullptr)
|
||||
{
|
||||
|
@ -40,10 +38,9 @@ BatchCommand::BatchCommand()
|
|||
_shader = nullptr;
|
||||
}
|
||||
|
||||
void BatchCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform)
|
||||
void BatchCommand::init(float globalOrder, GLuint textureID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform)
|
||||
{
|
||||
_viewport = viewport;
|
||||
_depth = depth;
|
||||
_globalOrder = globalOrder;
|
||||
_textureID = textureID;
|
||||
_blendType = blendType;
|
||||
_shader = shader;
|
||||
|
@ -57,59 +54,6 @@ BatchCommand::~BatchCommand()
|
|||
{
|
||||
}
|
||||
|
||||
int64_t BatchCommand::generateID()
|
||||
{
|
||||
_id = 0;
|
||||
|
||||
//Generate Material ID
|
||||
//TODO fix shader ID generation
|
||||
CCASSERT(_shader->getProgram() < pow(2,10), "ShaderID is greater than 2^10");
|
||||
//TODO fix texture ID generation
|
||||
CCASSERT(_textureID < pow(2,18), "TextureID is greater than 2^18");
|
||||
|
||||
//TODO fix blend id generation
|
||||
int blendID = 0;
|
||||
if(_blendType == BlendFunc::DISABLE)
|
||||
{
|
||||
blendID = 0;
|
||||
}
|
||||
else if(_blendType == BlendFunc::ALPHA_PREMULTIPLIED)
|
||||
{
|
||||
blendID = 1;
|
||||
}
|
||||
else if(_blendType == BlendFunc::ALPHA_NON_PREMULTIPLIED)
|
||||
{
|
||||
blendID = 2;
|
||||
}
|
||||
else if(_blendType == BlendFunc::ADDITIVE)
|
||||
{
|
||||
blendID = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
blendID = 4;
|
||||
}
|
||||
|
||||
//TODO Material ID should be part of the ID
|
||||
//
|
||||
// Temporal hack (later, these 32-bits should be packed in 24-bits
|
||||
//
|
||||
// +---------------------+-------------------+----------------------+
|
||||
// | Shader ID (10 bits) | Blend ID (4 bits) | Texture ID (18 bits) |
|
||||
// +---------------------+-------------------+----------------------+
|
||||
|
||||
_materialID = (int32_t)_shader->getProgram() << 22
|
||||
| (int32_t)blendID << 18
|
||||
| (int32_t)_textureID << 0;
|
||||
|
||||
//Generate RenderCommandID
|
||||
_id = (int64_t)_viewport << 61
|
||||
| (int64_t)1 << 60 //translucent
|
||||
| (int64_t)_depth << 36;
|
||||
|
||||
return _id;
|
||||
}
|
||||
|
||||
void BatchCommand::execute()
|
||||
{
|
||||
// Set material
|
||||
|
|
|
@ -43,26 +43,13 @@ public:
|
|||
BatchCommand();
|
||||
~BatchCommand();
|
||||
|
||||
void init(int viewport, int32_t depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform);
|
||||
|
||||
// +----------+----------+-----+-----------------------------------+
|
||||
// | | | | | |
|
||||
// | ViewPort | Transluc | | Depth | Material ID |
|
||||
// | 3 bits | 1 bit | | 24 bits | 24 bit2 |
|
||||
// +----------+----------+-----+----------------+------------------+
|
||||
virtual int64_t generateID();
|
||||
void init(float depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform);
|
||||
|
||||
void execute();
|
||||
|
||||
protected:
|
||||
int32_t _materialID;
|
||||
|
||||
//Key Data
|
||||
int _viewport; /// Which view port it belongs to
|
||||
|
||||
//TODO use material to determine if it's translucent
|
||||
int32_t _depth;
|
||||
|
||||
//Maternal
|
||||
GLuint _textureID;
|
||||
|
||||
|
|
|
@ -28,16 +28,13 @@ NS_CC_BEGIN
|
|||
|
||||
CustomCommand::CustomCommand()
|
||||
: func(nullptr)
|
||||
, _viewport(0)
|
||||
, _depth(0)
|
||||
{
|
||||
_type = RenderCommand::Type::CUSTOM_COMMAND;
|
||||
}
|
||||
|
||||
void CustomCommand::init(int viewport, int32_t depth)
|
||||
void CustomCommand::init(float globalOrder)
|
||||
{
|
||||
_viewport = viewport;
|
||||
_depth = depth;
|
||||
_globalOrder = globalOrder;
|
||||
}
|
||||
|
||||
CustomCommand::~CustomCommand()
|
||||
|
@ -45,17 +42,6 @@ CustomCommand::~CustomCommand()
|
|||
|
||||
}
|
||||
|
||||
int64_t CustomCommand::generateID()
|
||||
{
|
||||
_id = 0;
|
||||
|
||||
_id = (int64_t)_viewport << 61
|
||||
| (int64_t)1 << 60 // translucent
|
||||
| (int64_t)_depth << 36;
|
||||
|
||||
return _id;
|
||||
}
|
||||
|
||||
void CustomCommand::execute()
|
||||
{
|
||||
if(func)
|
||||
|
|
|
@ -39,14 +39,7 @@ public:
|
|||
|
||||
public:
|
||||
|
||||
void init(int viewport, int32_t depth);
|
||||
|
||||
// +----------+----------+-----+-----------------------------------+
|
||||
// | | | | | |
|
||||
// | ViewPort | Transluc | | Depth | |
|
||||
// | 3 bits | 1 bit | | 24 bits | |
|
||||
// +----------+----------+-----+----------------+------------------+
|
||||
virtual int64_t generateID();
|
||||
void init(float depth);
|
||||
|
||||
void execute();
|
||||
|
||||
|
@ -54,8 +47,6 @@ public:
|
|||
std::function<void()> func;
|
||||
|
||||
protected:
|
||||
int _viewport;
|
||||
int32_t _depth;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -86,17 +86,14 @@ void GroupCommandManager::releaseGroupID(int groupID)
|
|||
}
|
||||
|
||||
GroupCommand::GroupCommand()
|
||||
: _viewport(0)
|
||||
, _depth(0)
|
||||
{
|
||||
_type = RenderCommand::Type::GROUP_COMMAND;
|
||||
_renderQueueID = GroupCommandManager::getInstance()->getGroupID();
|
||||
}
|
||||
|
||||
void GroupCommand::init(int viewport, int32_t depth)
|
||||
void GroupCommand::init(float globalOrder)
|
||||
{
|
||||
_viewport = viewport;
|
||||
_depth = depth;
|
||||
_globalOrder = globalOrder;
|
||||
GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID);
|
||||
_renderQueueID = GroupCommandManager::getInstance()->getGroupID();
|
||||
}
|
||||
|
@ -106,15 +103,4 @@ GroupCommand::~GroupCommand()
|
|||
GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID);
|
||||
}
|
||||
|
||||
int64_t GroupCommand::generateID()
|
||||
{
|
||||
_id = 0;
|
||||
|
||||
_id = (int64_t)_viewport << 61
|
||||
| (int64_t)1 << 60 // translucent
|
||||
| (int64_t)_depth << 36;
|
||||
|
||||
return _id;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -56,23 +56,11 @@ public:
|
|||
GroupCommand();
|
||||
~GroupCommand();
|
||||
|
||||
public:
|
||||
void init(float depth);
|
||||
|
||||
void init(int viewport, int32_t depth);
|
||||
|
||||
// +----------+----------+-----+-----------------------------------+
|
||||
// | | | | | |
|
||||
// | ViewPort | Transluc | | Depth | |
|
||||
// | 3 bits | 1 bit | | 24 bits | |
|
||||
// +----------+----------+-----+----------------+------------------+
|
||||
virtual int64_t generateID() override;
|
||||
|
||||
inline bool isTranslucent() {return true;}
|
||||
inline int getRenderQueueID() {return _renderQueueID;}
|
||||
inline int getRenderQueueID() const {return _renderQueueID;}
|
||||
|
||||
protected:
|
||||
int _viewport;
|
||||
int32_t _depth;
|
||||
int _renderQueueID;
|
||||
};
|
||||
|
||||
|
|
|
@ -29,9 +29,7 @@
|
|||
NS_CC_BEGIN
|
||||
|
||||
QuadCommand::QuadCommand()
|
||||
:_viewport(0)
|
||||
,_depth(0)
|
||||
,_textureID(0)
|
||||
:_textureID(0)
|
||||
,_blendType(BlendFunc::DISABLE)
|
||||
,_quadsCount(0)
|
||||
{
|
||||
|
@ -40,10 +38,9 @@ QuadCommand::QuadCommand()
|
|||
_quads = nullptr;
|
||||
}
|
||||
|
||||
void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, ssize_t quadCount, const kmMat4 &mv)
|
||||
void QuadCommand::init(float globalOrder, GLuint textureID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, ssize_t quadCount, const kmMat4 &mv)
|
||||
{
|
||||
_viewport = viewport;
|
||||
_depth = depth;
|
||||
_globalOrder = globalOrder;
|
||||
_textureID = textureID;
|
||||
_blendType = blendType;
|
||||
_shader = shader;
|
||||
|
@ -52,16 +49,16 @@ void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram*
|
|||
_quads = quad;
|
||||
|
||||
_mv = mv;
|
||||
|
||||
generateMaterialID();
|
||||
}
|
||||
|
||||
QuadCommand::~QuadCommand()
|
||||
{
|
||||
}
|
||||
|
||||
int64_t QuadCommand::generateID()
|
||||
void QuadCommand::generateMaterialID()
|
||||
{
|
||||
_id = 0;
|
||||
|
||||
//Generate Material ID
|
||||
//TODO fix shader ID generation
|
||||
CCASSERT(_shader->getProgram() < pow(2,10), "ShaderID is greater than 2^10");
|
||||
|
@ -99,19 +96,12 @@ int64_t QuadCommand::generateID()
|
|||
// | Shader ID (10 bits) | Blend ID (4 bits) | Texture ID (18 bits) |
|
||||
// +---------------------+-------------------+----------------------+
|
||||
|
||||
_materialID = (int32_t)_shader->getProgram() << 22
|
||||
| (int32_t)blendID << 18
|
||||
| (int32_t)_textureID << 0;
|
||||
|
||||
//Generate RenderCommandID
|
||||
_id = (int64_t)_viewport << 61
|
||||
| (int64_t)1 << 60 //translucent
|
||||
| (int64_t)_depth << 36;
|
||||
|
||||
return _id;
|
||||
_materialID = (uint32_t)_shader->getProgram() << 22
|
||||
| (uint32_t)blendID << 18
|
||||
| (uint32_t)_textureID << 0;
|
||||
}
|
||||
|
||||
void QuadCommand::useMaterial()
|
||||
void QuadCommand::useMaterial() const
|
||||
{
|
||||
_shader->use();
|
||||
|
||||
|
|
|
@ -41,21 +41,15 @@ public:
|
|||
QuadCommand();
|
||||
~QuadCommand();
|
||||
|
||||
void init(int viewport, int32_t depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount,
|
||||
void init(float depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount,
|
||||
const kmMat4& mv);
|
||||
|
||||
// +----------+----------+-----+-----------------------------------+
|
||||
// | | | | | |
|
||||
// | ViewPort | Transluc | | Depth | Material ID |
|
||||
// | 3 bits | 1 bit | | 24 bits | 24 bit2 |
|
||||
// +----------+----------+-----+----------------+------------------+
|
||||
virtual int64_t generateID();
|
||||
|
||||
void useMaterial();
|
||||
void useMaterial() const;
|
||||
|
||||
//TODO use material to decide if it is translucent
|
||||
inline bool isTranslucent() const { return true; }
|
||||
|
||||
void generateMaterialID();
|
||||
inline uint32_t getMaterialID() const { return _materialID; }
|
||||
|
||||
inline GLuint getTextureID() const { return _textureID; }
|
||||
|
@ -73,12 +67,6 @@ public:
|
|||
protected:
|
||||
uint32_t _materialID;
|
||||
|
||||
//Key Data
|
||||
int _viewport; /// Which view port it belongs to
|
||||
|
||||
//TODO use material to determine if it's translucent
|
||||
int32_t _depth;
|
||||
|
||||
//Maternal
|
||||
GLuint _textureID;
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
NS_CC_BEGIN
|
||||
|
||||
RenderCommand::RenderCommand()
|
||||
: _type(RenderCommand::Type::UNKNOWN_COMMAND)
|
||||
, _globalOrder(0)
|
||||
{
|
||||
_id = 0;
|
||||
_type = RenderCommand::Type::UNKNOWN_COMMAND;
|
||||
}
|
||||
|
||||
RenderCommand::~RenderCommand()
|
||||
|
@ -57,9 +57,7 @@ void printBits(ssize_t const size, void const * const ptr)
|
|||
|
||||
void RenderCommand::printID()
|
||||
{
|
||||
printf("CommandID: ");
|
||||
printBits(sizeof(_id), &_id);
|
||||
printf("\n");
|
||||
printf("Command Depth: %f\n", _globalOrder);
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -33,7 +33,9 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
//TODO make RenderCommand inherent from Object
|
||||
/** Base class of the RenderCommand hierarchy.
|
||||
The Renderer knows how to render RenderCommands.
|
||||
*/
|
||||
class RenderCommand
|
||||
{
|
||||
public:
|
||||
|
@ -47,13 +49,11 @@ public:
|
|||
GROUP_COMMAND,
|
||||
};
|
||||
|
||||
virtual int64_t generateID() = 0;
|
||||
|
||||
/** Get Render Command Id */
|
||||
inline int64_t getID() { return _id; }
|
||||
inline float getGlobalOrder() const { return _globalOrder; }
|
||||
|
||||
/** Returns the Command type */
|
||||
inline Type getType() { return _type; }
|
||||
inline Type getType() const { return _type; }
|
||||
|
||||
protected:
|
||||
RenderCommand();
|
||||
|
@ -61,9 +61,11 @@ protected:
|
|||
|
||||
void printID();
|
||||
|
||||
//Generated IDs
|
||||
int64_t _id; /// used for sorting render commands
|
||||
// Type used in order to avoid dynamic cast, faster
|
||||
Type _type;
|
||||
|
||||
// commands are sort by depth
|
||||
float _globalOrder;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -34,12 +34,68 @@
|
|||
#include "CCEventDispatcher.h"
|
||||
#include "CCEventListenerCustom.h"
|
||||
#include "CCEventType.h"
|
||||
#include <algorithm> // for std::stable_sort
|
||||
#include <algorithm>
|
||||
|
||||
NS_CC_BEGIN
|
||||
using namespace std;
|
||||
|
||||
bool compareRenderCommand(RenderCommand* a, RenderCommand* b)
|
||||
{
|
||||
return a->getGlobalOrder() < b->getGlobalOrder();
|
||||
}
|
||||
|
||||
void RenderQueue::push_back(RenderCommand* command)
|
||||
{
|
||||
float z = command->getGlobalOrder();
|
||||
if(z < 0)
|
||||
_queueNegZ.push_back(command);
|
||||
else if(z > 0)
|
||||
_queuePosZ.push_back(command);
|
||||
else
|
||||
_queue0.push_back(command);
|
||||
}
|
||||
|
||||
ssize_t RenderQueue::size() const
|
||||
{
|
||||
return _queueNegZ.size() + _queue0.size() + _queuePosZ.size();
|
||||
}
|
||||
|
||||
void RenderQueue::sort()
|
||||
{
|
||||
// Don't sort _queue0, it already comes sorted
|
||||
std::sort(std::begin(_queueNegZ), std::end(_queueNegZ), compareRenderCommand);
|
||||
std::sort(std::begin(_queuePosZ), std::end(_queuePosZ), compareRenderCommand);
|
||||
}
|
||||
|
||||
RenderCommand* RenderQueue::operator[](ssize_t index) const
|
||||
{
|
||||
if(index < _queueNegZ.size())
|
||||
return _queueNegZ[index];
|
||||
|
||||
index -= _queueNegZ.size();
|
||||
|
||||
if(index < _queue0.size())
|
||||
return _queue0[index];
|
||||
|
||||
index -= _queue0.size();
|
||||
|
||||
if(index < _queuePosZ.size())
|
||||
return _queuePosZ[index];
|
||||
|
||||
CCASSERT(false, "invalid index");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void RenderQueue::clear()
|
||||
{
|
||||
_queueNegZ.clear();
|
||||
_queue0.clear();
|
||||
_queuePosZ.clear();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
#define DEFAULT_RENDER_QUEUE 0
|
||||
|
||||
Renderer::Renderer()
|
||||
|
@ -185,8 +241,6 @@ void Renderer::addCommand(RenderCommand* command, int renderQueue)
|
|||
{
|
||||
CCASSERT(renderQueue >=0, "Invalid render queue");
|
||||
CCASSERT(command->getType() != RenderCommand::Type::UNKNOWN_COMMAND, "Invalid Command Type");
|
||||
|
||||
command->generateID();
|
||||
_renderGroups[renderQueue].push_back(command);
|
||||
}
|
||||
|
||||
|
@ -207,11 +261,6 @@ int Renderer::createRenderQueue()
|
|||
return (int)_renderGroups.size() - 1;
|
||||
}
|
||||
|
||||
bool compareRenderCommand(RenderCommand* a, RenderCommand* b)
|
||||
{
|
||||
return a->getID() < b->getID();
|
||||
}
|
||||
|
||||
void Renderer::render()
|
||||
{
|
||||
//Uncomment this once everything is rendered by new renderer
|
||||
|
@ -223,9 +272,9 @@ void Renderer::render()
|
|||
{
|
||||
//Process render commands
|
||||
//1. Sort render commands based on ID
|
||||
for (auto it = _renderGroups.begin(); it != _renderGroups.end(); ++it)
|
||||
for (auto &renderqueue : _renderGroups)
|
||||
{
|
||||
std::stable_sort((*it).begin(), (*it).end(), compareRenderCommand);
|
||||
renderqueue.sort();
|
||||
}
|
||||
|
||||
while(!_renderStack.empty())
|
||||
|
@ -246,7 +295,7 @@ void Renderer::render()
|
|||
|
||||
if(commandType == RenderCommand::Type::QUAD_COMMAND)
|
||||
{
|
||||
QuadCommand* cmd = static_cast<QuadCommand*>(command);
|
||||
auto cmd = static_cast<QuadCommand*>(command);
|
||||
ssize_t cmdQuadCount = cmd->getQuadCount();
|
||||
|
||||
//Batch quads
|
||||
|
@ -268,19 +317,19 @@ void Renderer::render()
|
|||
else if(commandType == RenderCommand::Type::CUSTOM_COMMAND)
|
||||
{
|
||||
flush();
|
||||
CustomCommand* cmd = static_cast<CustomCommand*>(command);
|
||||
auto cmd = static_cast<CustomCommand*>(command);
|
||||
cmd->execute();
|
||||
}
|
||||
else if(commandType == RenderCommand::Type::BATCH_COMMAND)
|
||||
{
|
||||
flush();
|
||||
BatchCommand* cmd = static_cast<BatchCommand*>(command);
|
||||
auto cmd = static_cast<BatchCommand*>(command);
|
||||
cmd->execute();
|
||||
}
|
||||
else if(commandType == RenderCommand::Type::GROUP_COMMAND)
|
||||
{
|
||||
flush();
|
||||
GroupCommand* cmd = static_cast<GroupCommand*>(command);
|
||||
auto cmd = static_cast<GroupCommand*>(command);
|
||||
|
||||
_renderStack.top().currentIndex = i + 1;
|
||||
|
||||
|
@ -415,10 +464,10 @@ void Renderer::drawBatchedQuads()
|
|||
//Start drawing verties in batch
|
||||
for(ssize_t i = _firstCommand; i <= _lastCommand; i++)
|
||||
{
|
||||
RenderCommand* command = _renderGroups[_renderStack.top().renderQueueID][i];
|
||||
auto command = _renderGroups[_renderStack.top().renderQueueID][i];
|
||||
if (command->getType() == RenderCommand::Type::QUAD_COMMAND)
|
||||
{
|
||||
QuadCommand* cmd = static_cast<QuadCommand*>(command);
|
||||
auto cmd = static_cast<QuadCommand*>(command);
|
||||
if(_lastMaterialID != cmd->getMaterialID())
|
||||
{
|
||||
//Draw quads
|
||||
|
|
|
@ -37,7 +37,26 @@ NS_CC_BEGIN
|
|||
|
||||
class EventListenerCustom;
|
||||
|
||||
typedef std::vector<RenderCommand*> RenderQueue;
|
||||
/** Class that knows how to sort the Commands.
|
||||
Since the commands that have z==0 are "pushed back" in
|
||||
the correct order, the only Commands that need to be sorted,
|
||||
are the ones that have z <0 and z >0.
|
||||
And that is what this class does.
|
||||
*/
|
||||
class RenderQueue {
|
||||
|
||||
public:
|
||||
void push_back(RenderCommand* command);
|
||||
ssize_t size() const;
|
||||
void sort();
|
||||
RenderCommand* operator[](ssize_t index) const;
|
||||
void clear();
|
||||
|
||||
protected:
|
||||
std::vector<RenderCommand*> _queueNegZ;
|
||||
std::vector<RenderCommand*> _queue0;
|
||||
std::vector<RenderCommand*> _queuePosZ;
|
||||
};
|
||||
|
||||
struct RenderStackElement
|
||||
{
|
||||
|
|
|
@ -144,9 +144,11 @@ public:
|
|||
std::vector<K> keys() const
|
||||
{
|
||||
std::vector<K> keys;
|
||||
|
||||
|
||||
if (!_data.empty())
|
||||
{
|
||||
keys.reserve(_data.size());
|
||||
|
||||
for (auto iter = _data.cbegin(); iter != _data.cend(); ++iter)
|
||||
{
|
||||
keys.push_back(iter->first);
|
||||
|
@ -160,14 +162,21 @@ public:
|
|||
{
|
||||
std::vector<K> keys;
|
||||
|
||||
for (auto iter = _data.cbegin(); iter != _data.cend(); ++iter)
|
||||
if (!_data.empty())
|
||||
{
|
||||
if (iter->second == object)
|
||||
keys.reserve(_data.size() / 10);
|
||||
|
||||
for (auto iter = _data.cbegin(); iter != _data.cend(); ++iter)
|
||||
{
|
||||
keys.push_back(iter->first);
|
||||
if (iter->second == object)
|
||||
{
|
||||
keys.push_back(iter->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
keys.shrink_to_fit();
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ void BatchNode::draw()
|
|||
void BatchNode::generateGroupCommand()
|
||||
{
|
||||
Renderer* renderer = Director::getInstance()->getRenderer();
|
||||
_groupCommand->init(0,_vertexZ);
|
||||
_groupCommand->init(_globalZOrder);
|
||||
renderer->addCommand(_groupCommand);
|
||||
|
||||
renderer->pushGroup(_groupCommand->getRenderQueueID());
|
||||
|
|
|
@ -145,7 +145,7 @@ void Bone::setBoneData(BoneData *boneData)
|
|||
}
|
||||
|
||||
_name = _boneData->name;
|
||||
_ZOrder = _boneData->zOrder;
|
||||
_localZOrder = _boneData->zOrder;
|
||||
|
||||
_displayManager->initDisplayList(boneData);
|
||||
}
|
||||
|
@ -283,11 +283,11 @@ void Bone::updateZOrder()
|
|||
if (_dataVersion >= VERSION_COMBINED)
|
||||
{
|
||||
int zorder = _tweenData->zOrder + _boneData->zOrder;
|
||||
setZOrder(zorder);
|
||||
setLocalZOrder(zorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
setZOrder(_tweenData->zOrder);
|
||||
setLocalZOrder(_tweenData->zOrder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,10 +374,10 @@ Tween *Bone::getTween()
|
|||
return _tween;
|
||||
}
|
||||
|
||||
void Bone::setZOrder(int zOrder)
|
||||
void Bone::setLocalZOrder(int zOrder)
|
||||
{
|
||||
if (_ZOrder != zOrder)
|
||||
Node::setZOrder(zOrder);
|
||||
if (_localZOrder != zOrder)
|
||||
Node::setLocalZOrder(zOrder);
|
||||
}
|
||||
|
||||
kmMat4 Bone::getNodeToArmatureTransform() const
|
||||
|
|
|
@ -143,7 +143,7 @@ public:
|
|||
//! Update zorder
|
||||
void updateZOrder();
|
||||
|
||||
virtual void setZOrder(int zOrder) override;
|
||||
virtual void setLocalZOrder(int zOrder) override;
|
||||
|
||||
Tween *getTween();
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ void WidgetPropertiesReader0250::setPropsForWidgetFromJsonDictionary(Widget*widg
|
|||
widget->setVisible(DICTOOL->getBooleanValue_json(options, "visible"));
|
||||
}
|
||||
int z = DICTOOL->getIntValue_json(options, "ZOrder");
|
||||
widget->setZOrder(z);
|
||||
widget->setLocalZOrder(z);
|
||||
}
|
||||
|
||||
void WidgetPropertiesReader0250::setColorPropsForWidgetFromJsonDictionary(Widget *widget, const rapidjson::Value&options)
|
||||
|
@ -1062,7 +1062,7 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(Widget*widg
|
|||
widget->setVisible(DICTOOL->getBooleanValue_json(options, "visible"));
|
||||
}
|
||||
int z = DICTOOL->getIntValue_json(options, "ZOrder");
|
||||
widget->setZOrder(z);
|
||||
widget->setLocalZOrder(z);
|
||||
|
||||
bool layout = DICTOOL->checkObjectExist_json(options, "layoutParameter");
|
||||
if (layout)
|
||||
|
|
|
@ -203,7 +203,7 @@ void SceneReader::setPropertyFromJsonDict(const rapidjson::Value &root, cocos2d:
|
|||
node->setTag(nTag);
|
||||
|
||||
int nZorder = DICTOOL->getIntValue_json(root, "zorder");
|
||||
node->setZOrder(nZorder);
|
||||
node->setLocalZOrder(nZorder);
|
||||
|
||||
float fScaleX = DICTOOL->getFloatValue_json(root, "scalex", 1.0);
|
||||
float fScaleY = DICTOOL->getFloatValue_json(root, "scaley", 1.0);
|
||||
|
|
|
@ -225,7 +225,7 @@ void Skin::draw()
|
|||
kmGLGetMatrix(KM_GL_MODELVIEW, &mv);
|
||||
|
||||
//TODO implement z order
|
||||
_quadCommand.init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv);
|
||||
_quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ void Skeleton::draw()
|
|||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_oldTransMatrix);
|
||||
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -210,18 +210,18 @@ void Layout::stencilClippingVisit()
|
|||
|
||||
Renderer* renderer = Director::getInstance()->getRenderer();
|
||||
|
||||
_groupCommand.init(0,_vertexZ);
|
||||
_groupCommand.init(_globalZOrder);
|
||||
renderer->addCommand(&_groupCommand);
|
||||
|
||||
renderer->pushGroup(_groupCommand.getRenderQueueID());
|
||||
|
||||
_beforeVisitCmdStencil.init(0,_vertexZ);
|
||||
_beforeVisitCmdStencil.init(_globalZOrder);
|
||||
_beforeVisitCmdStencil.func = CC_CALLBACK_0(Layout::onBeforeVisitStencil, this);
|
||||
renderer->addCommand(&_beforeVisitCmdStencil);
|
||||
|
||||
_clippingStencil->visit();
|
||||
|
||||
_afterDrawStencilCmd.init(0,_vertexZ);
|
||||
_afterDrawStencilCmd.init(_globalZOrder);
|
||||
_afterDrawStencilCmd.func = CC_CALLBACK_0(Layout::onAfterDrawStencil, this);
|
||||
renderer->addCommand(&_afterDrawStencilCmd);
|
||||
|
||||
|
@ -251,7 +251,7 @@ void Layout::stencilClippingVisit()
|
|||
this->draw();
|
||||
}
|
||||
|
||||
_afterVisitCmdStencil.init(0,_vertexZ);
|
||||
_afterVisitCmdStencil.init(_globalZOrder);
|
||||
_afterVisitCmdStencil.func = CC_CALLBACK_0(Layout::onAfterVisitStencil, this);
|
||||
renderer->addCommand(&_afterVisitCmdStencil);
|
||||
|
||||
|
@ -336,13 +336,13 @@ void Layout::scissorClippingVisit()
|
|||
{
|
||||
Renderer* renderer = Director::getInstance()->getRenderer();
|
||||
|
||||
_beforeVisitCmdScissor.init(0, _vertexZ);
|
||||
_beforeVisitCmdScissor.init(_globalZOrder);
|
||||
_beforeVisitCmdScissor.func = CC_CALLBACK_0(Layout::onBeforeVisitScissor, this);
|
||||
renderer->addCommand(&_beforeVisitCmdScissor);
|
||||
|
||||
Node::visit();
|
||||
|
||||
_afterVisitCmdScissor.init(0, _vertexZ);
|
||||
_afterVisitCmdScissor.init(_globalZOrder);
|
||||
_afterVisitCmdScissor.func = CC_CALLBACK_0(Layout::onAfterVisitScissor, this);
|
||||
renderer->addCommand(&_afterVisitCmdScissor);
|
||||
}
|
||||
|
@ -651,14 +651,14 @@ void Layout::addBackGroundImage()
|
|||
if (_backGroundScale9Enabled)
|
||||
{
|
||||
_backGroundImage = extension::Scale9Sprite::create();
|
||||
_backGroundImage->setZOrder(-1);
|
||||
_backGroundImage->setLocalZOrder(-1);
|
||||
Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1);
|
||||
static_cast<extension::Scale9Sprite*>(_backGroundImage)->setPreferredSize(_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
_backGroundImage = Sprite::create();
|
||||
_backGroundImage->setZOrder(-1);
|
||||
_backGroundImage->setLocalZOrder(-1);
|
||||
Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1);
|
||||
}
|
||||
_backGroundImage->setPosition(Point(_size.width/2.0f, _size.height/2.0f));
|
||||
|
|
|
@ -195,7 +195,7 @@ public:
|
|||
* If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
|
||||
*
|
||||
* @param child A child node
|
||||
* @param zOrder Z order for drawing priority. Please refer to setZOrder(int)
|
||||
* @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int)
|
||||
*/
|
||||
virtual void addChild(Node * child, int zOrder) override;
|
||||
/**
|
||||
|
@ -204,7 +204,7 @@ public:
|
|||
* If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
|
||||
*
|
||||
* @param child A child node
|
||||
* @param zOrder Z order for drawing priority. Please refer to setZOrder(int)
|
||||
* @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int)
|
||||
* @param tag A interger to identify the node easily. Please refer to setTag(int)
|
||||
*/
|
||||
virtual void addChild(Node* child, int zOrder, int tag) override;
|
||||
|
|
|
@ -378,7 +378,7 @@ void ListView::refreshView()
|
|||
for (int i=0; i<length; i++)
|
||||
{
|
||||
Widget* item = _items.at(i);
|
||||
item->setZOrder(i);
|
||||
item->setLocalZOrder(i);
|
||||
remedyLayoutParameter(item);
|
||||
}
|
||||
updateInnerContainerSize();
|
||||
|
|
|
@ -242,7 +242,7 @@ public:
|
|||
* If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
|
||||
*
|
||||
* @param child A child node
|
||||
* @param zOrder Z order for drawing priority. Please refer to setZOrder(int)
|
||||
* @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int)
|
||||
*/
|
||||
virtual void addChild(Node * child, int zOrder) override;
|
||||
/**
|
||||
|
@ -251,7 +251,7 @@ public:
|
|||
* If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
|
||||
*
|
||||
* @param child A child node
|
||||
* @param zOrder Z order for drawing priority. Please refer to setZOrder(int)
|
||||
* @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int)
|
||||
* @param tag A interger to identify the node easily. Please refer to setTag(int)
|
||||
*/
|
||||
virtual void addChild(Node* child, int zOrder, int tag) override;
|
||||
|
|
|
@ -1040,7 +1040,7 @@ void Widget::copyProperties(Widget *widget)
|
|||
setBright(widget->isBright());
|
||||
setTouchEnabled(widget->isTouchEnabled());
|
||||
_touchPassedEnabled = false;
|
||||
setZOrder(widget->getZOrder());
|
||||
setLocalZOrder(widget->getLocalZOrder());
|
||||
setTag(widget->getTag());
|
||||
setName(widget->getName());
|
||||
setActionTag(widget->getActionTag());
|
||||
|
|
|
@ -212,7 +212,7 @@ public:
|
|||
* If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
|
||||
*
|
||||
* @param child A child node
|
||||
* @param zOrder Z order for drawing priority. Please refer to setZOrder(int)
|
||||
* @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int)
|
||||
*/
|
||||
virtual void addChild(Node * child, int zOrder) override;
|
||||
/**
|
||||
|
@ -221,7 +221,7 @@ public:
|
|||
* If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
|
||||
*
|
||||
* @param child A child node
|
||||
* @param zOrder Z order for drawing priority. Please refer to setZOrder(int)
|
||||
* @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int)
|
||||
* @param tag A interger to identify the node easily. Please refer to setTag(int)
|
||||
*/
|
||||
virtual void addChild(Node* child, int zOrder, int tag) override;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit f03e84b93ae69080e369962ba2e95ea9b2fd91c7
|
||||
Subproject commit de699f63aef423c3d90725171b0f020a719ef572
|
|
@ -58,75 +58,75 @@ const char* CCBProxy::getNodeTypeName(Node* pNode)
|
|||
}
|
||||
|
||||
if (NULL != dynamic_cast<LabelTTF*>(pNode)) {
|
||||
return "LabelTTF";
|
||||
return "cc.LabelTTF";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<LabelBMFont*>(pNode)) {
|
||||
return "LabelBMFont";
|
||||
return "cc.LabelBMFont";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<Sprite*>(pNode)) {
|
||||
return "Sprite";
|
||||
return "cc.Sprite";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<ControlButton*>(pNode)) {
|
||||
return "ControlButton";
|
||||
return "cc.ControlButton";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<LayerGradient*>(pNode)) {
|
||||
return "LayerGradient";
|
||||
return "cc.LayerGradient";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<LayerColor*>(pNode)) {
|
||||
return "LayerColor";
|
||||
return "cc.LayerColor";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<Scale9Sprite*>(pNode)) {
|
||||
return "LayerGradient";
|
||||
return "cc.LayerGradient";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<Menu*>(pNode)) {
|
||||
return "Menu";
|
||||
return "cc.Menu";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<MenuItemAtlasFont*>(pNode)) {
|
||||
return "MenuItemAtlasFont";
|
||||
return "cc.MenuItemAtlasFont";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<MenuItemFont*>(pNode)) {
|
||||
return "MenuItemFont";
|
||||
return "cc.MenuItemFont";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<MenuItemLabel*>(pNode)) {
|
||||
return "MenuItemLabel";
|
||||
return "cc.MenuItemLabel";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<MenuItemImage*>(pNode)) {
|
||||
return "MenuItemImage";
|
||||
return "cc.MenuItemImage";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<MenuItemToggle*>(pNode)) {
|
||||
return "MenuItemToggle";
|
||||
return "cc.MenuItemToggle";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<MenuItemSprite*>(pNode)) {
|
||||
return "MenuItemSprite";
|
||||
return "cc.MenuItemSprite";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<MenuItem*>(pNode)) {
|
||||
return "MenuItem";
|
||||
return "cc.MenuItem";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<Layer*>(pNode)) {
|
||||
return "Layer";
|
||||
return "cc.Layer";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<String*>(pNode)) {
|
||||
return "String";
|
||||
return "cc.String";
|
||||
}
|
||||
|
||||
if (NULL != dynamic_cast<ParticleSystemQuad*>(pNode)) {
|
||||
return "ParticleSystemQuad";
|
||||
return "cc.ParticleSystemQuad";
|
||||
}
|
||||
|
||||
return "No Support";
|
||||
|
|
|
@ -167,7 +167,7 @@ int LuaEngine::executeEvent(int nHandler, const char* pEventName, Object* pEvent
|
|||
_stack->pushString(pEventName);
|
||||
if (pEventSource)
|
||||
{
|
||||
_stack->pushObject(pEventSource, pEventSourceClassName ? pEventSourceClassName : "CCObject");
|
||||
_stack->pushObject(pEventSource, pEventSourceClassName ? pEventSourceClassName : "cc.Object");
|
||||
}
|
||||
int ret = _stack->executeFunctionByHandler(nHandler, pEventSource ? 2 : 1);
|
||||
_stack->clean();
|
||||
|
@ -329,7 +329,7 @@ int LuaEngine::handleMenuClickedEvent(void* data)
|
|||
return 0;
|
||||
|
||||
_stack->pushInt(menuItem->getTag());
|
||||
_stack->pushObject(menuItem, "MenuItem");
|
||||
_stack->pushObject(menuItem, "cc.MenuItem");
|
||||
int ret = _stack->executeFunctionByHandler(handler, 2);
|
||||
_stack->clean();
|
||||
return ret;
|
||||
|
@ -352,7 +352,7 @@ int LuaEngine::handleCallFuncActionEvent(void* data)
|
|||
Object* target = static_cast<Object*>(basicScriptData->value);
|
||||
if (NULL != target)
|
||||
{
|
||||
_stack->pushObject(target, "Node");
|
||||
_stack->pushObject(target, "cc.Node");
|
||||
}
|
||||
int ret = _stack->executeFunctionByHandler(handler, target ? 1 : 0);
|
||||
_stack->clean();
|
||||
|
@ -447,7 +447,7 @@ int LuaEngine::handleCommonEvent(void* data)
|
|||
}
|
||||
else
|
||||
{
|
||||
_stack->pushObject(commonInfo->eventSource, "Object");
|
||||
_stack->pushObject(commonInfo->eventSource, "cc.Object");
|
||||
}
|
||||
}
|
||||
int ret = _stack->executeFunctionByHandler(commonInfo->handler, commonInfo->eventSource ? 2 : 1);
|
||||
|
@ -585,7 +585,7 @@ int LuaEngine::handlerControlEvent(void* data)
|
|||
|
||||
if (0 != handler)
|
||||
{
|
||||
_stack->pushObject((Object*)basicScriptData->nativeObject, "Object");
|
||||
_stack->pushObject((Object*)basicScriptData->nativeObject, "cc.Object");
|
||||
_stack->pushInt(controlEvents);
|
||||
ret = _stack->executeFunctionByHandler(handler, 2);
|
||||
_stack->clean();
|
||||
|
@ -612,7 +612,7 @@ int LuaEngine::handleEventAcc(void* data)
|
|||
lua_State* L = _stack->getLuaState();
|
||||
|
||||
LuaEventAccelerationData* eventListennerAcc = static_cast<LuaEventAccelerationData*>(basicScriptData->value);
|
||||
toluafix_pushusertype_ccobject(L, eventListennerAcc->event->_ID, &(eventListennerAcc->event->_luaID), (void*)(eventListennerAcc->event),"Event");
|
||||
toluafix_pushusertype_ccobject(L, eventListennerAcc->event->_ID, &(eventListennerAcc->event->_luaID), (void*)(eventListennerAcc->event),"cc.Event");
|
||||
Acceleration* accleration = static_cast<Acceleration*>(eventListennerAcc->acc);
|
||||
lua_pushnumber(L,accleration->x);
|
||||
lua_pushnumber(L,accleration->y);
|
||||
|
@ -640,7 +640,7 @@ int LuaEngine::handleEventKeyboard(ScriptHandlerMgr::HandlerType type, void* dat
|
|||
|
||||
lua_State* L = _stack->getLuaState();
|
||||
lua_pushinteger(L, keyboardData->keyCode);
|
||||
toluafix_pushusertype_ccobject(L, keyboardData->event->_ID, &(keyboardData->event->_luaID), (void*)(keyboardData->event),"Event");
|
||||
toluafix_pushusertype_ccobject(L, keyboardData->event->_ID, &(keyboardData->event->_luaID), (void*)(keyboardData->event),"cc.Event");
|
||||
int ret = _stack->executeFunctionByHandler(handler, 2);
|
||||
_stack->clean();
|
||||
return ret;
|
||||
|
@ -667,8 +667,8 @@ int LuaEngine::handleEventTouch(ScriptHandlerMgr::HandlerType type, void* data)
|
|||
|
||||
Touch* touch = touchData->touch;
|
||||
if (NULL != touch) {
|
||||
_stack->pushObject(touchData->touch, "Touch");
|
||||
_stack->pushObject(touchData->event, "Event");
|
||||
_stack->pushObject(touchData->touch, "cc.Touch");
|
||||
_stack->pushObject(touchData->event, "cc.Event");
|
||||
ret = _stack->executeFunctionByHandler(handler, 2);
|
||||
}
|
||||
_stack->clean();
|
||||
|
@ -702,11 +702,11 @@ int LuaEngine::handleEventTouches(ScriptHandlerMgr::HandlerType type,void* data)
|
|||
for (auto& touch : touchesData->touches)
|
||||
{
|
||||
_stack->pushInt(i);
|
||||
_stack->pushObject(touch, "Touch");
|
||||
_stack->pushObject(touch, "cc.Touch");
|
||||
lua_rawset(L, -3);
|
||||
++i;
|
||||
}
|
||||
_stack->pushObject(touchesData->event, "Event");
|
||||
_stack->pushObject(touchesData->event, "cc.Event");
|
||||
|
||||
ret = _stack->executeFunctionByHandler(handler, 2);
|
||||
_stack->clean();
|
||||
|
@ -731,7 +731,7 @@ int LuaEngine::handleEventMouse(ScriptHandlerMgr::HandlerType type, void* data)
|
|||
if (0 == handler)
|
||||
return 0;
|
||||
|
||||
_stack->pushObject(mouseData->event, "Event");
|
||||
_stack->pushObject(mouseData->event, "cc.Event");
|
||||
int ret = _stack->executeFunctionByHandler(handler, 1);
|
||||
_stack->clean();
|
||||
|
||||
|
@ -754,7 +754,7 @@ int LuaEngine::handleEvenCustom(void* data)
|
|||
return 0;
|
||||
|
||||
lua_State* L = _stack->getLuaState();
|
||||
toluafix_pushusertype_ccobject(L, eventCustom->_ID, &(eventCustom->_luaID), (void*)(eventCustom),"EventCustom");
|
||||
toluafix_pushusertype_ccobject(L, eventCustom->_ID, &(eventCustom->_luaID), (void*)(eventCustom),"cc.EventCustom");
|
||||
int ret = _stack->executeFunctionByHandler(handler, 1);
|
||||
_stack->clean();
|
||||
|
||||
|
@ -859,14 +859,102 @@ int LuaEngine::handleEvent(ScriptHandlerMgr::HandlerType type, void* data, int n
|
|||
|
||||
int LuaEngine::handleTableViewEvent(ScriptHandlerMgr::HandlerType type,void* data)
|
||||
{
|
||||
CCASSERT(0, "TableView is not bound yet");
|
||||
return 0;
|
||||
if (nullptr == data)
|
||||
return 0;
|
||||
|
||||
BasicScriptData* eventData = static_cast<BasicScriptData*>(data);
|
||||
if (nullptr == eventData->nativeObject || nullptr == eventData->value)
|
||||
return 0;
|
||||
|
||||
LuaTableViewEventData* tableViewData = static_cast<LuaTableViewEventData*>(eventData->value);
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, type);
|
||||
|
||||
if (0 == handler)
|
||||
return 0;
|
||||
|
||||
Object* obj = static_cast<Object*>(eventData->nativeObject);
|
||||
if (nullptr == obj)
|
||||
return 0;
|
||||
|
||||
int ret = 0;
|
||||
switch (type)
|
||||
{
|
||||
case ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL:
|
||||
case ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM:
|
||||
{
|
||||
toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"cc.TableView");
|
||||
ret = _stack->executeFunctionByHandler(handler, 1);
|
||||
}
|
||||
break;
|
||||
case ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED:
|
||||
case ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT:
|
||||
case ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT:
|
||||
case ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE:
|
||||
{
|
||||
Object* cellObject = static_cast<Object*>(tableViewData->value);
|
||||
if (nullptr == cellObject) {
|
||||
break;
|
||||
}
|
||||
toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"cc.TableView");
|
||||
toluafix_pushusertype_ccobject(_stack->getLuaState(), cellObject->_ID, &(cellObject->_luaID), (void*)(cellObject),"cc.TableViewCell");
|
||||
ret = _stack->executeFunctionByHandler(handler, 2);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
int LuaEngine::handleTableViewEvent(ScriptHandlerMgr::HandlerType handlerType,void* data, int numResults, const std::function<void(lua_State*,int)>& func)
|
||||
{
|
||||
CCASSERT(0, "TableView is not bound yet");
|
||||
return 0;
|
||||
if (nullptr == data || numResults <= 0)
|
||||
return 0;
|
||||
|
||||
BasicScriptData* eventData = static_cast<BasicScriptData*>(data);
|
||||
if (nullptr == eventData->nativeObject || nullptr == eventData->value)
|
||||
return 0;
|
||||
|
||||
LuaTableViewEventData* tableViewData = static_cast<LuaTableViewEventData*>(eventData->value);
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, handlerType);
|
||||
|
||||
if (0 == handler)
|
||||
return 0;
|
||||
|
||||
Object* obj = static_cast<Object*>(eventData->nativeObject);
|
||||
if (nullptr == obj)
|
||||
return 0;
|
||||
|
||||
int ret = 0;
|
||||
switch (handlerType)
|
||||
{
|
||||
case ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX:
|
||||
{
|
||||
toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"cc.TableView");
|
||||
_stack->pushLong(*((ssize_t*)tableViewData->value));
|
||||
ret = _stack->executeFunction(handler, 2, 2, func);
|
||||
}
|
||||
break;
|
||||
case ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX:
|
||||
{
|
||||
toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"cc.TableView");
|
||||
_stack->pushLong(*((ssize_t*)tableViewData->value));
|
||||
ret = _stack->executeFunction(handler, 2, 1, func);
|
||||
}
|
||||
break;
|
||||
case ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS:
|
||||
{
|
||||
toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"cc.TableView");
|
||||
ret = _stack->executeFunction(handler, 1, 1, func);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int LuaEngine::handleAssetsManagerEvent(ScriptHandlerMgr::HandlerType type,void* data)
|
||||
|
@ -925,7 +1013,7 @@ int LuaEngine::handleStudioEventListener(ScriptHandlerMgr::HandlerType type,void
|
|||
if (0 == handler)
|
||||
return 0;
|
||||
|
||||
_stack->pushObject(listenerData->objTarget, "Object");
|
||||
_stack->pushObject(listenerData->objTarget, "cc.Object");
|
||||
_stack->pushInt(listenerData->eventType);
|
||||
|
||||
_stack->executeFunctionByHandler(handler, 2);
|
||||
|
@ -956,7 +1044,7 @@ int LuaEngine::handleArmatureWrapper(ScriptHandlerMgr::HandlerType type,void* da
|
|||
{
|
||||
LuaArmatureMovementEventData* movementData = static_cast<LuaArmatureMovementEventData*>(wrapperData->eventData);
|
||||
|
||||
_stack->pushObject(movementData->objTarget, "Armature");
|
||||
_stack->pushObject(movementData->objTarget, "ccs.Armature");
|
||||
_stack->pushInt(movementData->movementType);
|
||||
_stack->pushString(movementData->movementID.c_str());
|
||||
_stack->executeFunctionByHandler(handler, 3);
|
||||
|
@ -966,7 +1054,7 @@ int LuaEngine::handleArmatureWrapper(ScriptHandlerMgr::HandlerType type,void* da
|
|||
{
|
||||
LuaArmatureFrameEventData* frameData = static_cast<LuaArmatureFrameEventData*>(wrapperData->eventData);
|
||||
|
||||
_stack->pushObject(frameData->objTarget, "Bone");
|
||||
_stack->pushObject(frameData->objTarget, "ccs.Bone");
|
||||
_stack->pushString(frameData->frameEventName.c_str());
|
||||
_stack->pushInt(frameData->originFrameIndex);
|
||||
_stack->pushInt(frameData->currentFrameIndex);
|
||||
|
|
|
@ -151,7 +151,6 @@ bool LuaStack::init(void)
|
|||
register_all_cocos2dx_extension(_state);
|
||||
register_all_cocos2dx_deprecated(_state);
|
||||
register_cocos2dx_extension_CCBProxy(_state);
|
||||
register_cocos2dx_event_releated(_state);
|
||||
tolua_opengl_open(_state);
|
||||
register_all_cocos2dx_gui(_state);
|
||||
register_all_cocos2dx_studio(_state);
|
||||
|
|
|
@ -33,6 +33,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
std::unordered_map<std::string, std::string> g_luaType;
|
||||
std::unordered_map<std::string, std::string> g_typeCast;
|
||||
|
||||
#if COCOS2D_DEBUG >=1
|
||||
void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err)
|
||||
|
|
|
@ -35,6 +35,7 @@ extern "C" {
|
|||
using namespace cocos2d;
|
||||
|
||||
extern std::unordered_map<std::string, std::string> g_luaType;
|
||||
extern std::unordered_map<std::string, std::string> g_typeCast;
|
||||
|
||||
#if COCOS2D_DEBUG >=1
|
||||
void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err);
|
||||
|
|
|
@ -1 +1 @@
|
|||
bcec27eb626dbcf63b810cce7f0f48b2d02c2158
|
||||
bc70bac577759c95fbcf25da6937dbd9109da8d5
|
|
@ -36,7 +36,7 @@ extern "C" {
|
|||
|
||||
class GLNode:public cocos2d::Node
|
||||
{
|
||||
virtual void draw();
|
||||
virtual void draw() override;
|
||||
};
|
||||
|
||||
TOLUA_API int tolua_opengl_open(lua_State* tolua_S);
|
||||
|
|
|
@ -282,7 +282,7 @@ static int tolua_Cocos2d_ScriptHandlerMgr_registerScriptHandler00(lua_State* tol
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"ScriptHandlerMgr",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S, 2, "Object", 0, &tolua_err) ||
|
||||
!tolua_isusertype(tolua_S, 2, "cc.Object", 0, &tolua_err) ||
|
||||
!toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err) ||
|
||||
!tolua_isnumber(tolua_S, 4, 0, &tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,5,&tolua_err) )
|
||||
|
@ -316,7 +316,7 @@ static int tolua_Cocos2d_ScriptHandlerMgr_unregisterScriptHandler00(lua_State* t
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"ScriptHandlerMgr",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S, 2, "Object", 0, &tolua_err) ||
|
||||
!tolua_isusertype(tolua_S, 2, "cc.Object", 0, &tolua_err) ||
|
||||
!tolua_isnumber(tolua_S, 3, 0, &tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,4,&tolua_err) )
|
||||
goto tolua_lerror;
|
||||
|
@ -348,7 +348,7 @@ static int tolua_Cocos2d_ScriptHandlerMgr_removeObjectAllHandlers00(lua_State* t
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"ScriptHandlerMgr",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S, 2, "Object", 0, &tolua_err) ||
|
||||
!tolua_isusertype(tolua_S, 2, "cc.Object", 0, &tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,3,&tolua_err) )
|
||||
goto tolua_lerror;
|
||||
else
|
||||
|
|
|
@ -164,7 +164,7 @@ static int tolua_collect_WebSocket (lua_State* tolua_S)
|
|||
/* function to release collected object via destructor */
|
||||
static void tolua_reg_Web_Socket_type(lua_State* tolua_S)
|
||||
{
|
||||
tolua_usertype(tolua_S, "WebSocket");
|
||||
tolua_usertype(tolua_S, "cc.WebSocket");
|
||||
}
|
||||
|
||||
/* method: create of class WebSocket */
|
||||
|
@ -174,7 +174,7 @@ static int tolua_Cocos2d_WebSocket_create00(lua_State* tolua_S)
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertable(tolua_S,1,"WebSocket",0,&tolua_err) ||
|
||||
!tolua_isusertable(tolua_S,1,"cc.WebSocket",0,&tolua_err) ||
|
||||
!tolua_isstring(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||
)
|
||||
|
@ -185,7 +185,7 @@ static int tolua_Cocos2d_WebSocket_create00(lua_State* tolua_S)
|
|||
const char* urlName = ((const char*) tolua_tostring(tolua_S,2,0));
|
||||
LuaWebSocket *wSocket = new LuaWebSocket();
|
||||
wSocket->init(*wSocket, urlName);
|
||||
tolua_pushusertype(tolua_S,(void*)wSocket,"WebSocket");
|
||||
tolua_pushusertype(tolua_S,(void*)wSocket,"cc.WebSocket");
|
||||
tolua_register_gc(tolua_S,lua_gettop(tolua_S));
|
||||
}
|
||||
return 1;
|
||||
|
@ -204,7 +204,7 @@ static int tolua_Cocos2d_WebSocket_createByAProtocol00(lua_State* tolua_S)
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertable(tolua_S,1,"WebSocket",0,&tolua_err) ||
|
||||
!tolua_isusertable(tolua_S,1,"cc.WebSocket",0,&tolua_err) ||
|
||||
!tolua_isstring(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_isstring(tolua_S,3,0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,4,&tolua_err)
|
||||
|
@ -219,7 +219,7 @@ static int tolua_Cocos2d_WebSocket_createByAProtocol00(lua_State* tolua_S)
|
|||
protocols.push_back(protocol);
|
||||
LuaWebSocket *wSocket = new LuaWebSocket();
|
||||
wSocket->init(*wSocket, urlName,&protocols);
|
||||
tolua_pushusertype(tolua_S,(void*)wSocket,"WebSocket");
|
||||
tolua_pushusertype(tolua_S,(void*)wSocket,"cc.WebSocket");
|
||||
tolua_register_gc(tolua_S,lua_gettop(tolua_S));
|
||||
}
|
||||
return 1;
|
||||
|
@ -238,7 +238,7 @@ static int tolua_Cocos2d_WebSocket_createByProtocolArray00(lua_State* tolua_S)
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertable(tolua_S,1,"WebSocket",0,&tolua_err) ||
|
||||
!tolua_isusertable(tolua_S,1,"cc.WebSocket",0,&tolua_err) ||
|
||||
!tolua_isstring(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_isusertable(tolua_S,3,"CCArray",0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,4,&tolua_err)
|
||||
|
@ -262,7 +262,7 @@ static int tolua_Cocos2d_WebSocket_createByProtocolArray00(lua_State* tolua_S)
|
|||
}
|
||||
LuaWebSocket *wSocket = new LuaWebSocket();
|
||||
wSocket->init(*wSocket, urlName,&protocols);
|
||||
tolua_pushusertype(tolua_S,(void*)wSocket,"WebSocket");
|
||||
tolua_pushusertype(tolua_S,(void*)wSocket,"cc.WebSocket");
|
||||
tolua_register_gc(tolua_S,lua_gettop(tolua_S));
|
||||
}
|
||||
return 1;
|
||||
|
@ -281,7 +281,7 @@ static int tolua_Cocos2d_WebSocket_getReadyState00(lua_State* tolua_S)
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,1,"cc.WebSocket",0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,2,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
|
@ -312,7 +312,7 @@ static int tolua_Cocos2d_WebSocket_close00(lua_State* tolua_S)
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,1,"cc.WebSocket",0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,2,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
|
@ -340,7 +340,7 @@ static int tolua_Cocos2d_WebSocket_sendString00(lua_State* tolua_S)
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S, 1, "WebSocket", 0, &tolua_err) ||
|
||||
!tolua_isusertype(tolua_S, 1, "cc.WebSocket", 0, &tolua_err) ||
|
||||
!tolua_isstring(tolua_S, 2, 0, &tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S, 3, &tolua_err)
|
||||
)
|
||||
|
@ -376,12 +376,12 @@ tolua_lerror:
|
|||
TOLUA_API int tolua_web_socket_open(lua_State* tolua_S){
|
||||
tolua_open(tolua_S);
|
||||
tolua_reg_Web_Socket_type(tolua_S);
|
||||
tolua_module(tolua_S,NULL,0);
|
||||
tolua_beginmodule(tolua_S,NULL);
|
||||
tolua_module(tolua_S,"cc",0);
|
||||
tolua_beginmodule(tolua_S,"cc");
|
||||
#ifdef __cplusplus
|
||||
tolua_cclass(tolua_S,"WebSocket","WebSocket","",tolua_collect_WebSocket);
|
||||
tolua_cclass(tolua_S,"WebSocket","cc.WebSocket","",tolua_collect_WebSocket);
|
||||
#else
|
||||
tolua_cclass(tolua_S,"WebSocket","WebSocket","",NULL);
|
||||
tolua_cclass(tolua_S,"WebSocket","cc.WebSocket","",NULL);
|
||||
#endif
|
||||
tolua_beginmodule(tolua_S,"WebSocket");
|
||||
tolua_function(tolua_S, "create", tolua_Cocos2d_WebSocket_create00);
|
||||
|
@ -400,7 +400,7 @@ int tolua_Cocos2d_WebSocket_registerScriptHandler00(lua_State* tolua_S)
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,1,"cc.WebSocket",0,&tolua_err) ||
|
||||
!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,4,&tolua_err)
|
||||
|
@ -429,7 +429,7 @@ int tolua_Cocos2d_WebSocket_unregisterScriptHandler00(lua_State* tolua_S)
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,1,"cc.WebSocket",0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||
)
|
||||
|
@ -457,7 +457,7 @@ TOLUA_API int register_web_socket_manual(lua_State* tolua_S)
|
|||
if (nullptr == tolua_S)
|
||||
return 0 ;
|
||||
|
||||
lua_pushstring(tolua_S,"WebSocket");
|
||||
lua_pushstring(tolua_S,"cc.WebSocket");
|
||||
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
|
|
|
@ -39,10 +39,10 @@ class LuaWebSocket: public cocos2d::network::WebSocket,public cocos2d::network::
|
|||
{
|
||||
public:
|
||||
virtual ~LuaWebSocket();
|
||||
virtual void onOpen(WebSocket* ws);
|
||||
virtual void onMessage(WebSocket* ws, const WebSocket::Data& data);
|
||||
virtual void onClose(WebSocket* ws);
|
||||
virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error);
|
||||
virtual void onOpen(WebSocket* ws) override;
|
||||
virtual void onMessage(WebSocket* ws, const WebSocket::Data& data) override;
|
||||
virtual void onClose(WebSocket* ws) override;
|
||||
virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error) override;
|
||||
|
||||
enum WebSocketScriptHandlerType
|
||||
{
|
||||
|
|
|
@ -83,7 +83,7 @@ static int lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"ArmatureAnimation",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<ArmatureAnimation*>(tolua_tousertype(L,1,0));
|
||||
|
@ -153,7 +153,7 @@ static int lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"ArmatureAnimation",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<ArmatureAnimation*>(tolua_tousertype(L,1,0));
|
||||
|
@ -217,7 +217,7 @@ tolua_lerror:
|
|||
|
||||
static void extendArmatureAnimation(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "ArmatureAnimation");
|
||||
lua_pushstring(L, "ccs.ArmatureAnimation");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
|
@ -237,7 +237,7 @@ static int lua_cocos2dx_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc(lua
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"ArmatureDataManager",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<ArmatureDataManager*>(tolua_tousertype(L,1,0));
|
||||
|
@ -309,7 +309,7 @@ tolua_lerror:
|
|||
|
||||
static void extendArmatureDataManager(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "ArmatureDataManager");
|
||||
lua_pushstring(L, "ccs.ArmatureDataManager");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
|
@ -328,7 +328,7 @@ static int lua_cocos2dx_extension_Bone_setIgnoreMovementBoneData(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"Bone",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<cocostudio::Bone*>(tolua_tousertype(L,1,0));
|
||||
|
@ -373,7 +373,7 @@ static int lua_cocos2dx_extension_Bone_getIgnoreMovementBoneData(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"Bone",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<cocostudio::Bone*>(tolua_tousertype(L,1,0));
|
||||
|
@ -405,7 +405,7 @@ tolua_lerror:
|
|||
|
||||
static void extendBone(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "Bone");
|
||||
lua_pushstring(L, "ccs.Bone");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
|
|
|
@ -2123,6 +2123,15 @@ static int tolua_bnd_cast_deprecated00(lua_State* tolua_S)
|
|||
}
|
||||
else
|
||||
{
|
||||
std::string castName = tolua_tostring(tolua_S,2,NULL);
|
||||
auto iter = g_typeCast.find(castName);
|
||||
if (iter != g_typeCast.end() )
|
||||
{
|
||||
CCLOG("Cast name %s doesn't include modular name which it belongs to,please add the modular name",iter->first.c_str());
|
||||
tolua_pushstring(tolua_S, iter->second.c_str());
|
||||
lua_insert(tolua_S, 2);
|
||||
lua_pop(tolua_S, 1);
|
||||
}
|
||||
return tolua_bnd_cast(tolua_S);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,203 @@ USING_NS_CC;
|
|||
USING_NS_CC_EXT;
|
||||
using namespace cocostudio;
|
||||
|
||||
class LuaScrollViewDelegate:public Object, public ScrollViewDelegate
|
||||
{
|
||||
public:
|
||||
virtual ~LuaScrollViewDelegate()
|
||||
{}
|
||||
|
||||
virtual void scrollViewDidScroll(ScrollView* view) override
|
||||
{
|
||||
if (nullptr != view)
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL);
|
||||
if (0 != handler)
|
||||
{
|
||||
CommonScriptData data(handler,"");
|
||||
ScriptEvent event(kCommonEvent,(void*)&data);
|
||||
LuaEngine::getInstance()->sendEvent(&event);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
virtual void scrollViewDidZoom(ScrollView* view) override
|
||||
{
|
||||
if (nullptr != view)
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM);
|
||||
if (0 != handler)
|
||||
{
|
||||
CommonScriptData data(handler,"");
|
||||
ScriptEvent event(kCommonEvent,(void*)&data);
|
||||
LuaEngine::getInstance()->sendEvent(&event);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static int tolua_cocos2dx_ScrollView_setDelegate(lua_State* tolua_S)
|
||||
{
|
||||
if (nullptr == tolua_S)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
ScrollView* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (ScrollView*) tolua_tousertype(tolua_S,1,0);
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_ScrollView_setDelegate'\n", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
|
||||
if (0 == argc)
|
||||
{
|
||||
LuaScrollViewDelegate* delegate = new LuaScrollViewDelegate();
|
||||
if (nullptr == delegate)
|
||||
return 0;
|
||||
|
||||
self->setUserObject(delegate);
|
||||
self->setDelegate(delegate);
|
||||
|
||||
delegate->release();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'setDelegate' function of ScrollView wrong number of arguments: %d, was expecting %d\n", argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'setDelegate'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int tolua_cocos2d_ScrollView_registerScriptHandler(lua_State* tolua_S)
|
||||
{
|
||||
if (NULL == tolua_S)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
ScrollView* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<ScrollView*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_ScrollView_registerScriptHandler'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
if (2 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S, 3, 0, &tolua_err) )
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
||||
ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(tolua_S,3,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL);
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'registerScriptHandler' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 2);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int tolua_cocos2d_ScrollView_unregisterScriptHandler(lua_State* tolua_S)
|
||||
{
|
||||
if (NULL == tolua_S)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
ScrollView* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<ScrollView*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_ScrollView_unregisterScriptHandler'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
|
||||
if (1 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
goto tolua_lerror;
|
||||
#endif
|
||||
ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(tolua_S,2,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL);
|
||||
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'unregisterScriptHandler' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void extendScrollView(lua_State* tolua_S)
|
||||
{
|
||||
lua_pushstring(tolua_S, "cc.ScrollView");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
lua_pushstring(tolua_S,"setDelegate");
|
||||
lua_pushcfunction(tolua_S,tolua_cocos2dx_ScrollView_setDelegate );
|
||||
lua_rawset(tolua_S,-3);
|
||||
lua_pushstring(tolua_S,"registerScriptHandler");
|
||||
lua_pushcfunction(tolua_S,tolua_cocos2d_ScrollView_registerScriptHandler );
|
||||
lua_rawset(tolua_S,-3);
|
||||
lua_pushstring(tolua_S,"unregisterScriptHandler");
|
||||
lua_pushcfunction(tolua_S,tolua_cocos2d_ScrollView_unregisterScriptHandler );
|
||||
lua_rawset(tolua_S,-3);
|
||||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
}
|
||||
|
||||
|
||||
static int tolua_cocos2d_Control_registerControlEventHandler(lua_State* tolua_S)
|
||||
{
|
||||
if (NULL == tolua_S)
|
||||
|
@ -52,7 +249,7 @@ static int tolua_cocos2d_Control_registerControlEventHandler(lua_State* tolua_S)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"Control",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<Control*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
@ -108,7 +305,7 @@ static int tolua_cocos2d_control_unregisterControlEventHandler(lua_State* tolua_
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"Control",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<Control*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
@ -153,7 +350,7 @@ tolua_lerror:
|
|||
|
||||
static void extendControl(lua_State* tolua_S)
|
||||
{
|
||||
lua_pushstring(tolua_S, "Control");
|
||||
lua_pushstring(tolua_S, "cc.Control");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
|
@ -177,7 +374,7 @@ static int tolua_cocos2d_EditBox_registerScriptEditBoxHandler(lua_State* tolua_S
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"EditBox",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<EditBox*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
@ -226,7 +423,7 @@ static int tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler(lua_State* tolua
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"EditBox",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<EditBox*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
@ -258,7 +455,7 @@ tolua_lerror:
|
|||
|
||||
static void extendEditBox(lua_State* tolua_S)
|
||||
{
|
||||
lua_pushstring(tolua_S, "EditBox");
|
||||
lua_pushstring(tolua_S, "cc.EditBox");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
|
@ -281,7 +478,7 @@ static int tolua_cocos2d_CCBProxy_create(lua_State* tolua_S)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertable(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertable(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
|
@ -291,7 +488,7 @@ static int tolua_cocos2d_CCBProxy_create(lua_State* tolua_S)
|
|||
CCBProxy* tolua_ret = (CCBProxy*)CCBProxy::create();
|
||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int *pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCBProxy");
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.CCBProxy");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -316,7 +513,7 @@ static int tolua_cocos2d_CCBProxy_createCCBReader(lua_State* tolua_S)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<CCBProxy*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
@ -335,7 +532,7 @@ static int tolua_cocos2d_CCBProxy_createCCBReader(lua_State* tolua_S)
|
|||
CCBReader* tolua_ret = (CCBReader*) self->createCCBReader();
|
||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCBReader");
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.CCBReader");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -366,7 +563,7 @@ static int tolua_cocos2d_CCBProxy_readCCBFromFile(lua_State* tolua_S)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<CCBProxy*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
@ -384,7 +581,7 @@ static int tolua_cocos2d_CCBProxy_readCCBFromFile(lua_State* tolua_S)
|
|||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isstring(tolua_S, 2, 0, &tolua_err)||
|
||||
!tolua_isusertype(tolua_S,3,"CCBReader",0,&tolua_err)||
|
||||
!tolua_isusertype(tolua_S,3,"cc.CCBReader",0,&tolua_err)||
|
||||
!tolua_isboolean(tolua_S,4,1,&tolua_err )
|
||||
)
|
||||
goto tolua_lerror;
|
||||
|
@ -395,7 +592,7 @@ static int tolua_cocos2d_CCBProxy_readCCBFromFile(lua_State* tolua_S)
|
|||
tolua_ret = (Node*) self->readCCBFromFile(ccbFilePath, ccbReader, setOwner);
|
||||
ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"Node");
|
||||
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.Node");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -420,7 +617,7 @@ static int tolua_cocos2d_CCBProxy_getNodeTypeName(lua_State* tolua_S)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<CCBProxy*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
@ -437,7 +634,7 @@ static int tolua_cocos2d_CCBProxy_getNodeTypeName(lua_State* tolua_S)
|
|||
if (1 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
Node* node = static_cast<Node*>(tolua_tousertype(tolua_S,2,0));
|
||||
|
@ -466,7 +663,7 @@ static int tolua_cocos2d_CCBProxy_setCallback(lua_State* tolua_S)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<CCBProxy*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
@ -482,7 +679,7 @@ static int tolua_cocos2d_CCBProxy_setCallback(lua_State* tolua_S)
|
|||
if ( argc >= 2 && argc <= 3 )
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,2,"Node",0,&tolua_err) ||
|
||||
if (!tolua_isusertype(tolua_S,2,"cc.Node",0,&tolua_err) ||
|
||||
!toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err) ||
|
||||
!tolua_isnumber(tolua_S, 4, 1, &tolua_err)
|
||||
)
|
||||
|
@ -510,8 +707,8 @@ int register_cocos2dx_extension_CCBProxy(lua_State* tolua_S)
|
|||
{
|
||||
tolua_module(tolua_S,"cc",0);
|
||||
tolua_beginmodule(tolua_S,"cc");
|
||||
tolua_usertype(tolua_S,"CCBProxy");
|
||||
tolua_cclass(tolua_S,"CCBProxy","CCBProxy","Layer",NULL);
|
||||
tolua_usertype(tolua_S,"cc.CCBProxy");
|
||||
tolua_cclass(tolua_S,"CCBProxy","cc.CCBProxy","cc.Layer",NULL);
|
||||
tolua_beginmodule(tolua_S,"CCBProxy");
|
||||
tolua_function(tolua_S, "create", tolua_cocos2d_CCBProxy_create);
|
||||
tolua_function(tolua_S, "createCCBReader", tolua_cocos2d_CCBProxy_createCCBReader);
|
||||
|
@ -522,7 +719,7 @@ int register_cocos2dx_extension_CCBProxy(lua_State* tolua_S)
|
|||
tolua_endmodule(tolua_S);
|
||||
|
||||
std::string typeName = typeid(CCBProxy).name();
|
||||
g_luaType[typeName] = "CCBProxy";
|
||||
g_luaType[typeName] = "cc.CCBProxy";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -537,7 +734,7 @@ static int tolua_cocos2d_CCBReader_load(lua_State* tolua_S)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"CCBReader",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<CCBReader*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
@ -564,12 +761,12 @@ static int tolua_cocos2d_CCBReader_load(lua_State* tolua_S)
|
|||
Node* tolua_ret = (Node*) self->readNodeGraphFromFile(fileName);
|
||||
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"Node");
|
||||
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.Node");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S, 3, "Object", 0, &tolua_err))
|
||||
if (!tolua_isusertype(tolua_S, 3, "cc.Object", 0, &tolua_err))
|
||||
goto tolua_lerror;
|
||||
#endif
|
||||
Object* owner = static_cast<Object*>(tolua_tousertype(tolua_S, 3, 0));
|
||||
|
@ -579,7 +776,7 @@ static int tolua_cocos2d_CCBReader_load(lua_State* tolua_S)
|
|||
Node* tolua_ret = (Node*) self->readNodeGraphFromFile(fileName,owner);
|
||||
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"Node");
|
||||
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.Node");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -591,7 +788,7 @@ static int tolua_cocos2d_CCBReader_load(lua_State* tolua_S)
|
|||
Node* tolua_ret = (Node*) self->readNodeGraphFromFile(fileName,owner,size);
|
||||
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"Node");
|
||||
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.Node");
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
@ -608,7 +805,7 @@ tolua_lerror:
|
|||
|
||||
static void extendCCBReader(lua_State* tolua_S)
|
||||
{
|
||||
lua_pushstring(tolua_S, "CCBReader");
|
||||
lua_pushstring(tolua_S, "cc.CCBReader");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
|
@ -630,7 +827,7 @@ static int tolua_cocos2d_CCBAnimationManager_setCallFuncForLuaCallbackNamed(lua_
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"CCBAnimationManager",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<CCBAnimationManager*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
@ -647,7 +844,7 @@ static int tolua_cocos2d_CCBAnimationManager_setCallFuncForLuaCallbackNamed(lua_
|
|||
{
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,2, "CallFunc", 0, &tolua_err) ||
|
||||
if (!tolua_isusertype(tolua_S,2, "cc.CallFunc", 0, &tolua_err) ||
|
||||
!tolua_isstring(tolua_S, 3, 0, &tolua_err) )
|
||||
goto tolua_lerror;
|
||||
#endif
|
||||
|
@ -675,7 +872,7 @@ tolua_lerror:
|
|||
|
||||
static void extendCCBAnimationManager(lua_State* tolua_S)
|
||||
{
|
||||
lua_pushstring(tolua_S, "CCBAnimationManager");
|
||||
lua_pushstring(tolua_S, "cc.CCBAnimationManager");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
|
@ -692,7 +889,7 @@ public:
|
|||
virtual ~LuaAssetsManagerDelegateProtocol()
|
||||
{}
|
||||
|
||||
virtual void onProgress(int percent)
|
||||
virtual void onProgress(int percent) override
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS);
|
||||
if (0 != handler)
|
||||
|
@ -703,7 +900,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void onSuccess()
|
||||
virtual void onSuccess() override
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS);
|
||||
if (0 != handler)
|
||||
|
@ -714,7 +911,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void onError(AssetsManager::ErrorCode errorCode)
|
||||
virtual void onError(AssetsManager::ErrorCode errorCode) override
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR);
|
||||
if (0 != handler)
|
||||
|
@ -736,7 +933,7 @@ static int lua_cocos2dx_AssetsManager_setDelegate(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"AssetsManager",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (AssetsManager*) tolua_tousertype(L,1,0);
|
||||
|
@ -791,7 +988,7 @@ tolua_lerror:
|
|||
|
||||
static void extendAssetsManager(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "AssetsManager");
|
||||
lua_pushstring(L, "cc.AssetsManager");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
|
@ -800,6 +997,473 @@ static void extendAssetsManager(lua_State* L)
|
|||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
#define KEY_TABLEVIEW_DATA_SOURCE "TableViewDataSource"
|
||||
#define KEY_TABLEVIEW_DELEGATE "TableViewDelegate"
|
||||
|
||||
class LUA_TableViewDelegate:public Object, public TableViewDelegate
|
||||
{
|
||||
public:
|
||||
LUA_TableViewDelegate(){}
|
||||
|
||||
virtual ~LUA_TableViewDelegate(){}
|
||||
|
||||
|
||||
virtual void scrollViewDidScroll(ScrollView* view) override
|
||||
{
|
||||
if (nullptr != view)
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL);
|
||||
if (0 != handler)
|
||||
{
|
||||
LuaTableViewEventData eventData;
|
||||
BasicScriptData data(view,&eventData);
|
||||
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL, (void*)&data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void scrollViewDidZoom(ScrollView* view) override
|
||||
{
|
||||
if (nullptr != view)
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM);
|
||||
if (0 != handler)
|
||||
{
|
||||
LuaTableViewEventData eventData;
|
||||
BasicScriptData data(view,&eventData);
|
||||
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM, (void*)&data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void tableCellTouched(TableView* table, TableViewCell* cell) override
|
||||
{
|
||||
if (nullptr != table && nullptr != cell)
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED);
|
||||
if (0 != handler)
|
||||
{
|
||||
LuaTableViewEventData eventData(cell);
|
||||
BasicScriptData data(table,&eventData);
|
||||
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED,(void*)&data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void tableCellHighlight(TableView* table, TableViewCell* cell) override
|
||||
{
|
||||
if (nullptr != table && nullptr != cell)
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT);
|
||||
if (0 != handler)
|
||||
{
|
||||
LuaTableViewEventData eventData(cell);
|
||||
BasicScriptData data(table,&eventData);
|
||||
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT,(void*)&data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void tableCellUnhighlight(TableView* table, TableViewCell* cell) override
|
||||
{
|
||||
if (nullptr != table && nullptr != cell)
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT);
|
||||
if (0 != handler)
|
||||
{
|
||||
LuaTableViewEventData eventData(cell);
|
||||
BasicScriptData data(table,&eventData);
|
||||
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT,(void*)&data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void tableCellWillRecycle(TableView* table, TableViewCell* cell) override
|
||||
{
|
||||
if (nullptr != table && nullptr != cell)
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE);
|
||||
if (0 != handler)
|
||||
{
|
||||
LuaTableViewEventData eventData(cell);
|
||||
BasicScriptData data(table,&eventData);
|
||||
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE,(void*)&data);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static int lua_cocos2dx_TableView_setDelegate(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
TableView* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (TableView*) tolua_tousertype(L,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self)
|
||||
{
|
||||
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TableView_setDelegate'\n", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (0 == argc)
|
||||
{
|
||||
LUA_TableViewDelegate* delegate = new LUA_TableViewDelegate();
|
||||
if (nullptr == delegate)
|
||||
return 0;
|
||||
|
||||
Dictionary* userDict = static_cast<Dictionary*>(self->getUserObject());
|
||||
if (nullptr == userDict)
|
||||
{
|
||||
userDict = new Dictionary();
|
||||
if (NULL == userDict)
|
||||
return 0;
|
||||
|
||||
self->setUserObject(userDict);
|
||||
userDict->release();
|
||||
}
|
||||
|
||||
userDict->setObject(delegate, KEY_TABLEVIEW_DELEGATE);
|
||||
self->setDelegate(delegate);
|
||||
delegate->release();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'setDelegate' function of TableView 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 'setDelegate'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
class LUA_TableViewDataSource:public Object,public TableViewDataSource
|
||||
{
|
||||
public:
|
||||
LUA_TableViewDataSource(){}
|
||||
virtual ~LUA_TableViewDataSource(){}
|
||||
|
||||
virtual Size tableCellSizeForIndex(TableView *table, ssize_t idx) override
|
||||
{
|
||||
if (nullptr != table )
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX);
|
||||
if (0 != handler)
|
||||
{
|
||||
LuaTableViewEventData eventData(&idx);
|
||||
BasicScriptData data(table,&eventData);
|
||||
float width = 0.0;
|
||||
float height = 0.0;
|
||||
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX, (void*)&data,2,[&](lua_State* L,int numReturn){
|
||||
CCASSERT(numReturn == 2, "tableCellSizeForIndex return count error");
|
||||
ValueVector vec;
|
||||
width = (float)tolua_tonumber(L, -1, 0);
|
||||
lua_pop(L, 1);
|
||||
height = (float)tolua_tonumber(L, -1, 0);
|
||||
lua_pop(L, 1);
|
||||
});
|
||||
|
||||
return Size(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
return Size::ZERO;
|
||||
}
|
||||
|
||||
virtual TableViewCell* tableCellAtIndex(TableView *table, ssize_t idx) override
|
||||
{
|
||||
if (nullptr != table )
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX);
|
||||
if (0 != handler)
|
||||
{
|
||||
LuaTableViewEventData eventData(&idx);
|
||||
BasicScriptData data(table,&eventData);
|
||||
TableViewCell* viewCell = nullptr;
|
||||
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX, (void*)&data, 1, [&](lua_State* L, int numReturn){
|
||||
CCASSERT(numReturn == 1, "tableCellAtIndex return count error");
|
||||
viewCell = static_cast<TableViewCell*>(tolua_tousertype(L, -1, nullptr));
|
||||
lua_pop(L, 1);
|
||||
});
|
||||
|
||||
return viewCell;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual ssize_t numberOfCellsInTableView(TableView *table) override
|
||||
{
|
||||
if (nullptr != table )
|
||||
{
|
||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS);
|
||||
if (0 != handler)
|
||||
{
|
||||
LuaTableViewEventData eventData;
|
||||
BasicScriptData data(table,&eventData);
|
||||
ssize_t counts = 0;
|
||||
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS, (void*)&data,1, [&](lua_State* L, int numReturn){
|
||||
CCASSERT(numReturn == 1, "numberOfCellsInTableView return count error");
|
||||
counts = (ssize_t)tolua_tonumber(L, -1, 0);
|
||||
lua_pop(L, 1);
|
||||
});
|
||||
return counts;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
static int lua_cocos2dx_TableView_setDataSource(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
TableView* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (TableView*) tolua_tousertype(L,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self)
|
||||
{
|
||||
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TableView_setDataSource'\n", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (0 == argc)
|
||||
{
|
||||
LUA_TableViewDataSource* dataSource = new LUA_TableViewDataSource();
|
||||
if (nullptr == dataSource)
|
||||
return 0;
|
||||
|
||||
Dictionary* userDict = static_cast<Dictionary*>(self->getUserObject());
|
||||
if (nullptr == userDict)
|
||||
{
|
||||
userDict = new Dictionary();
|
||||
if (NULL == userDict)
|
||||
return 0;
|
||||
|
||||
self->setUserObject(userDict);
|
||||
userDict->release();
|
||||
}
|
||||
|
||||
userDict->setObject(dataSource, KEY_TABLEVIEW_DATA_SOURCE);
|
||||
|
||||
self->setDataSource(dataSource);
|
||||
|
||||
dataSource->release();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'setDataSource' function of TableView 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 'setDataSource'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int lua_cocos2dx_TableView_create(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertable(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (2 == argc || 1 == argc)
|
||||
{
|
||||
LUA_TableViewDataSource* dataSource = new LUA_TableViewDataSource();
|
||||
Size size;
|
||||
ok &= luaval_to_size(L, 2, &size);
|
||||
|
||||
TableView* ret = nullptr;
|
||||
|
||||
if (1 == argc)
|
||||
{
|
||||
ret = TableView::create(dataSource, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(L,3,"cc.Node",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
Node* node = static_cast<Node*>(tolua_tousertype(L, 3, nullptr));
|
||||
ret = TableView::create(dataSource, size, node);
|
||||
}
|
||||
|
||||
if (nullptr == ret)
|
||||
return 0;
|
||||
|
||||
ret->reloadData();
|
||||
|
||||
Dictionary* userDict = new Dictionary();
|
||||
userDict->setObject(dataSource, KEY_TABLEVIEW_DATA_SOURCE);
|
||||
ret->setUserObject(userDict);
|
||||
userDict->release();
|
||||
|
||||
dataSource->release();
|
||||
|
||||
|
||||
int nID = (int)ret->_ID;
|
||||
int* pLuaID = &ret->_luaID;
|
||||
toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)ret,"cc.TableView");
|
||||
|
||||
return 1;
|
||||
}
|
||||
CCLOG("'create' function of TableView 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 'create'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int lua_cocos2d_TableView_registerScriptHandler(lua_State* L)
|
||||
{
|
||||
if (NULL == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
TableView* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<TableView*>(tolua_tousertype(L,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(L,"invalid 'self' in function 'tolua_cocos2d_TableView_registerScriptHandler'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
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
|
||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||
ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,3,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL);
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'registerScriptHandler' function of TableView has wrong number of arguments: %d, was expecting %d\n", argc, 2);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'registerScriptHandler'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int lua_cocos2d_TableView_unregisterScriptHandler(lua_State* L)
|
||||
{
|
||||
if (NULL == L)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
TableView* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<TableView*>(tolua_tousertype(L,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(L,"invalid 'self' in function 'lua_cocos2d_TableView_unregisterScriptHandler'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (1 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isnumber(L, 2, 0, &tolua_err))
|
||||
goto tolua_lerror;
|
||||
#endif
|
||||
ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,2,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL);
|
||||
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'unregisterScriptHandler' function of TableView 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 'unregisterScriptHandler'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void extendTableView(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "cc.TableView");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "setDelegate", lua_cocos2dx_TableView_setDelegate);
|
||||
tolua_function(L, "setDataSource", lua_cocos2dx_TableView_setDataSource);
|
||||
tolua_function(L, "create", lua_cocos2dx_TableView_create);
|
||||
tolua_function(L, "registerScriptHandler", lua_cocos2d_TableView_registerScriptHandler);
|
||||
tolua_function(L, "unregisterScriptHandler", lua_cocos2d_TableView_unregisterScriptHandler);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
int register_all_cocos2dx_extension_manual(lua_State* tolua_S)
|
||||
{
|
||||
extendControl(tolua_S);
|
||||
|
@ -807,5 +1471,7 @@ int register_all_cocos2dx_extension_manual(lua_State* tolua_S)
|
|||
extendCCBReader(tolua_S);
|
||||
extendCCBAnimationManager(tolua_S);
|
||||
extendAssetsManager(tolua_S);
|
||||
extendScrollView(tolua_S);
|
||||
extendTableView(tolua_S);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -46,5 +46,16 @@ struct LuaAssetsManagerEventData
|
|||
}
|
||||
};
|
||||
|
||||
struct LuaTableViewEventData
|
||||
{
|
||||
void* value;
|
||||
|
||||
// Constructor
|
||||
LuaTableViewEventData(void* _value = nullptr)
|
||||
:value(_value)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_EXTENSION_MANUAL_H
|
||||
|
|
|
@ -94,7 +94,7 @@ static int lua_cocos2dx_Widget_addTouchEventListener(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"Widget",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<Widget*>(tolua_tousertype(L,1,0));
|
||||
|
@ -145,7 +145,7 @@ tolua_lerror:
|
|||
|
||||
static void extendWidget(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "Widget");
|
||||
lua_pushstring(L, "ccui.Widget");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ static int lua_cocos2dx_CheckBox_addEventListenerCheckBox(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"CheckBox",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<CheckBox*>(tolua_tousertype(L,1,0));
|
||||
|
@ -214,7 +214,7 @@ tolua_lerror:
|
|||
|
||||
static void extendCheckBox(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "CheckBox");
|
||||
lua_pushstring(L, "ccui.CheckBox");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
|
@ -233,7 +233,7 @@ static int lua_cocos2dx_Slider_addEventListenerSlider(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"Slider",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<Slider*>(tolua_tousertype(L,1,0));
|
||||
|
@ -283,7 +283,7 @@ tolua_lerror:
|
|||
|
||||
static void extendSlider(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "Slider");
|
||||
lua_pushstring(L, "ccui.Slider");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
|
@ -302,7 +302,7 @@ static int lua_cocos2dx_TextField_addEventListenerTextField(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"TextField",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<TextField*>(tolua_tousertype(L,1,0));
|
||||
|
@ -352,7 +352,7 @@ tolua_lerror:
|
|||
|
||||
static void extendTextField(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "TextField");
|
||||
lua_pushstring(L, "ccui.TextField");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
|
@ -371,7 +371,7 @@ static int lua_cocos2dx_PageView_addEventListenerPageView(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"PageView",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<PageView*>(tolua_tousertype(L,1,0));
|
||||
|
@ -421,7 +421,7 @@ tolua_lerror:
|
|||
|
||||
static void extendPageView(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "PageView");
|
||||
lua_pushstring(L, "ccui.PageView");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
|
@ -440,7 +440,7 @@ static int lua_cocos2dx_ListView_addEventListenerListView(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"ListView",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<ListView*>(tolua_tousertype(L,1,0));
|
||||
|
@ -490,7 +490,7 @@ tolua_lerror:
|
|||
|
||||
static void extendListView(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "ListView");
|
||||
lua_pushstring(L, "ccui.ListView");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
|
@ -509,7 +509,7 @@ static int lua_cocos2dx_LayoutParameter_setMargin(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"LayoutParameter",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"ccui.LayoutParameter",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<LayoutParameter*>(tolua_tousertype(L,1,0));
|
||||
|
@ -577,7 +577,7 @@ static int lua_cocos2dx_LayoutParameter_getMargin(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"LayoutParameter",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"ccui.LayoutParameter",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<LayoutParameter*>(tolua_tousertype(L,1,0));
|
||||
|
@ -628,7 +628,7 @@ tolua_lerror:
|
|||
|
||||
static void extendLayoutParameter(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "LayoutParameter");
|
||||
lua_pushstring(L, "ccui.LayoutParameter");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
|
|
|
@ -1 +1 @@
|
|||
f916840e52bdfd7e7283cb9c70ebfaf1c23b9301
|
||||
9d9d07e19dba691a22e4d184f0ec0e6ae6207a9b
|
|
@ -29,7 +29,7 @@ int lua_cocos2dx_physics_PhysicsBody_getJoints(lua_State* tolua_S)
|
|||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsBody",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0);
|
||||
|
@ -69,7 +69,7 @@ int lua_cocos2dx_physics_PhysicsBody_getJoints(lua_State* tolua_S)
|
|||
if(name != g_luaType.end()){
|
||||
className = name->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsJoint";
|
||||
className = "cc.PhysicsJoint";
|
||||
}
|
||||
|
||||
lua_pushnumber(tolua_S, (lua_Number)indexTable);
|
||||
|
@ -102,7 +102,7 @@ int lua_cocos2dx_physics_PhysicsWorld_getScene(lua_State* tolua_S)
|
|||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0);
|
||||
|
@ -129,7 +129,7 @@ int lua_cocos2dx_physics_PhysicsWorld_getScene(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "Scene";
|
||||
className = "cc.Scene";
|
||||
}
|
||||
|
||||
int ID = (int)(ret._ID);
|
||||
|
@ -162,7 +162,7 @@ int lua_cocos2dx_physics_PhysicsWorld_rayCast(lua_State* tolua_S)
|
|||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0);
|
||||
|
@ -191,7 +191,7 @@ int lua_cocos2dx_physics_PhysicsWorld_rayCast(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsWorld";
|
||||
className = "cc.PhysicsWorld";
|
||||
}
|
||||
|
||||
tolua_pushusertype(tolua_S, (void*)(&world), className.c_str());
|
||||
|
@ -229,7 +229,7 @@ int lua_cocos2dx_physics_PhysicsWorld_queryRect(lua_State* tolua_S)
|
|||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0);
|
||||
|
@ -257,7 +257,7 @@ int lua_cocos2dx_physics_PhysicsWorld_queryRect(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsWorld";
|
||||
className = "cc.PhysicsWorld";
|
||||
}
|
||||
|
||||
tolua_pushusertype(tolua_S, (void*)(&world), className.c_str());
|
||||
|
@ -268,7 +268,7 @@ int lua_cocos2dx_physics_PhysicsWorld_queryRect(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsShape";
|
||||
className = "cc.PhysicsShape";
|
||||
}
|
||||
toluafix_pushusertype_ccobject(tolua_S, shape._ID, &shape._luaID, (void*)(&shape), className.c_str());
|
||||
return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
|
||||
|
@ -305,7 +305,7 @@ int lua_cocos2dx_physics_PhysicsWorld_queryPoint(lua_State* tolua_S)
|
|||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0);
|
||||
|
@ -333,7 +333,7 @@ int lua_cocos2dx_physics_PhysicsWorld_queryPoint(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsWorld";
|
||||
className = "cc.PhysicsWorld";
|
||||
}
|
||||
|
||||
tolua_pushusertype(tolua_S, (void*)(&world), className.c_str());
|
||||
|
@ -344,7 +344,7 @@ int lua_cocos2dx_physics_PhysicsWorld_queryPoint(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsShape";
|
||||
className = "cc.PhysicsShape";
|
||||
}
|
||||
toluafix_pushusertype_ccobject(tolua_S, shape._ID, &shape._luaID, (void*)(&shape), className.c_str());
|
||||
return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
|
||||
|
@ -380,7 +380,7 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S)
|
|||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertable(tolua_S,1,"PhysicsBody",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertable(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
|
@ -409,7 +409,7 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsBody";
|
||||
className = "cc.PhysicsBody";
|
||||
}
|
||||
cocos2d::Object *dynObject = dynamic_cast<cocos2d::Object *>((cocos2d::PhysicsBody*)ret);
|
||||
if (NULL != dynObject) {
|
||||
|
@ -450,7 +450,7 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsBody";
|
||||
className = "cc.PhysicsBody";
|
||||
}
|
||||
cocos2d::Object *dynObject = dynamic_cast<cocos2d::Object *>((cocos2d::PhysicsBody*)ret);
|
||||
if (NULL != dynObject) {
|
||||
|
@ -493,7 +493,7 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsBody";
|
||||
className = "cc.PhysicsBody";
|
||||
}
|
||||
cocos2d::Object *dynObject = dynamic_cast<cocos2d::Object *>((cocos2d::PhysicsBody*)ret);
|
||||
if (NULL != dynObject) {
|
||||
|
@ -527,7 +527,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S)
|
|||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertable(tolua_S,1,"PhysicsBody",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertable(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
|
@ -556,7 +556,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsBody";
|
||||
className = "cc.PhysicsBody";
|
||||
}
|
||||
cocos2d::Object *dynObject = dynamic_cast<cocos2d::Object *>((cocos2d::PhysicsBody*)ret);
|
||||
if (NULL != dynObject) {
|
||||
|
@ -597,7 +597,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsBody";
|
||||
className = "cc.PhysicsBody";
|
||||
}
|
||||
cocos2d::Object *dynObject = dynamic_cast<cocos2d::Object *>((cocos2d::PhysicsBody*)ret);
|
||||
if (NULL != dynObject) {
|
||||
|
@ -640,7 +640,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsBody";
|
||||
className = "cc.PhysicsBody";
|
||||
}
|
||||
cocos2d::Object *dynObject = dynamic_cast<cocos2d::Object *>((cocos2d::PhysicsBody*)ret);
|
||||
if (NULL != dynObject) {
|
||||
|
@ -674,7 +674,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S)
|
|||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertable(tolua_S,1,"PhysicsBody",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertable(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
|
@ -703,7 +703,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsBody";
|
||||
className = "cc.PhysicsBody";
|
||||
}
|
||||
cocos2d::Object *dynObject = dynamic_cast<cocos2d::Object *>((cocos2d::PhysicsBody*)ret);
|
||||
if (NULL != dynObject) {
|
||||
|
@ -744,7 +744,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsBody";
|
||||
className = "cc.PhysicsBody";
|
||||
}
|
||||
cocos2d::Object *dynObject = dynamic_cast<cocos2d::Object *>((cocos2d::PhysicsBody*)ret);
|
||||
if (NULL != dynObject) {
|
||||
|
@ -787,7 +787,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "PhysicsBody";
|
||||
className = "cc.PhysicsBody";
|
||||
}
|
||||
cocos2d::Object *dynObject = dynamic_cast<cocos2d::Object *>((cocos2d::PhysicsBody*)ret);
|
||||
if (NULL != dynObject) {
|
||||
|
@ -821,7 +821,7 @@ int lua_cocos2dx_physics_PhysicsShape_recenterPoints(lua_State* tolua_S)
|
|||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertable(tolua_S,1,"PhysicsShape",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
|
@ -886,7 +886,7 @@ int lua_cocos2dx_physics_PhysicsShape_getPolyonCenter(lua_State* tolua_S)
|
|||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertable(tolua_S,1,"PhysicsShape",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
|
@ -924,14 +924,13 @@ int lua_cocos2dx_physics_PhysicsShapeBox_getPoints(lua_State* tolua_S)
|
|||
{
|
||||
int argc = 0;
|
||||
cocos2d::PhysicsShapeBox* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsShapeBox",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeBox",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsShapeBox*)tolua_tousertype(tolua_S,1,0);
|
||||
|
@ -967,14 +966,13 @@ int lua_cocos2dx_physics_PhysicsShapePolygon_getPoints(lua_State* tolua_S)
|
|||
{
|
||||
int argc = 0;
|
||||
cocos2d::PhysicsShapePolygon* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsShapePolygon",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapePolygon",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsShapePolygon*)tolua_tousertype(tolua_S,1,0);
|
||||
|
@ -1012,14 +1010,13 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPoints(lua_State* tolua_S)
|
|||
{
|
||||
int argc = 0;
|
||||
cocos2d::PhysicsShapeEdgeBox* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsShapeEdgeBox",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeEdgeBox",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsShapeEdgeBox*)tolua_tousertype(tolua_S,1,0);
|
||||
|
@ -1057,14 +1054,13 @@ int lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPoints(lua_State* tolua_S)
|
|||
{
|
||||
int argc = 0;
|
||||
cocos2d::PhysicsShapeEdgePolygon* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsShapeEdgePolygon",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeEdgePolygon",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsShapeEdgePolygon*)tolua_tousertype(tolua_S,1,0);
|
||||
|
@ -1102,14 +1098,13 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPoints(lua_State* tolua_S)
|
|||
{
|
||||
int argc = 0;
|
||||
cocos2d::PhysicsShapeEdgeChain* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"PhysicsShapeEdgeChain",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeEdgeChain",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::PhysicsShapeEdgeChain*)tolua_tousertype(tolua_S,1,0);
|
||||
|
@ -1145,7 +1140,7 @@ tolua_lerror:
|
|||
|
||||
int register_all_cocos2dx_physics_manual(lua_State* tolua_S)
|
||||
{
|
||||
lua_pushstring(tolua_S, "PhysicsBody");
|
||||
lua_pushstring(tolua_S, "cc.PhysicsBody");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
|
@ -1164,7 +1159,7 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S)
|
|||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
|
||||
lua_pushstring(tolua_S, "PhysicsShape");
|
||||
lua_pushstring(tolua_S, "cc.PhysicsShape");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
|
@ -1177,7 +1172,7 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S)
|
|||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
|
||||
lua_pushstring(tolua_S, "PhysicsShapeBox");
|
||||
lua_pushstring(tolua_S, "cc.PhysicsShapeBox");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
|
@ -1187,7 +1182,7 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S)
|
|||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
|
||||
lua_pushstring(tolua_S, "PhysicsShapeEdgeBox");
|
||||
lua_pushstring(tolua_S, "cc.PhysicsShapeEdgeBox");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
|
@ -1197,7 +1192,7 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S)
|
|||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
|
||||
lua_pushstring(tolua_S, "PhysicsShapePolygon");
|
||||
lua_pushstring(tolua_S, "cc.PhysicsShapePolygon");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
|
@ -1207,7 +1202,7 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S)
|
|||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
|
||||
lua_pushstring(tolua_S, "PhysicsShapeEdgePolygon");
|
||||
lua_pushstring(tolua_S, "cc.PhysicsShapeEdgePolygon");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
|
@ -1217,7 +1212,7 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S)
|
|||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
|
||||
lua_pushstring(tolua_S, "PhysicsShapeEdgeChain");
|
||||
lua_pushstring(tolua_S, "cc.PhysicsShapeEdgeChain");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
|
@ -1227,7 +1222,7 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S)
|
|||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
|
||||
lua_pushstring(tolua_S, "PhysicsWorld");
|
||||
lua_pushstring(tolua_S, "cc.PhysicsWorld");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
|
|
|
@ -94,7 +94,7 @@ static int lua_cocos2dx_CCSkeletonAnimation_createWithFile(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertable(L,1,"SkeletonAnimation",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertable(L,1,"sp.SkeletonAnimation",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
@ -115,7 +115,7 @@ static int lua_cocos2dx_CCSkeletonAnimation_createWithFile(lua_State* L)
|
|||
|
||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)tolua_ret,"SkeletonAnimation");
|
||||
toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)tolua_ret,"sp.SkeletonAnimation");
|
||||
return 1;
|
||||
} else if (3 == argc)
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ static int lua_cocos2dx_CCSkeletonAnimation_createWithFile(lua_State* L)
|
|||
|
||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)tolua_ret,"SkeletonAnimation");
|
||||
toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)tolua_ret,"sp.SkeletonAnimation");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ int tolua_Cocos2d_CCSkeletonAnimation_registerScriptHandler00(lua_State* tolua_S
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"SkeletonAnimation",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) ||
|
||||
!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||
)
|
||||
|
@ -180,7 +180,7 @@ int tolua_Cocos2d_CCSkeletonAnimation_unregisterScriptHandler00(lua_State* tolua
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"SkeletonAnimation",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,2,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
|
@ -205,7 +205,7 @@ static int tolua_Cocos2d_CCSkeletonAnimation_setTimeScale00(lua_State* tolua_S)
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"SkeletonAnimation",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||
)
|
||||
|
@ -232,7 +232,7 @@ static int tolua_Cocos2d_CCSkeletonAnimation_setDebugSlots00(lua_State* tolua_S)
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"SkeletonAnimation",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) ||
|
||||
!tolua_isboolean(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||
)
|
||||
|
@ -259,7 +259,7 @@ static int tolua_Cocos2d_CCSkeletonAnimation_setDebugBones00(lua_State* tolua_S)
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"SkeletonAnimation",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) ||
|
||||
!tolua_isboolean(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||
)
|
||||
|
@ -286,7 +286,7 @@ static int tolua_Cocos2d_CCSkeletonAnimation_setPremultipliedAlpha00(lua_State*
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"SkeletonAnimation",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) ||
|
||||
!tolua_isboolean(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||
)
|
||||
|
@ -311,13 +311,13 @@ tolua_lerror:
|
|||
|
||||
static int tolua_spine_SkeletoneAnimation_setBlendFunc(lua_State* tolua_S)
|
||||
{
|
||||
return tolua_cocos2dx_setBlendFunc<spine::SkeletonAnimation>(tolua_S,"SkeletonAnimation");
|
||||
return tolua_cocos2dx_setBlendFunc<spine::SkeletonAnimation>(tolua_S,"sp.SkeletonAnimation");
|
||||
}
|
||||
|
||||
|
||||
static void extendCCSkeletonAnimation(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "SkeletonAnimation");
|
||||
lua_pushstring(L, "sp.SkeletonAnimation");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
|
|
|
@ -270,7 +270,7 @@ void LuaMinXmlHttpRequest::getByteData(unsigned char* byteData)
|
|||
/* function to regType */
|
||||
static void lua_reg_xml_http_request(lua_State* L)
|
||||
{
|
||||
tolua_usertype(L, "XMLHttpRequest");
|
||||
tolua_usertype(L, "cc.XMLHttpRequest");
|
||||
}
|
||||
|
||||
static int lua_collect_xml_http_request (lua_State* L)
|
||||
|
@ -296,7 +296,7 @@ static int lua_cocos2dx_XMLHttpRequest_constructor(lua_State* L)
|
|||
self->autorelease();
|
||||
int ID = self? (int)self->_ID : -1;
|
||||
int* luaID = self? &self->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)self, "XMLHttpRequest");
|
||||
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)self, "cc.XMLHttpRequest");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ static int lua_get_XMLHttpRequest_responseType(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -345,7 +345,7 @@ static int lua_set_XMLHttpRequest_responseType(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -388,7 +388,7 @@ static int lua_get_XMLHttpRequest_withCredentials(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -417,7 +417,7 @@ static int lua_set_XMLHttpRequest_withCredentials(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -457,7 +457,7 @@ static int lua_get_XMLHttpRequest_timeout(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -486,7 +486,7 @@ static int lua_set_XMLHttpRequest_timeout(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -526,7 +526,7 @@ static int lua_get_XMLHttpRequest_readyState(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -555,7 +555,7 @@ static int lua_get_XMLHttpRequest_status(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -584,7 +584,7 @@ static int lua_get_XMLHttpRequest_statusText(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -613,7 +613,7 @@ static int lua_get_XMLHttpRequest_responseText(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -640,7 +640,7 @@ static int lua_get_XMLHttpRequest_response(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -711,7 +711,7 @@ static int lua_cocos2dx_XMLHttpRequest_open(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -796,7 +796,7 @@ static int lua_cocos2dx_XMLHttpRequest_send(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -855,7 +855,7 @@ static int lua_cocos2dx_XMLHttpRequest_setRequestHeader(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -902,7 +902,7 @@ static int lua_cocos2dx_XMLHttpRequest_getAllResponseHeaders(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -948,7 +948,7 @@ static int lua_cocos2dx_XMLHttpRequest_getResponseHeader(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -1002,7 +1002,7 @@ static int lua_cocos2dx_XMLHttpRequest_registerScriptHandler(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -1046,7 +1046,7 @@ static int lua_cocos2dx_XMLHttpRequest_unregisterScriptHandler(lua_State* L)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
|
||||
|
@ -1082,9 +1082,9 @@ TOLUA_API int register_xml_http_request(lua_State* L)
|
|||
{
|
||||
tolua_open(L);
|
||||
lua_reg_xml_http_request(L);
|
||||
tolua_module(L,NULL,0);
|
||||
tolua_beginmodule(L,NULL);
|
||||
tolua_cclass(L,"XMLHttpRequest","XMLHttpRequest","Object",lua_collect_xml_http_request);
|
||||
tolua_module(L,"cc",0);
|
||||
tolua_beginmodule(L,"cc");
|
||||
tolua_cclass(L,"XMLHttpRequest","cc.XMLHttpRequest","cc.Object",lua_collect_xml_http_request);
|
||||
tolua_beginmodule(L,"XMLHttpRequest");
|
||||
tolua_variable(L, "responseType", lua_get_XMLHttpRequest_responseType, lua_set_XMLHttpRequest_responseType);
|
||||
tolua_variable(L, "withCredentials", lua_get_XMLHttpRequest_withCredentials, lua_set_XMLHttpRequest_withCredentials);
|
||||
|
|
|
@ -17,7 +17,7 @@ function CCBReaderLoad(strFilePath,proxy,owner)
|
|||
local i = 1
|
||||
for i = 1,table.getn(ownerCallbackNames) do
|
||||
local callbackName = ownerCallbackNames[i]
|
||||
local callbackNode = tolua.cast(ownerCallbackNodes[i],"Node")
|
||||
local callbackNode = tolua.cast(ownerCallbackNodes[i],"cc.Node")
|
||||
|
||||
if "function" == type(owner[callbackName]) then
|
||||
proxy:setCallback(callbackNode, owner[callbackName], ownerCallbackControlEvents[i])
|
||||
|
@ -33,7 +33,7 @@ function CCBReaderLoad(strFilePath,proxy,owner)
|
|||
|
||||
for i = 1, table.getn(ownerOutletNames) do
|
||||
local outletName = ownerOutletNames[i]
|
||||
local outletNode = tolua.cast(ownerOutletNodes[i],"Node")
|
||||
local outletNode = tolua.cast(ownerOutletNodes[i],"cc.Node")
|
||||
owner[outletName] = outletNode
|
||||
end
|
||||
end
|
||||
|
@ -42,8 +42,8 @@ function CCBReaderLoad(strFilePath,proxy,owner)
|
|||
local animationManagersForNodes = ccbReader:getAnimationManagersForNodes()
|
||||
|
||||
for i = 1 , table.getn(nodesWithAnimationManagers) do
|
||||
local innerNode = tolua.cast(nodesWithAnimationManagers[i], "Node")
|
||||
local animationManager = tolua.cast(animationManagersForNodes[i], "CCBAnimationManager")
|
||||
local innerNode = tolua.cast(nodesWithAnimationManagers[i], "cc.Node")
|
||||
local animationManager = tolua.cast(animationManagersForNodes[i], "cc.CCBAnimationManager")
|
||||
local documentControllerName = animationManager:getDocumentControllerName()
|
||||
if "" == documentControllerName then
|
||||
|
||||
|
@ -59,7 +59,7 @@ function CCBReaderLoad(strFilePath,proxy,owner)
|
|||
|
||||
for i = 1,table.getn(documentCallbackNames) do
|
||||
local callbackName = documentCallbackNames[i]
|
||||
local callbackNode = tolua.cast(documentCallbackNodes[i],"Node")
|
||||
local callbackNode = tolua.cast(documentCallbackNodes[i],"cc.Node")
|
||||
if "" ~= documentControllerName and nil ~= ccb[documentControllerName] then
|
||||
if "function" == type(ccb[documentControllerName][callbackName]) then
|
||||
proxy:setCallback(callbackNode, ccb[documentControllerName][callbackName], documentCallbackControlEvents[i])
|
||||
|
@ -75,7 +75,7 @@ function CCBReaderLoad(strFilePath,proxy,owner)
|
|||
|
||||
for i = 1, table.getn(documentOutletNames) do
|
||||
local outletName = documentOutletNames[i]
|
||||
local outletNode = tolua.cast(documentOutletNodes[i],"Node")
|
||||
local outletNode = tolua.cast(documentOutletNodes[i],"cc.Node")
|
||||
|
||||
if nil ~= ccb[documentControllerName] then
|
||||
ccb[documentControllerName][outletName] = tolua.cast(outletNode, proxy:getNodeTypeName(outletNode))
|
||||
|
|
|
@ -706,6 +706,21 @@ end
|
|||
rawset(CCEGLView,"sharedOpenGLView",CCEGLViewDeprecated.sharedOpenGLView)
|
||||
--functions of CCFileUtils will be deprecated end
|
||||
|
||||
--Enums of CCTableView will be deprecated begin
|
||||
rawset(CCTableView, "kTableViewScroll",cc.SCROLLVIEW_SCRIPT_SCROLL)
|
||||
rawset(CCTableView,"kTableViewZoom",cc.SCROLLVIEW_SCRIPT_ZOOM)
|
||||
rawset(CCTableView,"kTableCellTouched",cc.TABLECELL_TOUCHED)
|
||||
rawset(CCTableView,"kTableCellSizeForIndex",cc.TABLECELL_SIZE_FOR_INDEX)
|
||||
rawset(CCTableView,"kTableCellSizeAtIndex",cc.TABLECELL_SIZE_AT_INDEX)
|
||||
rawset(CCTableView,"kNumberOfCellsInTableView",cc.NUMBER_OF_CELLS_IN_TABLEVIEW)
|
||||
--Enums of CCTableView will be deprecated end
|
||||
|
||||
--Enums of CCScrollView will be deprecated begin
|
||||
rawset(CCScrollView, "kScrollViewScroll",cc.SCROLLVIEW_SCRIPT_SCROLL)
|
||||
rawset(CCScrollView,"kScrollViewZoom",cc.SCROLLVIEW_SCRIPT_ZOOM)
|
||||
--Enums of CCScrollView will be deprecated end
|
||||
|
||||
|
||||
|
||||
--functions of CCApplication will be deprecated end
|
||||
local CCApplicationDeprecated = { }
|
||||
|
|
|
@ -175,6 +175,15 @@ end
|
|||
_G["CCEaseElasticOut"] = DeprecatedClass.CCEaseElasticOut()
|
||||
--CCEaseElasticOut class will be Deprecated,end
|
||||
|
||||
--CCTableViewCell class will be Deprecated,begin
|
||||
function DeprecatedClass.CCTableViewCell()
|
||||
deprecatedTip("CCTableViewCell","cc.TableViewCell")
|
||||
return cc.TableViewCell
|
||||
end
|
||||
_G["CCTableViewCell"] = DeprecatedClass.CCTableViewCell()
|
||||
--CCTableViewCell class will be Deprecated,end
|
||||
|
||||
|
||||
--CCEaseBackOut class will be Deprecated,begin
|
||||
function DeprecatedClass.CCEaseBackOut()
|
||||
deprecatedTip("CCEaseBackOut","cc.EaseBackOut")
|
||||
|
@ -719,6 +728,15 @@ end
|
|||
_G["CCPlace"] = DeprecatedClass.CCPlace()
|
||||
--CCPlace class will be Deprecated,end
|
||||
|
||||
--CCScrollView class will be Deprecated,begin
|
||||
function DeprecatedClass.CCScrollView()
|
||||
deprecatedTip("CCScrollView","cc.ScrollView")
|
||||
return cc.ScrollView
|
||||
end
|
||||
_G["CCScrollView"] = DeprecatedClass.CCScrollView()
|
||||
--CCScrollView class will be Deprecated,end
|
||||
|
||||
|
||||
--CCGLProgram class will be Deprecated,begin
|
||||
function DeprecatedClass.CCGLProgram()
|
||||
deprecatedTip("CCGLProgram","cc.GLProgram")
|
||||
|
@ -799,6 +817,15 @@ end
|
|||
_G["CCParticleFlower"] = DeprecatedClass.CCParticleFlower()
|
||||
--CCParticleFlower class will be Deprecated,end
|
||||
|
||||
--CCTableView class will be Deprecated,begin
|
||||
function DeprecatedClass.CCTableView()
|
||||
deprecatedTip("CCTableView","cc.TableView")
|
||||
return cc.TableView
|
||||
end
|
||||
_G["CCTableView"] = DeprecatedClass.CCTableView()
|
||||
--CCTableView class will be Deprecated,end
|
||||
|
||||
|
||||
--CCParticleSmoke class will be Deprecated,begin
|
||||
function DeprecatedClass.CCParticleSmoke()
|
||||
deprecatedTip("CCParticleSmoke","cc.ParticleSmoke")
|
||||
|
@ -2127,4 +2154,20 @@ end
|
|||
_G["CCBProxy"] = DeprecatedClass.CCBProxy()
|
||||
--CCBProxy class will be Deprecated,end
|
||||
|
||||
--WebSocket class will be Deprecated,begin
|
||||
function DeprecatedClass.WebSocket()
|
||||
deprecatedTip("WebSocket","cc.WebSocket")
|
||||
return cc.WebSocket
|
||||
end
|
||||
_G["WebSocket"] = DeprecatedClass.WebSocket()
|
||||
--WebSocket class will be Deprecated,end
|
||||
|
||||
--XMLHttpRequest class will be Deprecated,begin
|
||||
function DeprecatedClass.XMLHttpRequest()
|
||||
deprecatedTip("XMLHttpRequest","cc.XMLHttpRequest")
|
||||
return cc.XMLHttpRequest
|
||||
end
|
||||
_G["XMLHttpRequest"] = DeprecatedClass.XMLHttpRequest()
|
||||
--XMLHttpRequest class will be Deprecated,end
|
||||
|
||||
|
||||
|
|
|
@ -494,7 +494,7 @@ void ScrollView::addChild(Node * child, int zOrder, int tag)
|
|||
|
||||
void ScrollView::beforeDraw()
|
||||
{
|
||||
_beforeDrawCommand.init(0, _vertexZ);
|
||||
_beforeDrawCommand.init(_globalZOrder);
|
||||
_beforeDrawCommand.func = CC_CALLBACK_0(ScrollView::onBeforeDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_beforeDrawCommand);
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ void ScrollView::onBeforeDraw()
|
|||
|
||||
void ScrollView::afterDraw()
|
||||
{
|
||||
_afterDrawCommand.init(0, _vertexZ);
|
||||
_afterDrawCommand.init(_globalZOrder);
|
||||
_afterDrawCommand.func = CC_CALLBACK_0(ScrollView::onAfterDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_afterDrawCommand);
|
||||
}
|
||||
|
|
|
@ -1314,7 +1314,7 @@ void ActionFollow::onEnter()
|
|||
|
||||
void ActionFollow::draw()
|
||||
{
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionFollow::onDraw, this);
|
||||
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
|
@ -1630,7 +1630,7 @@ void ActionCatmullRomStacked::draw()
|
|||
kmGLPopMatrix();
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
|
||||
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
@ -1745,7 +1745,7 @@ void ActionCardinalSplineStacked::draw()
|
|||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
|
||||
kmGLPopMatrix();
|
||||
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCardinalSplineStacked::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
@ -2107,7 +2107,7 @@ void ActionCatmullRom::draw()
|
|||
kmGLPopMatrix();
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
|
||||
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
@ -2207,7 +2207,7 @@ void ActionCardinalSpline::draw()
|
|||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
|
||||
kmGLPopMatrix();
|
||||
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCardinalSpline::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ void Box2DTestLayer::draw()
|
|||
kmGLPushMatrix();
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV);
|
||||
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Box2DTestLayer::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ void Box2DView::draw()
|
|||
{
|
||||
Layer::draw();
|
||||
|
||||
_customCmd.init(0, _vertexZ);
|
||||
_customCmd.init(_globalZOrder);
|
||||
_customCmd.func = CC_CALLBACK_0(Box2DView::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCmd);
|
||||
}
|
||||
|
|
|
@ -611,7 +611,7 @@ void RawStencilBufferTest::draw()
|
|||
|
||||
auto iter = _renderCmds.begin();
|
||||
|
||||
iter->init(0, _vertexZ);
|
||||
iter->init(_globalZOrder);
|
||||
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onEnableStencil, this);
|
||||
renderer->addCommand(&(*iter));
|
||||
++iter;
|
||||
|
@ -628,7 +628,7 @@ void RawStencilBufferTest::draw()
|
|||
spritePoint.y = 0;
|
||||
_sprites.at(i)->setPosition( spritePoint );
|
||||
|
||||
iter->init(0, _vertexZ);
|
||||
iter->init(_globalZOrder);
|
||||
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawClip, this, i, stencilPoint);
|
||||
renderer->addCommand(&(*iter));
|
||||
++iter;
|
||||
|
@ -638,7 +638,7 @@ void RawStencilBufferTest::draw()
|
|||
_sprites.at(i)->visit();
|
||||
kmGLPopMatrix();
|
||||
|
||||
iter->init(0, _vertexZ);
|
||||
iter->init(_globalZOrder);
|
||||
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawSprite, this, i, winPoint);
|
||||
renderer->addCommand(&(*iter));
|
||||
++iter;
|
||||
|
@ -649,7 +649,7 @@ void RawStencilBufferTest::draw()
|
|||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
iter->init(0, _vertexZ);
|
||||
iter->init(_globalZOrder);
|
||||
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onDisableStencil, this);
|
||||
renderer->addCommand(&(*iter));
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ DrawPrimitivesTest::DrawPrimitivesTest()
|
|||
|
||||
void DrawPrimitivesTest::draw()
|
||||
{
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -503,7 +503,7 @@ void TestChangeZorder::changeZorder(float dt)
|
|||
|
||||
Node *node = getChildByTag(currentTag);
|
||||
|
||||
node->setZOrder(CCRANDOM_0_1() * 3);
|
||||
node->setLocalZOrder(CCRANDOM_0_1() * 3);
|
||||
|
||||
currentTag ++;
|
||||
currentTag = currentTag % 3;
|
||||
|
@ -637,7 +637,7 @@ void TestParticleDisplay::onEnter()
|
|||
bone->addDisplay(p1, 0);
|
||||
bone->changeDisplayWithIndex(0, true);
|
||||
bone->setIgnoreMovementBoneData(true);
|
||||
bone->setZOrder(100);
|
||||
bone->setLocalZOrder(100);
|
||||
bone->setScale(1.2f);
|
||||
armature->addBone(bone, "bady-a3");
|
||||
|
||||
|
@ -645,7 +645,7 @@ void TestParticleDisplay::onEnter()
|
|||
bone->addDisplay(p2, 0);
|
||||
bone->changeDisplayWithIndex(0, true);
|
||||
bone->setIgnoreMovementBoneData(true);
|
||||
bone->setZOrder(100);
|
||||
bone->setLocalZOrder(100);
|
||||
bone->setScale(1.2f);
|
||||
armature->addBone(bone, "bady-a30");
|
||||
}
|
||||
|
@ -1067,7 +1067,7 @@ void TestColliderDetector::update(float delta)
|
|||
}
|
||||
void TestColliderDetector::draw()
|
||||
{
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(TestColliderDetector::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
@ -1108,7 +1108,7 @@ std::string TestBoundingBox::title() const
|
|||
}
|
||||
void TestBoundingBox::draw()
|
||||
{
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(TestBoundingBox::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ bool UIImageViewTest::init()
|
|||
_uiLayer->addChild(sprite);
|
||||
*/
|
||||
|
||||
// imageView->setZOrder(20);
|
||||
// imageView->setLocalZOrder(20);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ void Atlas1::draw()
|
|||
// GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
||||
// GL_TEXTURE_2D
|
||||
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Atlas1::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
|
||||
|
@ -526,7 +526,7 @@ Atlas4::Atlas4()
|
|||
|
||||
void Atlas4::draw()
|
||||
{
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Atlas4::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
@ -1612,7 +1612,7 @@ std::string LabelBMFontBounds::subtitle() const
|
|||
|
||||
void LabelBMFontBounds::draw()
|
||||
{
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ LabelFNTSpriteActions::LabelFNTSpriteActions()
|
|||
|
||||
void LabelFNTSpriteActions::draw()
|
||||
{
|
||||
_renderCmd.init(0, _vertexZ);
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
|
||||
|
||||
|
@ -912,7 +912,7 @@ std::string LabelFNTBounds::subtitle() const
|
|||
|
||||
void LabelFNTBounds::draw()
|
||||
{
|
||||
_renderCmd.init(0, _vertexZ);
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
|
||||
}
|
||||
|
|
|
@ -166,11 +166,11 @@ void TouchableSpriteTest::onEnter()
|
|||
target->setOpacity(255);
|
||||
if (target == sprite2)
|
||||
{
|
||||
sprite1->setZOrder(100);
|
||||
sprite1->setLocalZOrder(100);
|
||||
}
|
||||
else if(target == sprite1)
|
||||
{
|
||||
sprite1->setZOrder(0);
|
||||
sprite1->setLocalZOrder(0);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ static std::function<Layer*()> createFunctions[] =
|
|||
CL(ConvertToNode),
|
||||
CL(NodeOpaqueTest),
|
||||
CL(NodeNonOpaqueTest),
|
||||
CL(NodeGlobalZValueTest),
|
||||
};
|
||||
|
||||
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
|
||||
|
@ -905,6 +906,55 @@ std::string NodeNonOpaqueTest::subtitle() const
|
|||
return "Node rendered with GL_BLEND enabled";
|
||||
}
|
||||
|
||||
/// NodeGlobalZValueTest
|
||||
|
||||
NodeGlobalZValueTest::NodeGlobalZValueTest()
|
||||
{
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
Sprite *sprite;
|
||||
auto parent = Node::create();
|
||||
if(i==4) {
|
||||
sprite = Sprite::create("Images/grossinis_sister2.png");
|
||||
_sprite = sprite;
|
||||
_sprite->setGlobalZOrder(-1);
|
||||
}
|
||||
else
|
||||
sprite = Sprite::create("Images/grossinis_sister1.png");
|
||||
|
||||
parent->addChild(sprite);
|
||||
this->addChild(parent);
|
||||
|
||||
float w = sprite->getContentSize().width;
|
||||
sprite->setPosition(s.width/2 - w*0.7*(i-5), s.height/2);
|
||||
}
|
||||
|
||||
this->scheduleUpdate();
|
||||
}
|
||||
|
||||
void NodeGlobalZValueTest::update(float dt)
|
||||
{
|
||||
static float accum = 0;
|
||||
|
||||
accum += dt;
|
||||
if( accum > 1) {
|
||||
float z = _sprite->getGlobalZOrder();
|
||||
_sprite->setGlobalZOrder(-z);
|
||||
accum = 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::string NodeGlobalZValueTest::title() const
|
||||
{
|
||||
return "Global Z Value";
|
||||
}
|
||||
|
||||
std::string NodeGlobalZValueTest::subtitle() const
|
||||
{
|
||||
return "Center Sprite should change go from foreground to background";
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// MySprite: Used by CameraTest1 and CameraTest2
|
||||
|
@ -932,7 +982,7 @@ protected:
|
|||
|
||||
void MySprite::draw()
|
||||
{
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -249,6 +249,20 @@ protected:
|
|||
NodeNonOpaqueTest();
|
||||
};
|
||||
|
||||
class NodeGlobalZValueTest : public TestCocosNodeDemo
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(NodeGlobalZValueTest);
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
virtual void update(float dt) override;
|
||||
|
||||
protected:
|
||||
NodeGlobalZValueTest();
|
||||
Sprite *_sprite;
|
||||
};
|
||||
|
||||
class CocosNodeTestScene : public TestScene
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -35,7 +35,11 @@
|
|||
static std::function<PerformanceContainerScene*()> createFunctions[] =
|
||||
{
|
||||
CL(TemplateVectorPerfTest),
|
||||
CL(ArrayPerfTest)
|
||||
CL(ArrayPerfTest),
|
||||
CL(TemplateMapStringKeyPerfTest),
|
||||
CL(DictionaryStringKeyPerfTest),
|
||||
CL(TemplateMapIntKeyPerfTest),
|
||||
CL(DictionaryIntKeyPerfTest)
|
||||
};
|
||||
|
||||
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
|
||||
|
@ -264,27 +268,6 @@ void PerformanceContainerScene::updateProfilerName()
|
|||
snprintf(_profilerName, sizeof(_profilerName)-1, "%s(%d)", testName(), quantityOfNodes);
|
||||
}
|
||||
|
||||
void PerformanceContainerScene::onExitTransitionDidStart()
|
||||
{
|
||||
Scene::onExitTransitionDidStart();
|
||||
|
||||
auto director = Director::getInstance();
|
||||
auto sched = director->getScheduler();
|
||||
|
||||
sched->unscheduleSelector(schedule_selector(PerformanceContainerScene::dumpProfilerInfo), this);
|
||||
}
|
||||
|
||||
void PerformanceContainerScene::onEnterTransitionDidFinish()
|
||||
{
|
||||
Scene::onEnterTransitionDidFinish();
|
||||
|
||||
auto director = Director::getInstance();
|
||||
auto sched = director->getScheduler();
|
||||
|
||||
CC_PROFILER_PURGE_ALL();
|
||||
sched->scheduleSelector(schedule_selector(PerformanceContainerScene::dumpProfilerInfo), this, 2, false);
|
||||
}
|
||||
|
||||
void PerformanceContainerScene::dumpProfilerInfo(float dt)
|
||||
{
|
||||
CC_PROFILER_DISPLAY_TIMERS();
|
||||
|
@ -507,8 +490,6 @@ void TemplateVectorPerfTest::generateTestFunctions()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string TemplateVectorPerfTest::title() const
|
||||
{
|
||||
return "Vector<T> Perf test";
|
||||
|
@ -519,8 +500,6 @@ std::string TemplateVectorPerfTest::subtitle() const
|
|||
return "Test 'pushBack', See console";
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// ArrayPerfTest
|
||||
|
@ -701,6 +680,685 @@ void ArrayPerfTest::generateTestFunctions()
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// TemplateMapStringKeyPerfTest
|
||||
//
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
void TemplateMapStringKeyPerfTest::generateTestFunctions()
|
||||
{
|
||||
auto createMap = [this](){
|
||||
Map<std::string, Node*> ret;
|
||||
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
{
|
||||
auto node = Node::create();
|
||||
node->setTag(i);
|
||||
ret.insert(StringUtils::format("key_%d", i), node);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
TestFunction testFunctions[] = {
|
||||
{ "insert", [=](){
|
||||
Map<std::string, Node*> map;
|
||||
|
||||
std::string* keys = new std::string[quantityOfNodes];
|
||||
|
||||
for (int i = 0; i < quantityOfNodes; ++i)
|
||||
{
|
||||
keys[i] = StringUtils::format("key_%d", i);
|
||||
}
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
map.insert(keys[i], Node::create());
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(keys);
|
||||
} } ,
|
||||
|
||||
{ "at", [=](){
|
||||
Map<std::string, Node*> map = createMap();
|
||||
|
||||
std::string* keys = new std::string[quantityOfNodes];
|
||||
Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes);
|
||||
for (int i = 0; i < quantityOfNodes; ++i)
|
||||
{
|
||||
keys[i] = StringUtils::format("key_%d", i);
|
||||
}
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
nodes[i] = map.at(keys[i]);
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(keys);
|
||||
|
||||
for (int i = 0; i < quantityOfNodes; ++i)
|
||||
{
|
||||
nodes[i]->setTag(100);
|
||||
}
|
||||
|
||||
CC_SAFE_FREE(nodes);
|
||||
} } ,
|
||||
|
||||
{ "erase", [=](){
|
||||
auto map = createMap();
|
||||
|
||||
std::string* keys = new std::string[quantityOfNodes];
|
||||
Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes);
|
||||
for (int i = 0; i < quantityOfNodes; ++i)
|
||||
{
|
||||
keys[i] = StringUtils::format("key_%d", i);
|
||||
}
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
map.erase(keys[i]);
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(keys);
|
||||
|
||||
CC_SAFE_FREE(nodes);
|
||||
} } ,
|
||||
|
||||
{ "clear", [=](){
|
||||
auto map = createMap();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
map.clear();
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
} } ,
|
||||
|
||||
{ "size", [=](){
|
||||
auto map = createMap();
|
||||
|
||||
ssize_t size = 0;
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
size = map.size();
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
} } ,
|
||||
|
||||
{ "keys(all)", [=](){
|
||||
auto map = createMap();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
auto keys = map.keys();
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
std::string allKeysString;
|
||||
for (const auto& key : keys)
|
||||
{
|
||||
allKeysString += "_" + key;
|
||||
}
|
||||
} } ,
|
||||
|
||||
{ "keys(object)", [=](){
|
||||
Map<std::string, Node*> map;
|
||||
|
||||
Node** nodes = (Node**) malloc(sizeof(Node*) * quantityOfNodes);
|
||||
Node* sameNode = Node::create();
|
||||
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
{
|
||||
if (quantityOfNodes % 100 == 0)
|
||||
{
|
||||
map.insert(StringUtils::format("key_%d", i), sameNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto node = Node::create();
|
||||
node->setTag(i);
|
||||
map.insert(StringUtils::format("key_%d", i), node);
|
||||
}
|
||||
}
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
auto keys = map.keys(sameNode);
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
std::string allKeysString;
|
||||
for (const auto& key : keys)
|
||||
{
|
||||
allKeysString += "_" + key;
|
||||
}
|
||||
|
||||
CC_SAFE_FREE(nodes);
|
||||
} } ,
|
||||
|
||||
{ "c++11 range loop", [=](){
|
||||
auto map = createMap();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
|
||||
for (const auto& e : map)
|
||||
{
|
||||
e.second->setTag(100);
|
||||
}
|
||||
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
} } ,
|
||||
|
||||
};
|
||||
|
||||
for (const auto& func : testFunctions)
|
||||
{
|
||||
_testFunctions.push_back(func);
|
||||
}
|
||||
}
|
||||
|
||||
std::string TemplateMapStringKeyPerfTest::title() const
|
||||
{
|
||||
return "Map<T> String Key Perf test";
|
||||
}
|
||||
|
||||
std::string TemplateMapStringKeyPerfTest::subtitle() const
|
||||
{
|
||||
return "Test 'insert', See console";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// DictionaryStringKeyPerfTest
|
||||
//
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
void DictionaryStringKeyPerfTest::generateTestFunctions()
|
||||
{
|
||||
auto createDict = [this](){
|
||||
Dictionary* ret = Dictionary::create();
|
||||
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
{
|
||||
auto node = Node::create();
|
||||
node->setTag(i);
|
||||
ret->setObject(node, StringUtils::format("key_%d", i));
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
TestFunction testFunctions[] = {
|
||||
{ "setObject", [=](){
|
||||
Dictionary* dict = Dictionary::create();
|
||||
|
||||
std::string* keys = new std::string[quantityOfNodes];
|
||||
|
||||
for (int i = 0; i < quantityOfNodes; ++i)
|
||||
{
|
||||
keys[i] = StringUtils::format("key_%d", i);
|
||||
}
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
dict->setObject(Node::create(), keys[i]);
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(keys);
|
||||
} } ,
|
||||
|
||||
{ "objectForKey", [=](){
|
||||
auto dict = createDict();
|
||||
|
||||
std::string* keys = new std::string[quantityOfNodes];
|
||||
Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes);
|
||||
for (int i = 0; i < quantityOfNodes; ++i)
|
||||
{
|
||||
keys[i] = StringUtils::format("key_%d", i);
|
||||
}
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
nodes[i] = static_cast<Node*>(dict->objectForKey(keys[i]));
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(keys);
|
||||
|
||||
for (int i = 0; i < quantityOfNodes; ++i)
|
||||
{
|
||||
nodes[i]->setTag(100);
|
||||
}
|
||||
|
||||
CC_SAFE_FREE(nodes);
|
||||
} } ,
|
||||
|
||||
{ "removeObjectForKey", [=](){
|
||||
auto dict = createDict();
|
||||
|
||||
std::string* keys = new std::string[quantityOfNodes];
|
||||
Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes);
|
||||
for (int i = 0; i < quantityOfNodes; ++i)
|
||||
{
|
||||
keys[i] = StringUtils::format("key_%d", i);
|
||||
}
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
dict->removeObjectForKey(keys[i]);
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(keys);
|
||||
|
||||
CC_SAFE_FREE(nodes);
|
||||
} } ,
|
||||
|
||||
{ "removeAllObjects", [=](){
|
||||
auto dict = createDict();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
dict->removeAllObjects();
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
} } ,
|
||||
|
||||
{ "count", [=](){
|
||||
auto dict = createDict();
|
||||
|
||||
ssize_t size = 0;
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
size = dict->count();
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
} } ,
|
||||
|
||||
{ "allKeys", [=](){
|
||||
auto dict = createDict();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
auto keys = dict->allKeys();
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
std::string allKeysString;
|
||||
Object* obj;
|
||||
CCARRAY_FOREACH(keys, obj)
|
||||
{
|
||||
auto key = static_cast<String*>(obj);
|
||||
allKeysString += (std::string("_") + key->getCString());
|
||||
}
|
||||
} } ,
|
||||
|
||||
{ "allKeysForObject", [=](){
|
||||
Dictionary* dict = Dictionary::create();
|
||||
|
||||
Node** nodes = (Node**) malloc(sizeof(Node*) * quantityOfNodes);
|
||||
Node* sameNode = Node::create();
|
||||
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
{
|
||||
if (quantityOfNodes % 100 == 0)
|
||||
{
|
||||
dict->setObject(sameNode, StringUtils::format("key_%d", i));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto node = Node::create();
|
||||
node->setTag(i);
|
||||
dict->setObject(node, StringUtils::format("key_%d", i));
|
||||
}
|
||||
}
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
auto keys = dict->allKeysForObject(sameNode);
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
std::string allKeysString;
|
||||
Object* obj;
|
||||
CCARRAY_FOREACH(keys, obj)
|
||||
{
|
||||
auto key = static_cast<String*>(obj);
|
||||
allKeysString += (std::string("_") + key->getCString());
|
||||
}
|
||||
|
||||
CC_SAFE_FREE(nodes);
|
||||
} } ,
|
||||
|
||||
{ "CCDICT_FOREACH", [=](){
|
||||
auto dict = createDict();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
|
||||
DictElement* e = nullptr;
|
||||
CCDICT_FOREACH(dict, e)
|
||||
{
|
||||
static_cast<Node*>(e->getObject())->setTag(100);
|
||||
}
|
||||
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
} } ,
|
||||
};
|
||||
|
||||
for (const auto& func : testFunctions)
|
||||
{
|
||||
_testFunctions.push_back(func);
|
||||
}
|
||||
}
|
||||
|
||||
std::string DictionaryStringKeyPerfTest::title() const
|
||||
{
|
||||
return "Dictionary String Key Perf test";
|
||||
}
|
||||
|
||||
std::string DictionaryStringKeyPerfTest::subtitle() const
|
||||
{
|
||||
return "Test `setObject`, See console";
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// TemplateMapIntKeyPerfTest
|
||||
//
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
void TemplateMapIntKeyPerfTest::generateTestFunctions()
|
||||
{
|
||||
auto createMap = [this](){
|
||||
Map<int, Node*> ret;
|
||||
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
{
|
||||
auto node = Node::create();
|
||||
node->setTag(i);
|
||||
ret.insert(100+i, node);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
TestFunction testFunctions[] = {
|
||||
{ "insert", [=](){
|
||||
Map<int, Node*> map;
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
map.insert(100 + i, Node::create());
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
} } ,
|
||||
|
||||
{ "at", [=](){
|
||||
auto map = createMap();
|
||||
Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes);
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
nodes[i] = map.at(100 + i);
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
for (int i = 0; i < quantityOfNodes; ++i)
|
||||
{
|
||||
nodes[i]->setTag(100);
|
||||
}
|
||||
|
||||
CC_SAFE_FREE(nodes);
|
||||
} } ,
|
||||
|
||||
{ "erase", [=](){
|
||||
auto map = createMap();
|
||||
|
||||
Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes);
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
map.erase(100 + i);
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
CC_SAFE_FREE(nodes);
|
||||
} } ,
|
||||
|
||||
{ "clear", [=](){
|
||||
auto map = createMap();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
map.clear();
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
} } ,
|
||||
|
||||
{ "size", [=](){
|
||||
auto map = createMap();
|
||||
|
||||
ssize_t size = 0;
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
size = map.size();
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
} } ,
|
||||
|
||||
{ "keys(all)", [=](){
|
||||
auto map = createMap();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
auto keys = map.keys();
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
int allKeysInt = 0;
|
||||
for (const auto& key : keys)
|
||||
{
|
||||
allKeysInt += key;
|
||||
}
|
||||
} } ,
|
||||
|
||||
{ "keys(object)", [=](){
|
||||
Map<int, Node*> map;
|
||||
|
||||
Node** nodes = (Node**) malloc(sizeof(Node*) * quantityOfNodes);
|
||||
Node* sameNode = Node::create();
|
||||
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
{
|
||||
if (quantityOfNodes % 100 == 0)
|
||||
{
|
||||
map.insert(100 + i, sameNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto node = Node::create();
|
||||
node->setTag(i);
|
||||
map.insert(100 + i, node);
|
||||
}
|
||||
}
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
auto keys = map.keys(sameNode);
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
int allKeysInt = 0;
|
||||
for (const auto& key : keys)
|
||||
{
|
||||
allKeysInt += key;
|
||||
}
|
||||
|
||||
CC_SAFE_FREE(nodes);
|
||||
} } ,
|
||||
|
||||
{ "c++11 range loop", [=](){
|
||||
auto map = createMap();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
|
||||
for (const auto& e : map)
|
||||
{
|
||||
e.second->setTag(100);
|
||||
}
|
||||
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
} } ,
|
||||
|
||||
};
|
||||
|
||||
for (const auto& func : testFunctions)
|
||||
{
|
||||
_testFunctions.push_back(func);
|
||||
}
|
||||
}
|
||||
|
||||
std::string TemplateMapIntKeyPerfTest::title() const
|
||||
{
|
||||
return "Map<T> Integer Key Perf test";
|
||||
}
|
||||
|
||||
std::string TemplateMapIntKeyPerfTest::subtitle() const
|
||||
{
|
||||
return "Test 'insert', See console";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// DictionaryIntKeyPerfTest
|
||||
//
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
void DictionaryIntKeyPerfTest::generateTestFunctions()
|
||||
{
|
||||
auto createDict = [this](){
|
||||
Dictionary* ret = Dictionary::create();
|
||||
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
{
|
||||
auto node = Node::create();
|
||||
node->setTag(i);
|
||||
ret->setObject(node, 100 + i);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
TestFunction testFunctions[] = {
|
||||
{ "setObject", [=](){
|
||||
Dictionary* dict = Dictionary::create();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
dict->setObject(Node::create(), 100 + i);
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
} } ,
|
||||
|
||||
{ "objectForKey", [=](){
|
||||
auto dict = createDict();
|
||||
|
||||
Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes);
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
nodes[i] = static_cast<Node*>(dict->objectForKey(100 + i));
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
for (int i = 0; i < quantityOfNodes; ++i)
|
||||
{
|
||||
nodes[i]->setTag(100);
|
||||
}
|
||||
|
||||
CC_SAFE_FREE(nodes);
|
||||
} } ,
|
||||
|
||||
{ "removeObjectForKey", [=](){
|
||||
auto dict = createDict();
|
||||
|
||||
Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes);
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
dict->removeObjectForKey(100 + i);
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
CC_SAFE_FREE(nodes);
|
||||
} } ,
|
||||
|
||||
{ "removeAllObjects", [=](){
|
||||
auto dict = createDict();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
dict->removeAllObjects();
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
} } ,
|
||||
|
||||
{ "count", [=](){
|
||||
auto dict = createDict();
|
||||
|
||||
unsigned int size = 0;
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
size = dict->count();
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
} } ,
|
||||
|
||||
{ "allKeys", [=](){
|
||||
auto dict = createDict();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
auto keys = dict->allKeys();
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
int allKeysInt = 0;
|
||||
Object* obj;
|
||||
CCARRAY_FOREACH(keys, obj)
|
||||
{
|
||||
auto key = static_cast<Integer*>(obj);
|
||||
allKeysInt += key->getValue();
|
||||
}
|
||||
} } ,
|
||||
|
||||
{ "allKeysForObject", [=](){
|
||||
Dictionary* dict = Dictionary::create();
|
||||
|
||||
Node** nodes = (Node**) malloc(sizeof(Node*) * quantityOfNodes);
|
||||
Node* sameNode = Node::create();
|
||||
|
||||
for( int i=0; i<quantityOfNodes; ++i)
|
||||
{
|
||||
if (quantityOfNodes % 100 == 0)
|
||||
{
|
||||
dict->setObject(sameNode, 100 + i);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto node = Node::create();
|
||||
node->setTag(i);
|
||||
dict->setObject(node, 100 + i);
|
||||
}
|
||||
}
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
auto keys = dict->allKeysForObject(sameNode);
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
|
||||
int allKeysInt = 0;
|
||||
Object* obj;
|
||||
CCARRAY_FOREACH(keys, obj)
|
||||
{
|
||||
auto key = static_cast<Integer*>(obj);
|
||||
allKeysInt += key->getValue();
|
||||
}
|
||||
|
||||
CC_SAFE_FREE(nodes);
|
||||
} } ,
|
||||
|
||||
{ "CCDICT_FOREACH", [=](){
|
||||
auto dict = createDict();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
|
||||
DictElement* e = nullptr;
|
||||
CCDICT_FOREACH(dict, e)
|
||||
{
|
||||
static_cast<Node*>(e->getObject())->setTag(100);
|
||||
}
|
||||
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
} } ,
|
||||
};
|
||||
|
||||
for (const auto& func : testFunctions)
|
||||
{
|
||||
_testFunctions.push_back(func);
|
||||
}
|
||||
}
|
||||
|
||||
std::string DictionaryIntKeyPerfTest::title() const
|
||||
{
|
||||
return "Dictionary Integer Key Perf test";
|
||||
}
|
||||
|
||||
std::string DictionaryIntKeyPerfTest::subtitle() const
|
||||
{
|
||||
return "Test `setObject`, See console";
|
||||
}
|
||||
|
||||
|
||||
///----------------------------------------
|
||||
void runContainerPerformanceTest()
|
||||
{
|
||||
|
|
|
@ -44,8 +44,6 @@ public:
|
|||
void dumpProfilerInfo(float dt);
|
||||
|
||||
// overrides
|
||||
virtual void onExitTransitionDidStart() override;
|
||||
virtual void onEnterTransitionDidFinish() override;
|
||||
virtual void update(float dt) override;
|
||||
|
||||
protected:
|
||||
|
@ -85,6 +83,49 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
class TemplateMapStringKeyPerfTest : public PerformanceContainerScene
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(TemplateMapStringKeyPerfTest);
|
||||
|
||||
virtual void generateTestFunctions() override;
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
class DictionaryStringKeyPerfTest : public PerformanceContainerScene
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DictionaryStringKeyPerfTest);
|
||||
|
||||
virtual void generateTestFunctions() override;
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
class TemplateMapIntKeyPerfTest : public PerformanceContainerScene
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(TemplateMapIntKeyPerfTest);
|
||||
|
||||
virtual void generateTestFunctions() override;
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
class DictionaryIntKeyPerfTest : public PerformanceContainerScene
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DictionaryIntKeyPerfTest);
|
||||
|
||||
virtual void generateTestFunctions() override;
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
void runContainerPerformanceTest();
|
||||
|
||||
|
|
|
@ -470,19 +470,19 @@ RenderTextureTestDepthStencil::~RenderTextureTestDepthStencil()
|
|||
|
||||
void RenderTextureTestDepthStencil::draw()
|
||||
{
|
||||
_renderCmds[0].init(0, _vertexZ);
|
||||
_renderCmds[0].init(_globalZOrder);
|
||||
_renderCmds[0].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeClear, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[0]);
|
||||
|
||||
_rend->beginWithClear(0, 0, 0, 0, 0, 0);
|
||||
|
||||
_renderCmds[1].init(0, _vertexZ);
|
||||
_renderCmds[1].init(_globalZOrder);
|
||||
_renderCmds[1].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeStencil, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[1]);
|
||||
|
||||
_spriteDS->visit();
|
||||
|
||||
_renderCmds[2].init(0, _vertexZ);
|
||||
_renderCmds[2].init(_globalZOrder);
|
||||
_renderCmds[2].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[2]);
|
||||
|
||||
|
@ -490,7 +490,7 @@ void RenderTextureTestDepthStencil::draw()
|
|||
|
||||
_rend->end();
|
||||
|
||||
_renderCmds[3].init(0, _vertexZ);
|
||||
_renderCmds[3].init(_globalZOrder);
|
||||
_renderCmds[3].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onAfterDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[3]);
|
||||
|
||||
|
@ -638,7 +638,7 @@ SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::SimpleSprite::crea
|
|||
|
||||
void SpriteRenderTextureBug::SimpleSprite::draw()
|
||||
{
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(SpriteRenderTextureBug::SimpleSprite::onBeforeDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ void ShaderNode::setPosition(const Point &newPosition)
|
|||
|
||||
void ShaderNode::draw()
|
||||
{
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ShaderNode::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
@ -526,7 +526,7 @@ void SpriteBlur::initProgram()
|
|||
|
||||
void SpriteBlur::draw()
|
||||
{
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(SpriteBlur::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ void ShaderSprite::initShader()
|
|||
|
||||
void ShaderSprite::draw()
|
||||
{
|
||||
_renderCommand.init(0, _vertexZ);
|
||||
_renderCommand.init(_globalZOrder);
|
||||
_renderCommand.func = CC_CALLBACK_0(ShaderSprite::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCommand);
|
||||
|
||||
|
|
|
@ -1794,7 +1794,7 @@ void TextureDrawAtPoint::draw()
|
|||
{
|
||||
TextureDemo::draw();
|
||||
|
||||
_renderCmd.init(0, _vertexZ);
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TextureDrawAtPoint::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
|
||||
|
||||
|
@ -1835,7 +1835,7 @@ void TextureDrawInRect::draw()
|
|||
{
|
||||
TextureDemo::draw();
|
||||
|
||||
_renderCmd.init(0, _vertexZ);
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TextureDrawInRect::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
|
||||
|
||||
|
|
|
@ -599,7 +599,7 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest()
|
|||
|
||||
void TMXOrthoObjectsTest::draw()
|
||||
{
|
||||
_renderCmd.init(0, _vertexZ);
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TMXOrthoObjectsTest::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ TMXIsoObjectsTest::TMXIsoObjectsTest()
|
|||
|
||||
void TMXIsoObjectsTest::draw()
|
||||
{
|
||||
_renderCmd.init(0, _vertexZ);
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TMXIsoObjectsTest::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
|
||||
}
|
||||
|
@ -1504,7 +1504,7 @@ TMXGIDObjectsTest::TMXGIDObjectsTest()
|
|||
|
||||
void TMXGIDObjectsTest::draw()
|
||||
{
|
||||
_renderCmd.init(0, _vertexZ);
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TMXGIDObjectsTest::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
|
||||
}
|
||||
|
|
|
@ -425,10 +425,10 @@ local function SpeedTest()
|
|||
local spawn = cc.Spawn:create(seq3_1, seq3_2)
|
||||
SpeedTest_action1 = cc.Speed:create(cc.RepeatForever:create(spawn), 1.0)
|
||||
|
||||
local spawn2 = tolua.cast(spawn:clone(), "Spawn")
|
||||
local spawn2 = tolua.cast(spawn:clone(), "cc.Spawn")
|
||||
SpeedTest_action2 = cc.Speed:create(cc.RepeatForever:create(spawn2), 1.0)
|
||||
|
||||
local spawn3 = tolua.cast(spawn:clone(), "Spawn")
|
||||
local spawn3 = tolua.cast(spawn:clone(), "cc.Spawn")
|
||||
SpeedTest_action3 = cc.Speed:create(cc.RepeatForever:create(spawn3), 1.0)
|
||||
|
||||
grossini:runAction(SpeedTest_action2)
|
||||
|
|
|
@ -551,7 +551,7 @@ local function ActionAnimate()
|
|||
|
||||
local animation3 = animation2:clone()
|
||||
-- problem
|
||||
tolua.cast(animation3,"Animation"):setLoops(4)
|
||||
tolua.cast(animation3,"cc.Animation"):setLoops(4)
|
||||
|
||||
local action3 = cc.Animate:create(animation3)
|
||||
kathia:runAction(action3)
|
||||
|
@ -740,7 +740,7 @@ local function ActionRotateToRepeat()
|
|||
local act2 = cc.RotateTo:create(1, 0)
|
||||
local seq = cc.Sequence:create(act1, act2)
|
||||
local rep1 = cc.RepeatForever:create(seq)
|
||||
local rep2 = cc.Repeat:create(tolua.cast(seq:clone(), "Sequence"), 10)
|
||||
local rep2 = cc.Repeat:create(tolua.cast(seq:clone(), "cc.Sequence"), 10)
|
||||
|
||||
tamara:runAction(rep1)
|
||||
kathia:runAction(rep2)
|
||||
|
@ -931,8 +931,8 @@ local function ActionOrbit()
|
|||
local seq = cc.Sequence:create(move, move_back)
|
||||
local rfe = cc.RepeatForever:create(seq)
|
||||
kathia:runAction(rfe)
|
||||
tamara:runAction(tolua.cast(rfe:clone(), "ActionInterval"))
|
||||
grossini:runAction(tolua.cast(rfe:clone(), "ActionInterval"))
|
||||
tamara:runAction(tolua.cast(rfe:clone(), "cc.ActionInterval"))
|
||||
grossini:runAction(tolua.cast(rfe:clone(), "cc.ActionInterval"))
|
||||
|
||||
|
||||
Helper.subtitleLabel:setString("OrbitCamera action")
|
||||
|
|
|
@ -428,7 +428,7 @@ end
|
|||
|
||||
function TestPerformance:refreshTitle()
|
||||
local subTitleInfo = ArmatureTestLayer.subTitle(5) .. self._armatureCount
|
||||
local label = tolua.cast(self:getChildByTag(10001),"LabelTTF")
|
||||
local label = tolua.cast(self:getChildByTag(10001),"cc.LabelTTF")
|
||||
label:setString(subTitleInfo)
|
||||
end
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
1cb290e913d84d8cd141945c8b4a78ea45481cd5
|
||||
09ed3c488f6d182685c416c291f8f325fb5cc2d2
|
|
@ -95,7 +95,7 @@ local function Effect2()
|
|||
|
||||
local delay = cc.DelayTime:create(1)
|
||||
|
||||
target:runAction(cc.Sequence:create(shaky, delay ,reuse, shuffle, tolua.cast(delay:clone(), "Action"), turnoff, turnon))
|
||||
target:runAction(cc.Sequence:create(shaky, delay ,reuse, shuffle, tolua.cast(delay:clone(), "cc.Action"), turnoff, turnon))
|
||||
return ret
|
||||
end
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ ccb["TestScrollViewsLayer"] = TestScrollViewsLayer
|
|||
|
||||
local function onMenuItemAClicked()
|
||||
if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then
|
||||
local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"LabelBMFont")
|
||||
local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"cc.LabelBMFont")
|
||||
if nil ~= labelBmFt then
|
||||
labelBmFt:setString("Menu Item A clicked.");
|
||||
end
|
||||
|
@ -39,7 +39,7 @@ end
|
|||
|
||||
local function onMenuItemBClicked()
|
||||
if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then
|
||||
local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"LabelBMFont")
|
||||
local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"cc.LabelBMFont")
|
||||
if nil ~= labelBmFt then
|
||||
labelBmFt:setString("Menu Item B clicked.");
|
||||
end
|
||||
|
@ -48,7 +48,7 @@ end
|
|||
|
||||
local function pressedC( ... )
|
||||
if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then
|
||||
local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"LabelBMFont")
|
||||
local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"cc.LabelBMFont")
|
||||
if nil ~= labelBmFt then
|
||||
labelBmFt:setString("Menu Item C clicked.");
|
||||
end
|
||||
|
@ -59,9 +59,9 @@ local function onMenuTestClicked()
|
|||
local scene = cc.Scene:create()
|
||||
local proxy = cc.CCBProxy:create()
|
||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestMenus.ccbi",proxy,HelloCocosBuilderLayer)
|
||||
local layer = tolua.cast(node,"Layer")
|
||||
local layer = tolua.cast(node,"cc.Layer")
|
||||
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF")
|
||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF")
|
||||
if nil ~= ccLabelTTF then
|
||||
ccLabelTTF:setString("ccb/ccb/TestMenus.ccbi")
|
||||
end
|
||||
|
@ -88,9 +88,9 @@ local function onSpriteTestClicked()
|
|||
local scene = cc.Scene:create()
|
||||
local proxy = cc.CCBProxy:create()
|
||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestSprites.ccbi",proxy,HelloCocosBuilderLayer)
|
||||
local layer = tolua.cast(node,"Layer")
|
||||
local layer = tolua.cast(node,"cc.Layer")
|
||||
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF")
|
||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF")
|
||||
if nil ~= ccLabelTTF then
|
||||
ccLabelTTF:setString("ccb/ccb/TestSprites.ccbi")
|
||||
end
|
||||
|
@ -107,9 +107,9 @@ local function onButtonTestClicked()
|
|||
local scene = cc.Scene:create()
|
||||
local proxy = cc.CCBProxy:create()
|
||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestButtons.ccbi",proxy,HelloCocosBuilderLayer)
|
||||
local layer = tolua.cast(node,"Layer")
|
||||
local layer = tolua.cast(node,"cc.Layer")
|
||||
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF")
|
||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF")
|
||||
if nil ~= ccLabelTTF then
|
||||
ccLabelTTF:setString("ccb/ccb/TestButtons.ccbi")
|
||||
end
|
||||
|
@ -122,7 +122,7 @@ local function onButtonTestClicked()
|
|||
end
|
||||
|
||||
local function onCCControlButtonClicked(sender,controlEvent)
|
||||
local labelTTF = tolua.cast(TestButtonsLayer["mCCControlEventLabel"],"LabelBMFont")
|
||||
local labelTTF = tolua.cast(TestButtonsLayer["mCCControlEventLabel"],"cc.LabelBMFont")
|
||||
|
||||
if nil == labelTTF then
|
||||
return
|
||||
|
@ -158,9 +158,9 @@ local function onAnimationsTestClicked()
|
|||
local scene = cc.Scene:create()
|
||||
local proxy = cc.CCBProxy:create()
|
||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestAnimations.ccbi",proxy,HelloCocosBuilderLayer)
|
||||
local layer = tolua.cast(node,"Layer")
|
||||
local layer = tolua.cast(node,"cc.Layer")
|
||||
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF")
|
||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF")
|
||||
if nil ~= ccLabelTTF then
|
||||
ccLabelTTF:setString("ccb/ccb/TestAnimations.ccbi")
|
||||
end
|
||||
|
@ -177,9 +177,9 @@ local function onParticleSystemTestClicked()
|
|||
local scene = cc.Scene:create()
|
||||
local proxy = cc.CCBProxy:create()
|
||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestParticleSystems.ccbi",proxy,HelloCocosBuilderLayer)
|
||||
local layer = tolua.cast(node,"Layer")
|
||||
local layer = tolua.cast(node,"cc.Layer")
|
||||
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF")
|
||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF")
|
||||
if nil ~= ccLabelTTF then
|
||||
ccLabelTTF:setString("ccb/ccb/TestParticleSystems.ccbi")
|
||||
end
|
||||
|
@ -193,7 +193,7 @@ end
|
|||
|
||||
local function onCCControlButtonIdleClicked()
|
||||
if nil ~= TestAnimationsLayer["mAnimationManager"] then
|
||||
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"CCBAnimationManager")
|
||||
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"cc.CCBAnimationManager")
|
||||
if nil ~= animationMgr then
|
||||
animationMgr:runAnimationsForSequenceNamedTweenDuration("Idle", 0.3)
|
||||
end
|
||||
|
@ -202,7 +202,7 @@ end
|
|||
|
||||
local function onCCControlButtonWaveClicked()
|
||||
if nil ~= TestAnimationsLayer["mAnimationManager"] then
|
||||
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"CCBAnimationManager")
|
||||
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"cc.CCBAnimationManager")
|
||||
if nil ~= animationMgr then
|
||||
animationMgr:runAnimationsForSequenceNamedTweenDuration("Wave", 0.3)
|
||||
end
|
||||
|
@ -211,7 +211,7 @@ end
|
|||
|
||||
local function onCCControlButtonJumpClicked()
|
||||
if nil ~= TestAnimationsLayer["mAnimationManager"] then
|
||||
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"CCBAnimationManager")
|
||||
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"cc.CCBAnimationManager")
|
||||
if nil ~= animationMgr then
|
||||
animationMgr:runAnimationsForSequenceNamedTweenDuration("Jump", 0.3)
|
||||
end
|
||||
|
@ -220,7 +220,7 @@ end
|
|||
|
||||
local function onCCControlButtonFunkyClicked()
|
||||
if nil ~= TestAnimationsLayer["mAnimationManager"] then
|
||||
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"CCBAnimationManager")
|
||||
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"cc.CCBAnimationManager")
|
||||
if nil ~= animationMgr then
|
||||
animationMgr:runAnimationsForSequenceNamedTweenDuration("Funky", 0.3)
|
||||
end
|
||||
|
@ -237,9 +237,9 @@ local function onScrollViewTestClicked()
|
|||
local scene = cc.Scene:create()
|
||||
local proxy = cc.CCBProxy:create()
|
||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestScrollViews.ccbi",proxy,HelloCocosBuilderLayer)
|
||||
local layer = tolua.cast(node,"Layer")
|
||||
local layer = tolua.cast(node,"cc.Layer")
|
||||
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF")
|
||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF")
|
||||
if nil ~= ccLabelTTF then
|
||||
ccLabelTTF:setString("ccb/ccb/TestScrollViews.ccbi")
|
||||
end
|
||||
|
@ -256,9 +256,9 @@ local function onTimelineCallbackSoundClicked()
|
|||
local scene = cc.Scene:create()
|
||||
local proxy = cc.CCBProxy:create()
|
||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestTimelineCallback.ccbi",proxy,HelloCocosBuilderLayer)
|
||||
local layer = tolua.cast(node,"Layer")
|
||||
local layer = tolua.cast(node,"cc.Layer")
|
||||
if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then
|
||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF")
|
||||
local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF")
|
||||
if nil ~= ccLabelTTF then
|
||||
ccLabelTTF:setString("ccb/ccb/TestTimelineCallback.ccbi")
|
||||
end
|
||||
|
@ -272,7 +272,7 @@ end
|
|||
|
||||
function onCallback1()
|
||||
if nil ~= TestTimelineLayer["helloLabel"] then
|
||||
local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"LabelTTF")
|
||||
local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"cc.LabelTTF")
|
||||
if nil ~= ccLabelTTF then
|
||||
ccLabelTTF:runAction(cc.RotateBy:create(1, 360))
|
||||
ccLabelTTF:setString("Callback 1");
|
||||
|
@ -282,7 +282,7 @@ end
|
|||
|
||||
function onCallback2()
|
||||
if nil ~= TestTimelineLayer["helloLabel"] then
|
||||
local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"LabelTTF")
|
||||
local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"cc.LabelTTF")
|
||||
if nil ~= ccLabelTTF then
|
||||
ccLabelTTF:runAction(cc.RotateBy:create(2, 360))
|
||||
ccLabelTTF:setString("Callback 2");
|
||||
|
@ -306,7 +306,7 @@ local function HelloCCBTestMainLayer()
|
|||
print(type(cc.Scene))
|
||||
local proxy = cc.CCBProxy:create()
|
||||
local node = CCBReaderLoad("cocosbuilderRes/ccb/HelloCocosBuilder.ccbi",proxy,HelloCocosBuilderLayer)
|
||||
local layer = tolua.cast(node,"Layer")
|
||||
local layer = tolua.cast(node,"cc.Layer")
|
||||
return layer
|
||||
end
|
||||
|
||||
|
|
|
@ -11,7 +11,9 @@ local ExtensionTestEnum =
|
|||
TEST_COCOSBUILDER = 2,
|
||||
TEST_WEBSOCKET = 3,
|
||||
TEST_EDITBOX = 4,
|
||||
TEST_MAX_COUNT = 5,
|
||||
TEST_TABLEVIEW = 5,
|
||||
TEST_SCROLLVIEW = 6,
|
||||
TEST_MAX_COUNT = 7,
|
||||
}
|
||||
|
||||
local testsName =
|
||||
|
@ -21,6 +23,8 @@ local testsName =
|
|||
"CocosBuilderTest",
|
||||
"WebSocketTest",
|
||||
"EditBoxTest",
|
||||
"TableViewTest",
|
||||
"ScrollViewTest",
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,7 +69,7 @@ local function runNotificationCenterTest()
|
|||
local s = cc.Director:getInstance():getWinSize()
|
||||
|
||||
local function toggleSwitch(tag,menuItem)
|
||||
local toggleItem = tolua.cast(menuItem,"MenuItemToggle")
|
||||
local toggleItem = tolua.cast(menuItem,"cc.MenuItemToggle")
|
||||
local nIndex = toggleItem:getSelectedIndex()
|
||||
local selectedItem = toggleItem:getSelectedItem()
|
||||
if 0 == nIndex then
|
||||
|
@ -151,7 +155,7 @@ local function runNotificationCenterTest()
|
|||
connectitem:setTag(NotificationCenterParam.kTagConnect+i)
|
||||
|
||||
local function connectToSwitch(tag,menuItem)
|
||||
local connectMenuitem = tolua.cast(menuItem,"MenuItemToggle")
|
||||
local connectMenuitem = tolua.cast(menuItem,"cc.MenuItemToggle")
|
||||
local bConnected = true
|
||||
if connectMenuitem:getSelectedIndex() == 0 then
|
||||
bConnected = false
|
||||
|
@ -372,7 +376,7 @@ local function runCCControlTest()
|
|||
if nil == pSender or nil == pDisplayValueLabel then
|
||||
return
|
||||
end
|
||||
local pControl = tolua.cast(pSender,"ControlSlider")
|
||||
local pControl = tolua.cast(pSender,"cc.ControlSlider")
|
||||
local strFmt = nil
|
||||
if pControl:getTag() == 1 then
|
||||
strFmt = string.format("Upper slider value = %.02f",pControl:getValue())
|
||||
|
@ -430,7 +434,7 @@ local function runCCControlTest()
|
|||
return
|
||||
end
|
||||
|
||||
local pPicker = tolua.cast(pSender,"ControlColourPicker")
|
||||
local pPicker = tolua.cast(pSender,"cc.ControlColourPicker")
|
||||
local strFmt = string.format("#%02X%02X%02X",pPicker:getColor().r, pPicker:getColor().g, pPicker:getColor().b)
|
||||
pColorLabel:setString(strFmt)
|
||||
end
|
||||
|
@ -495,7 +499,7 @@ local function runCCControlTest()
|
|||
return
|
||||
end
|
||||
|
||||
local pControl = tolua.cast(pSender,"ControlSwitch")
|
||||
local pControl = tolua.cast(pSender,"cc.ControlSwitch")
|
||||
if pControl:isOn() then
|
||||
pDisplayValueLabel:setString("On")
|
||||
else
|
||||
|
@ -770,7 +774,7 @@ local function runCCControlTest()
|
|||
return
|
||||
end
|
||||
|
||||
local pControl = tolua.cast(pSender,"ControlPotentiometer")
|
||||
local pControl = tolua.cast(pSender,"cc.ControlPotentiometer")
|
||||
local strFmt = string.format("%0.2f",pControl:getValue())
|
||||
pDisplayValueLabel:setString(strFmt )
|
||||
end
|
||||
|
@ -827,7 +831,7 @@ local function runCCControlTest()
|
|||
return
|
||||
end
|
||||
|
||||
local pControl = tolua.cast(pSender,"ControlStepper")
|
||||
local pControl = tolua.cast(pSender,"cc.ControlStepper")
|
||||
local strFmt = string.format("%0.02f",pControl:getValue() )
|
||||
pDisplayValueLabel:setString(strFmt )
|
||||
end
|
||||
|
@ -913,7 +917,7 @@ local function runEditBoxTest()
|
|||
local EditEmail = nil
|
||||
|
||||
local function editBoxTextEventHandle(strEventName,pSender)
|
||||
local edit = tolua.cast(pSender,"EditBox")
|
||||
local edit = tolua.cast(pSender,"cc.EditBox")
|
||||
local strFmt
|
||||
if strEventName == "began" then
|
||||
strFmt = string.format("editBox %p DidBegin !", edit)
|
||||
|
@ -988,6 +992,192 @@ local function runEditBoxTest()
|
|||
return newScene
|
||||
end
|
||||
|
||||
local TableViewTestLayer = class("TableViewTestLayer")
|
||||
TableViewTestLayer.__index = TableViewTestLayer
|
||||
|
||||
function TableViewTestLayer.extend(target)
|
||||
local t = tolua.getpeer(target)
|
||||
if not t then
|
||||
t = {}
|
||||
tolua.setpeer(target, t)
|
||||
end
|
||||
setmetatable(t, TableViewTestLayer)
|
||||
return target
|
||||
end
|
||||
|
||||
function TableViewTestLayer.scrollViewDidScroll(view)
|
||||
print("scrollViewDidScroll")
|
||||
end
|
||||
|
||||
function TableViewTestLayer.scrollViewDidZoom(view)
|
||||
print("scrollViewDidZoom")
|
||||
end
|
||||
|
||||
function TableViewTestLayer.tableCellTouched(table,cell)
|
||||
print("cell touched at index: " .. cell:getIdx())
|
||||
end
|
||||
|
||||
function TableViewTestLayer.cellSizeForTable(table,idx)
|
||||
return 60,60
|
||||
end
|
||||
|
||||
function TableViewTestLayer.tableCellAtIndex(table, idx)
|
||||
local strValue = string.format("%d",idx)
|
||||
local cell = table:dequeueCell()
|
||||
local label = nil
|
||||
if nil == cell then
|
||||
cell = cc.TableViewCell:new()
|
||||
local sprite = cc.Sprite:create("Images/Icon.png")
|
||||
sprite:setAnchorPoint(cc.p(0,0))
|
||||
sprite:setPosition(cc.p(0, 0))
|
||||
cell:addChild(sprite)
|
||||
|
||||
label = cc.LabelTTF:create(strValue, "Helvetica", 20.0)
|
||||
label:setPosition(cc.p(0,0))
|
||||
label:setAnchorPoint(cc.p(0,0))
|
||||
label:setTag(123)
|
||||
cell:addChild(label)
|
||||
else
|
||||
label = tolua.cast(cell:getChildByTag(123),"cc.LabelTTF")
|
||||
if nil ~= label then
|
||||
label:setString(strValue)
|
||||
end
|
||||
end
|
||||
|
||||
return cell
|
||||
end
|
||||
|
||||
function TableViewTestLayer.numberOfCellsInTableView(table)
|
||||
return 25
|
||||
end
|
||||
|
||||
function TableViewTestLayer:init()
|
||||
|
||||
local winSize = cc.Director:getInstance():getWinSize()
|
||||
|
||||
local tableView = cc.TableView:create(cc.size(600,60))
|
||||
tableView:setDirection(cc.SCROLLVIEW_DIRECTION_HORIZONTAL)
|
||||
tableView:setPosition(cc.p(20, winSize.height / 2 - 150))
|
||||
tableView:setDelegate()
|
||||
self:addChild(tableView)
|
||||
--registerScriptHandler functions must be before the reloadData funtion
|
||||
tableView:registerScriptHandler(TableViewTestLayer.numberOfCellsInTableView,cc.NUMBER_OF_CELLS_IN_TABLEVIEW)
|
||||
tableView:registerScriptHandler(TableViewTestLayer.scrollViewDidScroll,cc.SCROLLVIEW_SCRIPT_SCROLL)
|
||||
tableView:registerScriptHandler(TableViewTestLayer.scrollViewDidZoom,cc.SCROLLVIEW_SCRIPT_ZOOM)
|
||||
tableView:registerScriptHandler(TableViewTestLayer.tableCellTouched,cc.TABLECELL_TOUCHED)
|
||||
tableView:registerScriptHandler(TableViewTestLayer.cellSizeForTable,cc.TABLECELL_SIZE_FOR_INDEX)
|
||||
tableView:registerScriptHandler(TableViewTestLayer.tableCellAtIndex,cc.TABLECELL_SIZE_AT_INDEX)
|
||||
tableView:reloadData()
|
||||
|
||||
tableView = cc.TableView:create(cc.size(60, 350))
|
||||
tableView:setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL)
|
||||
tableView:setPosition(cc.p(winSize.width - 150, winSize.height / 2 - 150))
|
||||
tableView:setDelegate()
|
||||
tableView:setVerticalFillOrder(cc.TABLEVIEW_FILL_TOPDOWN)
|
||||
self:addChild(tableView)
|
||||
tableView:registerScriptHandler(TableViewTestLayer.scrollViewDidScroll,cc.SCROLLVIEW_SCRIPT_SCROLL)
|
||||
tableView:registerScriptHandler(TableViewTestLayer.scrollViewDidZoom,cc.SCROLLVIEW_SCRIPT_ZOOM)
|
||||
tableView:registerScriptHandler(TableViewTestLayer.tableCellTouched,cc.TABLECELL_TOUCHED)
|
||||
tableView:registerScriptHandler(TableViewTestLayer.cellSizeForTable,cc.TABLECELL_SIZE_FOR_INDEX)
|
||||
tableView:registerScriptHandler(TableViewTestLayer.tableCellAtIndex,cc.TABLECELL_SIZE_AT_INDEX)
|
||||
tableView:registerScriptHandler(TableViewTestLayer.numberOfCellsInTableView,cc.NUMBER_OF_CELLS_IN_TABLEVIEW)
|
||||
tableView:reloadData()
|
||||
|
||||
-- Back Menu
|
||||
local pToMainMenu = cc.Menu:create()
|
||||
CreateExtensionsBasicLayerMenu(pToMainMenu)
|
||||
pToMainMenu:setPosition(cc.p(0, 0))
|
||||
self:addChild(pToMainMenu,10)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function TableViewTestLayer.create()
|
||||
local layer = TableViewTestLayer.extend(cc.Layer:create())
|
||||
if nil ~= layer then
|
||||
layer:init()
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
local function runTableViewTest()
|
||||
local newScene = cc.Scene:create()
|
||||
local newLayer = TableViewTestLayer.create()
|
||||
newScene:addChild(newLayer)
|
||||
return newScene
|
||||
end
|
||||
|
||||
local function runScrollViewTest()
|
||||
local newScene = cc.Scene:create()
|
||||
local newLayer = cc.Layer:create()
|
||||
|
||||
-- Back Menu
|
||||
local pToMainMenu = cc.Menu:create()
|
||||
CreateExtensionsBasicLayerMenu(pToMainMenu)
|
||||
pToMainMenu:setPosition(cc.p(0, 0))
|
||||
newLayer:addChild(pToMainMenu,10)
|
||||
|
||||
local layerColor = cc.LayerColor:create(cc.c4b(128,64,0,255))
|
||||
newLayer:addChild(layerColor)
|
||||
|
||||
local scrollView1 = cc.ScrollView:create()
|
||||
local screenSize = cc.Director:getInstance():getWinSize()
|
||||
local function scrollView1DidScroll()
|
||||
print("scrollView1DidScroll")
|
||||
end
|
||||
local function scrollView1DidZoom()
|
||||
print("scrollView1DidZoom")
|
||||
end
|
||||
if nil ~= scrollView1 then
|
||||
scrollView1:setViewSize(cc.size(screenSize.width / 2,screenSize.height))
|
||||
scrollView1:setPosition(cc.p(0,0))
|
||||
scrollView1:setScale(1.0)
|
||||
scrollView1:ignoreAnchorPointForPosition(true)
|
||||
local flowersprite1 = cc.Sprite:create("ccb/flower.jpg")
|
||||
if nil ~= flowersprite1 then
|
||||
scrollView1:setContainer(flowersprite1)
|
||||
scrollView1:updateInset()
|
||||
end
|
||||
scrollView1:setDirection(cc.SCROLLVIEW_DIRECTION_BOTH )
|
||||
scrollView1:setClippingToBounds(true)
|
||||
scrollView1:setBounceable(true)
|
||||
scrollView1:setDelegate()
|
||||
scrollView1:registerScriptHandler(scrollView1DidScroll,cc.SCROLLVIEW_SCRIPT_SCROLL)
|
||||
scrollView1:registerScriptHandler(scrollView1DidZoom,cc.SCROLLVIEW_SCRIPT_ZOOM)
|
||||
end
|
||||
newLayer:addChild(scrollView1)
|
||||
|
||||
local scrollView2 = cc.ScrollView:create()
|
||||
local function scrollView2DidScroll()
|
||||
print("scrollView2DidScroll")
|
||||
end
|
||||
local function scrollView2DidZoom()
|
||||
print("scrollView2DidZoom")
|
||||
end
|
||||
if nil ~= scrollView2 then
|
||||
scrollView2:setViewSize(cc.size(screenSize.width / 2,screenSize.height))
|
||||
scrollView2:setPosition(cc.p(screenSize.width / 2,0))
|
||||
scrollView2:setScale(1.0)
|
||||
scrollView2:ignoreAnchorPointForPosition(true)
|
||||
local flowersprite2 = cc.Sprite:create("ccb/flower.jpg")
|
||||
if nil ~= flowersprite2 then
|
||||
scrollView2:setContainer(flowersprite2)
|
||||
scrollView2:updateInset()
|
||||
end
|
||||
scrollView2:setDirection(cc.SCROLLVIEW_DIRECTION_BOTH )
|
||||
scrollView2:setClippingToBounds(true)
|
||||
scrollView2:setBounceable(true)
|
||||
scrollView2:setDelegate()
|
||||
scrollView2:registerScriptHandler(scrollView2DidScroll,cc.SCROLLVIEW_SCRIPT_SCROLL)
|
||||
scrollView2:registerScriptHandler(scrollView2DidZoom,cc.SCROLLVIEW_SCRIPT_ZOOM)
|
||||
end
|
||||
newLayer:addChild(scrollView2)
|
||||
|
||||
newScene:addChild(newLayer)
|
||||
return newScene
|
||||
end
|
||||
|
||||
local CreateExtensionsTestTable =
|
||||
{
|
||||
runNotificationCenterTest,
|
||||
|
@ -995,6 +1185,8 @@ local CreateExtensionsTestTable =
|
|||
runCocosBuilder,
|
||||
runWebSocketTest,
|
||||
runEditBoxTest,
|
||||
runTableViewTest,
|
||||
runScrollViewTest,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -83,9 +83,9 @@
|
|||
toMainMenu:setPosition(cc.p(0, 0))
|
||||
layer:addChild(toMainMenu,10)
|
||||
|
||||
wsSendText = WebSocket:create("ws://echo.websocket.org")
|
||||
wsSendBinary = WebSocket:create("ws://echo.websocket.org")
|
||||
wsError = WebSocket:create("ws://invalid.url.com")
|
||||
wsSendText = cc.WebSocket:create("ws://echo.websocket.org")
|
||||
wsSendBinary = cc.WebSocket:create("ws://echo.websocket.org")
|
||||
wsError = cc.WebSocket:create("ws://invalid.url.com")
|
||||
|
||||
local function wsSendTextOpen(strData)
|
||||
sendTextStatus:setString("Send Text WS was opened.")
|
||||
|
|
|
@ -32,11 +32,11 @@ function LabelAtlasTest.step(dt)
|
|||
local string = string.format("%2.2f Test", m_time)
|
||||
|
||||
local label1_origin = LabelAtlasTest.layer:getChildByTag(kTagSprite1)
|
||||
local label1 = tolua.cast(label1_origin, "LabelAtlas")
|
||||
local label1 = tolua.cast(label1_origin, "cc.LabelAtlas")
|
||||
label1:setString(string) --
|
||||
|
||||
local label2_origin = LabelAtlasTest.layer:getChildByTag(kTagSprite2)
|
||||
local label2 = tolua.cast(label2_origin, "LabelAtlas")
|
||||
local label2 = tolua.cast(label2_origin, "cc.LabelAtlas")
|
||||
string = string.format("%d", m_time)
|
||||
|
||||
label2:setString(string)
|
||||
|
@ -88,11 +88,11 @@ function LabelAtlasColorTest.step(dt)
|
|||
m_time = m_time + dt
|
||||
local string = string.format("%2.2f Test", m_time)
|
||||
local label1_origin = LabelAtlasColorTest.layer:getChildByTag(kTagSprite1)
|
||||
local label1 = tolua.cast(label1_origin, "LabelAtlas")
|
||||
local label1 = tolua.cast(label1_origin, "cc.LabelAtlas")
|
||||
label1:setString(string)
|
||||
|
||||
local label2_origin = LabelAtlasColorTest.layer:getChildByTag(kTagSprite2)
|
||||
local label2 = tolua.cast(label2_origin, "LabelAtlas")
|
||||
local label2 = tolua.cast(label2_origin, "cc.LabelAtlas")
|
||||
string = string.format("%d", m_time)
|
||||
|
||||
label2:setString(string)
|
||||
|
@ -199,7 +199,7 @@ function Atlas3.create()
|
|||
label2:setColor(cc.c3b(255, 0, 0 ))
|
||||
layer:addChild(label2, 0, kTagBitmapAtlas2)
|
||||
|
||||
label2:runAction( tolua.cast(repeatAction:clone(), "Action") )
|
||||
label2:runAction( tolua.cast(repeatAction:clone(), "cc.Action") )
|
||||
|
||||
local label3 = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest2.fnt")
|
||||
-- testing anchors
|
||||
|
@ -223,13 +223,13 @@ function Atlas3.step(dt)
|
|||
m_time = m_time + dt
|
||||
local string = string.format("%2.2f Test j", m_time)
|
||||
|
||||
local label1 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas1), "LabelBMFont")
|
||||
local label1 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas1), "cc.LabelBMFont")
|
||||
label1:setString(string)
|
||||
|
||||
local label2 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas2), "LabelBMFont")
|
||||
local label2 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas2), "cc.LabelBMFont")
|
||||
label2:setString(string)
|
||||
|
||||
local label3 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas3), "LabelBMFont")
|
||||
local label3 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas3), "cc.LabelBMFont")
|
||||
label3:setString(string)
|
||||
end
|
||||
|
||||
|
@ -309,7 +309,7 @@ function Atlas4.create()
|
|||
label2:setPosition( cc.p(s.width/2.0, 80) )
|
||||
|
||||
local lastChar = label2:getChildByTag(3)
|
||||
lastChar:runAction(tolua.cast( rot_4ever:clone(), "Action" ))
|
||||
lastChar:runAction(tolua.cast( rot_4ever:clone(), "cc.Action" ))
|
||||
|
||||
layer:registerScriptHandler(Atlas4.onNodeEvent)
|
||||
|
||||
|
@ -329,7 +329,7 @@ function Atlas4.step(dt)
|
|||
|
||||
local string = string.format("%04.1f", m_time)
|
||||
|
||||
local label1 = tolua.cast(Atlas4.layer:getChildByTag(kTagBitmapAtlas2), "LabelBMFont")
|
||||
local label1 = tolua.cast(Atlas4.layer:getChildByTag(kTagBitmapAtlas2), "cc.LabelBMFont")
|
||||
label1:setString(string)
|
||||
end
|
||||
|
||||
|
@ -592,9 +592,9 @@ function LabelsEmpty.create()
|
|||
end
|
||||
|
||||
function LabelsEmpty.updateStrings(dt)
|
||||
local label1 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas1), "LabelBMFont")
|
||||
local label2 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas2), "LabelTTF")
|
||||
local label3 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas3), "LabelAtlas")
|
||||
local label1 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas1), "cc.LabelBMFont")
|
||||
local label2 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas2), "cc.LabelTTF")
|
||||
local label3 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas3), "cc.LabelAtlas")
|
||||
|
||||
if( LabelsEmpty.setEmpty == false) then
|
||||
label1:setString("not empty")
|
||||
|
@ -1083,7 +1083,7 @@ end
|
|||
|
||||
|
||||
function BitmapFontMultiLineAlignment.stringChanged(tag, sender)
|
||||
local item = tolua.cast(sender, "MenuItemFont")
|
||||
local item = tolua.cast(sender, "cc.MenuItemFont")
|
||||
item:setColor(cc.c3b(255, 0, 0))
|
||||
BitmapFontMultiLineAlignment._pLastAlignmentItem:setColor(cc.c3b(255, 255, 255))
|
||||
BitmapFontMultiLineAlignment._pLastAlignmentItem = item
|
||||
|
@ -1101,7 +1101,7 @@ end
|
|||
|
||||
function BitmapFontMultiLineAlignment.alignmentChanged(tag, sender)
|
||||
-- cclog("BitmapFontMultiLineAlignment.alignmentChanged, tag:"..tag)
|
||||
local item = tolua.cast(sender, "MenuItemFont")
|
||||
local item = tolua.cast(sender, "cc.MenuItemFont")
|
||||
item:setColor(cc.c3b(255, 0, 0))
|
||||
BitmapFontMultiLineAlignment._pLastAlignmentItem:setColor(cc.c3b(255, 255, 255))
|
||||
BitmapFontMultiLineAlignment._pLastAlignmentItem = item
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue