子弹碰撞到边界需要出现爆炸动画,然后子弹消失,出现爆炸。
    难点是在指定位置出现爆炸点
    这里可以通过重新sprite的锚点来确定爆炸位置。

    1. TankWar.prototype.removeGun = function () {
    2. const {gun} = this;
    3. const getGun = gun.getChildAt(0);
    4. gun.removeChildren();
    5. this.boom(getGun.x,getGun.y)
    6. }
    1. TankWar.prototype.boom = function (x,y) {
    2. const {BOOM} = constants;
    3. const id = this.loader.resources.spaceship.spritesheet.animations;
    4. console.log(id[BOOM],BOOM)
    5. const boom = new PIXI.AnimatedSprite(id[BOOM]);
    6. boom.animationSpeed = 0.2;
    7. boom.play();
    8. boom.name= BOOM
    9. boom.loop = false;
    10. boom.onComplete = () => {
    11. const getBOOM = this.application.stage.getChildByName(BOOM);
    12. this.application.stage.removeChild(getBOOM);
    13. }
    14. boom.scale.x = 2;
    15. boom.scale.y = 2;
    16. boom.anchor.set(0.5,0.5);
    17. boom.x = x;
    18. boom.y = y;
    19. this.application.stage.addChild(boom);
    20. }