Skip to content

Instantly share code, notes, and snippets.

@ippa
Created February 15, 2011 23:18
Show Gist options
  • Save ippa/828497 to your computer and use it in GitHub Desktop.
Save ippa/828497 to your computer and use it in GitHub Desktop.
Sprite.prototype.createInDOM = function() {
this.dom_element = this.image
this.dom_element.style.position = "absolute"
document.body.appendChild(this.dom_element)
this.updateDOM()
}
Sprite.prototype.updateDOM = function() {
this.dom_element.style.left = this.x + "px"
this.dom_element.style.top = this.y + "px"
var transform = ""
transform += "rotate(" + this.angle + "deg) "
if(this.flipped) { transform += "scale(-" + this.scale + "," + this.scale + ")"; }
else if(this.scale != 1) { transform += "scale(" + this.scale + ")"; }
this.dom_element.style.MozTransform = transform
this.dom_element.style.WebkitTransform = transform
this.dom_element.style.transform = transform
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment