DoStep() for children?

Help
2007-05-02
2013-06-04
  • Gianfranco Berardi

    I can't seem to find an elegant way to animate sprite hierarchies. That is, if I have a sprite with a child sprite, and I would like both to animate, I can't just run DoStep() on the parent and expect the child to also have DoStep() called on it. The API refers to a function that returns an item of type GlInsideNodeIt< KrImNode * >, but the source code mentions that it shouldn't be used.

    It seems the best solution for now is to keep a more complete list of sprites that I want to animate, but this will make it a bit tricky when I am deleting and adding sprites all the time.  Is there a more elegant solution, such as a way to request the children of a sprite?

     
    • Lee Thomason

      Lee Thomason - 2007-05-06

      Good point. Missing feature there. Should have DoStepRecursive() as well.

      You can walk the children of a node:

          GlInsideNodeIt<KrImNode*> it = monsters->ChildTreeIterator();
          it.Begin();
          while( !it.Done() )
          {

      ...and do so recursively if needed. That's probably easier (and safer) than maintaining a separate list of things to update.

      lee

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks