I make a Game Object called fx_slash.go that contains a sprite component (#sprite) which will play animation slash. It’s a 4-frames flip-book animation.
And my enemy.go contains a factory component (#factory_fx_slash) that set its prototype to fx_slash.go
Now I want to play a slash fx and then after the animation done do delete the whole game object (a game object spawned from fx_slash.go) not just its sprite component.
Is this following code acheived what I want? The slash fx is gone from the scene but I don’t know if the game object is still living in the dark or not.
enemy.script
local function play_fx_slash(self)
local pos = go.get_position(".")
local fx = factory.create("#factory_fx_slash", pos)
msg.post(msg.url(nil, fx, "sprite"), "play_animation", {id = hash("slash")})
end
function on_message(self, message_id, message, sender)
if message_id == hash("play_fx_slash") then
play_fx_slash(self)
elseif message_id == hash("animation_done") then
go.delete(sender) -- HERE, is the whole game object get deleted or just its sprite component?
end
end