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

Conflicts:
	cocos/2d/renderer/CCNewSpriteBatchNode.cpp
	cocos/2d/renderer/CCNewSpriteBatchNode.h
This commit is contained in:
boyu0 2013-12-24 16:07:25 +08:00
commit 1a453a26ab
49 changed files with 476 additions and 964 deletions

View File

@ -11,6 +11,7 @@ cocos2d-x-3.0beta0 ?? 2013
[NEW] New renderer support.
[FIX] Potential hash collision fix.
[FIX] Updates spine runtime to the latest version.
[FIX] Uses `const std::string&` instead of `const char*`.
[Android]
[NEW] build/android-build.sh: add supporting to generate .apk file
[FIX] XMLHttpRequest receives wrong binary array.
@ -19,6 +20,9 @@ cocos2d-x-3.0beta0 ?? 2013
[FIX] UserDefault::getDoubleForKey() doesn't pass default value to Java.
[Windows]
[NEW] CMake support for windows.
[Bindings]
[FIX] Don't bind override functions for JSB and LuaBining since they aren't needed at all.
[NEW] Adds spine JS binding support.
cocos2d-x-3.0alpha1 Nov.19 2013
[all platforms]

View File

@ -1 +1 @@
d5c3a61431f7098ddeabd3d035d501e3cc02c6b1
fc76c8739d4c7baa28d56f632e8d4c98c5eaf85e

View File

@ -1 +1 @@
52a991e88e049cd371a153ee168260276a7ac664
f36b451a97f9a0c93a4e23c417d7333f1e293993

View File

@ -117,12 +117,10 @@ platform/CCEGLViewProtocol.cpp \
platform/CCFileUtils.cpp \
platform/CCSAXParser.cpp \
platform/CCThread.cpp \
renderer/CCNewSpriteBatchNode.cpp \
renderer/CCCustomCommand.cpp \
renderer/CCFrustum.cpp \
renderer/CCGroupCommand.cpp \
renderer/CCMaterialManager.cpp \
renderer/CCNewClippingNode.cpp \
renderer/CCQuadCommand.cpp \
renderer/CCRenderCommand.cpp \
renderer/CCRenderer.cpp \
@ -207,6 +205,7 @@ LOCAL_EXPORT_LDLIBS := -lGLESv2 \
LOCAL_WHOLE_STATIC_LIBRARIES := cocos_freetype2_static
LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static
LOCAL_WHOLE_STATIC_LIBRARIES += spine_static
# define the macro to compile through support/zip_support/ioapi.c
LOCAL_CFLAGS := -Wno-psabi -DUSE_FILE32API
@ -219,3 +218,4 @@ include $(BUILD_STATIC_LIBRARY)
$(call import-module,freetype2/prebuilt/android)
$(call import-module,chipmunk)
$(call import-module,2d/platform/android)
$(call import-module,editor-support/spine)

View File

@ -31,10 +31,17 @@
#include "CCShaderCache.h"
#include "CCDirector.h"
#include "CCDrawingPrimitives.h"
#include "CCRenderer.h"
#include "CCGroupCommand.h"
#include "CCCustomCommand.h"
NS_CC_BEGIN
static GLint g_sStencilBits = -1;
// store the current stencil layer (position in the stencil buffer),
// this will allow nesting up to n ClippingNode,
// where n is the number of bits of the stencil buffer.
static GLint s_layer = -1;
static void setProgram(Node *n, GLProgram *p)
{
@ -50,7 +57,21 @@ ClippingNode::ClippingNode()
: _stencil(nullptr)
, _alphaThreshold(0.0f)
, _inverted(false)
{}
, _currentStencilEnabled(GL_FALSE)
, _currentStencilWriteMask(~0)
, _currentStencilFunc(GL_ALWAYS)
, _currentStencilRef(0)
, _currentStencilValueMask(~0)
, _currentStencilFail(GL_KEEP)
, _currentStencilPassDepthFail(GL_KEEP)
, _currentStencilPassDepthPass(GL_KEEP)
, _currentDepthWriteMask(GL_TRUE)
, _currentAlphaTestEnabled(GL_FALSE)
, _currentAlphaTestFunc(GL_ALWAYS)
, _currentAlphaTestRef(1)
{
}
ClippingNode::~ClippingNode()
{
@ -179,225 +200,36 @@ void ClippingNode::drawFullScreenQuadClearStencil()
void ClippingNode::visit()
{
// if stencil buffer disabled
if (g_sStencilBits < 1)
{
// draw everything, as if there where no stencil
Node::visit();
return;
}
//Add group command
// return fast (draw nothing, or draw everything if in inverted mode) if:
// - nil stencil node
// - or stencil node invisible:
if (!_stencil || !_stencil->isVisible())
{
if (_inverted)
{
// draw everything
Node::visit();
}
return;
}
Renderer* renderer = Director::getInstance()->getRenderer();
// store the current stencil layer (position in the stencil buffer),
// this will allow nesting up to n ClippingNode,
// where n is the number of bits of the stencil buffer.
static GLint layer = -1;
// all the _stencilBits are in use?
if (layer + 1 == g_sStencilBits)
{
// warn once
static bool once = true;
if (once)
{
char warning[200] = {0};
snprintf(warning, sizeof(warning), "Nesting more than %d stencils is not supported. Everything will be drawn without stencil for this node and its childs.", g_sStencilBits);
CCLOG("%s", warning);
once = false;
}
// draw everything, as if there where no stencil
Node::visit();
return;
}
///////////////////////////////////
// INIT
// increment the current layer
layer++;
// mask of the current layer (ie: for layer 3: 00000100)
GLint mask_layer = 0x1 << layer;
// mask of all layers less than the current (ie: for layer 3: 00000011)
GLint mask_layer_l = mask_layer - 1;
// mask of all layers less than or equal to the current (ie: for layer 3: 00000111)
GLint mask_layer_le = mask_layer | mask_layer_l;
// manually save the stencil state
GLboolean currentStencilEnabled = GL_FALSE;
GLuint currentStencilWriteMask = ~0;
GLenum currentStencilFunc = GL_ALWAYS;
GLint currentStencilRef = 0;
GLuint currentStencilValueMask = ~0;
GLenum currentStencilFail = GL_KEEP;
GLenum currentStencilPassDepthFail = GL_KEEP;
GLenum currentStencilPassDepthPass = GL_KEEP;
currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST);
glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)&currentStencilWriteMask);
glGetIntegerv(GL_STENCIL_FUNC, (GLint *)&currentStencilFunc);
glGetIntegerv(GL_STENCIL_REF, &currentStencilRef);
glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)&currentStencilValueMask);
glGetIntegerv(GL_STENCIL_FAIL, (GLint *)&currentStencilFail);
glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)&currentStencilPassDepthFail);
glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)&currentStencilPassDepthPass);
// enable stencil use
glEnable(GL_STENCIL_TEST);
// check for OpenGL error while enabling stencil test
CHECK_GL_ERROR_DEBUG();
// all bits on the stencil buffer are readonly, except the current layer bit,
// this means that operation like glClear or glStencilOp will be masked with this value
glStencilMask(mask_layer);
// manually save the depth test state
//GLboolean currentDepthTestEnabled = GL_TRUE;
GLboolean currentDepthWriteMask = GL_TRUE;
//currentDepthTestEnabled = glIsEnabled(GL_DEPTH_TEST);
glGetBooleanv(GL_DEPTH_WRITEMASK, &currentDepthWriteMask);
// disable depth test while drawing the stencil
//glDisable(GL_DEPTH_TEST);
// disable update to the depth buffer while drawing the stencil,
// as the stencil is not meant to be rendered in the real scene,
// it should never prevent something else to be drawn,
// only disabling depth buffer update should do
glDepthMask(GL_FALSE);
///////////////////////////////////
// CLEAR STENCIL BUFFER
// manually clear the stencil buffer by drawing a fullscreen rectangle on it
// setup the stencil test func like this:
// for each pixel in the fullscreen rectangle
// never draw it into the frame buffer
// if not in inverted mode: set the current layer value to 0 in the stencil buffer
// if in inverted mode: set the current layer value to 1 in the stencil buffer
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP);
// draw a fullscreen solid rectangle to clear the stencil buffer
//ccDrawSolidRect(Point::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1));
drawFullScreenQuadClearStencil();
///////////////////////////////////
// DRAW CLIPPING STENCIL
// setup the stencil test func like this:
// for each pixel in the stencil node
// never draw it into the frame buffer
// if not in inverted mode: set the current layer value to 1 in the stencil buffer
// if in inverted mode: set the current layer value to 0 in the stencil buffer
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
glStencilOp(!_inverted ? GL_REPLACE : GL_ZERO, GL_KEEP, GL_KEEP);
// enable alpha test only if the alpha threshold < 1,
// indeed if alpha threshold == 1, every pixel will be drawn anyways
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
GLboolean currentAlphaTestEnabled = GL_FALSE;
GLenum currentAlphaTestFunc = GL_ALWAYS;
GLclampf currentAlphaTestRef = 1;
#endif
if (_alphaThreshold < 1) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
// manually save the alpha test state
currentAlphaTestEnabled = glIsEnabled(GL_ALPHA_TEST);
glGetIntegerv(GL_ALPHA_TEST_FUNC, (GLint *)&currentAlphaTestFunc);
glGetFloatv(GL_ALPHA_TEST_REF, &currentAlphaTestRef);
// enable alpha testing
glEnable(GL_ALPHA_TEST);
// check for OpenGL error while enabling alpha test
CHECK_GL_ERROR_DEBUG();
// pixel will be drawn only if greater than an alpha threshold
glAlphaFunc(GL_GREATER, _alphaThreshold);
#else
// since glAlphaTest do not exists in OES, use a shader that writes
// pixel only if greater than an alpha threshold
GLProgram *program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
// set our alphaThreshold
program->use();
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
// we need to recursively apply this shader to all the nodes in the stencil node
// XXX: we should have a way to apply shader to all nodes without having to do this
setProgram(_stencil, program);
#endif
}
// draw the stencil node as if it was one of our child
// (according to the stencil test func/op and alpha (or alpha shader) test)
kmGLPushMatrix();
transform();
if (_stencil != nullptr)
{
_stencil->visit();
}
kmGLPopMatrix();
// restore alpha test state
if (_alphaThreshold < 1)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
// manually restore the alpha test state
glAlphaFunc(currentAlphaTestFunc, currentAlphaTestRef);
if (!currentAlphaTestEnabled)
{
glDisable(GL_ALPHA_TEST);
}
#else
// XXX: we need to find a way to restore the shaders of the stencil node and its childs
#endif
}
// restore the depth test state
glDepthMask(currentDepthWriteMask);
//if (currentDepthTestEnabled) {
// glEnable(GL_DEPTH_TEST);
//}
///////////////////////////////////
// DRAW CONTENT
// setup the stencil test func like this:
// for each pixel of this node and its childs
// if all layers less than or equals to the current are set to 1 in the stencil buffer
// draw the pixel and keep the current layer in the stencil buffer
// else
// do not draw the pixel but keep the current layer in the stencil buffer
glStencilFunc(GL_EQUAL, mask_layer_le, mask_layer_le);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
// draw (according to the stencil test func) this node and its childs
GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand();
groupCommand->init(0,_vertexZ);
renderer->addCommand(groupCommand);
renderer->pushGroup(groupCommand->getRenderQueueID());
CustomCommand* beforeVisitCmd = CustomCommand::getCommandPool().generateCommand();
beforeVisitCmd->init(0,_vertexZ);
beforeVisitCmd->func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this);
renderer->addCommand(beforeVisitCmd);
_stencil->visit();
CustomCommand* afterDrawStencilCmd = CustomCommand::getCommandPool().generateCommand();
afterDrawStencilCmd->init(0,_vertexZ);
afterDrawStencilCmd->func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this);
renderer->addCommand(afterDrawStencilCmd);
Node::visit();
///////////////////////////////////
// CLEANUP
// manually restore the stencil state
glStencilFunc(currentStencilFunc, currentStencilRef, currentStencilValueMask);
glStencilOp(currentStencilFail, currentStencilPassDepthFail, currentStencilPassDepthPass);
glStencilMask(currentStencilWriteMask);
if (!currentStencilEnabled)
{
glDisable(GL_STENCIL_TEST);
}
// we are done using this layer, decrement
layer--;
CustomCommand* afterVisitCmd = CustomCommand::getCommandPool().generateCommand();
afterVisitCmd->init(0,_vertexZ);
afterVisitCmd->func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this);
renderer->addCommand(afterVisitCmd);
renderer->popGroup();
}
Node* ClippingNode::getStencil() const
@ -432,4 +264,167 @@ void ClippingNode::setInverted(bool inverted)
_inverted = inverted;
}
void ClippingNode::onBeforeVisit()
{
///////////////////////////////////
// INIT
// increment the current layer
s_layer++;
// mask of the current layer (ie: for layer 3: 00000100)
GLint mask_layer = 0x1 << s_layer;
// mask of all layers less than the current (ie: for layer 3: 00000011)
GLint mask_layer_l = mask_layer - 1;
// mask of all layers less than or equal to the current (ie: for layer 3: 00000111)
_mask_layer_le = mask_layer | mask_layer_l;
// manually save the stencil state
_currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST);
glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)&_currentStencilWriteMask);
glGetIntegerv(GL_STENCIL_FUNC, (GLint *)&_currentStencilFunc);
glGetIntegerv(GL_STENCIL_REF, &_currentStencilRef);
glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)&_currentStencilValueMask);
glGetIntegerv(GL_STENCIL_FAIL, (GLint *)&_currentStencilFail);
glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)&_currentStencilPassDepthFail);
glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)&_currentStencilPassDepthPass);
// enable stencil use
glEnable(GL_STENCIL_TEST);
// check for OpenGL error while enabling stencil test
CHECK_GL_ERROR_DEBUG();
// all bits on the stencil buffer are readonly, except the current layer bit,
// this means that operation like glClear or glStencilOp will be masked with this value
glStencilMask(mask_layer);
// manually save the depth test state
glGetBooleanv(GL_DEPTH_WRITEMASK, &_currentDepthWriteMask);
// disable depth test while drawing the stencil
//glDisable(GL_DEPTH_TEST);
// disable update to the depth buffer while drawing the stencil,
// as the stencil is not meant to be rendered in the real scene,
// it should never prevent something else to be drawn,
// only disabling depth buffer update should do
glDepthMask(GL_FALSE);
///////////////////////////////////
// CLEAR STENCIL BUFFER
// manually clear the stencil buffer by drawing a fullscreen rectangle on it
// setup the stencil test func like this:
// for each pixel in the fullscreen rectangle
// never draw it into the frame buffer
// if not in inverted mode: set the current layer value to 0 in the stencil buffer
// if in inverted mode: set the current layer value to 1 in the stencil buffer
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP);
// draw a fullscreen solid rectangle to clear the stencil buffer
//ccDrawSolidRect(Point::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1));
drawFullScreenQuadClearStencil();
///////////////////////////////////
// DRAW CLIPPING STENCIL
// setup the stencil test func like this:
// for each pixel in the stencil node
// never draw it into the frame buffer
// if not in inverted mode: set the current layer value to 1 in the stencil buffer
// if in inverted mode: set the current layer value to 0 in the stencil buffer
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
glStencilOp(!_inverted ? GL_REPLACE : GL_ZERO, GL_KEEP, GL_KEEP);
// enable alpha test only if the alpha threshold < 1,
// indeed if alpha threshold == 1, every pixel will be drawn anyways
if (_alphaThreshold < 1) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
// manually save the alpha test state
_currentAlphaTestEnabled = glIsEnabled(GL_ALPHA_TEST);
glGetIntegerv(GL_ALPHA_TEST_FUNC, (GLint *)&_currentAlphaTestFunc);
glGetFloatv(GL_ALPHA_TEST_REF, &_currentAlphaTestRef);
// enable alpha testing
glEnable(GL_ALPHA_TEST);
// check for OpenGL error while enabling alpha test
CHECK_GL_ERROR_DEBUG();
// pixel will be drawn only if greater than an alpha threshold
glAlphaFunc(GL_GREATER, _alphaThreshold);
#else
// since glAlphaTest do not exists in OES, use a shader that writes
// pixel only if greater than an alpha threshold
GLProgram *program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
// set our alphaThreshold
program->use();
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
// we need to recursively apply this shader to all the nodes in the stencil node
// XXX: we should have a way to apply shader to all nodes without having to do this
setProgram(_stencil, program);
#endif
}
//Draw _stencil
}
void ClippingNode::onAfterDrawStencil()
{
// restore alpha test state
if (_alphaThreshold < 1)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
// manually restore the alpha test state
glAlphaFunc(_currentAlphaTestFunc, _currentAlphaTestRef);
if (!_currentAlphaTestEnabled)
{
glDisable(GL_ALPHA_TEST);
}
#else
// XXX: we need to find a way to restore the shaders of the stencil node and its childs
#endif
}
// restore the depth test state
glDepthMask(_currentDepthWriteMask);
//if (currentDepthTestEnabled) {
// glEnable(GL_DEPTH_TEST);
//}
///////////////////////////////////
// DRAW CONTENT
// setup the stencil test func like this:
// for each pixel of this node and its childs
// if all layers less than or equals to the current are set to 1 in the stencil buffer
// draw the pixel and keep the current layer in the stencil buffer
// else
// do not draw the pixel but keep the current layer in the stencil buffer
glStencilFunc(GL_EQUAL, _mask_layer_le, _mask_layer_le);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
// draw (according to the stencil test func) this node and its childs
}
void ClippingNode::onAfterVisit()
{
///////////////////////////////////
// CLEANUP
// manually restore the stencil state
glStencilFunc(_currentStencilFunc, _currentStencilRef, _currentStencilValueMask);
glStencilOp(_currentStencilFail, _currentStencilPassDepthFail, _currentStencilPassDepthPass);
glStencilMask(_currentStencilWriteMask);
if (!_currentStencilEnabled)
{
glDisable(GL_STENCIL_TEST);
}
// we are done using this layer, decrement
s_layer--;
}
NS_CC_END

