diff --git a/source/core/src/main/com/csse3200/game/components/upgrades/DancePartyUpgrade.java b/source/core/src/main/com/csse3200/game/components/upgrades/DancePartyUpgrade.java index 84421bb6..735d4e6d 100644 --- a/source/core/src/main/com/csse3200/game/components/upgrades/DancePartyUpgrade.java +++ b/source/core/src/main/com/csse3200/game/components/upgrades/DancePartyUpgrade.java @@ -162,8 +162,11 @@ public void activate() { public void deactivate() { isActive = false; layout.setVisible(false); - meter.remove(); - text.remove(); + // Ensure the text and meter are removed from the stage after time finish + if (meter != null && meter.hasParent()) { + meter.remove(); + text.remove(); + } ServiceLocator.getDocketService().getEvents().trigger("UnDancing"); } diff --git a/source/core/src/main/com/csse3200/game/components/upgrades/ExtortionUpgrade.java b/source/core/src/main/com/csse3200/game/components/upgrades/ExtortionUpgrade.java index bd3543ff..94906680 100644 --- a/source/core/src/main/com/csse3200/game/components/upgrades/ExtortionUpgrade.java +++ b/source/core/src/main/com/csse3200/game/components/upgrades/ExtortionUpgrade.java @@ -144,8 +144,11 @@ public void deactivate() { ServiceLocator.getRandomComboService().getEvents().trigger("extortion unactive"); - meter.remove(); - text.remove(); + // Ensure the text and meter are removed from the stage after time finish + if (meter != null && meter.hasParent()) { + meter.remove(); + text.remove(); + } } /**