1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | var SnailBait = function () { processCollision: function (sprite, otherSprite) { if ('coin' === otherSprite.type || // bad guys 'sapphire' === otherSprite.type || 'ruby' === otherSprite.type || 'button' === otherSprite.type || 'snail bomb' === otherSprite.type) { otherSprite.visible = false; } if ('bat' === otherSprite.type || // good guys 'bee' === otherSprite.type || 'snail' === otherSprite.type || 'snail bomb' === otherSprite.type) { snailBait.explode(sprite); } if (sprite.jumping && 'platform' === otherSprite.type) { this.processPlatformCollisionDuringJump(sprite, otherSprite); } }, ... }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | processPlatformCollisionDuringJump: function (sprite, platform) { var isDescending = sprite.descendAnimationTimer.isRunning(); sprite.stopJumping(); if (isDescending) { // Collided with platform while descending // land on platform sprite.track = platform.track; sprite.top = snailBait.calculatePlatformTop(sprite.track) - sprite.height; } else { // Collided with platform while ascending sprite.fall(); } } }; |
1 2 3 4 5 6 7 8 9 10 11 12 | var SnailBait = function () { ... this.runner.fall = function () { snailBait.runner.track = 1; snailBait.runner.top = snailBait.calculatePlatformTop(snailBait.runner.track) - snailBait.runner.height; }; ... }; |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |