Skip to content

Instantly share code, notes, and snippets.

@tonistiigi
Created May 29, 2012 08:10
Show Gist options
  • Save tonistiigi/2823223 to your computer and use it in GitHub Desktop.
Save tonistiigi/2823223 to your computer and use it in GitHub Desktop.
LimeJS Sprite clone method
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