diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2011-08-04 22:08:09 +0300 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2011-08-04 22:08:09 +0300 |
| commit | 925e2c397f4be7ae9413b6e9e262b1bc47d5ce8c (patch) | |
| tree | a4975838e6cf70f4499676b0ec600ab6f5a5e478 /Cat.js | |
| parent | 7959a10b847947d91601f1ed53f750cc0f77d878 (diff) | |
| download | catgag-925e2c397f4be7ae9413b6e9e262b1bc47d5ce8c.tar.gz catgag-925e2c397f4be7ae9413b6e9e262b1bc47d5ce8c.zip | |
Make gagging work
Diffstat (limited to 'Cat.js')
| -rw-r--r-- | Cat.js | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -42,7 +42,11 @@ var p = Cat.prototype = new Container(); } for (i = 0; this._gags[i]; i++) { - //if (this._gags[i].escaped && + if (this._gags[i].escaped && this.rect().collidesWith(this._gags[i].rect())) { + window.Log("CATCHED"); + this.getStage().removeChild(this._gags[i]); + this._gags.splice(i, 1); + } } } @@ -59,10 +63,14 @@ var p = Cat.prototype = new Container(); p.gag = function() { if (!this._gagging) { this._gagging = true; - // @todo create/shoot the gag + this._gags.push(new Gag(this, this.x, this.y, this.rotation)); window.setTimeout(function(cat) { cat._gagging = false; }, 250, this); } } + + p.rect = function() { + return new Rectangle(this.x-this.regX, this.y-this.regY, this.img.width, this.img.height); + } window.Cat = Cat; }(window)); |
