Created
March 13, 2013 14:06
-
-
Save unstoppablecarl/5152423 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
updateSize: function(width, height){ | |
// get current center | |
var centerX = this.pos.x + this.size.x/2, | |
centerY = this.pos.y + this.size.y/2; | |
// set new width / height | |
this.size.x = width; | |
this.size.y = height; | |
// make the center coord match what it was previously | |
this.pos.x = centerX - this.size.x/2; | |
this.pos.y = centerY - this.size.y/2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment