Santiago Posted October 9, 2017 Share Posted October 9, 2017 I can't get on working some animations to a group of enemies, and I can't solve it. I could do it with a spritesheet, but with an atlas seems not working here's the code: moveEnemies: function () { for (var i = 0; i < this.enemies.length; i++) { this.enemyChild = this.enemies.children[i]; if (this.enemyChild.body.touching.down) { if (this.enemyChild.body.x < (this.player.body.x - 40)) { this.enemyChild.body.velocity.x = 100; this.enemyChild.scale.x = 1; this.enemies.callAll('animations.add', 'animations', 'enemigoAnim',Phaser.Animation.generateFrameNames('caminaE_', 1, 4), 10, true); this.enemies.callAll('animations.play', 'animations', 'caminaE_'); } else if (this.enemyChild.body.x > (this.player.body.x + 40)) { this.enemyChild.body.velocity.x = -100; this.enemyChild.scale.x = -1; this.enemies.callAll('animations.add', 'animations', 'enemigoAnim',Phaser.Animation.generateFrameNames('caminaE_', 1, 4), 10, true); this.enemies.callAll('animations.play', 'animations', 'caminaE_'); } else { this.enemies.children[i].body.velocity.x = 0; //this.enemies.callAll('animations.stop', 'animations', 'enemigoAnim') } } } }, ataquePlayer: function () { if (this.Q.justDown && game.physics.arcade.overlap(this.player, this.enemies)) { //this.player.animations.play('ataque') this.counter++ game.physics.arcade.overlap(this.player, this.enemies, function (player, enemy) { enemy.damage(25); enemy.body.drag.x = 150 if (player.scale.x == 1) { enemy.body.velocity.x = 130 enemy.body.velocity.y = -300 } else { enemy.body.velocity.x = -130 enemy.body.velocity.y = -300 } }); } Link to comment Share on other sites More sharing options...
Santiago Posted October 11, 2017 Author Share Posted October 11, 2017 Nobody can help? Link to comment Share on other sites More sharing options...
samme Posted October 11, 2017 Share Posted October 11, 2017 this.enemies.callAll('animations.play', 'animations', 'enemigoAnim'); Link to comment Share on other sites More sharing options...
Recommended Posts