trueicecold Posted March 16, 2015 Share Posted March 16, 2015 Hello, I'm trying to destroy a group after an animation ends, but I'm getting script errors... Code:this.enemy_sprite = this.group.create(x, y, 'zombie');this.enemy_sprite.scale.set(1);this.enemy_sprite.scale.x = -1;this.enemy_sprite.smoothed = false;this.enemy_sprite.anchor.set(0.5, 0.5);this.walk_anim = this.enemy_sprite.animations.add('walk');this.walk_anim.play(10, true);this.group.destroy(true);works ok, but:this.enemy_sprite = this.group.create(x, y, 'zombie');this.enemy_sprite.scale.set(1);this.enemy_sprite.scale.x = -1;this.enemy_sprite.smoothed = false;this.enemy_sprite.anchor.set(0.5, 0.5);this.walk_anim = this.enemy_sprite.animations.add('walk');this.walk_anim.onComplete.add(this.destroy, this);this.walk_anim.play(10, false);this.destroy = function() { this.group.destroy(true);}causes a JS error: Uncaught TypeError: Cannot read property 'getFrame' of null phaser.js:53464 Phaser.Animation.update phaser.js:53464 Phaser.AnimationManager.update phaser.js:52802 Phaser.Sprite.preUpdate phaser.js:37442 Phaser.Group.preUpdate phaser.js:21860 Phaser.Group.preUpdate phaser.js:21860 Phaser.Stage.preUpdate phaser.js:20367 Phaser.Game.updateLogic phaser.js:26737 Phaser.Game.update phaser.js:26684 Phaser.RequestAnimationFrame.updateRAF phaser.js:46614 Phaser.RequestAnimationFrame.start._onLoop phaser.js:46598 I'm using the latest Phaser 2.2.2 from github (pulled yesterday) Link to comment Share on other sites More sharing options...
Recommended Posts