diff --git a/evwkow5289.js b/evwkow5289.js index cddcbe2..f7cb525 100644 --- a/evwkow5289.js +++ b/evwkow5289.js @@ -7,7 +7,16 @@ if (!this.initialized) { this.dom = this.entityLoaded.dom; - var size = GameLib.Utils.GetWindowSize(); + GameLib.Event.Subscribe( + GameLib.Event.WINDOW_RESIZE, + function(data) { + this.size = data; + this.x = size.width / 2; + this.y = size.height / 2; + }.bind(this) + ) + + this.size = GameLib.Utils.GetWindowSize(); this.x = size.width / 2; this.y = size.height / 2; @@ -45,16 +54,16 @@ if (this.x < 0) { this.x = 0; } -if (this.x > size.width) { - this.x = size.width; +if (this.x > this.size.width) { + this.x = this.size.width; } if (this.y < 0) { this.y = 0; } -if (this.y > size.height) { - this.y = size.height; +if (this.y > this.size.height) { + this.y = this.size.height; } GameLib.Event.Emit(