Skip to content

IterateSelector #2

@mikecann

Description

@mikecann

I have a need for a selector that iterates over each child regardless that it passed or fails, it will still wait if the Task returns RUNNING however.

Its basically just a modified version of the SequenceSelector, not sure if this is the best way to do this or not:

   public class IterateSelector extends SequenceSelector
{
    override protected function updateTask (dt :Number) :int {
        while (_childIdx < _children.length) {
            _curChild = _children[_childIdx];
            var childStatus :int = _curChild.update(dt);
            if (childStatus == SUCCESS || childStatus==FAIL) {
                // the child completed. Move on to the next.
                _curChild = null;
                _childIdx++;
            } else {
                // RUNNING return immediately
                return childStatus;
            }
        }

        // all our children have completed successfully
        return SUCCESS;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions