diff options
| -rw-r--r-- | Cat.js | 12 | ||||
| -rw-r--r-- | index.html | 17 |
2 files changed, 26 insertions, 3 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)); @@ -9,6 +9,7 @@ <script src="../EaselJS/src/easeljs/display/SpriteSheet.js"></script> <script src="../EaselJS/src/easeljs/display/Shadow.js"></script> <script src="../EaselJS/src/easeljs/geom/Matrix2D.js"></script> +<script src="../EaselJS/src/easeljs/geom/Rectangle.js"></script> <script src="../EaselJS/src/easeljs/events/MouseEvent.js"></script> <script src="../EaselJS/src/easeljs/events/KeyboardEvent.js"></script> <script src="../EaselJS/src/easeljs/display/DisplayObject.js"></script> @@ -22,12 +23,26 @@ <!-- <script src="easel.js"></script> --> + <script src="Gag.js"></script> <script src="Cat.js"></script> <script src="catgag.js"></script> + +<style> +#log { +border: 1px solid black; +float: left; +width: 400px; +height: 400px; +} + +</style> + </head> <body> <div class="canvasHolder"> - <canvas id="canvas" width="800" height="600" style="border: 1px solid black" ></canvas> + <canvas id="canvas" width="800" height="600" style="border: 1px solid black; float: left; margin-right: 10px;" ></canvas> + <textarea id="log"></textarea> + <div style="clear: both;" /> </div> <div id="help"> <p> |
