From 2dcc3678676683b6734818be9487ca2cff508828 Mon Sep 17 00:00:00 2001 From: linshun Date: Mon, 21 Jan 2013 18:24:25 +0800 Subject: [PATCH 1/5] Update authors list --- AUTHORS.txt | 27 +++++++++++++++++++++++++-- samples | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index f7e4b3807b..a221168ac9 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -15,8 +15,31 @@ Core Developers: Ricardo Quesada -Developers: - +Contributors: +Name GithubID Main contribution + +Dali Kilani @dadilcool added instruction to read me + +Chris @hannon235 added node.js api for box2d + +Jason Aeschliman @jaeschliman fix cc.Node setposition + +Sun Zhuoshi(Intel) @sunzhuoshi engine loader fix + +Alejandro Reyero @KaTXi fix error message + +Long Xiang @seanlong resource loader count + +Timm Drevensek(Zynga) @timmjd cc.Class fix + +Lzzy Chen @czizzy audio engine fix + cleanup comments + +Mcscooter @mcscooter tilempapxml fix + +Roed @roed mouse rightclick api + +Surith Thekkiam(Zynga) @folecr match Cocos2dx api Cocos2d-x and cocos2d-html5 can not grow so fast without the active community. diff --git a/samples b/samples index 6fe2ddb0e2..9ef674e77e 160000 --- a/samples +++ b/samples @@ -1 +1 @@ -Subproject commit 6fe2ddb0e2dd7c37b463a246d3cf31fa1668441f +Subproject commit 9ef674e77e86fbe9ef93caf28b371f9e3d2fe1ab From 4f084fa72672495cda12f5631328116ee0c3c5d0 Mon Sep 17 00:00:00 2001 From: Timm Drevensek Date: Wed, 23 Jan 2013 15:39:34 +0100 Subject: [PATCH 2/5] - move samples repo to new Scale9Sprite - fixed Scale9Sprite to work with all tests --- cocos2d/sprite_nodes/CCSprite.js | 2 +- .../GUI/CCControlExtension/CCScale9Sprite.js | 109 ++++++++++++------ samples | 2 +- 3 files changed, 78 insertions(+), 35 deletions(-) diff --git a/cocos2d/sprite_nodes/CCSprite.js b/cocos2d/sprite_nodes/CCSprite.js index c2786e4688..2e96f6a2b5 100644 --- a/cocos2d/sprite_nodes/CCSprite.js +++ b/cocos2d/sprite_nodes/CCSprite.js @@ -914,7 +914,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ context.drawImage(this._texture, posX, -(posY + this._texture.height)); } else { context.drawImage(this._texture, - 0, 0, + this._rect.origin.x, this._rect.origin.y, this._rect.size.width, this._rect.size.height, posX, -(posY + this._rect.size.height), this._rect.size.width, this._rect.size.height); diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.js b/extensions/GUI/CCControlExtension/CCScale9Sprite.js index a2644fcf1e..8b13324600 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.js +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.js @@ -80,19 +80,8 @@ cc.Scale9Sprite = cc.Node.extend({ }, _updatePositions:function () { - var size = this._contentSize; - - var sizableWidth = size.width - this._topLeft.getContentSize().width - this._topRight.getContentSize().width; - var sizableHeight = size.height - this._topLeft.getContentSize().height - this._bottomRight.getContentSize().height; - var horizontalScale = sizableWidth / this._centre.getContentSize().width; - var verticalScale = sizableHeight / this._centre.getContentSize().height; - this._centre.setScaleX(horizontalScale); - this._centre.setScaleY(verticalScale); - var rescaledWidth = this._centre.getContentSize().width * horizontalScale; - var rescaledHeight = this._centre.getContentSize().height * verticalScale; - var leftWidth = this._bottomLeft.getContentSize().width; - var bottomHeight = this._bottomLeft.getContentSize().height; + var size = this._contentSize; this._bottomLeft.setAnchorPoint(cc.p(0, 0)); this._bottomRight.setAnchorPoint(cc.p(0, 0)); @@ -104,24 +93,67 @@ cc.Scale9Sprite = cc.Node.extend({ this._bottom.setAnchorPoint(cc.p(0, 0)); this._centre.setAnchorPoint(cc.p(0, 0)); - // Position corners - this._bottomLeft.setPosition(cc.p(0, 0)); - this._bottomRight.setPosition(cc.p(leftWidth + rescaledWidth, 0)); - this._topLeft.setPosition(cc.p(0, bottomHeight + rescaledHeight)); - this._topRight.setPosition(cc.p(leftWidth + rescaledWidth, bottomHeight + rescaledHeight)); - - // Scale and position borders - this._left.setPosition(cc.p(0, bottomHeight)); - this._left.setScaleY(verticalScale); - this._right.setPosition(cc.p(leftWidth + rescaledWidth, bottomHeight)); - this._right.setScaleY(verticalScale); - this._bottom.setPosition(cc.p(leftWidth, 0)); - this._bottom.setScaleX(horizontalScale); - this._top.setPosition(cc.p(leftWidth, bottomHeight + rescaledHeight)); - this._top.setScaleX(horizontalScale); - - // Position centre - this._centre.setPosition(cc.p(leftWidth, bottomHeight)); + if(!this._capInsets) + { + var equalWidth = size.width / 3; + var equalHeight = size.height / 3; + + var equalWidthScale = equalWidth / this._centre.getContentSize().width; + var equalHeightScale = equalHeight / this._centre.getContentSize().height; + + this._topLeft.setScale(equalWidthScale, equalHeightScale); + this._top.setScale(equalWidthScale, equalHeightScale); + this._topRight.setScale(equalWidthScale, equalHeightScale); + this._left.setScale(equalWidthScale, equalHeightScale); + this._centre.setScale(equalWidthScale, equalHeightScale); + this._right.setScale(equalWidthScale, equalHeightScale); + this._bottomLeft.setScale(equalWidthScale, equalHeightScale); + this._bottom.setScale(equalWidthScale, equalHeightScale); + this._bottomRight.setScale(equalWidthScale, equalHeightScale); + + this._topLeft.setPosition(cc.p(0, 2 * equalHeight)); + this._top.setPosition(cc.p(equalWidth, 2 * equalHeight)); + this._topRight.setPosition(cc.p(2 * equalWidth, 2 * equalHeight)); + this._left.setPosition(cc.p(0, equalHeight)); + this._centre.setPosition(cc.p(equalWidth, equalHeight)); + this._right.setPosition(cc.p(2 * equalWidth, equalHeight)); + this._bottomLeft.setPosition(cc.p(0, 0)); + this._bottom.setPosition(cc.p(equalWidth, 0)); + this._bottomRight.setPosition(cc.p(2 * equalWidth, 0)); + } + else + { + var sizableWidth = size.width - this._topLeft.getContentSize().width - this._topRight.getContentSize().width; + var sizableHeight = size.height - this._topLeft.getContentSize().height - this._bottomRight.getContentSize().height; + var horizontalScale = sizableWidth / this._centre.getContentSize().width; + var verticalScale = sizableHeight / this._centre.getContentSize().height; + this._centre.setScaleX(horizontalScale); + this._centre.setScaleY(verticalScale); + var rescaledWidth = this._centre.getContentSize().width * horizontalScale; + var rescaledHeight = this._centre.getContentSize().height * verticalScale; + + var leftWidth = this._bottomLeft.getContentSize().width; + var bottomHeight = this._bottomLeft.getContentSize().height; + + // Position corners + this._bottomLeft.setPosition(cc.p(0, 0)); + this._bottomRight.setPosition(cc.p(leftWidth + rescaledWidth, 0)); + this._topLeft.setPosition(cc.p(0, bottomHeight + rescaledHeight)); + this._topRight.setPosition(cc.p(leftWidth + rescaledWidth, bottomHeight + rescaledHeight)); + + // Scale and position borders + this._left.setPosition(cc.p(0, bottomHeight)); + this._left.setScaleY(verticalScale); + this._right.setPosition(cc.p(leftWidth + rescaledWidth, bottomHeight)); + this._right.setScaleY(verticalScale); + this._bottom.setPosition(cc.p(leftWidth, 0)); + this._bottom.setScaleX(horizontalScale); + this._top.setPosition(cc.p(leftWidth, bottomHeight + rescaledHeight)); + this._top.setScaleX(horizontalScale); + + // Position centre + this._centre.setPosition(cc.p(leftWidth, bottomHeight)); + } }, ctor:function () { @@ -237,7 +269,6 @@ cc.Scale9Sprite = cc.Node.extend({ initWithBatchNode:function (batchNode, rect, unused, capInsets) { if (batchNode) { this.updateWithBatchNode(batchNode, rect, unused, capInsets); - this.setAnchorPoint(cc.p(0.5, 0.5)); } this.m_positionsAreDirty = true; return true; @@ -377,16 +408,27 @@ cc.Scale9Sprite = cc.Node.extend({ this._spriteRect = rect; this._originalSize = new cc.Size(rect.size.width, rect.size.height); this._preferredSize = this._originalSize; - this._capInsetsInternal = capInsets; + this._capInsetsInternal = capInsets || cc.RectZero(); // If there is no specified center region - if (cc.Rect.CCRectEqualToRect(this._capInsetsInternal, cc.RectZero())) { + if (cc.Rect.CCRectEqualToRect(this._capInsetsInternal, cc.RectZero()) || + cc.Rect.CCRectEqualToRect(this._capInsetsInternal, this._spriteRect)) { // Apply the 3x3 grid format this._capInsetsInternal = cc.RectMake( rect.origin.x + this._originalSize.width / 3, rect.origin.y + this._originalSize.height / 3, this._originalSize.width / 3, this._originalSize.height / 3); + this._capInsets = null; + } + else + { + this._capInsetsInternal = cc.RectMake( + rect.origin.x + this._capInsetsInternal.origin.x, + rect.origin.y + this._capInsetsInternal.origin.y, + this._capInsetsInternal.size.width, + this._capInsetsInternal.size.height + ); } // Get the image edges @@ -456,6 +498,7 @@ cc.Scale9Sprite = cc.Node.extend({ this.setContentSize(rect.size); this.addChild(this._scale9Image); + this.setAnchorPoint(cc.p(0.5, 0.5)); return true; }, diff --git a/samples b/samples index 6fe2ddb0e2..e13d88278e 160000 --- a/samples +++ b/samples @@ -1 +1 @@ -Subproject commit 6fe2ddb0e2dd7c37b463a246d3cf31fa1668441f +Subproject commit e13d88278e33fa16ff4174b0aa1049c3d4ab01af From 564becc913c94f8d8a2c5c325402e5c2244d8681 Mon Sep 17 00:00:00 2001 From: Timm Drevensek Date: Thu, 24 Jan 2013 11:08:28 +0100 Subject: [PATCH 3/5] scaling now has a different behavior --- .../GUI/CCControlExtension/CCScale9Sprite.js | 91 ++++++------------- samples | 2 +- 2 files changed, 31 insertions(+), 62 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.js b/extensions/GUI/CCControlExtension/CCScale9Sprite.js index 8b13324600..5ea6d3c679 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.js +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.js @@ -93,67 +93,36 @@ cc.Scale9Sprite = cc.Node.extend({ this._bottom.setAnchorPoint(cc.p(0, 0)); this._centre.setAnchorPoint(cc.p(0, 0)); - if(!this._capInsets) - { - var equalWidth = size.width / 3; - var equalHeight = size.height / 3; - - var equalWidthScale = equalWidth / this._centre.getContentSize().width; - var equalHeightScale = equalHeight / this._centre.getContentSize().height; - - this._topLeft.setScale(equalWidthScale, equalHeightScale); - this._top.setScale(equalWidthScale, equalHeightScale); - this._topRight.setScale(equalWidthScale, equalHeightScale); - this._left.setScale(equalWidthScale, equalHeightScale); - this._centre.setScale(equalWidthScale, equalHeightScale); - this._right.setScale(equalWidthScale, equalHeightScale); - this._bottomLeft.setScale(equalWidthScale, equalHeightScale); - this._bottom.setScale(equalWidthScale, equalHeightScale); - this._bottomRight.setScale(equalWidthScale, equalHeightScale); - - this._topLeft.setPosition(cc.p(0, 2 * equalHeight)); - this._top.setPosition(cc.p(equalWidth, 2 * equalHeight)); - this._topRight.setPosition(cc.p(2 * equalWidth, 2 * equalHeight)); - this._left.setPosition(cc.p(0, equalHeight)); - this._centre.setPosition(cc.p(equalWidth, equalHeight)); - this._right.setPosition(cc.p(2 * equalWidth, equalHeight)); - this._bottomLeft.setPosition(cc.p(0, 0)); - this._bottom.setPosition(cc.p(equalWidth, 0)); - this._bottomRight.setPosition(cc.p(2 * equalWidth, 0)); - } - else - { - var sizableWidth = size.width - this._topLeft.getContentSize().width - this._topRight.getContentSize().width; - var sizableHeight = size.height - this._topLeft.getContentSize().height - this._bottomRight.getContentSize().height; - var horizontalScale = sizableWidth / this._centre.getContentSize().width; - var verticalScale = sizableHeight / this._centre.getContentSize().height; - this._centre.setScaleX(horizontalScale); - this._centre.setScaleY(verticalScale); - var rescaledWidth = this._centre.getContentSize().width * horizontalScale; - var rescaledHeight = this._centre.getContentSize().height * verticalScale; - - var leftWidth = this._bottomLeft.getContentSize().width; - var bottomHeight = this._bottomLeft.getContentSize().height; - - // Position corners - this._bottomLeft.setPosition(cc.p(0, 0)); - this._bottomRight.setPosition(cc.p(leftWidth + rescaledWidth, 0)); - this._topLeft.setPosition(cc.p(0, bottomHeight + rescaledHeight)); - this._topRight.setPosition(cc.p(leftWidth + rescaledWidth, bottomHeight + rescaledHeight)); - - // Scale and position borders - this._left.setPosition(cc.p(0, bottomHeight)); - this._left.setScaleY(verticalScale); - this._right.setPosition(cc.p(leftWidth + rescaledWidth, bottomHeight)); - this._right.setScaleY(verticalScale); - this._bottom.setPosition(cc.p(leftWidth, 0)); - this._bottom.setScaleX(horizontalScale); - this._top.setPosition(cc.p(leftWidth, bottomHeight + rescaledHeight)); - this._top.setScaleX(horizontalScale); - - // Position centre - this._centre.setPosition(cc.p(leftWidth, bottomHeight)); - } + var sizableWidth = size.width - this._topLeft.getContentSize().width - this._topRight.getContentSize().width; + var sizableHeight = size.height - this._topLeft.getContentSize().height - this._bottomRight.getContentSize().height; + var horizontalScale = sizableWidth / this._centre.getContentSize().width; + var verticalScale = sizableHeight / this._centre.getContentSize().height; + this._centre.setScaleX(horizontalScale); + this._centre.setScaleY(verticalScale); + var rescaledWidth = this._centre.getContentSize().width * horizontalScale; + var rescaledHeight = this._centre.getContentSize().height * verticalScale; + + var leftWidth = this._bottomLeft.getContentSize().width; + var bottomHeight = this._bottomLeft.getContentSize().height; + + // Position corners + this._bottomLeft.setPosition(cc.p(0, 0)); + this._bottomRight.setPosition(cc.p(leftWidth + rescaledWidth, 0)); + this._topLeft.setPosition(cc.p(0, bottomHeight + rescaledHeight)); + this._topRight.setPosition(cc.p(leftWidth + rescaledWidth, bottomHeight + rescaledHeight)); + + // Scale and position borders + this._left.setPosition(cc.p(0, bottomHeight)); + this._left.setScaleY(verticalScale); + this._right.setPosition(cc.p(leftWidth + rescaledWidth, bottomHeight)); + this._right.setScaleY(verticalScale); + this._bottom.setPosition(cc.p(leftWidth, 0)); + this._bottom.setScaleX(horizontalScale); + this._top.setPosition(cc.p(leftWidth, bottomHeight + rescaledHeight)); + this._top.setScaleX(horizontalScale); + + // Position centre + this._centre.setPosition(cc.p(leftWidth, bottomHeight)); }, ctor:function () { diff --git a/samples b/samples index e13d88278e..6b64d616c9 160000 --- a/samples +++ b/samples @@ -1 +1 @@ -Subproject commit e13d88278e33fa16ff4174b0aa1049c3d4ab01af +Subproject commit 6b64d616c996b6aa4e20a28b4b03060a80f13845 From efdcd60aa82b0ac6be061c687d43cabed7ff9635 Mon Sep 17 00:00:00 2001 From: Timm Drevensek Date: Thu, 24 Jan 2013 11:10:40 +0100 Subject: [PATCH 4/5] minimize difference --- .../GUI/CCControlExtension/CCScale9Sprite.js | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.js b/extensions/GUI/CCControlExtension/CCScale9Sprite.js index 5ea6d3c679..4ee8a0974c 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.js +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.js @@ -80,19 +80,8 @@ cc.Scale9Sprite = cc.Node.extend({ }, _updatePositions:function () { - var size = this._contentSize; - this._bottomLeft.setAnchorPoint(cc.p(0, 0)); - this._bottomRight.setAnchorPoint(cc.p(0, 0)); - this._topLeft.setAnchorPoint(cc.p(0, 0)); - this._topRight.setAnchorPoint(cc.p(0, 0)); - this._left.setAnchorPoint(cc.p(0, 0)); - this._right.setAnchorPoint(cc.p(0, 0)); - this._top.setAnchorPoint(cc.p(0, 0)); - this._bottom.setAnchorPoint(cc.p(0, 0)); - this._centre.setAnchorPoint(cc.p(0, 0)); - var sizableWidth = size.width - this._topLeft.getContentSize().width - this._topRight.getContentSize().width; var sizableHeight = size.height - this._topLeft.getContentSize().height - this._bottomRight.getContentSize().height; var horizontalScale = sizableWidth / this._centre.getContentSize().width; @@ -105,6 +94,16 @@ cc.Scale9Sprite = cc.Node.extend({ var leftWidth = this._bottomLeft.getContentSize().width; var bottomHeight = this._bottomLeft.getContentSize().height; + this._bottomLeft.setAnchorPoint(cc.p(0, 0)); + this._bottomRight.setAnchorPoint(cc.p(0, 0)); + this._topLeft.setAnchorPoint(cc.p(0, 0)); + this._topRight.setAnchorPoint(cc.p(0, 0)); + this._left.setAnchorPoint(cc.p(0, 0)); + this._right.setAnchorPoint(cc.p(0, 0)); + this._top.setAnchorPoint(cc.p(0, 0)); + this._bottom.setAnchorPoint(cc.p(0, 0)); + this._centre.setAnchorPoint(cc.p(0, 0)); + // Position corners this._bottomLeft.setPosition(cc.p(0, 0)); this._bottomRight.setPosition(cc.p(leftWidth + rescaledWidth, 0)); From 5abdcd13bb8ac3a21cb8719732e500b7d0ced37b Mon Sep 17 00:00:00 2001 From: Timm Drevensek Date: Thu, 24 Jan 2013 17:31:00 +0100 Subject: [PATCH 5/5] fix --- cocos2d/sprite_nodes/CCSprite.js | 8 ++++++++ samples | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cocos2d/sprite_nodes/CCSprite.js b/cocos2d/sprite_nodes/CCSprite.js index 2e96f6a2b5..a6246039e0 100644 --- a/cocos2d/sprite_nodes/CCSprite.js +++ b/cocos2d/sprite_nodes/CCSprite.js @@ -244,6 +244,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _texture:null, _originalTexture:null, _color:null, + _colorized:false, // // Shared data // @@ -912,6 +913,12 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ this._rect.size.width = this._texture.width; this._rect.size.height = this._texture.height; context.drawImage(this._texture, posX, -(posY + this._texture.height)); + } else if(this._colorized) { + context.drawImage(this._texture, + 0, 0, + this._rect.size.width, this._rect.size.height, + posX, -(posY + this._rect.size.height), + this._rect.size.width, this._rect.size.height); } else { context.drawImage(this._texture, this._rect.origin.x, this._rect.origin.y, @@ -1440,6 +1447,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ if (cc.renderContextType === cc.CANVAS) { var cacheTextureForColor = cc.TextureCache.getInstance().getTextureColors(this._originalTexture); if (cacheTextureForColor) { + this._colorized = true; //generate color texture cache if (this._texture instanceof HTMLCanvasElement && !this._rectRotated) { cc.generateTintImage(this.getTexture(), cacheTextureForColor, this._color, this.getTextureRect(), this._texture); diff --git a/samples b/samples index 6b64d616c9..11315bd617 160000 --- a/samples +++ b/samples @@ -1 +1 @@ -Subproject commit 6b64d616c996b6aa4e20a28b4b03060a80f13845 +Subproject commit 11315bd61785e291f97bdbe34d759d2165871ef5