Created
May 29, 2012 08:10
-
-
Save tonistiigi/2823223 to your computer and use it in GitHub Desktop.
LimeJS Sprite clone method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lime.Node.prototype.clone = function() { | |
var copy = new this.constructor() | |
.setScale(this.getScale()) | |
.setPosition(this.getPosition()) | |
.setSize(this.getSize()) | |
.setAnchorPoint(this.getAnchorPoint()) | |
.setRotation(this.getRotation()) | |
.setAutoResize(this.getAutoResize()) | |
.setOpacity(this.getOpacity()); | |
for (var i = 0; i < this.children_.length; i++) { | |
copy.appendChild(this.children_[i].clone()); | |
} | |
return copy; | |
}; | |
lime.Sprite.prototype.clone = function() { | |
return goog.base(this, 'clone') | |
.setFill(this.getFill()) | |
.setStroke(this.getStroke()); | |
}; | |
lime.Label.prototype.clone = function() { | |
return goog.base(this, 'clone') | |
.setText(this.getText()) | |
.setFontFamily(this.getFontFamily()) | |
.setFontSize(this.getFontSize()) | |
.setFontColor(this.getFontColor()) | |
.setAlign(this.getAlign()) | |
.setFontWeight(this.getFontWeight()) | |
.setPadding(this.getPadding()) | |
.setLineHeight(this.getLineHeight()) | |
.setShadowColor(this.getShadowColor()) | |
.setShadowBlur(this.getShadowBlur()) | |
.setShadowOffset(this.getShadowOffset()); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment