1
\$\begingroup\$

I've looked in forums, the doc, and the code, and I'm thinking this isn't currently possible, but maybe I'm missing something, so just to be sure: is there a way to set a group as child of and actor? or, in other words, how do I create a hierarchy of actors?

I'm trying to make sorta of a strategic game, and I have things like "empires", "kingdoms", ""cities", "buildings", "people", "objects", and I thought initially that maybe would be a good idea make these things actors. But I can't find anything like addActor inside Actor class, or addGroup, it seems there is no way for "kingdoms" to have"cities", for "cities" to have "buildings", for actors to have child actors or child groups.

\$\endgroup\$
  • \$\begingroup\$ Why not just have the actors be Groups? Group extends from Actor so you will still have the same basic functionality. \$\endgroup\$ – Charanor Jan 1 '18 at 0:11
  • \$\begingroup\$ You're right. I didn't think of that. I guess it sounds kind of weird, technically "buildings" are not a group of "persons", and a "person" is not a group of "items", but it can work anyway, so I'm going with this way. Thanks! And have a great year. \$\endgroup\$ – ontheway Jan 1 '18 at 17:42
1
\$\begingroup\$

We don't know which things are containers and what they can contain. But let's assume your world work this way:

  1. Empires can contains Kingdoms, but also Cities (which are not contained by any Kingdom but belongs to an empire) and even Buildings following the same reasoning.
  2. Kingdoms can contains Cities and Buildings (again, buildings which are not contained by any City but belongs to a Kingdom)
  3. Cities can contains Buildings, Peoples and Objects

Now we've got something. Everything that can contains one or more type of Actors is a Group.

So you'll add to the stage a bunch of Groups (Empires in my exemple) containg themselves other groups (Empire is a Group containing other Groups like Kingdoms, themselves containing other groups and so on..)

Hope it helps.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.