Delete object(with animation)

Hi,

I found a framework “animation(Spine)”, made an animation, and all that is required for the animation to work and be displayed in the Corona
The question is, how to remove an object(with animation)? If

animatedObj:removeSelf() -> Error: attempt to call method 'removeSelf' (a nil value)
print(animatedObj.__index) -> table: 0CFC3E80
print(animatedObj._properties) -> nil
display.remove( animatedObj ) -> Do nothing
animatedObj:identifyBoundingBoxes() -> 
->table: 0CFB0548 {
->  [_class] => table: 0CFB0548 {
->                [removeEventListener] => function: 0F4003D0
->                [addEventListener] => function: 0F400390
->                [__index] => table: 0F3D5E38 {
->                               *table: 0F3D5E38
->                             }
->              }
->  [_proxy] => userdata: 0CFB01C8
->}
->BoundingBox Name: drowned_anchor	=> YourInstance.imgBoxes[1]

Spine framework:


Character animation using Spine and meshes:
https://coronalabs.com/blog/coronageek/corona-geek-189/

Some examples from my code:

drowned_anchor_cfg = {
	spineJson = "img/local/creeps/drowned_anchor/drowned_anchor.json",
	imageSheetName = "img/local/creeps/drowned_anchor/drowned_anchor.png",
	texturePackerLuaFile = "img.local.creeps.drowned_anchor.drowned_anchor",
	debug = false,
	debugAabb = false,
	----skin = "greenGuy",
	animationName = "stand",
	animLoop = false,
	scale = 0.5,
	displayGroup = backgroundGroup
}
function checkIfDead()
	for i=1, #unit_creep do
		if unit_creep[i] ~= nil and creep_monster_hp[i] ~= nil and tonumber(unit_creep[i].imgBoxes[1].hp) <= 0 then
			creep_monster_hp[i]:removeSelf()
			creep_monster_hp[i]= nil
			unit_creep[i]:identifyBoundingBoxes()
			--unit_creep[i]:removeSelf()
			--print(unit_creep[i].__index)
			--print(unit_creep.__index)
			--print(unit_creep._properties)
			--unit_creep[i].imgBoxes[1]:removeSelf()
			--display.remove( unit_creep[i] )
			--display.remove( unit_creep[i].imgBoxes[1] )
		end

	end
end
for r = 1, #sampleData_monsters_anim do
	counter_creep = counter_creep+1
	addCounter_creep = counter_creep*280+(maxScale*100)
	local p = sampleData_monsters_anim[r]
	unit_creep[r] = SpineHelper:new(drowned_anchor_cfg )
	unit_creep[r]:changeAnimation({newAnimation=p.anim, loop=true})
	unit_creep[r]:drawBoundingBox({bone=p.boundingBone, slot=p.boundingSlot, boundingBox=p.boundingBox})
	unit_creep[r].x = (_W/2.2) + addCounter_creep
	unit_creep[r].y = _H-425
	unit_creep[r].imgBoxes[1].name = p.name
	unit_creep[r].imgBoxes[1].id = p.id
	unit_creep[r].imgBoxes[1].hp = p.hp
	unit_creep[r].imgBoxes[1]:toFront()
	unit_creep[r].imgBoxes[1]:addEventListener( "tap", activeHero_enemy );
	--backgroundGroup:insert(unit_creep[r])
	unit_creep[r].skill = {}
	for e = 1, #p.skill do
		unit_creep[r].skill[e] = {}
		unit_creep[r].skill[e].name = p.skill[e].name
		unit_creep[r].skill[e].description = p.skill[e].description
		unit_creep[r].skill[e].doing = p.skill[e].doing
	end
end
P.S.

ezgif-3-c3491529e028

Not sure if that’s what you are referring to but have you looked into the transition library?

https://docs.coronalabs.com/api/library/transition/index.html

Example:

    transition.to( obj, {time = 1000, alpha = 0, onComplete = function ()
           display.remove(obj)
           obj = nil
    end} )
2 Likes

Wow! Works!! :frowning:
Thank you for pointing the right way, now I know a little more about the capabilities of “transitionLib” :relaxed:

1 Like