[Resolved] Removing a display object from display group in order to reuse

Hi,

is there a way to remove a display object from display group without deleting rendering-related resources?

In object:removeSelf() documentation it says,
“”"
When an object is removed, the rendering-related resources of the removed object are deleted immediately.
“”"

But that’s NOT the behaviour I want. I’d like to put that display object into a queue and reuse it. The reason I need to do that is because on Android, it seems like creating new display object is an expensive operation. In our game, we have to generate new game item dynamically and if we do display.newImageRect as the game plays, it lags our game like crazy (we generate about 10~20 items per generation).

So the workaround for us is pre-generate display objects and reuse it over and over. So we need a way to remove display object from display group without deleting rendering-related resources.

Is it possible? [import]uid: 120903 topic_id: 33346 reply_id: 333346[/import]

Pretty sure you can remove from a group without deleting the object:

displayGroup:remove(object)

However because it’s part of the stage beyond display groups I don’t think it will have the result you want.

Can you not toggle the visibility on or off depending when you need it? [import]uid: 33275 topic_id: 33346 reply_id: 132409[/import]

From displayGroup:remove() documentation

“”"
Using this method will delete the specified child object, not simply remove it from the group. If you want to remove an object from a group, insert it into a different group, or insert it into the global StageObject group instead.
“”"

So I guess there is a workaround (i.e. inserting into a different group). Thanks @SegaBoy.
[import]uid: 120903 topic_id: 33346 reply_id: 132416[/import]

Pretty sure you can remove from a group without deleting the object:

displayGroup:remove(object)

However because it’s part of the stage beyond display groups I don’t think it will have the result you want.

Can you not toggle the visibility on or off depending when you need it? [import]uid: 33275 topic_id: 33346 reply_id: 132409[/import]

From displayGroup:remove() documentation

“”"
Using this method will delete the specified child object, not simply remove it from the group. If you want to remove an object from a group, insert it into a different group, or insert it into the global StageObject group instead.
“”"

So I guess there is a workaround (i.e. inserting into a different group). Thanks @SegaBoy.
[import]uid: 120903 topic_id: 33346 reply_id: 132416[/import]