1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | SnailBait.prototype = { ... createRubySprites: function () { var ruby, rubyArtist = new SpriteSheetArtist(this.spritesheet, this.rubyCells); for (var i = 0; i < this.rubyData.length; ++i) { ruby = new Sprite('ruby', rubyArtist, [ new CycleBehavior(this.RUBY_SPARKLE_DURATION, this.RUBY_SPARKLE_INTERVAL), new BounceBehavior(800, 600, 120) ]); ruby.width = this.RUBY_CELLS_WIDTH; ruby.height = this.RUBY_CELLS_HEIGHT; ruby.value = 100; this.rubies.push(ruby); } }, ... }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | var SnailBait = function () { ... // The collide behavior is attached to the runner this.collideBehavior = { ... adjustScore: function (otherSprite) { if (otherSprite.value) { snailBait.score += otherSprite.value; snailBait.score = snailBait.score < 0 ? 0 : snailBait.score; snailBait.scoreElement.innerHTML = snailBait.score; } }, ... } }; |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |