skeleton:removeSelf()

Type: function

Overview

Removes the skeleton, like object:removeSelf() on any display object; display.remove(skeleton) does the same. The skeleton overrides the display group’s removeSelf: it marks the skeleton removed, removes the meshes of any skeleton:split(), then calls the group’s own removeSelf.

A removed skeleton answers only the event-dispatcher keys; every other key reads nil, removeSelf included, so calling skeleton:removeSelf() a second time raises Lua’s attempt to call method 'removeSelf' (a nil value). Use display.remove(skeleton), or check if skeleton.removeSelf then, where the skeleton may already be removed. Removing skeletons describes what happens after removal.

Syntax

skeleton:removeSelf()

Example

spineboy:removeSelf()
print(spineboy.removeSelf)  -- nil: the skeleton is removed
display.remove(spineboy)    -- does nothing on a removed object