when the boss is killed, trigger an event. then try using the following code:
Code: Select all
local BOSS_EVENT = "boss_killed" --name of event triggered when the boss dies
local ENEMY_LAYER = "enemies" --name of the layer with enemies on it
function onEvent(eventName)
if(eventName == BOSS_EVENT) then
SaveData[Level.filename()] = SaveData[Level.filename()] or {}
SaveData[Level.filename()].missionClear = true
end
end
function onStart()
if(SaveData[Level.filename()] and SaveData[Level.filename()].missionClear == true) then
Layer.get(ENEMY_LAYER):hide(true)
end
end
this should also be portable across levels should you ever need another level with the same mechanic.
(if it doesn't work, let me know cause i'm typing this off the top of my head haha~)