| 1 | class FrogDestroyer extends GameObject |
| 2 | { |
| 3 | |
| 4 | timeOfDestroy = 0; |
| 5 | timer = 0; |
| 6 | |
| 7 | constructor (x, y, sprite, layer, animationLength, destroyAfter) |
| 8 | { |
| 9 | super(x, y, sprite, layer); |
| 10 | |
| 11 | this.renderer.setAnimation("destroy", 0, animationLength); |
| 12 | |
| 13 | this.timeOfDestroy = this.renderer.cycle.cycleArray.length * animationLength; |
| 14 | } |
| 15 | |
| 16 | update (deltaTime) |
| 17 | { |
| 18 | super.update(deltaTime); |
| 19 | |
| 20 | this.timer += deltaTime; |
| 21 | if (this.timer > this.timeOfDestroy) |
| 22 | { |
| 23 | this.destroy(); |
| 24 | } |
| 25 | } |
| 26 | } |