Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3_lua_ui_fix

This commit is contained in:
samuele3hu 2014-06-10 16:50:26 +08:00
commit 90907f451e
4 changed files with 58 additions and 49 deletions

View File

@ -19,6 +19,7 @@ cocos2d-x-3.2 ???
[FIX] Lua-binding: Add xxtea encrypt support [FIX] Lua-binding: Add xxtea encrypt support
[FIX] Node: setPhysicsBody() can not work correctly if it is added to a Node [FIX] Node: setPhysicsBody() can not work correctly if it is added to a Node
[FIX] Node: state of _transformUpdated, _transformDirty and _inverseDirty are wrong in setParent() [FIX] Node: state of _transformUpdated, _transformDirty and _inverseDirty are wrong in setParent()
[FIX] Node: _orderOfArrival is set to 0 after visit
[FIX] Other: link error with Xcode 6 when building with 32-bit architecture [FIX] Other: link error with Xcode 6 when building with 32-bit architecture
[FIX] Repeat: will run one more over in rare situations [FIX] Repeat: will run one more over in rare situations
[FIX] Scale9Sprite: support culling [FIX] Scale9Sprite: support culling

View File

@ -69,6 +69,13 @@ SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect,
return spriteFrame; return spriteFrame;
} }
SpriteFrame::SpriteFrame(void)
: _rotated(false)
, _texture(nullptr)
{
}
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect) bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect)
{ {
Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS(rect); Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS(rect);

View File

@ -75,34 +75,6 @@ public:
The originalSize is the size in points of the frame before being trimmed. The originalSize is the size in points of the frame before being trimmed.
*/ */
static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize); static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
/**
* @js NA
* @lua NA
*/
virtual ~SpriteFrame(void);
/** Initializes a SpriteFrame with a texture, rect in points.
It is assumed that the frame was not trimmed.
*/
bool initWithTexture(Texture2D* pobTexture, const Rect& rect);
/** Initializes a SpriteFrame with a texture filename, rect in points;
It is assumed that the frame was not trimmed.
*/
bool initWithTextureFilename(const std::string& filename, const Rect& rect);
/** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
The originalSize is the size in points of the frame before being trimmed.
*/
bool initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
/** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
The originalSize is the size in pixels of the frame before being trimmed.
@since v1.1
*/
bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
// attributes // attributes
inline const Rect& getRectInPixels() const { return _rectInPixels; } inline const Rect& getRectInPixels() const { return _rectInPixels; }
@ -141,6 +113,39 @@ public:
// Overrides // Overrides
virtual SpriteFrame *clone() const override; virtual SpriteFrame *clone() const override;
CC_CONSTRUCTOR_ACCESS:
/**
* @lua NA
*/
SpriteFrame(void);
/**
* @lua NA
*/
virtual ~SpriteFrame(void);
/** Initializes a SpriteFrame with a texture, rect in points.
It is assumed that the frame was not trimmed.
*/
bool initWithTexture(Texture2D* pobTexture, const Rect& rect);
/** Initializes a SpriteFrame with a texture filename, rect in points;
It is assumed that the frame was not trimmed.
*/
bool initWithTextureFilename(const std::string& filename, const Rect& rect);
/** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
The originalSize is the size in points of the frame before being trimmed.
*/
bool initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
/** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
The originalSize is the size in pixels of the frame before being trimmed.
@since v1.1
*/
bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
protected: protected:
Vec2 _offset; Vec2 _offset;

View File

@ -132,13 +132,12 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
ow = abs(ow); ow = abs(ow);
oh = abs(oh); oh = abs(oh);
// create frame // create frame
spriteFrame = new SpriteFrame(); spriteFrame = SpriteFrame::createWithTexture(texture,
spriteFrame->initWithTexture(texture, Rect(x, y, w, h),
Rect(x, y, w, h), false,
false, Vec2(ox, oy),
Vec2(ox, oy), Size((float)ow, (float)oh)
Size((float)ow, (float)oh) );
);
} }
else if(format == 1 || format == 2) else if(format == 1 || format == 2)
{ {
@ -155,13 +154,12 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
Size sourceSize = SizeFromString(frameDict["sourceSize"].asString()); Size sourceSize = SizeFromString(frameDict["sourceSize"].asString());
// create frame // create frame
spriteFrame = new SpriteFrame(); spriteFrame = SpriteFrame::createWithTexture(texture,
spriteFrame->initWithTexture(texture, frame,
frame, rotated,
rotated, offset,
offset, sourceSize
sourceSize );
);
} }
else if (format == 3) else if (format == 3)
{ {
@ -186,17 +184,15 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
} }
// create frame // create frame
spriteFrame = new SpriteFrame(); spriteFrame = SpriteFrame::createWithTexture(texture,
spriteFrame->initWithTexture(texture, Rect(textureRect.origin.x, textureRect.origin.y, spriteSize.width, spriteSize.height),
Rect(textureRect.origin.x, textureRect.origin.y, spriteSize.width, spriteSize.height), textureRotated,
textureRotated, spriteOffset,
spriteOffset, spriteSourceSize);
spriteSourceSize);
} }
// add sprite frame // add sprite frame
_spriteFrames.insert(spriteFrameName, spriteFrame); _spriteFrames.insert(spriteFrameName, spriteFrame);
spriteFrame->release();
} }
} }