mirror of https://github.com/axmolengine/axmol.git
Merge pull request #807 from dumganhar/gles20
issue #1056: Updated SpriteTest.
This commit is contained in:
commit
98ba5ef203
|
@ -39,7 +39,7 @@ THE SOFTWARE.
|
||||||
// externals
|
// externals
|
||||||
#include "kazmath/GL/matrix.h"
|
#include "kazmath/GL/matrix.h"
|
||||||
|
|
||||||
#if CC_COCOSNODE_RENDER_SUBPIXEL
|
#if CC_NODE_RENDER_SUBPIXEL
|
||||||
#define RENDER_IN_SUBPIXEL
|
#define RENDER_IN_SUBPIXEL
|
||||||
#else
|
#else
|
||||||
#define RENDER_IN_SUBPIXEL (int)
|
#define RENDER_IN_SUBPIXEL (int)
|
||||||
|
|
|
@ -43,24 +43,25 @@ __arr__++)
|
||||||
|
|
||||||
I found that it's not work in C++. So it keep what it's look like in version 1.0.0-rc3. ---By Bin
|
I found that it's not work in C++. So it keep what it's look like in version 1.0.0-rc3. ---By Bin
|
||||||
*/
|
*/
|
||||||
#define CCARRAY_FOREACH(__array__, __object__) \
|
#define CCARRAY_FOREACH(__array__, __object__) \
|
||||||
if (__array__ && __array__->data->num > 0) \
|
if ((__array__) && (__array__)->data->num > 0) \
|
||||||
for(CCObject** arr = __array__->data->arr, **end = __array__->data->arr + __array__->data->num-1; \
|
for(CCObject** arr = (__array__)->data->arr, **end = (__array__)->data->arr + (__array__)->data->num-1; \
|
||||||
arr <= end && ((__object__ = *arr) != NULL/* || true*/); \
|
arr <= end && (((__object__) = *arr) != NULL/* || true*/); \
|
||||||
arr++)
|
arr++)
|
||||||
|
|
||||||
#define CCARRAY_FOREACH_REVERSE(__array__, __object__) \
|
#define CCARRAY_FOREACH_REVERSE(__array__, __object__) \
|
||||||
if (__array__ && __array__->data->num > 0) \
|
if ((__array__) && (__array__)->data->num > 0) \
|
||||||
for(CCObject** arr = __array__->data->arr + __array__->data->num-1, **end = __array__->data->arr; \
|
for(CCObject** arr = (__array__)->data->arr + (__array__)->data->num-1, **end = (__array__)->data->arr; \
|
||||||
arr >= end && ((__object__ = *arr) != NULL/* || true*/); \
|
arr >= end && (((__object__) = *arr) != NULL/* || true*/); \
|
||||||
arr--)
|
arr--)
|
||||||
|
|
||||||
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
|
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
|
||||||
#define CCARRAY_VERIFY_TYPE(__array__, __type__) \
|
#define CCARRAY_VERIFY_TYPE(__array__, __type__) \
|
||||||
do { \
|
do { \
|
||||||
if (__array__ && __array__->data->num > 0) \
|
if ((__array__) && (__array__)->data->num > 0) \
|
||||||
for(CCObject** arr = __array__->data->arr, **end = __array__->data->arr + __array__->data->num-1; arr <= end; arr++) \
|
for(CCObject** arr = (__array__)->data->arr, \
|
||||||
CCAssert(dynamic_cast<__type__>(*arr), "element type is wrong!"); \
|
**end = (__array__)->data->arr + (__array__)->data->num-1; arr <= end; arr++) \
|
||||||
|
CCAssert(dynamic_cast<__type__>(*arr), "element type is wrong!"); \
|
||||||
} while(false)
|
} while(false)
|
||||||
#else
|
#else
|
||||||
#define CCARRAY_VERIFY_TYPE(__array__, __type__) void(0)
|
#define CCARRAY_VERIFY_TYPE(__array__, __type__) void(0)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -155,6 +155,9 @@ public:
|
||||||
*/
|
*/
|
||||||
static CCSprite* spriteWithFile(const char *pszFileName, const CCRect& rect);
|
static CCSprite* spriteWithFile(const char *pszFileName, const CCRect& rect);
|
||||||
|
|
||||||
|
/** Creates an sprite.
|
||||||
|
*/
|
||||||
|
static CCSprite* node();
|
||||||
public:
|
public:
|
||||||
CCSprite(void);
|
CCSprite(void);
|
||||||
virtual ~CCSprite(void);
|
virtual ~CCSprite(void);
|
||||||
|
@ -213,74 +216,74 @@ public:
|
||||||
The rect used will be the size of the texture.
|
The rect used will be the size of the texture.
|
||||||
The offset will be (0,0).
|
The offset will be (0,0).
|
||||||
*/
|
*/
|
||||||
bool initWithTexture(CCTexture2D *pTexture);
|
virtual bool initWithTexture(CCTexture2D *pTexture);
|
||||||
|
|
||||||
/** Initializes an sprite with a texture and a rect.
|
/** Initializes an sprite with a texture and a rect.
|
||||||
The offset will be (0,0).
|
The offset will be (0,0).
|
||||||
*/
|
*/
|
||||||
bool initWithTexture(CCTexture2D *pTexture, const CCRect& rect);
|
virtual bool initWithTexture(CCTexture2D *pTexture, const CCRect& rect);
|
||||||
|
|
||||||
/** Initializes an sprite with a texture and a rect in points, optionally rotated.
|
/** Initializes an sprite with a texture and a rect in points, optionally rotated.
|
||||||
The offset will be (0,0).
|
The offset will be (0,0).
|
||||||
IMPORTANT: This is the designated initializer.
|
IMPORTANT: This is the designated initializer.
|
||||||
*/
|
*/
|
||||||
bool initWithTexture(CCTexture2D *pTexture, const CCRect& rect, bool rotated);
|
virtual bool initWithTexture(CCTexture2D *pTexture, const CCRect& rect, bool rotated);
|
||||||
|
|
||||||
// Initializes an sprite with an sprite frame.
|
// Initializes an sprite with an sprite frame.
|
||||||
bool initWithSpriteFrame(CCSpriteFrame *pSpriteFrame);
|
virtual bool initWithSpriteFrame(CCSpriteFrame *pSpriteFrame);
|
||||||
|
|
||||||
/** Initializes an sprite with an sprite frame name.
|
/** Initializes an sprite with an sprite frame name.
|
||||||
An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name.
|
An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name.
|
||||||
If the CCSpriteFrame doesn't exist it will raise an exception.
|
If the CCSpriteFrame doesn't exist it will raise an exception.
|
||||||
@since v0.9
|
@since v0.9
|
||||||
*/
|
*/
|
||||||
bool initWithSpriteFrameName(const char *pszSpriteFrameName);
|
virtual bool initWithSpriteFrameName(const char *pszSpriteFrameName);
|
||||||
|
|
||||||
/** Initializes an sprite with an image filename.
|
/** Initializes an sprite with an image filename.
|
||||||
The rect used will be the size of the image.
|
The rect used will be the size of the image.
|
||||||
The offset will be (0,0).
|
The offset will be (0,0).
|
||||||
*/
|
*/
|
||||||
bool initWithFile(const char *pszFilename);
|
virtual bool initWithFile(const char *pszFilename);
|
||||||
|
|
||||||
/** Initializes an sprite with an image filename, and a rect.
|
/** Initializes an sprite with an image filename, and a rect.
|
||||||
The offset will be (0,0).
|
The offset will be (0,0).
|
||||||
*/
|
*/
|
||||||
bool initWithFile(const char *pszFilename, const CCRect& rect);
|
virtual bool initWithFile(const char *pszFilename, const CCRect& rect);
|
||||||
|
|
||||||
// BatchNode methods
|
// BatchNode methods
|
||||||
|
|
||||||
/** updates the quad according the the rotation, position, scale values. */
|
/** updates the quad according the the rotation, position, scale values. */
|
||||||
void updateTransform(void);
|
virtual void updateTransform(void);
|
||||||
|
|
||||||
/** updates the texture rect of the CCSprite in points.
|
/** updates the texture rect of the CCSprite in points.
|
||||||
It will call setTextureRect:rotated:untrimmedSize with rotated = NO, and utrimmedSize = rect.size.
|
It will call setTextureRect:rotated:untrimmedSize with rotated = NO, and utrimmedSize = rect.size.
|
||||||
*/
|
*/
|
||||||
void setTextureRect(const CCRect& rect);
|
virtual void setTextureRect(const CCRect& rect);
|
||||||
|
|
||||||
/** set the texture rect, rectRotated and untrimmed size of the CCSprite in points.
|
/** set the texture rect, rectRotated and untrimmed size of the CCSprite in points.
|
||||||
It will update the texture coordinates and the vertex rectangle.
|
It will update the texture coordinates and the vertex rectangle.
|
||||||
*/
|
*/
|
||||||
void setTextureRect(const CCRect& rect, bool rotated, const CCSize& untrimmedSize);
|
virtual void setTextureRect(const CCRect& rect, bool rotated, const CCSize& untrimmedSize);
|
||||||
|
|
||||||
/** set the vertex rect.
|
/** set the vertex rect.
|
||||||
It will be called internally by setTextureRect. Useful if you want to create 2x images from SD images in Retina Display.
|
It will be called internally by setTextureRect. Useful if you want to create 2x images from SD images in Retina Display.
|
||||||
Do not call it manually. Use setTextureRect instead.
|
Do not call it manually. Use setTextureRect instead.
|
||||||
*/
|
*/
|
||||||
void setVertexRect(const CCRect& rect);
|
virtual void setVertexRect(const CCRect& rect);
|
||||||
|
|
||||||
// Frames
|
// Frames
|
||||||
|
|
||||||
/** sets a new display frame to the CCSprite. */
|
/** sets a new display frame to the CCSprite. */
|
||||||
void setDisplayFrame(CCSpriteFrame *pNewFrame);
|
virtual void setDisplayFrame(CCSpriteFrame *pNewFrame);
|
||||||
|
|
||||||
/** returns whether or not a CCSpriteFrame is being displayed */
|
/** returns whether or not a CCSpriteFrame is being displayed */
|
||||||
bool isFrameDisplayed(CCSpriteFrame *pFrame);
|
virtual bool isFrameDisplayed(CCSpriteFrame *pFrame);
|
||||||
|
|
||||||
/** returns the current displayed frame. */
|
/** returns the current displayed frame. */
|
||||||
CCSpriteFrame* displayFrame(void);
|
virtual CCSpriteFrame* displayFrame(void);
|
||||||
|
|
||||||
CCSpriteBatchNode* getBatchNode(void);
|
virtual CCSpriteBatchNode* getBatchNode(void);
|
||||||
void setBatchNode(CCSpriteBatchNode *pobSpriteBatchNode);
|
virtual void setBatchNode(CCSpriteBatchNode *pobSpriteBatchNode);
|
||||||
|
|
||||||
// Animation
|
// Animation
|
||||||
|
|
||||||
|
@ -288,7 +291,7 @@ public:
|
||||||
The animation name will be get from the CCAnimationCache
|
The animation name will be get from the CCAnimationCache
|
||||||
@since v0.99.5
|
@since v0.99.5
|
||||||
*/
|
*/
|
||||||
void setDisplayFrameWithAnimationName(const char *animationName, int frameIndex);
|
virtual void setDisplayFrameWithAnimationName(const char *animationName, int frameIndex);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setTextureCoords(CCRect rect);
|
virtual void setTextureCoords(CCRect rect);
|
||||||
|
|
|
@ -216,15 +216,14 @@ void CCAnimationCache::addAnimationsWithDictionary(CCDictionary* dictionary)
|
||||||
if( properties )
|
if( properties )
|
||||||
{
|
{
|
||||||
version = atoi(valueForKey("format", properties));
|
version = atoi(valueForKey("format", properties));
|
||||||
}
|
CCArray* spritesheets = (CCArray*)properties->objectForKey("spritesheets");
|
||||||
|
|
||||||
CCArray* spritesheets = (CCArray*)properties->objectForKey("spritesheets");
|
CCObject* pObj = NULL;
|
||||||
|
CCARRAY_FOREACH(spritesheets, pObj)
|
||||||
CCObject* pObj = NULL;
|
{
|
||||||
CCARRAY_FOREACH(spritesheets, pObj)
|
CCString* name = (CCString*)(pObj);
|
||||||
{
|
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(name->c_str());
|
||||||
CCString* name = (CCString*)(pObj);
|
}
|
||||||
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(name->c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (version) {
|
switch (version) {
|
||||||
|
|
|
@ -137,6 +137,20 @@ CCSprite* CCSprite::spriteWithSpriteFrameName(const char *pszSpriteFrameName)
|
||||||
return spriteWithSpriteFrame(pFrame);
|
return spriteWithSpriteFrame(pFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCSprite* CCSprite::node()
|
||||||
|
{
|
||||||
|
CCSprite *pSprite = new CCSprite();
|
||||||
|
if (pSprite && pSprite->init())
|
||||||
|
{
|
||||||
|
pSprite->autorelease();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CC_SAFE_DELETE(pSprite);
|
||||||
|
}
|
||||||
|
return pSprite;
|
||||||
|
}
|
||||||
|
|
||||||
bool CCSprite::init(void)
|
bool CCSprite::init(void)
|
||||||
{
|
{
|
||||||
return initWithTexture(NULL, CCRectZero);
|
return initWithTexture(NULL, CCRectZero);
|
||||||
|
@ -505,7 +519,7 @@ void CCSprite::updateTransform(void)
|
||||||
|
|
||||||
// recursively iterate over children
|
// recursively iterate over children
|
||||||
if( m_bHasChildren ) {
|
if( m_bHasChildren ) {
|
||||||
arrayMakeObjectsPerformSelectorWithType(m_pChildren, &CCSprite::updateTransform, CCSprite);
|
arrayMakeObjectsPerformSelectorWithType(m_pChildren, &CCSprite::updateTransform, CCSprite*);
|
||||||
}
|
}
|
||||||
#if CC_SPRITE_DEBUG_DRAW
|
#if CC_SPRITE_DEBUG_DRAW
|
||||||
// draw bounding box
|
// draw bounding box
|
||||||
|
@ -701,7 +715,7 @@ void CCSprite::sortAllChildren()
|
||||||
|
|
||||||
if ( m_pobBatchNode)
|
if ( m_pobBatchNode)
|
||||||
{
|
{
|
||||||
arrayMakeObjectsPerformSelectorWithType(m_pChildren, &CCSprite::sortAllChildren, CCSprite);
|
arrayMakeObjectsPerformSelectorWithType(m_pChildren, &CCSprite::sortAllChildren, CCSprite*);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bReorderChildDirty = false;
|
m_bReorderChildDirty = false;
|
||||||
|
|
|
@ -98,10 +98,12 @@ bool CCSpriteBatchNode::initWithTexture(CCTexture2D *tex, unsigned int capacity)
|
||||||
updateBlendFunc();
|
updateBlendFunc();
|
||||||
|
|
||||||
// no lazy alloc in this node
|
// no lazy alloc in this node
|
||||||
m_pChildren = CCArray::array();
|
m_pChildren = new CCArray();
|
||||||
m_pobDescendants = CCArray::array();
|
m_pChildren->initWithCapacity(capacity);
|
||||||
m_pChildren->retain();
|
|
||||||
m_pobDescendants->retain();
|
m_pobDescendants = new CCArray();
|
||||||
|
m_pobDescendants->initWithCapacity(capacity);
|
||||||
|
|
||||||
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor));
|
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -169,10 +171,10 @@ void CCSpriteBatchNode::visit(void)
|
||||||
void CCSpriteBatchNode::addChild(CCNode *child, int zOrder, int tag)
|
void CCSpriteBatchNode::addChild(CCNode *child, int zOrder, int tag)
|
||||||
{
|
{
|
||||||
CCAssert(child != NULL, "child should not be null");
|
CCAssert(child != NULL, "child should not be null");
|
||||||
|
CCAssert(dynamic_cast<CCSprite*>(child) != NULL, "CCSpriteBatchNode only supports CCSprites as children");
|
||||||
CCSprite *pSprite = (CCSprite*)(child);
|
CCSprite *pSprite = (CCSprite*)(child);
|
||||||
// check CCSprite is using the same texture id
|
// check CCSprite is using the same texture id
|
||||||
CCAssert(pSprite->getTexture()->getName() == m_pobTextureAtlas->getTexture()->getName(), "");
|
CCAssert(pSprite->getTexture()->getName() == m_pobTextureAtlas->getTexture()->getName(), "CCSprite is not using the same texture id");
|
||||||
|
|
||||||
CCNode::addChild(child, zOrder, tag);
|
CCNode::addChild(child, zOrder, tag);
|
||||||
|
|
||||||
|
@ -231,18 +233,7 @@ void CCSpriteBatchNode::removeChildAtIndex(unsigned int uIndex, bool bDoCleanup)
|
||||||
void CCSpriteBatchNode::removeAllChildrenWithCleanup(bool bCleanup)
|
void CCSpriteBatchNode::removeAllChildrenWithCleanup(bool bCleanup)
|
||||||
{
|
{
|
||||||
// Invalidate atlas index. issue #569
|
// Invalidate atlas index. issue #569
|
||||||
if (m_pChildren && m_pChildren->count() > 0)
|
arrayMakeObjectsPerformSelectorWithObject(m_pobDescendants, &CCSprite::setBatchNode, NULL, CCSprite*);
|
||||||
{
|
|
||||||
CCObject* pObject = NULL;
|
|
||||||
CCARRAY_FOREACH(m_pChildren, pObject)
|
|
||||||
{
|
|
||||||
CCSprite* pChild = (CCSprite*) pObject;
|
|
||||||
if (pChild)
|
|
||||||
{
|
|
||||||
removeSpriteFromAtlas(pChild);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CCNode::removeAllChildrenWithCleanup(bCleanup);
|
CCNode::removeAllChildrenWithCleanup(bCleanup);
|
||||||
|
|
||||||
|
@ -280,7 +271,7 @@ void CCSpriteBatchNode::sortAllChildren()
|
||||||
if (m_pChildren->count() > 0)
|
if (m_pChildren->count() > 0)
|
||||||
{
|
{
|
||||||
//first sort all children recursively based on zOrder
|
//first sort all children recursively based on zOrder
|
||||||
arrayMakeObjectsPerformSelectorWithType(m_pChildren, &CCSprite::sortAllChildren, CCSprite);
|
arrayMakeObjectsPerformSelectorWithType(m_pChildren, &CCSprite::sortAllChildren, CCSprite*);
|
||||||
|
|
||||||
int index=0;
|
int index=0;
|
||||||
|
|
||||||
|
@ -403,7 +394,7 @@ void CCSpriteBatchNode::draw(void)
|
||||||
|
|
||||||
CC_NODE_DRAW_SETUP();
|
CC_NODE_DRAW_SETUP();
|
||||||
|
|
||||||
arrayMakeObjectsPerformSelectorWithType(m_pChildren, &CCSprite::updateTransform, CCSprite);
|
arrayMakeObjectsPerformSelectorWithType(m_pChildren, &CCSprite::updateTransform, CCSprite*);
|
||||||
|
|
||||||
ccGLBlendFunc( m_blendFunc.src, m_blendFunc.dst );
|
ccGLBlendFunc( m_blendFunc.src, m_blendFunc.dst );
|
||||||
|
|
||||||
|
@ -561,57 +552,41 @@ unsigned int CCSpriteBatchNode::atlasIndexForChild(CCSprite *pobSprite, int nZ)
|
||||||
|
|
||||||
// add child helper
|
// add child helper
|
||||||
|
|
||||||
void CCSpriteBatchNode::insertChild(CCSprite *pobSprite, unsigned int uIndex)
|
void CCSpriteBatchNode::insertChild(CCSprite *pSprite, unsigned int uIndex)
|
||||||
{
|
{
|
||||||
pobSprite->setBatchNode(this);
|
pSprite->setBatchNode(this);
|
||||||
pobSprite->setAtlasIndex(uIndex);
|
pSprite->setAtlasIndex(uIndex);
|
||||||
pobSprite->setDirty(true);
|
pSprite->setDirty(true);
|
||||||
|
|
||||||
if (m_pobTextureAtlas->getTotalQuads() == m_pobTextureAtlas->getCapacity())
|
if(m_pobTextureAtlas->getTotalQuads() == m_pobTextureAtlas->getCapacity())
|
||||||
{
|
{
|
||||||
increaseAtlasCapacity();
|
increaseAtlasCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
ccV3F_C4B_T2F_Quad quad = pobSprite->getQuad();
|
ccV3F_C4B_T2F_Quad quad = pSprite->getQuad();
|
||||||
m_pobTextureAtlas->insertQuad(&quad, uIndex);
|
m_pobTextureAtlas->insertQuad(&quad, uIndex);
|
||||||
|
|
||||||
m_pobDescendants->insertObject(pobSprite, uIndex);
|
ccArray *descendantsData = m_pobDescendants->data;
|
||||||
|
|
||||||
// update indices
|
ccArrayInsertObjectAtIndex(descendantsData, pSprite, uIndex);
|
||||||
unsigned int i = 0;
|
|
||||||
if (m_pobDescendants && m_pobDescendants->count() > 0)
|
|
||||||
{
|
|
||||||
CCObject* pObject = NULL;
|
|
||||||
CCARRAY_FOREACH(m_pobDescendants, pObject)
|
|
||||||
{
|
|
||||||
CCSprite* pChild = (CCSprite*) pObject;
|
|
||||||
if (pChild)
|
|
||||||
{
|
|
||||||
if (i > uIndex)
|
|
||||||
{
|
|
||||||
pChild->setAtlasIndex(pChild->getAtlasIndex() + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
++i;
|
// update indices
|
||||||
}
|
unsigned int i = uIndex+1;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// add children recursively
|
CCSprite* pChild = NULL;
|
||||||
CCArray *pChildren = pobSprite->getChildren();
|
for(; i<descendantsData->num; i++){
|
||||||
if (pChildren && pChildren->count() > 0)
|
pChild = (CCSprite*)descendantsData->arr[i];
|
||||||
{
|
pChild->setAtlasIndex(pChild->getAtlasIndex() + 1);
|
||||||
CCObject* pObject = NULL;
|
}
|
||||||
CCARRAY_FOREACH(pChildren, pObject)
|
|
||||||
{
|
// add children recursively
|
||||||
CCSprite* pChild = (CCSprite*) pObject;
|
CCObject* pObj = NULL;
|
||||||
if (pChild)
|
CCARRAY_FOREACH(pSprite->getChildren(), pObj)
|
||||||
{
|
{
|
||||||
unsigned int uIndex = atlasIndexForChild(pChild, pChild->getZOrder());
|
pChild = (CCSprite*)pObj;
|
||||||
insertChild(pChild, uIndex);
|
unsigned int idx = atlasIndexForChild(pChild, pChild->getZOrder());
|
||||||
}
|
insertChild(pChild, idx);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// addChild helper, faster than insertChild
|
// addChild helper, faster than insertChild
|
||||||
|
@ -754,18 +729,17 @@ CCSpriteBatchNode * CCSpriteBatchNode::addSpriteWithoutQuad(CCSprite*child, unsi
|
||||||
|
|
||||||
// XXX: optimize with a binary search
|
// XXX: optimize with a binary search
|
||||||
int i=0;
|
int i=0;
|
||||||
if (m_pobDescendants && m_pobDescendants->count() > 0)
|
|
||||||
|
CCObject* pObject = NULL;
|
||||||
|
CCARRAY_FOREACH(m_pobDescendants, pObject)
|
||||||
{
|
{
|
||||||
CCObject* pObject = NULL;
|
CCSprite* pChild = (CCSprite*) pObject;
|
||||||
CCARRAY_FOREACH(m_pobDescendants, pObject)
|
if (pChild && (pChild->getAtlasIndex() >= z))
|
||||||
{
|
{
|
||||||
CCSprite* pChild = (CCSprite*) pObject;
|
++i;
|
||||||
if (pChild && (pChild->getAtlasIndex() >= z))
|
|
||||||
{
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pobDescendants->insertObject(child, i);
|
m_pobDescendants->insertObject(child, i);
|
||||||
|
|
||||||
// IMPORTANT: Call super, and not self. Avoid adding it to the texture atlas array
|
// IMPORTANT: Call super, and not self. Avoid adding it to the texture atlas array
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
20e32b9a1ad61e6bf3e179cc5e1cd7d7bdec57fa
|
45fa60a7892453b6d2be3554738d829d7743303e
|
|
@ -483,7 +483,6 @@ public:
|
||||||
SpriteBatchNodeReorderOneChild();
|
SpriteBatchNodeReorderOneChild();
|
||||||
void reorderSprite(ccTime dt);
|
void reorderSprite(ccTime dt);
|
||||||
virtual std::string title();
|
virtual std::string title();
|
||||||
virtual std::string subtitle();
|
|
||||||
private:
|
private:
|
||||||
CCSpriteBatchNode *m_pBatchNode;
|
CCSpriteBatchNode *m_pBatchNode;
|
||||||
CCSprite *m_pReorderSprite;
|
CCSprite *m_pReorderSprite;
|
||||||
|
|
|
@ -805,7 +805,7 @@ TMXIsoZorder::TMXIsoZorder()
|
||||||
addChild(map, 0, kTagTileMap);
|
addChild(map, 0, kTagTileMap);
|
||||||
|
|
||||||
CCSize s = map->getContentSize();
|
CCSize s = map->getContentSize();
|
||||||
////----UXLOG("ContentSize: %f, %f", s.width,s.height);
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
||||||
map->setPosition(ccp(-s.width/2,0));
|
map->setPosition(ccp(-s.width/2,0));
|
||||||
|
|
||||||
m_tamara = CCSprite::spriteWithFile(s_pPathSister1);
|
m_tamara = CCSprite::spriteWithFile(s_pPathSister1);
|
||||||
|
@ -1011,7 +1011,7 @@ TMXOrthoVertexZ::TMXOrthoVertexZ()
|
||||||
// can use any CCSprite and it will work OK.
|
// can use any CCSprite and it will work OK.
|
||||||
CCTMXLayer* layer = map->layerNamed("trees");
|
CCTMXLayer* layer = map->layerNamed("trees");
|
||||||
m_tamara = layer->tileAt(ccp(0,11));
|
m_tamara = layer->tileAt(ccp(0,11));
|
||||||
CCLOG("%@ vertexZ: %f", m_tamara, m_tamara->getVertexZ());
|
CCLOG("%p vertexZ: %f", m_tamara, m_tamara->getVertexZ());
|
||||||
m_tamara->retain();
|
m_tamara->retain();
|
||||||
|
|
||||||
CCActionInterval* move = CCMoveBy::actionWithDuration(10, ccpMult( ccp(400,450), 1/CC_CONTENT_SCALE_FACTOR()));
|
CCActionInterval* move = CCMoveBy::actionWithDuration(10, ccpMult( ccp(400,450), 1/CC_CONTENT_SCALE_FACTOR()));
|
||||||
|
|
Loading…
Reference in New Issue