Search the Community
Showing results for tags 'group.visible'.
-
I'm making a game similar to the traditional magic tower,and now I have a problem when dealing with the battles between the monster and the braver. here's my code in update(): function update(){ ... game.physics.arcade.collide(braver, monsters, battle, null, this); ... } and here's my battle(): function battle(player, monster) { var x = (player.attack > monster.defence ? player.attack - monster.defence : 0); var y = (monster.attack > player.defence ? monster.attack - player.defence : 0); battleScene.visible = true; while (1) { if (Date.now() > battleTimer) { battleTimer = Date.now() + 1000; monster.health -= x; if (monster.health <= 0) { monster.kill(); player.gold += monster.gold; player.exp += monster.exp; break; } player.health -= y; if (player.health <= 0) { player.kill(); break; } } } battleScene.visible = false; } battleScene is a group,the battle box,What makes me crazy is that battleScene doesn't show on the screen at all(even with battleScene.visible = true),I've tried game.world.bringToTop(battleScene); but it doesn't work,too.So how can I fix that bug?