Skip to content

Update method invocation order. #1005

Open
@slembcke

Description

@slembcke

From a conversation with @Birkemose:

In 2.x it seemed update was called in the order you scheduled them, meaning that children was always called update after its parent, if update was ex scheduled in onEnter. In 3.x this is not the case. Not sure why. It might not be a huge issue for many, but when building slightly more complex stuff, you can no longer rely on the parent have run its update, before the children does. Basically, update should always be called in same order as visit.

Makes a lot of sense.

Looking at the old scheduler code, there isn't anything that handles parent child relationships specifically. So I think the ordering in the old versions probably had more to do with if you scheduled your node before or after calling [super onEnter]. (That's what you meant right Lars?) Since scheduling updates is automatic in 3.x, we should see if we can set up a more sensible update order since right now it's effectively undefined.
https://github.com/cocos2d/cocos2d-iphone-classic/blob/develop-v2/cocos2d/CCScheduler.m#L589

Does it make more sense to run updates in visit order or a parent first tree traversal?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions