Aatos Media,
I haven’t tried this but have you tried to set the host’s Type to different value after the child is built to prevent it’s rebuild? This might again be a bad way to do this if this works but I had to share my idea
If you want to host appear after culling if it’s not destroyed by player then I don’t know what to do. Some how you need to iterate through child to host to set the Type…
And I think the removeSelf() or display.remove(object) is right way to do because in objectType.remove function uses the same method.
I have at the moment 2 different enemies in my map and both have own objectTypes in my gamedata.lua and have the addObjectType function in game.lua.
gamedata.lua:
[lua]
local F = {}
function F.EnemyList()
local objectType = {}
objectType.objectType = “Enemy”
– A function which creates your custom object
objectType.build = function(event)
local object = display.newSprite( sheetPic, sheetSequenceData)
physics.addBody( object, “static”, {radius = 25} )
object.x, object.y = event.object.x, event.object.y
event.object.parent:insert(object)
return object
end
– A function which deletes your custom object
objectType.remove = function(object)
display.remove(object)
end
return objectType
end
function F.BossList()
local objectType = {}
objectType.objectType = “Boss”
– A function which creates your custom object
objectType.build = function(event)
local object = display.newSprite( sheetPic, sheetSequenceData)
physics.addBody( object, “static”, {radius = 83})
object:setSequence( “spin” )
object:play()
object.x, object.y = event.object.x, event.object.y
event.object.parent:insert(object)
end
end
return object
end
– A function which deletes your custom object
objectType.remove = function(object)
display.remove(object)
end
return objectType
end
return F
[/lua]
game.lua:
[lua]
local gamedata = require( “gamedata” )
local BL = gamedata.BossList()
local EL = gamedata.EnemyList()
addObjectType(EL)
addObjectType(BL)
[/lua]
I stripped some unnecessary lines like variables for sprites etc.
I hope this helps!