View File

@ -120,6 +120,27 @@ protected:
Node* _stencil;
GLfloat _alphaThreshold;
bool _inverted;
protected:
//renderData and callback
void onBeforeVisit();
void onAfterDrawStencil();
void onAfterVisit();
GLboolean _currentStencilEnabled;
GLuint _currentStencilWriteMask;
GLenum _currentStencilFunc;
GLint _currentStencilRef;
GLuint _currentStencilValueMask;
GLenum _currentStencilFail;
GLenum _currentStencilPassDepthFail;
GLenum _currentStencilPassDepthPass;
GLboolean _currentDepthWriteMask;
GLboolean _currentAlphaTestEnabled;
GLenum _currentAlphaTestFunc;
GLclampf _currentAlphaTestRef;
GLint _mask_layer_le;
private:
CC_DISALLOW_COPY_AND_ASSIGN(ClippingNode);

View File

@ -33,7 +33,7 @@ Use any of these editors to generate BMFonts:
#ifndef __CCBITMAP_FONT_ATLAS_H__
#define __CCBITMAP_FONT_ATLAS_H__
#include "renderer/CCNewSpriteBatchNode.h"
#include "CCSpriteBatchNode.h"
#include "uthash.h"
#include <map>
#include <sstream>
@ -190,7 +190,7 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only)
@since v0.8
*/
class CC_DLL LabelBMFont : public NewSpriteBatchNode, public LabelProtocol
class CC_DLL LabelBMFont : public SpriteBatchNode, public LabelProtocol
{
public:
/**

View File

@ -42,6 +42,8 @@ THE SOFTWARE.
#include "CCProfiling.h"
#include "CCLayer.h"
#include "CCScene.h"
#include "CCRenderer.h"
#include "CCQuadCommand.h"
// external
#include "kazmath/GL/matrix.h"
@ -342,28 +344,32 @@ void SpriteBatchNode::reorderBatch(bool reorder)
_reorderChildDirty=reorder;
}
// draw
void SpriteBatchNode::draw(void)
void SpriteBatchNode::draw()
{
CC_PROFILER_START("CCSpriteBatchNode - draw");
// Optimization: Fast Dispatch
if( _textureAtlas->getTotalQuads() == 0 )
{
return;
}
CC_NODE_DRAW_SETUP();
for(const auto &child: _children) {
for(const auto &child: _children)
child->updateTransform();
}
GL::blendFunc( _blendFunc.src, _blendFunc.dst );
auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP);
_textureAtlas->drawQuads();
kmMat4 mv;
kmGLGetMatrix(KM_GL_MODELVIEW, &mv);
CC_PROFILER_STOP("CCSpriteBatchNode - draw");
QuadCommand* cmd = QuadCommand::getCommandPool().generateCommand();
cmd->init(0,
_vertexZ,
_textureAtlas->getTexture()->getName(),
shader,
_blendFunc,
_textureAtlas->getQuads(),
_textureAtlas->getTotalQuads(),
mv);
Director::getInstance()->getRenderer()->addCommand(cmd);
}
void SpriteBatchNode::increaseAtlasCapacity(void)

View File

@ -139,12 +139,10 @@ set(COCOS2D_SRC
platform/CCEGLViewProtocol.cpp
platform/CCFileUtils.cpp
../../external/edtaa3func/edtaa3func.cpp
renderer/CCNewSpriteBatchNode.cpp
renderer/CCCustomCommand.cpp
renderer/CCFrustum.cpp
renderer/CCGroupCommand.cpp
renderer/CCMaterialManager.cpp
renderer/CCNewClippingNode.cpp
renderer/CCQuadCommand.cpp
renderer/CCRenderCommand.cpp
renderer/CCRenderer.cpp

View File

@ -119,12 +119,10 @@ THE SOFTWARE.
#include "CCParticleSystemQuad.h"
// new renderer
#include "renderer/CCNewSpriteBatchNode.h"
#include "renderer/CCCustomCommand.h"
#include "renderer/CCFrustum.h"
#include "renderer/CCGroupCommand.h"
#include "renderer/CCMaterialManager.h"
#include "renderer/CCNewClippingNode.h"
#include "renderer/CCQuadCommand.h"
#include "renderer/CCRenderCommand.h"
#include "renderer/CCRenderCommandPool.h"

View File

@ -321,11 +321,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
<ClCompile Include="renderer\CCFrustum.cpp" />
<ClCompile Include="renderer\CCGroupCommand.cpp" />
<ClCompile Include="renderer\CCMaterialManager.cpp" />
<ClCompile Include="renderer\CCNewClippingNode.cpp" />
<ClCompile Include="renderer\CCNewRenderTexture.cpp" />
<ClCompile Include="renderer\CCNewSprite.cpp" />
<ClCompile Include="renderer\CCNewSpriteBatchNode.cpp" />
<ClCompile Include="renderer\CCNewTextureAtlas.cpp" />
<ClCompile Include="renderer\CCQuadCommand.cpp" />
<ClCompile Include="renderer\CCRenderCommand.cpp" />
<ClCompile Include="renderer\CCRenderer.cpp" />
@ -530,11 +525,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
<ClInclude Include="renderer\CCFrustum.h" />
<ClInclude Include="renderer\CCGroupCommand.h" />
<ClInclude Include="renderer\CCMaterialManager.h" />
<ClInclude Include="renderer\CCNewClippingNode.h" />
<ClInclude Include="renderer\CCNewRenderTexture.h" />
<ClInclude Include="renderer\CCNewSprite.h" />
<ClInclude Include="renderer\CCNewSpriteBatchNode.h" />
<ClInclude Include="renderer\CCNewTextureAtlas.h" />
<ClInclude Include="renderer\CCQuadCommand.h" />
<ClInclude Include="renderer\CCRenderCommand.h" />
<ClInclude Include="renderer\CCRenderCommandPool.h" />

View File

@ -586,21 +586,6 @@
<ClCompile Include="renderer\CCMaterialManager.cpp">
<Filter>renderer</Filter>
</ClCompile>
<ClCompile Include="renderer\CCNewClippingNode.cpp">
<Filter>renderer</Filter>
</ClCompile>
<ClCompile Include="renderer\CCNewRenderTexture.cpp">
<Filter>renderer</Filter>
</ClCompile>
<ClCompile Include="renderer\CCNewSprite.cpp">
<Filter>renderer</Filter>
</ClCompile>
<ClCompile Include="renderer\CCNewSpriteBatchNode.cpp">
<Filter>renderer</Filter>
</ClCompile>
<ClCompile Include="renderer\CCNewTextureAtlas.cpp">
<Filter>renderer</Filter>
</ClCompile>
<ClCompile Include="renderer\CCQuadCommand.cpp">
<Filter>renderer</Filter>
</ClCompile>
@ -1207,21 +1192,6 @@
<ClInclude Include="renderer\CCMaterialManager.h">
<Filter>renderer</Filter>
</ClInclude>
<ClInclude Include="renderer\CCNewClippingNode.h">
<Filter>renderer</Filter>
</ClInclude>
<ClInclude Include="renderer\CCNewRenderTexture.h">
<Filter>renderer</Filter>
</ClInclude>
<ClInclude Include="renderer\CCNewSprite.h">
<Filter>renderer</Filter>
</ClInclude>
<ClInclude Include="renderer\CCNewSpriteBatchNode.h">
<Filter>renderer</Filter>
</ClInclude>
<ClInclude Include="renderer\CCNewTextureAtlas.h">
<Filter>renderer</Filter>
</ClInclude>
<ClInclude Include="renderer\CCQuadCommand.h">
<Filter>renderer</Filter>
</ClInclude>

View File

@ -1,301 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCNewClippingNode.h"
#include "CCGroupCommand.h"
#include "CCRenderer.h"
#include "CCCustomCommand.h"
#include "CCShaderCache.h"
#include "CCDirector.h"
NS_CC_BEGIN
// store the current stencil layer (position in the stencil buffer),
// this will allow nesting up to n ClippingNode,
// where n is the number of bits of the stencil buffer.
static GLint layer = -1;
static void setProgram(Node *n, GLProgram *p)
{
n->setShaderProgram(p);
for(const auto &child : n->getChildren())
setProgram(child, p);
}
NewClippingNode *NewClippingNode::create()
{
NewClippingNode* pRet = new NewClippingNode();
if(pRet && pRet->init())
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
NewClippingNode *NewClippingNode::create(Node *pStencil)
{
NewClippingNode* pRet = new NewClippingNode();
if(pRet && pRet->init(pStencil))
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
NewClippingNode::~NewClippingNode()
{
}
NewClippingNode::NewClippingNode()
:ClippingNode()
{
currentStencilEnabled = GL_FALSE;
currentStencilWriteMask = ~0;
currentStencilFunc = GL_ALWAYS;
currentStencilRef = 0;
currentStencilValueMask = ~0;
currentStencilFail = GL_KEEP;
currentStencilPassDepthFail = GL_KEEP;
currentStencilPassDepthPass = GL_KEEP;
currentDepthWriteMask = GL_TRUE;
currentAlphaTestEnabled = GL_FALSE;
currentAlphaTestFunc = GL_ALWAYS;
currentAlphaTestRef = 1;
}
void NewClippingNode::visit()
{
//Add group command
Renderer* renderer = Director::getInstance()->getRenderer();
GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand();
groupCommand->init(0,_vertexZ);
renderer->addCommand(groupCommand);
renderer->pushGroup(groupCommand->getRenderQueueID());
CustomCommand* beforeVisitCmd = CustomCommand::getCommandPool().generateCommand();
beforeVisitCmd->init(0,_vertexZ);
beforeVisitCmd->func = CC_CALLBACK_0(NewClippingNode::beforeVisit, this);
renderer->addCommand(beforeVisitCmd);
_stencil->visit();
CustomCommand* afterDrawStencilCmd = CustomCommand::getCommandPool().generateCommand();
afterDrawStencilCmd->init(0,_vertexZ);
afterDrawStencilCmd->func = CC_CALLBACK_0(NewClippingNode::afterDrawStencil, this);
renderer->addCommand(afterDrawStencilCmd);
Node::visit();
CustomCommand* afterVisitCmd = CustomCommand::getCommandPool().generateCommand();
afterVisitCmd->init(0,_vertexZ);
afterVisitCmd->func = CC_CALLBACK_0(NewClippingNode::afterVisit, this);
renderer->addCommand(afterVisitCmd);
renderer->popGroup();
}
void NewClippingNode::beforeVisit()
{
///////////////////////////////////
// INIT
// increment the current layer
layer++;
// mask of the current layer (ie: for layer 3: 00000100)
GLint mask_layer = 0x1 << layer;
// mask of all layers less than the current (ie: for layer 3: 00000011)
GLint mask_layer_l = mask_layer - 1;
// mask of all layers less than or equal to the current (ie: for layer 3: 00000111)
mask_layer_le = mask_layer | mask_layer_l;
// manually save the stencil state
currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST);
glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)&currentStencilWriteMask);
glGetIntegerv(GL_STENCIL_FUNC, (GLint *)&currentStencilFunc);
glGetIntegerv(GL_STENCIL_REF, &currentStencilRef);
glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)&currentStencilValueMask);
glGetIntegerv(GL_STENCIL_FAIL, (GLint *)&currentStencilFail);
glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)&currentStencilPassDepthFail);
glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)&currentStencilPassDepthPass);
// enable stencil use
glEnable(GL_STENCIL_TEST);
// check for OpenGL error while enabling stencil test
CHECK_GL_ERROR_DEBUG();
// all bits on the stencil buffer are readonly, except the current layer bit,
// this means that operation like glClear or glStencilOp will be masked with this value
glStencilMask(mask_layer);
// manually save the depth test state
//currentDepthTestEnabled = glIsEnabled(GL_DEPTH_TEST);
glGetBooleanv(GL_DEPTH_WRITEMASK, &currentDepthWriteMask);
// disable depth test while drawing the stencil
//glDisable(GL_DEPTH_TEST);
// disable update to the depth buffer while drawing the stencil,
// as the stencil is not meant to be rendered in the real scene,
// it should never prevent something else to be drawn,
// only disabling depth buffer update should do
glDepthMask(GL_FALSE);
///////////////////////////////////
// CLEAR STENCIL BUFFER
// manually clear the stencil buffer by drawing a fullscreen rectangle on it
// setup the stencil test func like this:
// for each pixel in the fullscreen rectangle
// never draw it into the frame buffer
// if not in inverted mode: set the current layer value to 0 in the stencil buffer
// if in inverted mode: set the current layer value to 1 in the stencil buffer
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP);
// draw a fullscreen solid rectangle to clear the stencil buffer
//ccDrawSolidRect(Point::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1));
drawFullScreenQuadClearStencil();
///////////////////////////////////
// DRAW CLIPPING STENCIL
// setup the stencil test func like this:
// for each pixel in the stencil node
// never draw it into the frame buffer
// if not in inverted mode: set the current layer value to 1 in the stencil buffer
// if in inverted mode: set the current layer value to 0 in the stencil buffer
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
glStencilOp(!_inverted ? GL_REPLACE : GL_ZERO, GL_KEEP, GL_KEEP);
// enable alpha test only if the alpha threshold < 1,
// indeed if alpha threshold == 1, every pixel will be drawn anyways
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
// GLboolean currentAlphaTestEnabled = GL_FALSE;
// GLenum currentAlphaTestFunc = GL_ALWAYS;
// GLclampf currentAlphaTestRef = 1;
#endif
if (_alphaThreshold < 1) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
// manually save the alpha test state
currentAlphaTestEnabled = glIsEnabled(GL_ALPHA_TEST);
glGetIntegerv(GL_ALPHA_TEST_FUNC, (GLint *)&currentAlphaTestFunc);
glGetFloatv(GL_ALPHA_TEST_REF, &currentAlphaTestRef);
// enable alpha testing
glEnable(GL_ALPHA_TEST);
// check for OpenGL error while enabling alpha test
CHECK_GL_ERROR_DEBUG();
// pixel will be drawn only if greater than an alpha threshold
glAlphaFunc(GL_GREATER, _alphaThreshold);
#else
// since glAlphaTest do not exists in OES, use a shader that writes
// pixel only if greater than an alpha threshold
GLProgram *program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
// set our alphaThreshold
program->use();
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
// we need to recursively apply this shader to all the nodes in the stencil node
// XXX: we should have a way to apply shader to all nodes without having to do this
setProgram(_stencil, program);
#endif
}
//Draw _stencil
}
void NewClippingNode::afterDrawStencil()
{
// restore alpha test state
if (_alphaThreshold < 1)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
// manually restore the alpha test state
glAlphaFunc(currentAlphaTestFunc, currentAlphaTestRef);
if (!currentAlphaTestEnabled)
{
glDisable(GL_ALPHA_TEST);
}
#else
// XXX: we need to find a way to restore the shaders of the stencil node and its childs
#endif
}
// restore the depth test state
glDepthMask(currentDepthWriteMask);
//if (currentDepthTestEnabled) {
// glEnable(GL_DEPTH_TEST);
//}
///////////////////////////////////
// DRAW CONTENT
// setup the stencil test func like this:
// for each pixel of this node and its childs
// if all layers less than or equals to the current are set to 1 in the stencil buffer
// draw the pixel and keep the current layer in the stencil buffer
// else
// do not draw the pixel but keep the current layer in the stencil buffer
glStencilFunc(GL_EQUAL, mask_layer_le, mask_layer_le);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
// draw (according to the stencil test func) this node and its childs
}
void NewClippingNode::afterVisit()
{
///////////////////////////////////
// CLEANUP
// manually restore the stencil state
glStencilFunc(currentStencilFunc, currentStencilRef, currentStencilValueMask);
glStencilOp(currentStencilFail, currentStencilPassDepthFail, currentStencilPassDepthPass);
glStencilMask(currentStencilWriteMask);
if (!currentStencilEnabled)
{
glDisable(GL_STENCIL_TEST);
}
// we are done using this layer, decrement
layer--;
}
NS_CC_END

View File

@ -1,70 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __NewClippingNode_H_
#define __NewClippingNode_H_
#include "CCPlatformMacros.h"
#include "CCClippingNode.h"
NS_CC_BEGIN
class NewClippingNode : public ClippingNode
{
public:
static NewClippingNode* create();
static NewClippingNode* create(Node* pStencil);
virtual ~NewClippingNode();
virtual void visit() override;
protected:
NewClippingNode();
void beforeVisit();
void afterDrawStencil();
void afterVisit();
GLboolean currentStencilEnabled;
GLuint currentStencilWriteMask;
GLenum currentStencilFunc;
GLint currentStencilRef;
GLuint currentStencilValueMask;
GLenum currentStencilFail;
GLenum currentStencilPassDepthFail;
GLenum currentStencilPassDepthPass;
GLboolean currentDepthWriteMask;
GLboolean currentAlphaTestEnabled;
GLenum currentAlphaTestFunc;
GLclampf currentAlphaTestRef;
GLint mask_layer_le;
};
NS_CC_END
#endif //__NewClippingNode_H_

View File

@ -1,101 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCNewSpriteBatchNode.h"
#include "CCDirector.h"
#include "CCShaderCache.h"
#include "CCTextureCache.h"
#include "CCSprite.h"
#include "CCQuadCommand.h"
#include "CCRenderer.h"
NS_CC_BEGIN
NewSpriteBatchNode *NewSpriteBatchNode::createWithTexture(Texture2D *tex, int capacity)
{
NewSpriteBatchNode* batchNode = new NewSpriteBatchNode();
batchNode->initWithTexture(tex, capacity);
batchNode->autorelease();
return batchNode;
}
NewSpriteBatchNode *NewSpriteBatchNode::create(const std::string& fileImage, long capacity)
{
NewSpriteBatchNode* batchNode = new NewSpriteBatchNode();
batchNode->initWithFile(fileImage, capacity);
batchNode->autorelease();
return batchNode;
}
NewSpriteBatchNode::NewSpriteBatchNode()
:SpriteBatchNode()
{
}
NewSpriteBatchNode::~NewSpriteBatchNode()
{
}
bool NewSpriteBatchNode::init()
{
Texture2D* texture = new Texture2D();
texture->autorelease();
return this->initWithTexture(texture, 0);
}
void NewSpriteBatchNode::draw()
{
// Optimization: Fast Dispatch
if( _textureAtlas->getTotalQuads() == 0 )
{
return;
}
for(const auto &child: _children)
child->updateTransform();
// arrayMakeObjectsPerformSelector(_children, updateTransform, NewSprite*);
auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP);
kmMat4 mv;
kmGLGetMatrix(KM_GL_MODELVIEW, &mv);
QuadCommand* cmd = QuadCommand::getCommandPool().generateCommand();
cmd->init(0,
_vertexZ,
_textureAtlas->getTexture()->getName(),
shader,
_blendFunc,
_textureAtlas->getQuads(),
_textureAtlas->getTotalQuads(),
mv);
Director::getInstance()->getRenderer()->addCommand(cmd);
}
NS_CC_END

View File

@ -1,51 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCNewSpriteBatchNode_H_
#define __CCNewSpriteBatchNode_H_
#include "CCPlatformMacros.h"
#include "CCTexture2D.h"
#include "CCSpriteBatchNode.h"
NS_CC_BEGIN
class NewSpriteBatchNode : public SpriteBatchNode
{
static const int DEFAULT_CAPACITY = 29;
public:
static NewSpriteBatchNode* createWithTexture(Texture2D* tex, int capacity = DEFAULT_CAPACITY);
static NewSpriteBatchNode* create(const std::string& fileImage, long capacity = DEFAULT_CAPACITY);
void draw(void);
protected:
NewSpriteBatchNode();
virtual ~NewSpriteBatchNode();
bool init();
};
NS_CC_END
#endif //__CCNewSpriteBatchNode_H_

View File

@ -56,7 +56,7 @@ Armature *Armature::create()
}
Armature *Armature::create(const char *name)
Armature *Armature::create(const std::string& name)
{
Armature *armature = new Armature();
if (armature && armature->init(name))
@ -68,7 +68,7 @@ Armature *Armature::create(const char *name)
return nullptr;
}
Armature *Armature::create(const char *name, Bone *parentBone)
Armature *Armature::create(const std::string& name, Bone *parentBone)
{
Armature *armature = new Armature();
if (armature && armature->init(name, parentBone))
@ -105,7 +105,7 @@ bool Armature::init()
}
bool Armature::init(const char *name)
bool Armature::init(const std::string& name)
{
bool bRet = false;
do
@ -121,14 +121,12 @@ bool Armature::init(const char *name)
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
_name = name == nullptr ? "" : name;
_name = name;
ArmatureDataManager *armatureDataManager = ArmatureDataManager::getInstance();
if(_name.length() != 0)
if(!_name.empty())
{
_name = name;
AnimationData *animationData = armatureDataManager->getAnimationData(name);
CCASSERT(animationData, "AnimationData not exist! ");
@ -196,14 +194,14 @@ bool Armature::init(const char *name)
return bRet;
}
bool Armature::init(const char *name, Bone *parentBone)
bool Armature::init(const std::string& name, Bone *parentBone)
{
_parentBone = parentBone;
return init(name);
}
Bone *Armature::createBone(const char *boneName)
Bone *Armature::createBone(const std::string& boneName)
{
Bone *existedBone = getBone(boneName);
if(existedBone != nullptr)
@ -233,12 +231,12 @@ Bone *Armature::createBone(const char *boneName)
}
void Armature::addBone(Bone *bone, const char *parentName)
void Armature::addBone(Bone *bone, const std::string& parentName)
{
CCASSERT( bone != nullptr, "Argument must be non-nil");
CCASSERT(_boneDic.at(bone->getName()) == nullptr, "bone already added. It can't be added again");
if (nullptr != parentName)
if (!parentName.empty())
{
Bone *boneParent = _boneDic.at(parentName);
if (boneParent)
@ -278,13 +276,13 @@ void Armature::removeBone(Bone *bone, bool recursion)
}
Bone *Armature::getBone(const char *name) const
Bone *Armature::getBone(const std::string& name) const
{
return _boneDic.at(name);
}
void Armature::changeBoneParent(Bone *bone, const char *parentName)
void Armature::changeBoneParent(Bone *bone, const std::string& parentName)
{
CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!");
@ -294,7 +292,7 @@ void Armature::changeBoneParent(Bone *bone, const char *parentName)
bone->setParentBone(nullptr);
}
if (parentName != nullptr)
if (!parentName.empty())
{
Bone *boneParent = _boneDic.at(parentName);

View File

@ -84,9 +84,9 @@ public:
* @param name Armature will use the name to find the ArmatureData to initializes it.
* @return A initialized armature which is marked as "autorelease".
*/
static Armature *create(const char *name);
static Armature *create(const std::string& name);
static Armature *create(const char *name, Bone *parentBone);
static Armature *create(const std::string& name, Bone *parentBone);
public:
/**
@ -108,29 +108,29 @@ public:
* Init an armature with specified name
* @param name Armature name
*/
virtual bool init(const char *name);
virtual bool init(const std::string& name);
virtual bool init(const char *name, Bone *parentBone);
virtual bool init(const std::string& name, Bone *parentBone);
/**
* Add a Bone to this Armature,
*
* @param bone The Bone you want to add to Armature
* @param parentName The parent Bone's name you want to add to . If it's nullptr, then set Armature to its parent
*/
virtual void addBone(Bone *bone, const char *parentName);
virtual void addBone(Bone *bone, const std::string& parentName);
/**
* Get a bone with the specified name
*
* @param name The bone's name you want to get
*/
virtual Bone *getBone(const char *name) const;
virtual Bone *getBone(const std::string& name) const;
/**
* Change a bone's parent with the specified parent name.
*
* @param bone The bone you want to change parent
* @param parentName The new parent's name.
*/
virtual void changeBoneParent(Bone *bone, const char *parentName);
virtual void changeBoneParent(Bone *bone, const std::string& parentName);
/**
* Remove a bone with the specified name. If recursion it will also remove child Bone recursionly.
*
@ -247,7 +247,7 @@ protected:
* @js NA
* @lua NA
*/
Bone *createBone(const char *boneName );
Bone *createBone(const std::string& boneName );
protected:
ArmatureData *_armatureData;

View File

@ -164,11 +164,11 @@ float ArmatureAnimation::getSpeedScale() const
}
void ArmatureAnimation::play(const char *animationName, int durationTo, int loop)
void ArmatureAnimation::play(const std::string& animationName, int durationTo, int loop)
{
CCASSERT(_animationData, "_animationData can not be null");
_movementData = _animationData->getMovement(animationName);
_movementData = _animationData->getMovement(animationName.c_str());
CCASSERT(_movementData, "_movementData can not be null");
//! Get key frame count
@ -461,11 +461,11 @@ void ArmatureAnimation::setFrameEventCallFunc(Object *target, SEL_FrameEventCall
_frameEventCallFunc = callFunc;
}
void ArmatureAnimation::setMovementEventCallFunc(std::function<void(Armature *armature, MovementEventType movementType, const char *movementID)> listener)
void ArmatureAnimation::setMovementEventCallFunc(std::function<void(Armature *armature, MovementEventType movementType, const std::string& movementID)> listener)
{
_movementEventListener = listener;
}
void ArmatureAnimation::setFrameEventCallFunc(std::function<void(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex)> listener)
void ArmatureAnimation::setFrameEventCallFunc(std::function<void(Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex)> listener)
{
_frameEventListener = listener;
}
@ -477,7 +477,7 @@ void ArmatureAnimation::setUserObject(Object *pUserObject)
_userObject = pUserObject;
}
void ArmatureAnimation::frameEvent(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex)
void ArmatureAnimation::frameEvent(Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex)
{
if ((_frameEventTarget && _frameEventCallFunc) || _frameEventListener)
{
@ -492,7 +492,7 @@ void ArmatureAnimation::frameEvent(Bone *bone, const char *frameEventName, int o
}
void ArmatureAnimation::movementEvent(Armature *armature, MovementEventType movementType, const char *movementID)
void ArmatureAnimation::movementEvent(Armature *armature, MovementEventType movementType, const std::string& movementID)
{
if ((_movementEventTarget && _movementEventCallFunc) || _movementEventListener)
{

View File

@ -44,8 +44,8 @@ enum MovementEventType
class Armature;
class Bone;
typedef void (cocos2d::Object::*SEL_MovementEventCallFunc)(Armature *, MovementEventType, const char *);
typedef void (cocos2d::Object::*SEL_FrameEventCallFunc)(Bone *, const char *, int, int);
typedef void (cocos2d::Object::*SEL_MovementEventCallFunc)(Armature *, MovementEventType, const std::string&);
typedef void (cocos2d::Object::*SEL_FrameEventCallFunc)(Bone *, const std::string&, int, int);
#define movementEvent_selector(_SELECTOR) (cocostudio::SEL_MovementEventCallFunc)(&_SELECTOR)
#define frameEvent_selector(_SELECTOR) (cocostudio::SEL_FrameEventCallFunc)(&_SELECTOR)
@ -53,7 +53,7 @@ typedef void (cocos2d::Object::*SEL_FrameEventCallFunc)(Bone *, const char *, in
struct FrameEvent
{
Bone *bone;
const char *frameEventName;
std::string frameEventName;
int originFrameIndex;
int currentFrameIndex;
};
@ -62,7 +62,7 @@ struct MovementEvent
{
Armature *armature;
MovementEventType movementType;
const char *movementID;
std::string movementID;
};
class ArmatureAnimation : public ProcessBase
@ -123,7 +123,7 @@ public:
* loop = 0 : this animation is not loop
* loop > 0 : this animation is loop
*/
virtual void play(const char *animationName, int durationTo = -1, int loop = -1);
virtual void play(const std::string& animationName, int durationTo = -1, int loop = -1);
/**
* Play animation by index, the other param is the same to play.
@ -191,8 +191,8 @@ public:
*/
CC_DEPRECATED_ATTRIBUTE void setFrameEventCallFunc(cocos2d::Object *target, SEL_FrameEventCallFunc callFunc);
void setMovementEventCallFunc(std::function<void(Armature *armature, MovementEventType movementType, const char *movementID)> listener);
void setFrameEventCallFunc(std::function<void(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex)> listener);
void setMovementEventCallFunc(std::function<void(Armature *armature, MovementEventType movementType, const std::string& movementID)> listener);
void setFrameEventCallFunc(std::function<void(Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex)> listener);
virtual void setAnimationData(AnimationData *data)
{
@ -254,12 +254,12 @@ protected:
* @js NA
* @lua NA
*/
void frameEvent(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex);
void frameEvent(Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex);
/**
* Emit a movement event
*/
void movementEvent(Armature *armature, MovementEventType movementType, const char *movementID);
void movementEvent(Armature *armature, MovementEventType movementType, const std::string& movementID);
void updateMovementList();
@ -319,8 +319,8 @@ protected:
cocos2d::Object *_frameEventTarget;
std::function<void(Armature *armature, MovementEventType movementType, const char *movementID)> _movementEventListener;
std::function<void(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex)> _frameEventListener;
std::function<void(Armature *armature, MovementEventType movementType, const std::string& movementID)> _movementEventListener;
std::function<void(Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex)> _frameEventListener;
};
}

View File

@ -89,7 +89,7 @@ bool ArmatureDataManager::init()
return bRet;
}
void ArmatureDataManager::removeArmatureFileInfo(const char *configFilePath)
void ArmatureDataManager::removeArmatureFileInfo(const std::string& configFilePath)
{
if (RelativeData *data = getRelativeData(configFilePath))
{
@ -119,7 +119,7 @@ void ArmatureDataManager::removeArmatureFileInfo(const char *configFilePath)
}
void ArmatureDataManager::addArmatureData(const char *id, ArmatureData *armatureData, const char *configFilePath)
void ArmatureDataManager::addArmatureData(const std::string& id, ArmatureData *armatureData, const std::string& configFilePath)
{
if (RelativeData *data = getRelativeData(configFilePath))
{
@ -129,19 +129,19 @@ void ArmatureDataManager::addArmatureData(const char *id, ArmatureData *armature
_armarureDatas.insert(id, armatureData);
}
ArmatureData *ArmatureDataManager::getArmatureData(const char *id)
ArmatureData *ArmatureDataManager::getArmatureData(const std::string& id)
{
ArmatureData *armatureData = nullptr;
armatureData = (ArmatureData *)_armarureDatas.at(id);
return armatureData;
}
void ArmatureDataManager::removeArmatureData(const char *id)
void ArmatureDataManager::removeArmatureData(const std::string& id)
{
_armarureDatas.erase(id);
}
void ArmatureDataManager::addAnimationData(const char *id, AnimationData *animationData, const char *configFilePath)
void ArmatureDataManager::addAnimationData(const std::string& id, AnimationData *animationData, const std::string& configFilePath)
{
if (RelativeData *data = getRelativeData(configFilePath))
{
@ -151,19 +151,19 @@ void ArmatureDataManager::addAnimationData(const char *id, AnimationData *animat
_animationDatas.insert(id, animationData);
}
AnimationData *ArmatureDataManager::getAnimationData(const char *id)
AnimationData *ArmatureDataManager::getAnimationData(const std::string& id)
{
AnimationData *animationData = nullptr;
animationData = (AnimationData *)_animationDatas.at(id);
return animationData;
}
void ArmatureDataManager::removeAnimationData(const char *id)
void ArmatureDataManager::removeAnimationData(const std::string& id)
{
_animationDatas.erase(id);
}
void ArmatureDataManager::addTextureData(const char *id, TextureData *textureData, const char *configFilePath)
void ArmatureDataManager::addTextureData(const std::string& id, TextureData *textureData, const std::string& configFilePath)
{
if (RelativeData *data = getRelativeData(configFilePath))
{
@ -174,7 +174,7 @@ void ArmatureDataManager::addTextureData(const char *id, TextureData *textureDat
}
TextureData *ArmatureDataManager::getTextureData(const char *id)
TextureData *ArmatureDataManager::getTextureData(const std::string& id)
{
TextureData *textureData = nullptr;
textureData = (TextureData *)_textureDatas.at(id);
@ -182,12 +182,12 @@ TextureData *ArmatureDataManager::getTextureData(const char *id)
}
void ArmatureDataManager::removeTextureData(const char *id)
void ArmatureDataManager::removeTextureData(const std::string& id)
{
_textureDatas.erase(id);
}
void ArmatureDataManager::addArmatureFileInfo(const char *configFilePath)
void ArmatureDataManager::addArmatureFileInfo(const std::string& configFilePath)
{
addRelativeData(configFilePath);
@ -195,7 +195,7 @@ void ArmatureDataManager::addArmatureFileInfo(const char *configFilePath)
DataReaderHelper::getInstance()->addDataFromFile(configFilePath);
}
void ArmatureDataManager::addArmatureFileInfoAsync(const char *configFilePath, Object *target, SEL_SCHEDULE selector)
void ArmatureDataManager::addArmatureFileInfoAsync(const std::string& configFilePath, Object *target, SEL_SCHEDULE selector)
{
addRelativeData(configFilePath);
@ -203,7 +203,7 @@ void ArmatureDataManager::addArmatureFileInfoAsync(const char *configFilePath, O
DataReaderHelper::getInstance()->addDataFromFileAsync("", "", configFilePath, target, selector);
}
void ArmatureDataManager::addArmatureFileInfo(const char *imagePath, const char *plistPath, const char *configFilePath)
void ArmatureDataManager::addArmatureFileInfo(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath)
{
addRelativeData(configFilePath);
@ -212,7 +212,7 @@ void ArmatureDataManager::addArmatureFileInfo(const char *imagePath, const char
addSpriteFrameFromFile(plistPath, imagePath);
}
void ArmatureDataManager::addArmatureFileInfoAsync(const char *imagePath, const char *plistPath, const char *configFilePath, Object *target, SEL_SCHEDULE selector)
void ArmatureDataManager::addArmatureFileInfoAsync(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath, Object *target, SEL_SCHEDULE selector)
{
addRelativeData(configFilePath);
@ -221,7 +221,7 @@ void ArmatureDataManager::addArmatureFileInfoAsync(const char *imagePath, const
addSpriteFrameFromFile(plistPath, imagePath);
}
void ArmatureDataManager::addSpriteFrameFromFile(const char *plistPath, const char *imagePath, const char *configFilePath)
void ArmatureDataManager::addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath, const std::string& configFilePath)
{
if (RelativeData *data = getRelativeData(configFilePath))
{
@ -249,7 +249,7 @@ const cocos2d::Map<std::string, TextureData*>& ArmatureDataManager::getTextureDa
return _textureDatas;
}
void CCArmatureDataManager::addRelativeData(const char *configFilePath)
void CCArmatureDataManager::addRelativeData(const std::string& configFilePath)
{
if (_relativeDatas.find(configFilePath) == _relativeDatas.end())
{
@ -257,7 +257,7 @@ void CCArmatureDataManager::addRelativeData(const char *configFilePath)
}
}
RelativeData *CCArmatureDataManager::getRelativeData(const char* configFilePath)
RelativeData *CCArmatureDataManager::getRelativeData(const std::string& configFilePath)
{
return &_relativeDatas[configFilePath];
}

View File

@ -77,89 +77,89 @@ public:
* @param id The id of the armature data
* @param armatureData ArmatureData *
*/
void addArmatureData(const char *id, ArmatureData *armatureData, const char *configFilePath = "");
void addArmatureData(const std::string& id, ArmatureData *armatureData, const std::string& configFilePath = "");
/**
* @brief get armature data
* @param id the id of the armature data you want to get
* @return ArmatureData *
*/
ArmatureData *getArmatureData(const char *id);
ArmatureData *getArmatureData(const std::string& id);
/**
* @brief remove armature data
* @param id the id of the armature data you want to get
*/
void removeArmatureData(const char *id);
void removeArmatureData(const std::string& id);
/**
* @brief add animation data
* @param id the id of the animation data
* @return AnimationData *
*/
void addAnimationData(const char *id, AnimationData *animationData, const char *configFilePath = "");
void addAnimationData(const std::string& id, AnimationData *animationData, const std::string& configFilePath = "");
/**
* @brief get animation data from _animationDatas(Dictionary)
* @param id the id of the animation data you want to get
* @return AnimationData *
*/
AnimationData *getAnimationData(const char *id);
AnimationData *getAnimationData(const std::string& id);
/**
* @brief remove animation data
* @param id the id of the animation data
*/
void removeAnimationData(const char *id);
void removeAnimationData(const std::string& id);
/**
* @brief add texture data
* @param id the id of the texture data
* @return TextureData *
*/
void addTextureData(const char *id, TextureData *textureData, const char *configFilePath = "");
void addTextureData(const std::string& id, TextureData *textureData, const std::string& configFilePath = "");
/**
* @brief get texture data
* @param id the id of the texture data you want to get
* @return TextureData *
*/
TextureData *getTextureData(const char *id);
TextureData *getTextureData(const std::string& id);
/**
* @brief remove texture data
* @param id the id of the texture data you want to get
*/
void removeTextureData(const char *id);
void removeTextureData(const std::string& id);
/**
* @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager.
*/
void addArmatureFileInfo(const char *configFilePath);
void addArmatureFileInfo(const std::string& configFilePath);
/**
* @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager.
* It will load data in a new thread
*/
void addArmatureFileInfoAsync(const char *configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector);
void addArmatureFileInfoAsync(const std::string& configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector);
/**
* @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager.
*/
void addArmatureFileInfo(const char *imagePath, const char *plistPath, const char *configFilePath);
void addArmatureFileInfo(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath);
/**
* @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager.
* It will load data in a new thread
*/
void addArmatureFileInfoAsync(const char *imagePath, const char *plistPath, const char *configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector);
void addArmatureFileInfoAsync(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector);
/**
* @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name
*/
void addSpriteFrameFromFile(const char *plistPath, const char *imagePath, const char *configFilePath = "");
void addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath, const std::string& configFilePath = "");
virtual void removeArmatureFileInfo(const char *configFilePath);
virtual void removeArmatureFileInfo(const std::string& configFilePath);
/**
@ -173,8 +173,8 @@ public:
const cocos2d::Map<std::string, TextureData*>& getTextureDatas() const;
protected:
void addRelativeData(const char* configFilePath);
RelativeData *getRelativeData(const char* configFilePath);
void addRelativeData(const std::string& configFilePath);
RelativeData *getRelativeData(const std::string& configFilePath);
private:
/**
* @brief save amature datas

View File

@ -47,7 +47,7 @@ Bone *Bone::create()
}
Bone *Bone::create(const char *name)
Bone *Bone::create(const std::string& name)
{
Bone *pBone = new Bone();
@ -101,16 +101,13 @@ bool Bone::init()
}
bool Bone::init(const char *name)
bool Bone::init(const std::string& name)
{
bool bRet = false;
do
{
if(nullptr != name)
{
_name = name;
}
_name = name;
CC_SAFE_DELETE(_tweenData);
_tweenData = new FrameData();
@ -425,7 +422,7 @@ void Bone::changeDisplayByIndex(int index, bool force)
}
void Bone::changeDisplayByName(const char *name, bool force)
void Bone::changeDisplayByName(const std::string& name, bool force)
{
_displayManager->changeDisplayByName(name, force);
}

View File

@ -50,7 +50,7 @@ public:
* @param name If name is not null, then set name to the bone's name
* @return A initialized bone which is marked as "autorelease".
*/
static Bone *create(const char *name);
static Bone *create(const std::string& name);
public:
/**
@ -72,7 +72,7 @@ public:
* Initializes a Bone with the specified name
* @param name Bone's name.
*/
virtual bool init(const char *name);
virtual bool init(const std::string& name);
/**
* Add display and use displayData to init the display.
@ -92,7 +92,7 @@ public:
void removeDisplay(int index);
void changeDisplayByIndex(int index, bool force);
void changeDisplayByName(const char *name, bool force);
void changeDisplayByName(const std::string& name, bool force);
/**
* Add a child to this bone, and it will let this child call setParent(Bone *parent) function to set self to it's parent

View File

@ -59,8 +59,6 @@ static const char *A_MOVEMENT_SCALE = "sc";
static const char *A_MOVEMENT_DELAY = "dl";
static const char *A_DISPLAY_INDEX = "dI";
// static const char *A_VERT = "vert";
// static const char *A_FRAG = "frag";
static const char *A_PLIST = "plist";
static const char *A_PARENT = "parent";
@ -73,9 +71,8 @@ static const char *A_EVENT = "evt";
static const char *A_SOUND = "sd";
static const char *A_SOUND_EFFECT = "sdE";
static const char *A_TWEEN_EASING = "twE";
//static const char *A_EASING_PARAM_NUMBER = "twEPN";
static const char *A_EASING_PARAM = "twEP";
//static const char *A_TWEEN_ROTATE = "twR";
static const char *A_TWEEN_ROTATE = "twR";
static const char *A_IS_ARMATURE = "isArmature";
static const char *A_DISPLAY_TYPE = "displayType";
static const char *A_MOVEMENT = "mov";
@ -108,17 +105,12 @@ static const char *A_GREEN_OFFSET = "gM";
static const char *A_BLUE_OFFSET = "bM";
static const char *A_COLOR_TRANSFORM = "colorTransform";
static const char *A_TWEEN_FRAME = "tweenFrame";
//static const char *A_ROTATION = "rotation";
//static const char *A_USE_COLOR_INFO = "uci";
static const char *CONTOUR = "con";
static const char *CONTOUR_VERTEX = "con_vt";
//static const char *MOVEMENT_EVENT_FRAME = "movementEventFrame";
//static const char *SOUND_FRAME = "soundFrame";
static const char *FL_NAN = "NaN";
@ -262,14 +254,14 @@ DataReaderHelper::~DataReaderHelper()
_dataReaderHelper = nullptr;
}
void DataReaderHelper::addDataFromFile(const char *filePath)
void DataReaderHelper::addDataFromFile(const std::string& filePath)
{
/*
* Check if file is already added to ArmatureDataManager, if then return.
*/
for(unsigned int i = 0; i < _configFileList.size(); i++)
{
if (_configFileList[i].compare(filePath) == 0)
if (_configFileList[i] == filePath)
{
return;
}
@ -295,34 +287,38 @@ void DataReaderHelper::addDataFromFile(const char *filePath)
size_t startPos = filePathStr.find_last_of(".");
std::string str = &filePathStr[startPos];
// Read content from file
ssize_t size;
std::string fullPath = CCFileUtils::getInstance()->fullPathForFilename(filePath);
char *pFileContent = (char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size);
unsigned char *pTempContent = (unsigned char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size);
std::string contentStr = std::string((const char*)pTempContent, size);
DataInfo dataInfo;
dataInfo.filename = filePathStr;
dataInfo.asyncStruct = nullptr;
dataInfo.baseFilePath = basefilePath;
if (str.compare(".xml") == 0)
if (str == ".xml")
{
DataReaderHelper::addDataFromCache(pFileContent, &dataInfo);
DataReaderHelper::addDataFromCache(contentStr, &dataInfo);
}
else if(str.compare(".json") == 0 || str.compare(".ExportJson") == 0)
else if(str == ".json" || str == ".ExportJson")
{
DataReaderHelper::addDataFromJsonCache(pFileContent, &dataInfo);
DataReaderHelper::addDataFromJsonCache(contentStr, &dataInfo);
}
free(pFileContent);
free(pTempContent);
}
void DataReaderHelper::addDataFromFileAsync(const char *imagePath, const char *plistPath, const char *filePath, Object *target, SEL_SCHEDULE selector)
void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const std::string& plistPath, const std::string& filePath, Object *target, SEL_SCHEDULE selector)
{
/*
* Check if file is already added to ArmatureDataManager, if then return.
*/
for(unsigned int i = 0; i < _configFileList.size(); i++)
{
if (_configFileList[i].compare(filePath) == 0)
if (_configFileList[i] == filePath)
{
if (target && selector)
{
@ -400,11 +396,11 @@ void DataReaderHelper::addDataFromFileAsync(const char *imagePath, const char *p
// XXX fileContent is being leaked
data->fileContent = (char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size);
if (str.compare(".xml") == 0)
if (str == ".xml")
{
data->configType = DragonBone_XML;
}
else if(str.compare(".json") == 0 || str.compare(".ExportJson") == 0)
else if(str == ".json" || str == ".ExportJson")
{
data->configType = CocoStudio_JSON;
}
@ -478,7 +474,7 @@ void DataReaderHelper::addDataAsyncCallBack(float dt)
}
void DataReaderHelper::removeConfigFile(const char *configFile)
void DataReaderHelper::removeConfigFile(const std::string& configFile)
{
std::vector<std::string>::iterator it = _configFileList.end();
for (std::vector<std::string>::iterator i = _configFileList.begin(); i != _configFileList.end(); i++)
@ -497,10 +493,10 @@ void DataReaderHelper::removeConfigFile(const char *configFile)
void DataReaderHelper::addDataFromCache(const char *pFileContent, DataInfo *dataInfo)
void DataReaderHelper::addDataFromCache(const std::string& pFileContent, DataInfo *dataInfo)
{
tinyxml2::XMLDocument document;
document.Parse(pFileContent);
document.Parse(pFileContent.c_str());
tinyxml2::XMLElement *root = document.RootElement();
CCASSERT(root, "XML error or XML is empty.");
@ -600,7 +596,7 @@ ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML
std::string parentNameStr = parentName;
while (parentXML)
{
if (parentNameStr.compare(parentXML->Attribute(A_NAME)) == 0)
if (parentNameStr == parentXML->Attribute(A_NAME))
{
break;
}
@ -745,7 +741,7 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML
if(_easing != nullptr)
{
std::string str = _easing;
if(str.compare(FL_NAN) != 0)
if(str != FL_NAN)
{
if( movementXML->QueryIntAttribute(A_TWEEN_EASING, &(tweenEasing)) == tinyxml2::XML_SUCCESS)
{
@ -782,7 +778,7 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML
while (parentXml)
{
if (parentName.compare(parentXml->Attribute(A_NAME)) == 0)
if (parentName == parentXml->Attribute(A_NAME))
{
break;
}
@ -921,8 +917,8 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxml2::XMLElement *parentFrameXml, BoneData *boneData, DataInfo *dataInfo)
{
float x, y, scale_x, scale_y, skew_x, skew_y = 0;
int duration, displayIndex, zOrder, tweenEasing, blendType = 0;
float x = 0, y = 0, scale_x = 0, scale_y = 0, skew_x = 0, skew_y = 0, tweenRotate = 0;
int duration = 0, displayIndex = 0, zOrder = 0, tweenEasing = 0, blendType = 0;
FrameData *frameData = new FrameData();
@ -1005,6 +1001,10 @@ FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxm
{
frameData->zOrder = zOrder;
}
if( frameXML->QueryFloatAttribute(A_TWEEN_ROTATE, &tweenRotate) == tinyxml2::XML_SUCCESS )
{
frameData->tweenRotate = tweenRotate;
}
if ( frameXML->QueryIntAttribute(A_BLEND_TYPE, &blendType) == tinyxml2::XML_SUCCESS )
{
switch (blendType)
@ -1070,7 +1070,7 @@ FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxm
if(_easing != nullptr)
{
std::string str = _easing;
if(str.compare(FL_NAN) != 0)
if(str != FL_NAN)
{
if( frameXML->QueryIntAttribute(A_TWEEN_EASING, &(tweenEasing)) == tinyxml2::XML_SUCCESS)
{
@ -1184,10 +1184,10 @@ ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML, D
void DataReaderHelper::addDataFromJsonCache(const char *fileContent, DataInfo *dataInfo)
void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, DataInfo *dataInfo)
{
JsonDictionary json;
json.initWithDescription(fileContent);
json.initWithDescription(fileContent.c_str());
dataInfo->contentScale = json.getItemFloatValue(CONTENT_SCALE, 1);

View File

@ -108,12 +108,12 @@ public:
*/
~DataReaderHelper();
void addDataFromFile(const char *filePath);
void addDataFromFileAsync(const char *imagePath, const char *plistPath, const char *filePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector);
void addDataFromFile(const std::string& filePath);
void addDataFromFileAsync(const std::string& imagePath, const std::string& plistPath, const std::string& filePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector);
void addDataAsyncCallBack(float dt);
void removeConfigFile(const char *configFile);
void removeConfigFile(const std::string& configFile);
public:
/**
@ -122,7 +122,7 @@ public:
*
* @param xmlPath The cache of the xml
*/
static void addDataFromCache(const char *pFileContent, DataInfo *dataInfo = nullptr);
static void addDataFromCache(const std::string& pFileContent, DataInfo *dataInfo = nullptr);
@ -154,7 +154,7 @@ public:
static ContourData *decodeContour(tinyxml2::XMLElement *contourXML, DataInfo *dataInfo);
public:
static void addDataFromJsonCache(const char *fileContent, DataInfo *dataInfo = nullptr);
static void addDataFromJsonCache(const std::string& fileContent, DataInfo *dataInfo = nullptr);
static ArmatureData *decodeArmature(JsonDictionary &json, DataInfo *dataInfo);
static BoneData *decodeBone(JsonDictionary &json, DataInfo *dataInfo);

View File

@ -123,8 +123,8 @@ void BaseData::subtract(BaseData *from, BaseData *to, bool limit)
if (to->tweenRotate)
{
skewX += to->tweenRotate;
skewY -= to->tweenRotate;
skewX += to->tweenRotate * M_PI * 2;
skewY -= to->tweenRotate * M_PI * 2;
}
}
@ -142,7 +142,7 @@ Color4B BaseData::getColor()
return Color4B(r, g, b, a);
}
const char *DisplayData::changeDisplayToTexture(const char *displayName)
const std::string& DisplayData::changeDisplayToTexture(const std::string& displayName)
{
// remove .xxx
std::string textureName = displayName;
@ -241,7 +241,7 @@ void ArmatureData::addBoneData(BoneData *boneData)
boneDataDic.insert(boneData->name, boneData);
}
BoneData *ArmatureData::getBoneData(const char *boneName)
BoneData *ArmatureData::getBoneData(const std::string& boneName)
{
return static_cast<BoneData*>(boneDataDic.at(boneName));
}
@ -343,7 +343,7 @@ void MovementData::addMovementBoneData(MovementBoneData *movBoneData)
movBoneDataDic.insert(movBoneData->name, movBoneData);
}
MovementBoneData *MovementData::getMovementBoneData(const char *boneName)
MovementBoneData *MovementData::getMovementBoneData(const std::string& boneName)
{
return movBoneDataDic.at(boneName);
}
@ -364,7 +364,7 @@ void AnimationData::addMovement(MovementData *movData)
movementNames.push_back(movData->name);
}
MovementData *AnimationData::getMovement(const char *movementName)
MovementData *AnimationData::getMovement(const std::string& movementName)
{
return movementDataDic.at(movementName);
}

View File

@ -136,7 +136,7 @@ class DisplayData : public cocos2d::Object
public:
CC_CREATE_NO_PARAM_NO_INIT(DisplayData)
static const char *changeDisplayToTexture(const char *displayName);
static const std::string& changeDisplayToTexture(const std::string& displayName);
public:
/**
* @js ctor
@ -279,7 +279,7 @@ public:
bool init();
void addBoneData(BoneData *boneData);
BoneData *getBoneData(const char *boneName);
BoneData *getBoneData(const std::string& boneName);
public:
std::string name;
cocos2d::Map<std::string, BoneData*> boneDataDic;
@ -403,7 +403,7 @@ public:
~MovementData(void);
void addMovementBoneData(MovementBoneData *movBoneData);
MovementBoneData *getMovementBoneData(const char *boneName);
MovementBoneData *getMovementBoneData(const std::string& boneName);
public:
std::string name;
int duration; //! the frames this movement will last
@ -435,7 +435,7 @@ public:
/**
* @brief save movment bone data
* @key const char *
* @key const std::string&
* @value MovementBoneData *
*/
cocos2d::Map<std::string, MovementBoneData*> movBoneDataDic;
@ -465,7 +465,7 @@ public:
~AnimationData(void);
void addMovement(MovementData *movData);
MovementData *getMovement(const char *movementName);
MovementData *getMovement(const std::string& movementName);
ssize_t getMovementCount();
public:
std::string name;

View File

@ -243,7 +243,7 @@ void DisplayManager::changeDisplayByIndex(int index, bool force)
setCurrentDecorativeDisplay(decoDisplay);
}
void CCDisplayManager::changeDisplayByName(const char *name, bool force)
void CCDisplayManager::changeDisplayByName(const std::string& name, bool force)
{
for (int i = 0; i<_decoDisplayList.size(); i++)
{

View File

@ -85,7 +85,7 @@ public:
*/
void changeDisplayByIndex(int index, bool force);
void changeDisplayByName(const char *name, bool force);
void changeDisplayByName(const std::string& name, bool force);
cocos2d::Node *getDisplayRenderNode() const;
DisplayType getDisplayRenderNodeType() const;

View File

@ -51,7 +51,7 @@ Skin *Skin::create()
return nullptr;
}
Skin *Skin::createWithSpriteFrameName(const char *pszSpriteFrameName)
Skin *Skin::createWithSpriteFrameName(const std::string& pszSpriteFrameName)
{
Skin *skin = new Skin();
if(skin && skin->initWithSpriteFrameName(pszSpriteFrameName))
@ -63,7 +63,7 @@ Skin *Skin::createWithSpriteFrameName(const char *pszSpriteFrameName)
return nullptr;
}
Skin *Skin::create(const char *pszFileName)
Skin *Skin::create(const std::string& pszFileName)
{
Skin *skin = new Skin();
if(skin && skin->initWithFile(pszFileName))

View File

@ -34,8 +34,8 @@ class Skin : public cocos2d::Sprite
{
public:
static Skin *create();
static Skin *createWithSpriteFrameName(const char *pszSpriteFrameName);
static Skin *create(const char *pszFileName);
static Skin *createWithSpriteFrameName(const std::string& pszSpriteFrameName);
static Skin *create(const std::string& pszFileName);
public:
/**
* @js ctor

View File

@ -47,7 +47,7 @@ void SpriteFrameCacheHelper::purge()
_spriteFrameCacheHelper = nullptr;
}
void SpriteFrameCacheHelper::addSpriteFrameFromFile(const char *plistPath, const char *imagePath)
void SpriteFrameCacheHelper::addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath)
{
CCSpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath, imagePath);
}

View File

@ -47,7 +47,7 @@ public:
/**
* @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name
*/
void addSpriteFrameFromFile(const char *plistPath, const char *imagePath);
void addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath);
private:
SpriteFrameCacheHelper();

View File

@ -42,7 +42,7 @@ namespace spine {
/**
Draws a skeleton.
*/
class CCSkeleton: public cocos2d::NodeRGBA, public cocos2d::BlendProtocol {
class CCSkeleton: public cocos2d::Node, public cocos2d::BlendProtocol {
public:
spSkeleton* skeleton;
spBone* rootBone;

@ -1 +1 @@
Subproject commit 3b8073deee86beb5ede81a24e3ccbfef711bfa41
Subproject commit daff147b1ff3d3754cb014c4e9c575676dea68b9

View File

@ -14,7 +14,8 @@ LOCAL_SRC_FILES := ScriptingCore.cpp \
jsb_opengl_functions.cpp \
jsb_opengl_manual.cpp \
jsb_opengl_registration.cpp \
../../auto-generated/js-bindings/jsb_cocos2dx_auto.cpp
../../auto-generated/js-bindings/jsb_cocos2dx_auto.cpp \
../../auto-generated/js-bindings/jsb_cocos2dx_spine_auto.cpp
LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT
@ -24,7 +25,10 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/../../../audio/include \
$(LOCAL_PATH)/../../../storage \
$(LOCAL_PATH)/../../auto-generated/js-bindings \
$(LOCAL_PATH)/../../../../extensions
$(LOCAL_PATH)/../../../../extensions \
$(LOCAL_PATH)/../../../editor-support/spine \
$(LOCAL_PATH)/../../../editor-support
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/../../auto-generated/js-bindings \

View File

@ -12,6 +12,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_auto.cpp" />
<ClCompile Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_spine_auto.cpp" />
<ClCompile Include="..\cocos2d_specifics.cpp" />
<ClCompile Include="..\jsb_opengl_functions.cpp" />
<ClCompile Include="..\jsb_opengl_manual.cpp" />
@ -23,6 +24,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_auto.hpp" />
<ClInclude Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_spine_auto.hpp" />
<ClInclude Include="..\cocos2d_specifics.hpp" />
<ClInclude Include="..\jsb_helper.h" />
<ClInclude Include="..\jsb_opengl_functions.h" />

View File

@ -41,6 +41,9 @@
<ClCompile Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_auto.cpp">
<Filter>generated</Filter>
</ClCompile>
<ClCompile Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_spine_auto.cpp">
<Filter>generated</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\cocos2d_specifics.hpp">
@ -79,6 +82,9 @@
<ClInclude Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_auto.hpp">
<Filter>generated</Filter>
</ClInclude>
<ClInclude Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_spine_auto.hpp">
<Filter>generated</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_auto_api.js">

View File

@ -1 +1 @@
b633b49d700c36e38f74509d09c52255e2300ecf
e240eefd2a238e3ae31d78fd78cade02ff8344fb

View File

@ -535,20 +535,18 @@ std::string TestAnimationEvent::title() const
{
return "Test Armature Animation Event";
}
void TestAnimationEvent::animationEvent(Armature *armature, MovementEventType movementType, const char *movementID)
void TestAnimationEvent::animationEvent(Armature *armature, MovementEventType movementType, const std::string& movementID)
{
std::string id = movementID;
if (movementType == LOOP_COMPLETE)
{
if (id.compare("Fire") == 0)
if (movementID == "Fire")
{
ActionInterval *actionToRight = MoveTo::create(2, Point(VisibleRect::right().x - 50, VisibleRect::right().y));
armature->stopAllActions();
armature->runAction(Sequence::create(actionToRight, CallFunc::create( CC_CALLBACK_0(TestAnimationEvent::callback1, this)), nullptr));
armature->getAnimation()->play("Walk");
}
else if (id.compare("FireMax") == 0)
else if (movementID == "FireMax")
{
ActionInterval *actionToLeft = MoveTo::create(2, Point(VisibleRect::left().x + 50, VisibleRect::left().y));
armature->stopAllActions();
@ -596,9 +594,9 @@ std::string TestFrameEvent::title() const
{
return "Test Frame Event";
}
void TestFrameEvent::onFrameEvent(Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex)
void TestFrameEvent::onFrameEvent(Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex)
{
CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt, currentFrameIndex);
CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt.c_str(), currentFrameIndex);
if (!_gridNode->getActionByTag(FRAME_EVENT_ACTION_TAG) || _gridNode->getActionByTag(FRAME_EVENT_ACTION_TAG)->isDone())
{
@ -778,9 +776,9 @@ std::string TestColliderDetector::title() const
{
return "Test Collider Detector";
}
void TestColliderDetector::onFrameEvent(Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex)
void TestColliderDetector::onFrameEvent(Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex)
{
CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt, currentFrameIndex);
CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt.c_str(), currentFrameIndex);
/*
* originFrameIndex is the frame index editted in Action Editor

View File

@ -153,7 +153,7 @@ public:
virtual void onEnter();
virtual std::string title() const override;
void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const char *movementID);
void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID);
void callback1();
void callback2();
@ -166,7 +166,7 @@ class TestFrameEvent : public ArmatureTestLayer
public:
virtual void onEnter();
virtual std::string title() const override;
void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex);
void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex);
void checkAction(float dt);
protected:
NodeGrid* _gridNode;
@ -215,7 +215,7 @@ public:
virtual void draw();
virtual void update(float delta);
void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex);
void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex);
void initWorld();
@ -273,7 +273,7 @@ public:
virtual void update(float delta);
virtual void draw();
void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex);
void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex);
void initWorld() {};
cocostudio::Armature *armature;

View File

@ -229,7 +229,7 @@ NewSpriteBatchTest::NewSpriteBatchTest()
touchListener->onTouchesEnded = CC_CALLBACK_2(NewSpriteBatchTest::onTouchesEnded, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
auto BatchNode = NewSpriteBatchNode::create("Images/grossini_dance_atlas.png", 50);
auto BatchNode = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 50);
addChild(BatchNode, 0, kTagSpriteBatchNode);
}
@ -259,7 +259,7 @@ void NewSpriteBatchTest::onTouchesEnded(const std::vector<Touch *> &touches, Eve
void NewSpriteBatchTest::addNewSpriteWithCoords(Point p)
{
auto BatchNode = static_cast<NewSpriteBatchNode*>( getChildByTag(kTagSpriteBatchNode) );
auto BatchNode = static_cast<SpriteBatchNode*>( getChildByTag(kTagSpriteBatchNode) );
int idx = (int) (CCRANDOM_0_1() * 1400 / 100);
int x = (idx%5) * 85;
@ -295,7 +295,7 @@ NewClippingNodeTest::NewClippingNodeTest()
{
auto s = Director::getInstance()->getWinSize();
auto clipper = NewClippingNode::create();
auto clipper = ClippingNode::create();
clipper->setTag( kTagClipperNode );
clipper->setContentSize( Size(200, 200) );
clipper->setAnchorPoint( Point(0.5, 0.5) );

View File

@ -8,6 +8,7 @@
#include "jsb_cocos2dx_builder_auto.hpp"
#include "jsb_cocos2dx_studio_auto.hpp"
#include "jsb_cocos2dx_gui_auto.hpp"
#include "jsb_cocos2dx_spine_auto.hpp"
#include "extension/jsb_cocos2dx_extension_manual.h"
#include "cocostudio/jsb_cocos2dx_studio_manual.h"
#include "gui/jsb_cocos2dx_gui_manual.h"
@ -70,6 +71,8 @@ bool AppDelegate::applicationDidFinishLaunching()
sc->addRegisterCallback(register_all_cocos2dx_studio);
sc->addRegisterCallback(register_all_cocos2dx_studio_manual);
sc->addRegisterCallback(register_all_cocos2dx_spine);
sc->start();
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)

View File

@ -5,6 +5,7 @@
#include "ScriptingCore.h"
#include "jsb_cocos2dx_auto.hpp"
#include "jsb_cocos2dx_extension_auto.hpp"
#include "jsb_cocos2dx_spine_auto.hpp"
#include "cocos2d_specifics.hpp"
#include "extension/jsb_cocos2dx_extension_manual.h"
#include "chipmunk/js_bindings_chipmunk_registration.h"
@ -40,6 +41,7 @@ bool AppDelegate::applicationDidFinishLaunching()
sc->addRegisterCallback(register_all_cocos2dx_extension);
sc->addRegisterCallback(register_cocos2dx_js_extensions);
sc->addRegisterCallback(register_all_cocos2dx_extension_manual);
sc->addRegisterCallback(register_all_cocos2dx_spine);
sc->addRegisterCallback(jsb_register_chipmunk);
sc->addRegisterCallback(JSB_register_opengl);
sc->addRegisterCallback(jsb_register_system);

View File

@ -24,4 +24,4 @@ include $(BUILD_SHARED_LIBRARY)
$(call import-module,scripting/javascript/bindings)
$(call import-module,scripting/javascript/bindings/extension)
$(call import-module,scripting/javascript/bindings/chipmunk)
$(call import-module,scripting/javascript/bindings/localstorage)
$(call import-module,scripting/javascript/bindings/localstorage)

View File

@ -0,0 +1,40 @@
[cocos2dx_spine]
prefix = cocos2dx_spine
target_namespace = cc
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
android_flags = -D_SIZE_T_DEFINED_
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
clang_flags = -nostdinc -x c++ -std=c++11
cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/gui -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath/include -I%(cocosdir)s/extensions -I%(cocosdir)s/external -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s
cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT
cxxgenerator_headers =
# extra arguments for clang
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s
headers = %(cocosdir)s/cocos/editor-support/spine/spine-cocos2dx.h
skip = CCSkeleton::[createWithData],
CCSkeletonAnimation::[createWithData]
classes = CCSkeleton CCSkeletonAnimation
remove_prefix = CC
classes_have_no_parents =
base_classes_to_skip =
abstract_classes =
script_control_cpp =
rename_functions =
rename_classes =

View File

@ -92,4 +92,7 @@ echo "Generating bindings for cocos2dx_gui..."
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_gui.ini -s cocos2dx_gui -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_gui_auto
echo "Generating bindings for cocos2dx_studio..."
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_studio.ini -s cocos2dx_studio -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_studio_auto
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_studio.ini -s cocos2dx_studio -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_studio_auto
echo "Generating bindings for cocos2dx_spine..."
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_spine.ini -s cocos2dx_spine -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_spine_auto

View File

@ -35,7 +35,7 @@ classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* M
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
# functions from all classes.
skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule getPosition$],
skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule getPosition$ setContentSize setAnchorPoint],
Sprite::[getQuad getBlendFunc ^setPosition$ setBlendFunc],
SpriteBatchNode::[getBlendFunc setBlendFunc getDescendants],
MotionStreak::[getBlendFunc setBlendFunc draw update],