Is there something along the lines of adding a World as a graphic to another World? (Or an Entity to another Entity?)


(John) #1

In a lot of Flash libraries, you have roughly this concept: In Flex 3 terms, you start off with a Canvas, which can have children added to it. Each child is pretty much a graphic, and the Canvas is pretty much your background. But each child can also have its own children, and each of those children can have their own children. This is really convenient, because you can, for instance, create a Canvas with a whole bunch of buttons and labels on it, and then you can add the whole thing to another Canvas, only using a single function call. Afterwards the inner Canvas can change its graphics internally, without ever bothering the outer one or violating basic OOP.

I’m new to FlashPunk, and this is most likely just something I haven’t run across yet, but in Flashpunk, all I’ve found so far is that there’s the equivalent of a Canvas at the top - this is the World that FP.world is set to - and then you just keep adding children directly to that. But I haven’t seen mention so far of any way to add children (Entities and Graphics) to other children, nor have I seen mention of adding Worlds to other Worlds or anything like that.

How do you go about this in FlashPunk? Thanks!


(TaylorAnderson) #2

I’m not entirely sure if this concept exists in Flashpunk…if it does I haven’t heard mention of it. A world is distinct from an entity, the only thing worlds can add is other entities


(John) #3

And every Entity/Graphic has to be added directly to the world, not to other Graphics and Entities?


(TaylorAnderson) #4

Entities, in order to show up, have to be added to the world, yes. Entities can add other entities to the world as well, just by saying world.add(entity). Graphics however, are tied to entities; each entity has a graphic, and that graphic can be one Graphic or a Graphiclist with several Graphics. I encourage you to look up some Flashpunk tutorials for more details on all this stuff: there are plenty of them


(Linck) #5

There is no built in way to do that that I know, but you could structure this yourself. As you can call FP.world from anywhere, you can create an entity that will act as a world, and build it’s own functions for managing other entities. It would act like a bridge between the world and other entities. Don’t know if this is a really good idea though.