Object transition and remove

Hi all.
In my app, i have so much transition. I create some obj, transition and insert them to the scene view. When i jump to other scene, i must purge this scene, and that is problem

  • When I purge scene, how Corona destroy all children off scene view? It seem to corona doesn’t call object:removeSelf(). I want to overload the object.removeSelf to cancel object transition when remove them. But the purgeScene doesn’t call object removeSelf. What’s method corona use to destroy all children object when you remove the parent object?
  • Another question, when you call object:removeSelf() , does corona auto cancel all transition of this object? [import]uid: 9190 topic_id: 35597 reply_id: 335597[/import]

Hello @khanh.dq,
For scene management, are you using Storyboard or Director? To remove objects in a Storyboard scene, you must add them to the scene’s view group (self.view). For Director, you must add them to “localGroup”.

Corona does not auto-cancel transitions on objects. You must do this yourself. A convenient method is to attach the transitions to the objects themselves, as properties. That way you can have a handy method to loop through and stop all transitions on the scene end. Please check this blog post for more info:
http://www.coronalabs.com/blog/2012/08/15/faq-wednesday-display-object-listeners/

Best regards,
Brent [import]uid: 200026 topic_id: 35597 reply_id: 141479[/import]

Thanks Brent,
I used storyboard, and added all object to scene’s view. When I purge scene, all object is removed, but their transition isn’t cancel. And the method object.remove isn’t called.

Can you tell me what is method corona used to remove all object children when i call method removeSelf of parent object? I want to overload this method, and call transition.cancel exactly for what object have transition, without loop thought all object and find what have transition.

Because I create some object in other module, and don’t have the direct reference to them in my scene module. Overload the object.removeSelf is better way for me. [import]uid: 9190 topic_id: 35597 reply_id: 141488[/import]

Hi @khanh.dq,
When Corona clears the scene, it clears the display objects that are children of the scene (it clears them from the display hierarchy). It does not cancel transitions on them, timers, Runtime listeners, or clear out other references/tables/pointers to those objects. If you don’t clear out and “nil” all external references to the objects, they will remain locked in memory (bad).

So, you will need to loop through them somehow to cancel and remove the transitions. You can store references to your objects in another table and loop through it… but if you do, you must also clear/empty the table when you exit the scene!

I suggested you attach the transitions to the actual objects, because if you create them in another module, each object will have a reference to its transition later. This way, you can cancel the transitions from any scene, if an object has one applied.

You might also loop through the display group by its number of children, checking if they contain an attached transition, then canceling it.
http://docs.coronalabs.com/api/type/GroupObject/numChildren.html

Brent [import]uid: 200026 topic_id: 35597 reply_id: 141637[/import]

Hello @khanh.dq,
For scene management, are you using Storyboard or Director? To remove objects in a Storyboard scene, you must add them to the scene’s view group (self.view). For Director, you must add them to “localGroup”.

Corona does not auto-cancel transitions on objects. You must do this yourself. A convenient method is to attach the transitions to the objects themselves, as properties. That way you can have a handy method to loop through and stop all transitions on the scene end. Please check this blog post for more info:
http://www.coronalabs.com/blog/2012/08/15/faq-wednesday-display-object-listeners/

Best regards,
Brent [import]uid: 200026 topic_id: 35597 reply_id: 141479[/import]

Thanks Brent,
I used storyboard, and added all object to scene’s view. When I purge scene, all object is removed, but their transition isn’t cancel. And the method object.remove isn’t called.

Can you tell me what is method corona used to remove all object children when i call method removeSelf of parent object? I want to overload this method, and call transition.cancel exactly for what object have transition, without loop thought all object and find what have transition.

Because I create some object in other module, and don’t have the direct reference to them in my scene module. Overload the object.removeSelf is better way for me. [import]uid: 9190 topic_id: 35597 reply_id: 141488[/import]

Hi @khanh.dq,
When Corona clears the scene, it clears the display objects that are children of the scene (it clears them from the display hierarchy). It does not cancel transitions on them, timers, Runtime listeners, or clear out other references/tables/pointers to those objects. If you don’t clear out and “nil” all external references to the objects, they will remain locked in memory (bad).

So, you will need to loop through them somehow to cancel and remove the transitions. You can store references to your objects in another table and loop through it… but if you do, you must also clear/empty the table when you exit the scene!

I suggested you attach the transitions to the actual objects, because if you create them in another module, each object will have a reference to its transition later. This way, you can cancel the transitions from any scene, if an object has one applied.

You might also loop through the display group by its number of children, checking if they contain an attached transition, then canceling it.
http://docs.coronalabs.com/api/type/GroupObject/numChildren.html

Brent [import]uid: 200026 topic_id: 35597 reply_id: 141637[/import]