microspace Posted September 6, 2018 Share Posted September 6, 2018 I'm creating group of items (barrels). After killing some of items with weapon, I call items.callAll('revive');, but barrels are spawning in random position. Who came across with this problem? items = this.game.add.group(); items.enableBody = true; // inside for loop: var sprite = group.create(element.x, element.y, 'barrel'); Link to comment Share on other sites More sharing options...
samme Posted September 6, 2018 Share Posted September 6, 2018 Normally sprites reappear at the same position as before (because they were just hidden the whole time). How are you killing the barrels? Link to comment Share on other sites More sharing options...
microspace Posted September 13, 2018 Author Share Posted September 13, 2018 I do this: //bullets weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; weapon.bulletAngleOffset = 0; weapon.bulletSpeed = 400; weapon.fireAngle = Phaser.ANGLE_RIGHT; // shoot at right direcion by default weapon.trackSprite(player, 0, -9, false); //-65 выведено экспериментальным путём //weapon.addBulletAnimation("fly", [0, 1, 2, 3, 4, 5, 6, 7], 40, true); this code executes when bullet hits barrel: bulletHitBarrel: function(sprite, bullet) { var damage = 48; sprite.damage(damage); explosion.x = sprite.x; explosion.y = sprite.y - 30; explosion.visible = true; explosion.animations.play('EXPL'); bullet.kill(); }, I think that this is bug. Anyway I avoided it the other way (I set limit for health to not to drop below minimal level) Link to comment Share on other sites More sharing options...
Recommended Posts