Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Issue #4277: add setSpriteFrame function to cc.Sprite #1664

Merged
merged 2 commits into from

1 participant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
24 AUTHORS.txt
@@ -101,6 +101,17 @@ Christian Schwartz @cschwartz SpriteFrame.initWithTextureFilename converted
XiaoJun Zheng @SmallAiTT _getResType error fix
cc.ScrollView bug fix
cc.LabelTTF bug fix
+ rewrite functions in CCNS.js with regex
+ refactor CCScheduler.js and CCCommon.js
+ cc.BMFontConfiguration bug fix
+ refactor cc.Application to cc.game
+ refactor cc.loader
+ refactor cc.Textur2D
+ refactor some functions about array operation
+ move sys.xxx to cc.sys.xxx
+ refactor some public functions in cc to private
+ add node.js scripts for publishing game
+ refactor cc.CCBReader
Guozhu Cheng @bengol cc.SimpleAudioEngine bug fix
@@ -118,11 +129,12 @@ Luis Parravicini @luisparravicini cc.Director refactoring
typo fix
Jose Antonio @jandujar cc.ParticleSystem bug fix for CocoStudio animations
+ SceneReader bug fix
BoHao Tang @btspoony cc.TableView bug fix
Claudiu @csaftoiu cc.LabelTTF bug fix
- cc.DrawNode bug fix
+ cc.DrawNode bugs fix
cc.NodeRGBA bug fix
cc.Texture2D bug fix
@@ -137,6 +149,16 @@ XieDaijin @NijiadeIX CCControl bug fix
samael @samael65535 CCPhysicsSprite bug fix
+NatWeiss @NatWeiss Add analytics plugin protocol ,Flurry plugin and ProtocolAds.js plugin protocol
+ cc.FileUtils refactoring
+
+Andor Salga @asalga typo fix
+
+erykwalder @erykwalder Function.prototype.bind bug fix
+
+ZippoLag @ZippoLag cc.Application.getCurrentLanguage bug fix
+
+
Cocos2d-x and cocos2d-html5 can not grow so fast without the active community.
Thanks to all developers who report & trace bugs, dicuss the engine usage in forum & QQ groups!
View
4 cocos2d/actions/CCActionInterval.js
@@ -2407,7 +2407,7 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{
var numberOfFrames = frames.length, locSplitTimes = this._splitTimes;
for (var i = this._nextFrame; i < numberOfFrames; i++) {
if (locSplitTimes[i] <= time) {
- this.target.setDisplayFrame(frames[i].getSpriteFrame());
+ this.target.setSpriteFrame(frames[i].getSpriteFrame());
this._nextFrame = i + 1;
} else {
// Issue 1438. Could be more than one frame per tick, due to low frame rate or frame delta < 1/FPS
@@ -2442,7 +2442,7 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{
*/
stop:function () {
if (this._animation.getRestoreOriginalFrame() && this.target)
- this.target.setDisplayFrame(this._origFrame);
+ this.target.setSpriteFrame(this._origFrame);
cc.Action.prototype.stop.call(this);
}
});
View
41 cocos2d/core/sprites/CCSprite.js
@@ -450,7 +450,7 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{
spriteFrame.addLoadedEventListener(this._spriteFrameLoadedCallback, this);
}
var ret = this.initWithTexture(spriteFrame.getTexture(), spriteFrame.getRect());
- this.setDisplayFrame(spriteFrame);
+ this.setSpriteFrame(spriteFrame);
return ret;
},
@@ -759,7 +759,7 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{
cc.log("cc.Sprite.setDisplayFrameWithAnimationName(): Invalid frame index");
return;
}
- this.setDisplayFrame(animFrame.getSpriteFrame());
+ this.setSpriteFrame(animFrame.getSpriteFrame());
},
/**
@@ -1529,12 +1529,19 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{
// Frames
/**
- * Sets a new display frame to the cc.Sprite.
- * @param {cc.SpriteFrame} newFrame
+ * Sets a new spriteFrame to the cc.Sprite.
+ * @param {cc.SpriteFrame|String} newFrame
+ * @deprecated
*/
- setDisplayFrame: null,
+ setSpriteFrame: null,
+
+ _setSpriteFrameForWebGL: function (newFrame) {
+ if(typeof(newFrame) == "string"){
+ newFrame = cc.spriteFrameCache.getSpriteFrame(newFrame);
+ if(!newFrame)
+ throw "Invalid spriteFrameName";
+ }
- _setDisplayFrameForWebGL: function (newFrame) {
this.setNodeDirty(true);
var frameOffset = newFrame.getOffset();
this._unflippedOffsetPositionFromCenter.x = frameOffset.x;
@@ -1563,7 +1570,13 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{
this.setTextureRect(newFrame.getRect(), this._rectRotated, newFrame.getOriginalSize());
},
- _setDisplayFrameForCanvas: function (newFrame) {
+ _setSpriteFrameForCanvas: function (newFrame) {
+ if(typeof(newFrame) == "string"){
+ newFrame = cc.spriteFrameCache.getSpriteFrame(newFrame);
+ if(!newFrame)
+ throw "Invalid spriteFrameName";
+ }
+
this.setNodeDirty(true);
var frameOffset = newFrame.getOffset();
@@ -1603,6 +1616,16 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{
},
/**
+ * Sets a new display frame to the cc.Sprite.
+ * @param {cc.SpriteFrame|String} newFrame
+ * @deprecated
+ */
+ setDisplayFrame: function(newFrame){
+ cc.log("setDisplayFrame is deprecated, please use setSpriteFrame instead.");
+ this.setSpriteFrame(newFrame);
+ },
+
+ /**
* Returns whether or not a cc.SpriteFrame is being displayed
* @param {cc.SpriteFrame} frame
* @return {Boolean}
@@ -2036,7 +2059,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
_p.setOpacity = _p._setOpacityForWebGL;
_p.setColor = _p._setColorForWebGL;
_p.updateDisplayedColor = _p._updateDisplayedColorForWebGL;
- _p.setDisplayFrame = _p._setDisplayFrameForWebGL;
+ _p.setSpriteFrame = _p._setSpriteFrameForWebGL;
_p.isFrameDisplayed = _p._isFrameDisplayedForWebGL;
_p.setBatchNode = _p._setBatchNodeForWebGL;
_p.setTexture = _p._setTextureForWebGL;
@@ -2056,7 +2079,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
_p.setOpacity = _p._setOpacityForCanvas;
_p.setColor = _p._setColorForCanvas;
_p.updateDisplayedColor = _p._updateDisplayedColorForCanvas;
- _p.setDisplayFrame = _p._setDisplayFrameForCanvas;
+ _p.setSpriteFrame = _p._setSpriteFrameForCanvas;
_p.isFrameDisplayed = _p._isFrameDisplayedForCanvas;
_p.setBatchNode = _p._setBatchNodeForCanvas;
_p.setTexture = _p._setTextureForCanvas;
View
4 extensions/ccb-reader/CCBAnimationManager.js
@@ -542,7 +542,7 @@ cc.BuilderAnimationManager = cc.Class.extend({
} else if(propName === "opacity"){
node.setOpacity(value);
} else if(propName === "displayFrame"){
- node.setDisplayFrame(value);
+ node.setSpriteFrame(value);
} else if(propName === "color"){
var ccColor3B = value.getColor();
if(ccColor3B.r !== 255 || ccColor3B.g !== 255 || ccColor3B.b !== 255){
@@ -672,7 +672,7 @@ cc.BuilderSetSpriteFrame = cc.ActionInstant.extend({
return true;
},
update:function (time) {
- this.target.setDisplayFrame(this._spriteFrame);
+ this.target.setSpriteFrame(this._spriteFrame);
}
});
View
2  extensions/ccb-reader/CCSpriteLoader.js
@@ -61,7 +61,7 @@ cc.SpriteLoader = cc.NodeLoader.extend({
onHandlePropTypeSpriteFrame:function (node, parent, propertyName, ccSpriteFrame, ccbReader) {
if (propertyName === PROPERTY_DISPLAYFRAME) {
if(ccSpriteFrame)
- node.setDisplayFrame(ccSpriteFrame);
+ node.setSpriteFrame(ccSpriteFrame);
else
cc.log("ERROR: SpriteFrame is null");
} else {
Something went wrong with that request. Please try again.