mirror of https://github.com/axmolengine/axmol.git
Avoid unnecessary object duplication using passing arguments by reference
This commit is contained in:
parent
6fbca287a2
commit
43c2001d71
|
@ -84,12 +84,12 @@ bool Scale9Sprite::init()
|
|||
return this->initWithBatchNode(NULL, Rect::ZERO, Rect::ZERO);
|
||||
}
|
||||
|
||||
bool Scale9Sprite::initWithBatchNode(SpriteBatchNode* batchnode, Rect rect, Rect capInsets)
|
||||
bool Scale9Sprite::initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, const Rect& capInsets)
|
||||
{
|
||||
return this->initWithBatchNode(batchnode, rect, false, capInsets);
|
||||
}
|
||||
|
||||
bool Scale9Sprite::initWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bool rotated, Rect capInsets)
|
||||
bool Scale9Sprite::initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, bool rotated, const Rect& capInsets)
|
||||
{
|
||||
if(batchnode)
|
||||
{
|
||||
|
@ -108,10 +108,11 @@ bool Scale9Sprite::initWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bool
|
|||
#define TRANSLATE_Y(x, y, ytranslate) \
|
||||
y+=ytranslate; \
|
||||
|
||||
bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bool rotated, Rect capInsets)
|
||||
bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, const Rect& originalRect, bool rotated, const Rect& capInsets)
|
||||
{
|
||||
GLubyte opacity = getOpacity();
|
||||
Color3B color = getColor();
|
||||
Rect rect(originalRect);
|
||||
|
||||
// Release old sprites
|
||||
this->removeAllChildrenWithCleanup(true);
|
||||
|
@ -453,7 +454,7 @@ void Scale9Sprite::updatePositions()
|
|||
_centre->setPosition(Point(leftWidth, bottomHeight));
|
||||
}
|
||||
|
||||
bool Scale9Sprite::initWithFile(const char* file, Rect rect, Rect capInsets)
|
||||
bool Scale9Sprite::initWithFile(const char* file, const Rect& rect, const Rect& capInsets)
|
||||
{
|
||||
CCASSERT(file != NULL, "Invalid file for sprite");
|
||||
|
||||
|
@ -462,7 +463,7 @@ bool Scale9Sprite::initWithFile(const char* file, Rect rect, Rect capInsets)
|
|||
return pReturn;
|
||||
}
|
||||
|
||||
Scale9Sprite* Scale9Sprite::create(const char* file, Rect rect, Rect capInsets)
|
||||
Scale9Sprite* Scale9Sprite::create(const char* file, const Rect& rect, const Rect& capInsets)
|
||||
{
|
||||
Scale9Sprite* pReturn = new Scale9Sprite();
|
||||
if ( pReturn && pReturn->initWithFile(file, rect, capInsets) )
|
||||
|
@ -474,14 +475,14 @@ Scale9Sprite* Scale9Sprite::create(const char* file, Rect rect, Rect capInsets)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool Scale9Sprite::initWithFile(const char* file, Rect rect)
|
||||
bool Scale9Sprite::initWithFile(const char* file, const Rect& rect)
|
||||
{
|
||||
CCASSERT(file != NULL, "Invalid file for sprite");
|
||||
bool pReturn = this->initWithFile(file, rect, Rect::ZERO);
|
||||
return pReturn;
|
||||
}
|
||||
|
||||
Scale9Sprite* Scale9Sprite::create(const char* file, Rect rect)
|
||||
Scale9Sprite* Scale9Sprite::create(const char* file, const Rect& rect)
|
||||
{
|
||||
Scale9Sprite* pReturn = new Scale9Sprite();
|
||||
if ( pReturn && pReturn->initWithFile(file, rect) )
|
||||
|
@ -494,13 +495,13 @@ Scale9Sprite* Scale9Sprite::create(const char* file, Rect rect)
|
|||
}
|
||||
|
||||
|
||||
bool Scale9Sprite::initWithFile(Rect capInsets, const char* file)
|
||||
bool Scale9Sprite::initWithFile(const Rect& capInsets, const char* file)
|
||||
{
|
||||
bool pReturn = this->initWithFile(file, Rect::ZERO, capInsets);
|
||||
return pReturn;
|
||||
}
|
||||
|
||||
Scale9Sprite* Scale9Sprite::create(Rect capInsets, const char* file)
|
||||
Scale9Sprite* Scale9Sprite::create(const Rect& capInsets, const char* file)
|
||||
{
|
||||
Scale9Sprite* pReturn = new Scale9Sprite();
|
||||
if ( pReturn && pReturn->initWithFile(capInsets, file) )
|
||||
|
@ -531,7 +532,7 @@ Scale9Sprite* Scale9Sprite::create(const char* file)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool Scale9Sprite::initWithSpriteFrame(SpriteFrame* spriteFrame, Rect capInsets)
|
||||
bool Scale9Sprite::initWithSpriteFrame(SpriteFrame* spriteFrame, const Rect& capInsets)
|
||||
{
|
||||
Texture2D* texture = spriteFrame->getTexture();
|
||||
CCASSERT(texture != NULL, "CCTexture must be not nil");
|
||||
|
@ -543,7 +544,7 @@ bool Scale9Sprite::initWithSpriteFrame(SpriteFrame* spriteFrame, Rect capInsets)
|
|||
return pReturn;
|
||||
}
|
||||
|
||||
Scale9Sprite* Scale9Sprite::createWithSpriteFrame(SpriteFrame* spriteFrame, Rect capInsets)
|
||||
Scale9Sprite* Scale9Sprite::createWithSpriteFrame(SpriteFrame* spriteFrame, const Rect& capInsets)
|
||||
{
|
||||
Scale9Sprite* pReturn = new Scale9Sprite();
|
||||
if ( pReturn && pReturn->initWithSpriteFrame(spriteFrame, capInsets) )
|
||||
|
@ -573,7 +574,7 @@ Scale9Sprite* Scale9Sprite::createWithSpriteFrame(SpriteFrame* spriteFrame)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool Scale9Sprite::initWithSpriteFrameName(const char* spriteFrameName, Rect capInsets)
|
||||
bool Scale9Sprite::initWithSpriteFrameName(const char* spriteFrameName, const Rect& capInsets)
|
||||
{
|
||||
CCASSERT((SpriteFrameCache::getInstance()) != NULL, "SpriteFrameCache::getInstance() must be non-NULL");
|
||||
|
||||
|
@ -586,7 +587,7 @@ bool Scale9Sprite::initWithSpriteFrameName(const char* spriteFrameName, Rect cap
|
|||
return pReturn;
|
||||
}
|
||||
|
||||
Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const char* spriteFrameName, Rect capInsets)
|
||||
Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const char* spriteFrameName, const Rect& capInsets)
|
||||
{
|
||||
Scale9Sprite* pReturn = new Scale9Sprite();
|
||||
if ( pReturn && pReturn->initWithSpriteFrameName(spriteFrameName, capInsets) )
|
||||
|
@ -621,7 +622,7 @@ Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const char* spriteFrameNam
|
|||
|
||||
}
|
||||
|
||||
Scale9Sprite* Scale9Sprite::resizableSpriteWithCapInsets(Rect capInsets)
|
||||
Scale9Sprite* Scale9Sprite::resizableSpriteWithCapInsets(const Rect& capInsets)
|
||||
{
|
||||
Scale9Sprite* pReturn = new Scale9Sprite();
|
||||
if ( pReturn && pReturn->initWithBatchNode(_scale9Image, _spriteRect, capInsets) )
|
||||
|
|
|
@ -70,25 +70,25 @@ public:
|
|||
* Creates a 9-slice sprite with a texture file, a delimitation zone and
|
||||
* with the specified cap insets.
|
||||
*
|
||||
* @see initWithFile(const char *file, Rect rect, Rect capInsets)
|
||||
* @see initWithFile(const char *file, const Rect& rect, const Rect& capInsets)
|
||||
*/
|
||||
static Scale9Sprite* create(const char* file, Rect rect, Rect capInsets);
|
||||
static Scale9Sprite* create(const char* file, const Rect& rect, const Rect& capInsets);
|
||||
|
||||
/**
|
||||
* Creates a 9-slice sprite with a texture file. The whole texture will be
|
||||
* broken down into a 3×3 grid of equal blocks.
|
||||
*
|
||||
* @see initWithFile(Rect capInsets, const char *file)
|
||||
* @see initWithFile(const Rect& capInsets, const char *file)
|
||||
*/
|
||||
static Scale9Sprite* create(Rect capInsets, const char* file);
|
||||
static Scale9Sprite* create(const Rect& capInsets, const char* file);
|
||||
|
||||
/**
|
||||
* Creates a 9-slice sprite with a texture file and a delimitation zone. The
|
||||
* texture will be broken down into a 3×3 grid of equal blocks.
|
||||
*
|
||||
* @see initWithFile(const char *file, Rect rect)
|
||||
* @see initWithFile(const char *file, const Rect& rect)
|
||||
*/
|
||||
static Scale9Sprite* create(const char* file, Rect rect);
|
||||
static Scale9Sprite* create(const char* file, const Rect& rect);
|
||||
|
||||
/**
|
||||
* Creates a 9-slice sprite with a texture file. The whole texture will be
|
||||
|
@ -114,9 +114,9 @@ public:
|
|||
* to resize the sprite will all it's 9-slice goodness intract.
|
||||
* It respects the anchorPoint too.
|
||||
*
|
||||
* @see initWithSpriteFrame(SpriteFrame *spriteFrame, Rect capInsets)
|
||||
* @see initWithSpriteFrame(SpriteFrame *spriteFrame, const Rect& capInsets)
|
||||
*/
|
||||
static Scale9Sprite* createWithSpriteFrame(SpriteFrame* spriteFrame, Rect capInsets);
|
||||
static Scale9Sprite* createWithSpriteFrame(SpriteFrame* spriteFrame, const Rect& capInsets);
|
||||
|
||||
/**
|
||||
* Creates a 9-slice sprite with an sprite frame name.
|
||||
|
@ -135,9 +135,9 @@ public:
|
|||
* to resize the sprite will all it's 9-slice goodness intract.
|
||||
* It respects the anchorPoint too.
|
||||
*
|
||||
* @see initWithSpriteFrameName(const char *spriteFrameName, Rect capInsets)
|
||||
* @see initWithSpriteFrameName(const char *spriteFrameName, const Rect& capInsets)
|
||||
*/
|
||||
static Scale9Sprite* createWithSpriteFrameName(const char*spriteFrameName, Rect capInsets);
|
||||
static Scale9Sprite* createWithSpriteFrameName(const char*spriteFrameName, const Rect& capInsets);
|
||||
|
||||
/**
|
||||
* Initializes a 9-slice sprite with a texture file, a delimitation zone and
|
||||
|
@ -152,7 +152,7 @@ public:
|
|||
* texture's full rect.
|
||||
* @param capInsets The values to use for the cap insets.
|
||||
*/
|
||||
virtual bool initWithFile(const char* file, Rect rect, Rect capInsets);
|
||||
virtual bool initWithFile(const char* file, const Rect& rect, const Rect& capInsets);
|
||||
|
||||
/**
|
||||
* Initializes a 9-slice sprite with a texture file and a delimitation zone. The
|
||||
|
@ -166,7 +166,7 @@ public:
|
|||
* is the whole image. If the shape is the whole texture, set this to the
|
||||
* texture's full rect.
|
||||
*/
|
||||
virtual bool initWithFile(const char* file, Rect rect);
|
||||
virtual bool initWithFile(const char* file, const Rect& rect);
|
||||
|
||||
/**
|
||||
* Initializes a 9-slice sprite with a texture file and with the specified cap
|
||||
|
@ -178,7 +178,7 @@ public:
|
|||
* @param file The name of the texture file.
|
||||
* @param capInsets The values to use for the cap insets.
|
||||
*/
|
||||
virtual bool initWithFile(Rect capInsets, const char* file);
|
||||
virtual bool initWithFile(const Rect& capInsets, const char* file);
|
||||
|
||||
/**
|
||||
* Initializes a 9-slice sprite with a texture file. The whole texture will be
|
||||
|
@ -201,7 +201,7 @@ public:
|
|||
* @param spriteFrame The sprite frame object.
|
||||
* @param capInsets The values to use for the cap insets.
|
||||
*/
|
||||
virtual bool initWithSpriteFrame(SpriteFrame* spriteFrame, Rect capInsets);
|
||||
virtual bool initWithSpriteFrame(SpriteFrame* spriteFrame, const Rect& capInsets);
|
||||
|
||||
/**
|
||||
* Initializes a 9-slice sprite with an sprite frame.
|
||||
|
@ -223,7 +223,7 @@ public:
|
|||
* @param spriteFrameName The sprite frame name.
|
||||
* @param capInsets The values to use for the cap insets.
|
||||
*/
|
||||
virtual bool initWithSpriteFrameName(const char*spriteFrameName, Rect capInsets);
|
||||
virtual bool initWithSpriteFrameName(const char*spriteFrameName, const Rect& capInsets);
|
||||
|
||||
/**
|
||||
* Initializes a 9-slice sprite with an sprite frame name.
|
||||
|
@ -236,8 +236,8 @@ public:
|
|||
virtual bool initWithSpriteFrameName(const char*spriteFrameName);
|
||||
|
||||
virtual bool init();
|
||||
virtual bool initWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bool rotated, Rect capInsets);
|
||||
virtual bool initWithBatchNode(SpriteBatchNode* batchnode, Rect rect, Rect capInsets);
|
||||
virtual bool initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, bool rotated, const Rect& capInsets);
|
||||
virtual bool initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, const Rect& capInsets);
|
||||
|
||||
/**
|
||||
* Creates and returns a new sprite object with the specified cap insets.
|
||||
|
@ -247,9 +247,9 @@ public:
|
|||
*
|
||||
* @param capInsets The values to use for the cap insets.
|
||||
*/
|
||||
Scale9Sprite* resizableSpriteWithCapInsets(Rect capInsets);
|
||||
Scale9Sprite* resizableSpriteWithCapInsets(const Rect& capInsets);
|
||||
|
||||
virtual bool updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bool rotated, Rect capInsets);
|
||||
virtual bool updateWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, bool rotated, const Rect& capInsets);
|
||||
virtual void setSpriteFrame(SpriteFrame * spriteFrame);
|
||||
|
||||
// overrides
|
||||
|
|
Loading…
Reference in New Issue