mirror of https://github.com/axmolengine/axmol.git
commit
52f22d0b4c
|
@ -1 +1 @@
|
|||
66ec3b51e58b6b9c5c67d6dc67275582cbfd7cc9
|
||||
62c66f19d8d60722b497aa7a840912e528314ed5
|
|
@ -1 +1 @@
|
|||
3bf906169e90a3e1c2fd3ee256c43d4581150d49
|
||||
25c7b001405ec665fae2e7479ffe269f0cc0ee4f
|
|
@ -73,7 +73,6 @@ sprite_nodes/CCSprite.cpp \
|
|||
sprite_nodes/CCSpriteBatchNode.cpp \
|
||||
sprite_nodes/CCSpriteFrame.cpp \
|
||||
sprite_nodes/CCSpriteFrameCache.cpp \
|
||||
sprite_nodes/CCSpriteSheet.cpp \
|
||||
support/CCArray.cpp \
|
||||
support/CCProfiling.cpp \
|
||||
support/CCPointExtension.cpp \
|
||||
|
|
|
@ -193,7 +193,6 @@ void CCNode::setRotation(float newRotation)
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
/// scale getter
|
||||
float CCNode::getScale(void)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2010 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
|
|
@ -141,19 +141,19 @@ namespace cocos2d {
|
|||
CC_PROPERTY(CCPoint, m_tPosition, Position)
|
||||
CC_PROPERTY(CCPoint, m_tPositionInPixels, PositionInPixels)
|
||||
|
||||
/** The X skew angle of the node in degrees.
|
||||
This angle describes the shear distortion in the X direction.
|
||||
Thus, it is the angle between the Y axis and the left edge of the shape
|
||||
The default skewX angle is 0. Positive values distort the node in a CW direction.
|
||||
*/
|
||||
CC_PROPERTY(float, m_fSkewX, SkewX);
|
||||
/** The X skew angle of the node in degrees.
|
||||
This angle describes the shear distortion in the X direction.
|
||||
Thus, it is the angle between the Y axis and the left edge of the shape
|
||||
The default skewX angle is 0. Positive values distort the node in a CW direction.
|
||||
*/
|
||||
CC_PROPERTY(float, m_fSkewX, SkewX)
|
||||
|
||||
/** The Y skew angle of the node in degrees.
|
||||
This angle describes the shear distortion in the Y direction.
|
||||
Thus, it is the angle between the X axis and the bottom edge of the shape
|
||||
The default skewY angle is 0. Positive values distort the node in a CCW direction.
|
||||
*/
|
||||
CC_PROPERTY(float, m_fSkewY, SkewY);
|
||||
/** The Y skew angle of the node in degrees.
|
||||
This angle describes the shear distortion in the Y direction.
|
||||
Thus, it is the angle between the X axis and the bottom edge of the shape
|
||||
The default skewY angle is 0. Positive values distort the node in a CCW direction.
|
||||
*/
|
||||
CC_PROPERTY(float, m_fSkewY, SkewY)
|
||||
|
||||
CC_PROPERTY_READONLY(CCArray*, m_pChildren, Children)
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
@ -36,8 +37,6 @@ THE SOFTWARE.
|
|||
namespace cocos2d {
|
||||
|
||||
class CCSpriteBatchNode;
|
||||
class CCSpriteSheet;
|
||||
class CCSpriteSheetInternalOnly;
|
||||
class CCSpriteFrame;
|
||||
class CCAnimation;
|
||||
class CCRect;
|
||||
|
@ -64,9 +63,11 @@ typedef enum {
|
|||
CC_HONOR_PARENT_TRANSFORM_ROTATE = 1 << 1,
|
||||
//! Scale with it's parent
|
||||
CC_HONOR_PARENT_TRANSFORM_SCALE = 1 << 2,
|
||||
//! Skew with it's parent
|
||||
CC_HONOR_PARENT_TRANSFORM_SKEW = 1 << 3,
|
||||
|
||||
//! All possible transformation enabled. Default value.
|
||||
CC_HONOR_PARENT_TRANSFORM_ALL = CC_HONOR_PARENT_TRANSFORM_TRANSLATE | CC_HONOR_PARENT_TRANSFORM_ROTATE | CC_HONOR_PARENT_TRANSFORM_SCALE,
|
||||
CC_HONOR_PARENT_TRANSFORM_ALL = CC_HONOR_PARENT_TRANSFORM_TRANSLATE | CC_HONOR_PARENT_TRANSFORM_ROTATE | CC_HONOR_PARENT_TRANSFORM_SCALE | CC_HONOR_PARENT_TRANSFORM_SKEW,
|
||||
|
||||
} ccHonorParentTransform;
|
||||
|
||||
|
@ -195,8 +196,6 @@ public:
|
|||
*/
|
||||
static CCSprite* spriteWithBatchNode(CCSpriteBatchNode *batchNode, CCRect rect);
|
||||
|
||||
static CCSprite* spriteWithSpriteSheet(CCSpriteSheetInternalOnly *pSpriteSheet, CCRect rect);
|
||||
|
||||
public:
|
||||
bool init(void);
|
||||
virtual ~CCSprite(void);
|
||||
|
@ -213,6 +212,8 @@ public:
|
|||
virtual void setPosition(CCPoint pos);
|
||||
virtual void setPositionInPixels(CCPoint pos);
|
||||
virtual void setRotation(float fRotation);
|
||||
virtual void setSkewX(float sx);
|
||||
virtual void setSkewY(float sy);
|
||||
virtual void setScaleX(float fScaleX);
|
||||
virtual void setScaleY(float fScaleY);
|
||||
virtual void setScale(float fScale);
|
||||
|
@ -288,11 +289,10 @@ public:
|
|||
*/
|
||||
bool initWithFile(const char *pszFilename, CCRect rect);
|
||||
|
||||
/** Initializes an sprite with an CCSpriteSheet and a rect in points */
|
||||
/** Initializes an sprite with an CCSpriteBatchNode and a rect in points */
|
||||
bool initWithBatchNode(CCSpriteBatchNode *batchNode, CCRect rect);
|
||||
bool initWithSpriteSheet(CCSpriteSheetInternalOnly *pSpriteSheet, CCRect rect);
|
||||
|
||||
/** Initializes an sprite with an CCSpriteSheet and a rect in pixels
|
||||
/** Initializes an sprite with an CCSpriteBatchNode and a rect in pixels
|
||||
@since v0.99.5
|
||||
*/
|
||||
bool initWithBatchNodeRectInPixels(CCSpriteBatchNode *batchNode, CCRect rect);
|
||||
|
@ -318,7 +318,6 @@ public:
|
|||
@since v0.99.0
|
||||
*/
|
||||
void useBatchNode(CCSpriteBatchNode *batchNode);
|
||||
void useSpriteSheetRender(CCSpriteSheetInternalOnly *pSpriteSheet);
|
||||
|
||||
// Frames
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2009-2010 Ricardo Quesada
|
||||
Copyright (C) 2009 Matt Oswald
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2008-2011 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
@ -53,7 +54,7 @@ public:
|
|||
// attributes
|
||||
|
||||
inline CCRect getRectInPixels(void) { return m_obRectInPixels; }
|
||||
inline void setRectInPixels(CCRect rectInPixels) { m_obRectInPixels = rectInPixels; }
|
||||
void setRectInPixels(CCRect rectInPixels);
|
||||
|
||||
inline bool isRotated(void) { return m_bRotated; }
|
||||
inline void setRotated(bool bRotated) { m_bRotated = bRotated; }
|
||||
|
@ -61,7 +62,7 @@ public:
|
|||
/** get rect of the frame */
|
||||
inline CCRect getRect(void) { return m_obRect; }
|
||||
/** set rect of the frame */
|
||||
inline void setRect(CCRect rect) { m_obRect = rect; }
|
||||
void setRect(CCRect rect);
|
||||
|
||||
/** get offset of the frame */
|
||||
inline CCPoint getOffsetInPixels(void) { return m_obOffsetInPixels; }
|
||||
|
|
|
@ -3,6 +3,7 @@ Copyright (c) 2010-2011 cocos2d-x.org
|
|||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2009 Jason Booth
|
||||
Copyright (c) 2009 Robert J Payne
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2009-2010 Ricardo Quesada
|
||||
Copyright (C) 2009 Matt Oswald
|
||||
|
||||
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 __SPRITE_CCSPRITE_SHEET_H__
|
||||
#define __SPRITE_CCSPRITE_SHEET_H__
|
||||
|
||||
#include "CCSpriteBatchNode.h"
|
||||
|
||||
namespace cocos2d {
|
||||
/* Added only to prevent GCC compile warnings
|
||||
Will be removed in v1.1
|
||||
*/
|
||||
class CC_DLL CCSpriteSheetInternalOnly : public CCSpriteBatchNode
|
||||
{
|
||||
};
|
||||
|
||||
/** @brief CCSpriteSheet is like a batch node: if it contains children, it will draw them in 1 single OpenGL call
|
||||
* (often known as "batch draw").
|
||||
*
|
||||
* A CCSpriteSheet can reference one and only one texture (one image file, one texture atlas).
|
||||
* Only the CCSprites that are contained in that texture can be added to the CCSpriteSheet.
|
||||
* All CCSprites added to a CCSpriteSheet are drawn in one OpenGL ES draw call.
|
||||
* If the CCSprites are not added to a CCSpriteSheet then an OpenGL ES draw call will be needed for each one, which is less efficient.
|
||||
*
|
||||
*
|
||||
* Limitations:
|
||||
* - The only object that is accepted as child (or grandchild) is CCSprite or any subclass of CCSprite. eg: particles, labels and layer can't be added to a CCSpriteSheet.
|
||||
* - Either all its children are Aliased or Antialiased. It can't be a mix. This is because "alias" is a property of the texture, and all the sprites share the same texture.
|
||||
*
|
||||
* @since v0.7.1
|
||||
* @deprecated Use CCSpriteBatchNode instead. This class will be removed in v1.1
|
||||
*/
|
||||
class CC_DLL CCSpriteSheet: public CCSpriteSheetInternalOnly
|
||||
{
|
||||
};
|
||||
|
||||
}//namespace cocos2d
|
||||
|
||||
#endif // __SPRITE_CCSPRITE_SHEET_H__
|
|
@ -75,20 +75,20 @@ namespace cocos2d{
|
|||
|
||||
for( int i=0; i<n; i++) {
|
||||
unsigned char a = s[i] - m_cMapStartChar;
|
||||
float row = (float) (a % m_nItemsPerRow);
|
||||
float col = (float) (a / m_nItemsPerRow);
|
||||
float row = (float) (a % m_uItemsPerRow);
|
||||
float col = (float) (a / m_uItemsPerRow);
|
||||
|
||||
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
|
||||
// Issue #938. Don't use texStepX & texStepY
|
||||
float left = (2 * row * m_nItemWidth + 1) / (2 * textureWide);
|
||||
float right = left + (m_nItemWidth * 2 - 2) / (2 * textureWide);
|
||||
float top = (2 * col * m_nItemHeight + 1) / (2 * textureHigh);
|
||||
float bottom = top + (m_nItemHeight * 2 - 2) / (2 * textureHigh);
|
||||
float left = (2 * row * m_uItemWidth + 1) / (2 * textureWide);
|
||||
float right = left + (m_uItemWidth * 2 - 2) / (2 * textureWide);
|
||||
float top = (2 * col * m_uItemHeight + 1) / (2 * textureHigh);
|
||||
float bottom = top + (m_uItemHeight * 2 - 2) / (2 * textureHigh);
|
||||
#else
|
||||
float left = row * m_nItemWidth / textureWide;
|
||||
float right = left + m_nItemWidth / textureWide;
|
||||
float top = col * m_nItemHeight / textureHigh;
|
||||
float bottom = top + m_nItemHeight / textureHigh;
|
||||
float left = row * m_uItemWidth / textureWide;
|
||||
float right = left + m_uItemWidth / textureWide;
|
||||
float top = col * m_uItemHeight / textureHigh;
|
||||
float bottom = top + m_uItemHeight / textureHigh;
|
||||
#endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
|
||||
|
||||
quad.tl.texCoords.u = left;
|
||||
|
@ -100,17 +100,17 @@ namespace cocos2d{
|
|||
quad.br.texCoords.u = right;
|
||||
quad.br.texCoords.v = bottom;
|
||||
|
||||
quad.bl.vertices.x = (float) (i * m_nItemWidth);
|
||||
quad.bl.vertices.x = (float) (i * m_uItemWidth);
|
||||
quad.bl.vertices.y = 0;
|
||||
quad.bl.vertices.z = 0.0f;
|
||||
quad.br.vertices.x = (float)(i * m_nItemWidth + m_nItemWidth);
|
||||
quad.br.vertices.x = (float)(i * m_uItemWidth + m_uItemWidth);
|
||||
quad.br.vertices.y = 0;
|
||||
quad.br.vertices.z = 0.0f;
|
||||
quad.tl.vertices.x = (float)(i * m_nItemWidth);
|
||||
quad.tl.vertices.y = (float)(m_nItemHeight);
|
||||
quad.tl.vertices.x = (float)(i * m_uItemWidth);
|
||||
quad.tl.vertices.y = (float)(m_uItemHeight);
|
||||
quad.tl.vertices.z = 0.0f;
|
||||
quad.tr.vertices.x = (float)(i * m_nItemWidth + m_nItemWidth);
|
||||
quad.tr.vertices.y = (float)(m_nItemHeight);
|
||||
quad.tr.vertices.x = (float)(i * m_uItemWidth + m_uItemWidth);
|
||||
quad.tr.vertices.y = (float)(m_uItemHeight);
|
||||
quad.tr.vertices.z = 0.0f;
|
||||
|
||||
m_pTextureAtlas->updateQuad(&quad, i);
|
||||
|
@ -129,8 +129,8 @@ namespace cocos2d{
|
|||
this->updateAtlasValues();
|
||||
|
||||
CCSize s;
|
||||
s.width = (float)(m_sString.length() * m_nItemWidth);
|
||||
s.height = (float)(m_nItemHeight);
|
||||
s.width = (float)(m_sString.length() * m_uItemWidth);
|
||||
s.height = (float)(m_uItemHeight);
|
||||
this->setContentSizeInPixels(s);
|
||||
}
|
||||
|
||||
|
|
|
@ -486,7 +486,7 @@ namespace cocos2d{
|
|||
if( ! fontChar )
|
||||
{
|
||||
fontChar = new CCSprite();
|
||||
fontChar->initWithSpriteSheet((CCSpriteSheetInternalOnly *) this, rect);
|
||||
fontChar->initWithBatchNode(this, rect);
|
||||
this->addChild(fontChar, 0, i);
|
||||
fontChar->release();
|
||||
}
|
||||
|
|
|
@ -559,10 +559,6 @@
|
|||
RelativePath="..\include\CCSpriteFrameCache.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCSpriteSheet.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCString.h"
|
||||
>
|
||||
|
@ -887,10 +883,6 @@
|
|||
RelativePath="..\sprite_nodes\CCSpriteFrameCache.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\sprite_nodes\CCSpriteSheet.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="support"
|
||||
|
|
|
@ -99,7 +99,6 @@ OBJECTS = \
|
|||
$(OBJECTS_DIR)/CCSpriteBatchNode.o \
|
||||
$(OBJECTS_DIR)/CCSpriteFrame.o \
|
||||
$(OBJECTS_DIR)/CCSpriteFrameCache.o \
|
||||
$(OBJECTS_DIR)/CCSpriteSheet.o \
|
||||
$(OBJECTS_DIR)/base64.o \
|
||||
$(OBJECTS_DIR)/CCArray.o \
|
||||
$(OBJECTS_DIR)/CCPointExtension.o \
|
||||
|
@ -344,9 +343,6 @@ $(OBJECTS_DIR)/CCSpriteFrame.o : ../sprite_nodes/CCSpriteFrame.cpp
|
|||
$(OBJECTS_DIR)/CCSpriteFrameCache.o : ../sprite_nodes/CCSpriteFrameCache.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCSpriteFrameCache.o ../sprite_nodes/CCSpriteFrameCache.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCSpriteSheet.o : ../sprite_nodes/CCSpriteSheet.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCSpriteSheet.o ../sprite_nodes/CCSpriteSheet.cpp
|
||||
|
||||
$(OBJECTS_DIR)/base64.o : ../support/base64.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/base64.o ../support/base64.cpp
|
||||
|
||||
|
|
|
@ -520,10 +520,6 @@
|
|||
RelativePath="..\include\CCSpriteFrameCache.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCSpriteSheet.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCString.h"
|
||||
>
|
||||
|
@ -728,10 +724,6 @@
|
|||
RelativePath="..\sprite_nodes\CCSpriteFrameCache.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\sprite_nodes\CCSpriteSheet.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="support"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2010 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
@ -26,7 +27,6 @@ THE SOFTWARE.
|
|||
#include "CCSpriteBatchNode.h"
|
||||
#include "CCAnimation.h"
|
||||
#include "CCAnimationCache.h"
|
||||
#include "CCSpriteSheet.h"
|
||||
#include "ccConfig.h"
|
||||
#include "CCSprite.h"
|
||||
#include "CCSpriteFrame.h"
|
||||
|
@ -54,6 +54,7 @@ struct transformValues_ {
|
|||
CCPoint pos; // position x and y
|
||||
CCPoint scale; // scale x and y
|
||||
float rotation;
|
||||
CCPoint skew; // skew x and y
|
||||
CCPoint ap; // anchor point in pixels
|
||||
bool visible;
|
||||
};
|
||||
|
@ -167,17 +168,12 @@ CCSprite* CCSprite::spriteWithSpriteFrameName(const char *pszSpriteFrameName)
|
|||
return spriteWithSpriteFrame(pFrame);
|
||||
}
|
||||
|
||||
CCSprite* CCSprite::spriteWithSpriteSheet(CCSpriteSheetInternalOnly *pSpriteSheet, CCRect rect)
|
||||
{
|
||||
return spriteWithBatchNode(pSpriteSheet, rect);
|
||||
}
|
||||
|
||||
bool CCSprite::init(void)
|
||||
{
|
||||
m_bDirty = m_bRecursiveDirty = false;
|
||||
|
||||
// by default use "Self Render".
|
||||
// if the sprite is added to an SpriteSheet, then it will automatically switch to "SpriteSheet Render"
|
||||
// if the sprite is added to an batchnode, then it will automatically switch to "SpriteSheet Render"
|
||||
useSelfRender();
|
||||
|
||||
m_bOpacityModifyRGB = true;
|
||||
|
@ -323,11 +319,6 @@ CCSprite* CCSprite::initWithCGImage(CGImageRef pImage, const char *pszKey)
|
|||
}
|
||||
*/
|
||||
|
||||
bool CCSprite::initWithSpriteSheet(CCSpriteSheetInternalOnly *pSpriteSheet, CCRect rect)
|
||||
{
|
||||
return initWithBatchNode(pSpriteSheet, rect);
|
||||
}
|
||||
|
||||
CCSprite::CCSprite()
|
||||
: m_pobTexture(NULL)
|
||||
{
|
||||
|
@ -365,11 +356,6 @@ void CCSprite::useBatchNode(CCSpriteBatchNode *batchNode)
|
|||
m_pobBatchNode = batchNode;
|
||||
}
|
||||
|
||||
void CCSprite::useSpriteSheetRender(CCSpriteSheetInternalOnly *pSpriteSheet)
|
||||
{
|
||||
useBatchNode(pSpriteSheet);
|
||||
}
|
||||
|
||||
void CCSprite::initAnimationDictionary(void)
|
||||
{
|
||||
m_pAnimations = new CCMutableDictionary<string, CCAnimation*>();
|
||||
|
@ -406,7 +392,7 @@ void CCSprite::setTextureRectInPixels(CCRect rect, bool rotated, CCSize size)
|
|||
m_obOffsetPositionInPixels.x = relativeOffsetInPixels.x + (m_tContentSizeInPixels.width - m_obRectInPixels.size.width) / 2;
|
||||
m_obOffsetPositionInPixels.y = relativeOffsetInPixels.y + (m_tContentSizeInPixels.height - m_obRectInPixels.size.height) / 2;
|
||||
|
||||
// rendering using SpriteSheet
|
||||
// rendering using batch node
|
||||
if (m_bUsesBatchNode)
|
||||
{
|
||||
// update dirty_, don't update recursiveDirty_
|
||||
|
@ -544,6 +530,13 @@ void CCSprite::updateTransform(void)
|
|||
matrix = CCAffineTransformMake(c * m_fScaleX, s * m_fScaleX,
|
||||
-s * m_fScaleY, c * m_fScaleY,
|
||||
m_tPositionInPixels.x, m_tPositionInPixels.y);
|
||||
if( m_fSkewX || m_fSkewY )
|
||||
{
|
||||
CCAffineTransform skewMatrix = CCAffineTransformMake(1.0f, tanf(CC_DEGREES_TO_RADIANS(m_fSkewY)),
|
||||
tanf(CC_DEGREES_TO_RADIANS(m_fSkewX)), 1.0f,
|
||||
0.0f, 0.0f);
|
||||
matrix = CCAffineTransformConcat(skewMatrix, matrix);
|
||||
}
|
||||
matrix = CCAffineTransformTranslate(matrix, -m_tAnchorPointInPixels.x, -m_tAnchorPointInPixels.y);
|
||||
} else // parent_ != batchNode_
|
||||
{
|
||||
|
@ -571,7 +564,7 @@ void CCSprite::updateTransform(void)
|
|||
|
||||
CCAffineTransform newMatrix = CCAffineTransformIdentity;
|
||||
|
||||
// 2nd: Translate, Rotate, Scale
|
||||
// 2nd: Translate, Skew, Rotate, Scale
|
||||
if( prevHonor & CC_HONOR_PARENT_TRANSFORM_TRANSLATE )
|
||||
{
|
||||
newMatrix = CCAffineTransformTranslate(newMatrix, tv.pos.x, tv.pos.y);
|
||||
|
@ -582,6 +575,13 @@ void CCSprite::updateTransform(void)
|
|||
newMatrix = CCAffineTransformRotate(newMatrix, -CC_DEGREES_TO_RADIANS(tv.rotation));
|
||||
}
|
||||
|
||||
if ( prevHonor & CC_HONOR_PARENT_TRANSFORM_SKEW )
|
||||
{
|
||||
CCAffineTransform skew = CCAffineTransformMake(1.0f, tanf(CC_DEGREES_TO_RADIANS(tv.skew.y)), tanf(CC_DEGREES_TO_RADIANS(tv.skew.x)), 1.0f, 0.0f, 0.0f);
|
||||
// apply the skew to the transform
|
||||
newMatrix = CCAffineTransformConcat(skew, newMatrix);
|
||||
}
|
||||
|
||||
if( prevHonor & CC_HONOR_PARENT_TRANSFORM_SCALE )
|
||||
{
|
||||
newMatrix = CCAffineTransformScale(newMatrix, tv.scale.x, tv.scale.y);
|
||||
|
@ -643,6 +643,8 @@ void CCSprite::getTransformValues(struct transformValues_ *tv)
|
|||
tv->scale.x = m_fScaleX;
|
||||
tv->scale.y = m_fScaleY;
|
||||
tv->rotation = m_fRotation;
|
||||
tv->skew.x = m_fSkewX;
|
||||
tv->skew.y = m_fSkewY;
|
||||
tv->ap = m_tAnchorPointInPixels;
|
||||
tv->visible = m_bIsVisible;
|
||||
}
|
||||
|
@ -835,6 +837,18 @@ void CCSprite::setRotation(float fRotation)
|
|||
SET_DIRTY_RECURSIVELY();
|
||||
}
|
||||
|
||||
void CCSprite::setSkewX(float sx)
|
||||
{
|
||||
CCNode::setSkewX(sx);
|
||||
SET_DIRTY_RECURSIVELY();
|
||||
}
|
||||
|
||||
void CCSprite::setSkewY(float sy)
|
||||
{
|
||||
CCNode::setSkewY(sy);
|
||||
SET_DIRTY_RECURSIVELY();
|
||||
}
|
||||
|
||||
void CCSprite::setScaleX(float fScaleX)
|
||||
{
|
||||
CCNode::setScaleX(fScaleX);
|
||||
|
@ -882,7 +896,7 @@ void CCSprite::setFlipX(bool bFlipX)
|
|||
if (m_bFlipX != bFlipX)
|
||||
{
|
||||
m_bFlipX = bFlipX;
|
||||
setTextureRectInPixels(m_obRectInPixels, m_bRectRotated, m_obRectInPixels.size);
|
||||
setTextureRectInPixels(m_obRectInPixels, m_bRectRotated, m_tContentSizeInPixels);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -896,7 +910,7 @@ void CCSprite::setFlipY(bool bFlipY)
|
|||
if (m_bFlipY != bFlipY)
|
||||
{
|
||||
m_bFlipY = bFlipY;
|
||||
setTextureRectInPixels(m_obRectInPixels, m_bRectRotated, m_obRectInPixels.size);
|
||||
setTextureRectInPixels(m_obRectInPixels, m_bRectRotated, m_tContentSizeInPixels);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1050,7 +1064,11 @@ bool CCSprite::isFrameDisplayed(CCSpriteFrame *pFrame)
|
|||
|
||||
CCSpriteFrame* CCSprite::displayedFrame(void)
|
||||
{
|
||||
return CCSpriteFrame::frameWithTexture(m_pobTexture, m_obRect);
|
||||
return CCSpriteFrame::frameWithTexture(m_pobTexture,
|
||||
m_obRectInPixels,
|
||||
m_bRectRotated,
|
||||
m_obUnflippedOffsetPositionFromCenter,
|
||||
m_tContentSizeInPixels);
|
||||
}
|
||||
|
||||
void CCSprite::addAnimation(CCAnimation *pAnimation)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2009-2010 Ricardo Quesada
|
||||
Copyright (c) 2009 Matt Oswald
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
@ -335,8 +336,9 @@ namespace cocos2d
|
|||
// this is likely computationally expensive
|
||||
unsigned int quantity = (m_pobTextureAtlas->getCapacity() + 1) * 4 / 3;
|
||||
|
||||
CCLOG("cocos2d: CCSpriteSheet: resizing TextureAtlas capacity from %u to %u.",
|
||||
(unsigned int)m_pobTextureAtlas->getCapacity(), (unsigned int)quantity);
|
||||
CCLOG("cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [%lu] to [%lu].",
|
||||
(long)m_pobTextureAtlas->getCapacity(),
|
||||
(long)quantity);
|
||||
|
||||
if (! m_pobTextureAtlas->resizeCapacity(quantity))
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2008-2011 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
@ -86,4 +87,17 @@ CCObject* CCSpriteFrame::copyWithZone(CCZone *pZone)
|
|||
|
||||
return pCopy;
|
||||
}
|
||||
|
||||
void CCSpriteFrame::setRect(CCRect rect)
|
||||
{
|
||||
m_obRect = rect;
|
||||
m_obRectInPixels = CC_RECT_POINTS_TO_PIXELS(m_obRect);
|
||||
}
|
||||
|
||||
void CCSpriteFrame::setRectInPixels(CCRect rectInPixels)
|
||||
{
|
||||
m_obRectInPixels = rectInPixels;
|
||||
m_obRect = CC_RECT_PIXELS_TO_POINTS(rectInPixels);
|
||||
}
|
||||
|
||||
}//namespace cocos2d
|
||||
|
|
|
@ -3,6 +3,7 @@ Copyright (c) 2010-2011 cocos2d-x.org
|
|||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2009 Jason Booth
|
||||
Copyright (c) 2009 Robert J Payne
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2009-2010 Ricardo Quesada
|
||||
Copyright (c) 2009 Matt Oswald
|
||||
|
||||
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 "CCSpriteSheet.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
}//namespace cocos2d
|
|
@ -236,7 +236,7 @@ namespace cocos2d {
|
|||
{
|
||||
CCRect rect = m_pTileSet->rectForGID(gid);
|
||||
tile = new CCSprite();
|
||||
tile->initWithSpriteSheet((CCSpriteSheetInternalOnly *)this, rect);
|
||||
tile->initWithBatchNode(this, rect);
|
||||
tile->setPositionInPixels(positionAt(pos));
|
||||
tile->setVertexZ((float)vertexZForPos(pos));
|
||||
tile->setAnchorPoint(CCPointZero);
|
||||
|
@ -268,11 +268,11 @@ namespace cocos2d {
|
|||
if( ! m_pReusedTile )
|
||||
{
|
||||
m_pReusedTile = new CCSprite();
|
||||
m_pReusedTile->initWithSpriteSheet((CCSpriteSheetInternalOnly *) this, rect);
|
||||
m_pReusedTile->initWithBatchNode(this, rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pReusedTile->initWithSpriteSheet((CCSpriteSheetInternalOnly *) this, rect);
|
||||
m_pReusedTile->initWithBatchNode(this, rect);
|
||||
}
|
||||
m_pReusedTile->setPositionInPixels(positionAt(pos));
|
||||
m_pReusedTile->setVertexZ((float)vertexZForPos(pos));
|
||||
|
@ -316,11 +316,11 @@ namespace cocos2d {
|
|||
if( ! m_pReusedTile )
|
||||
{
|
||||
m_pReusedTile = new CCSprite();
|
||||
m_pReusedTile->initWithSpriteSheet((CCSpriteSheetInternalOnly *) this, rect);
|
||||
m_pReusedTile->initWithBatchNode(this, rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pReusedTile->initWithSpriteSheet((CCSpriteSheetInternalOnly *) this, rect);
|
||||
m_pReusedTile->initWithBatchNode(this, rect);
|
||||
}
|
||||
|
||||
m_pReusedTile->setPositionInPixels(positionAt(pos));
|
||||
|
@ -349,11 +349,11 @@ namespace cocos2d {
|
|||
if( ! m_pReusedTile )
|
||||
{
|
||||
m_pReusedTile = new CCSprite();
|
||||
m_pReusedTile->initWithSpriteSheet((CCSpriteSheetInternalOnly *) this, rect);
|
||||
m_pReusedTile->initWithBatchNode(this, rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pReusedTile->initWithSpriteSheet((CCSpriteSheetInternalOnly *) this, rect);
|
||||
m_pReusedTile->initWithBatchNode(this, rect);
|
||||
}
|
||||
|
||||
m_pReusedTile->setPosition(positionAt(pos));
|
||||
|
|
|
@ -52,8 +52,8 @@ namespace cocos2d {
|
|||
{
|
||||
m_pPosToAtlasIndex = new StringToIntegerDictionary();
|
||||
this->updateAtlasValues();
|
||||
this->setContentSize(CCSizeMake((float)(m_pTGAInfo->width*m_nItemWidth),
|
||||
(float)(m_pTGAInfo->height*m_nItemHeight)));
|
||||
this->setContentSize(CCSizeMake((float)(m_pTGAInfo->width*m_uItemWidth),
|
||||
(float)(m_pTGAInfo->height*m_uItemHeight)));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -180,22 +180,22 @@ namespace cocos2d {
|
|||
|
||||
int x = pos.x;
|
||||
int y = pos.y;
|
||||
float row = (float) (value.r % m_nItemsPerRow);
|
||||
float col = (float) (value.r / m_nItemsPerRow);
|
||||
float row = (float) (value.r % m_uItemsPerRow);
|
||||
float col = (float) (value.r / m_uItemsPerRow);
|
||||
|
||||
float textureWide = (float) (m_pTextureAtlas->getTexture()->getPixelsWide());
|
||||
float textureHigh = (float) (m_pTextureAtlas->getTexture()->getPixelsHigh());
|
||||
|
||||
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
|
||||
float left = (2 * row * m_nItemWidth + 1) / (2 * textureWide);
|
||||
float right = left + (m_nItemWidth * 2 - 2) / (2 * textureWide);
|
||||
float top = (2 * col * m_nItemHeight + 1) / (2 * textureHigh);
|
||||
float bottom = top + (m_nItemHeight * 2 - 2) / (2 * textureHigh);
|
||||
float left = (2 * row * m_uItemWidth + 1) / (2 * textureWide);
|
||||
float right = left + (m_uItemWidth * 2 - 2) / (2 * textureWide);
|
||||
float top = (2 * col * m_uItemHeight + 1) / (2 * textureHigh);
|
||||
float bottom = top + (m_uItemHeight * 2 - 2) / (2 * textureHigh);
|
||||
#else
|
||||
float left = (row * m_nItemWidth) / textureWide;
|
||||
float right = left + m_nItemWidth / textureWide;
|
||||
float top = (col * m_nItemHeight) / textureHigh;
|
||||
float bottom = top + m_nItemHeight / textureHigh;
|
||||
float left = (row * m_uItemWidth) / textureWide;
|
||||
float right = left + m_uItemWidth / textureWide;
|
||||
float top = (col * m_uItemHeight) / textureHigh;
|
||||
float bottom = top + m_uItemHeight / textureHigh;
|
||||
#endif
|
||||
|
||||
quad.tl.texCoords.u = left;
|
||||
|
@ -207,17 +207,17 @@ namespace cocos2d {
|
|||
quad.br.texCoords.u = right;
|
||||
quad.br.texCoords.v = bottom;
|
||||
|
||||
quad.bl.vertices.x = (float) (x * m_nItemWidth);
|
||||
quad.bl.vertices.y = (float) (y * m_nItemHeight);
|
||||
quad.bl.vertices.x = (float) (x * m_uItemWidth);
|
||||
quad.bl.vertices.y = (float) (y * m_uItemHeight);
|
||||
quad.bl.vertices.z = 0.0f;
|
||||
quad.br.vertices.x = (float)(x * m_nItemWidth + m_nItemWidth);
|
||||
quad.br.vertices.y = (float)(y * m_nItemHeight);
|
||||
quad.br.vertices.x = (float)(x * m_uItemWidth + m_uItemWidth);
|
||||
quad.br.vertices.y = (float)(y * m_uItemHeight);
|
||||
quad.br.vertices.z = 0.0f;
|
||||
quad.tl.vertices.x = (float)(x * m_nItemWidth);
|
||||
quad.tl.vertices.y = (float)(y * m_nItemHeight + m_nItemHeight);
|
||||
quad.tl.vertices.x = (float)(x * m_uItemWidth);
|
||||
quad.tl.vertices.y = (float)(y * m_uItemHeight + m_uItemHeight);
|
||||
quad.tl.vertices.z = 0.0f;
|
||||
quad.tr.vertices.x = (float)(x * m_nItemWidth + m_nItemWidth);
|
||||
quad.tr.vertices.y = (float)(y * m_nItemHeight + m_nItemHeight);
|
||||
quad.tr.vertices.x = (float)(x * m_uItemWidth + m_uItemWidth);
|
||||
quad.tr.vertices.y = (float)(y * m_uItemHeight + m_uItemHeight);
|
||||
quad.tr.vertices.z = 0.0f;
|
||||
|
||||
m_pTextureAtlas->updateQuad(&quad, index);
|
||||
|
|
|
@ -1 +1 @@
|
|||
c5fe5c3cfe6e071c8107a4694e285fa651fae4b9
|
||||
7f2063dcb0f20a43cc812de14bb52b3ed82ea209
|
Loading…
Reference in New Issue