rich Posted July 31, 2015 Share Posted July 31, 2015 Hi all, I've been working hard on the contents for the Phaser Book of Games (I'll write more about that next week), which strangely enough, has included making lots of games! and one thing I keep coming back to - and am therefore going to add into Phaser, is the need for a new different type of Group. Groups are vital in any game, but because they inherit from the Pixi DisplayObjectContainer they're essentially display objects in their own right. Yet there is a real need for a Group that isn't part of the display list. For example when doing depth sorting in a scene you need to have all display objects in a single Group to be able to sort them based on their z-index: think Zelda where you can walk 'down' the screen and objects should appear behind and in front of you. But in order to do that currently all of those objects need to be in the same Group - which means you can't use all of the great features of Group like 'getFirstDead' because you might get any object back and then have to process it yourself in code. So my thinking is that we need a new type of Group that doesn't extend a display object and isn't on the display list itself at all. You can add objects to it and then use methods like 'getRandom' or 'getValue' or 'find' or all manner of searching methods to interrogate the contents of the Group and retrieve them. This would allow you to logically break your game objects up, in as many different ways as you wish, while doing so completely independently of the display list. What I'm struggling with is what to call them though. In an ideal world I could rename Group to Layer, and then use Group for this. But I can't do that, as it will break every tutorial ever written for Phaser I was thinking 'pool' - that is what they are on a technical level, but it doesn't sound right to me. Whatever word I use it has to be 'snappy' and easy to write without making a typo (i.e. "container" is quite easy to spell wrong) So ... any ideas? (either for a name for this new thing or for any features you'd like it to have) Link to comment Share on other sites More sharing options...
wayfinder Posted July 31, 2015 Share Posted July 31, 2015 Set, Cluster, Collection, List. Link to comment Share on other sites More sharing options...
qdrj Posted July 31, 2015 Share Posted July 31, 2015 SetCollection yep. too slow... Link to comment Share on other sites More sharing options...
tips4design Posted July 31, 2015 Share Posted July 31, 2015 Yes, collection sounds good.What I thought of, there should be a class for creating particle reusable objects. What I mean by this is what you have to manually do when create bullets for a game:- create a pool of X bullets, all invisible- when you shoot a bullet, you take an unused one from the pool- kill the bullet if it is destroyed or exits screen.This is usually done to avoid memory leaks and reuses objects instead of deleting/instantiating them.So, the API would be something like this:var bullets = new Phaser.Pool(sprite, 100); // instantiate 100x spritevar myBullet = pool.get(); // returns one unused item for the poolpool.release(obj); // kills it or make it invisible, also marks it as unusedHere, sprite could either be an instance Sprite or any object class than can be instantiated.This Pool class could extend the Collection class.I am on my tablet and probably most of the stuff I've written here makes no sense, but I hope you understood my idea.I know that you can already do this using Groups, but having a simpler way to create re-usable objects would be nice. Link to comment Share on other sites More sharing options...
drhayes Posted July 31, 2015 Share Posted July 31, 2015 +1 for Collection and List. Doesn't score well on "snappy", but it is what it is. Set as a data type is about to land in ES2015. Bunch? ALot? Link to comment Share on other sites More sharing options...
stupot Posted July 31, 2015 Share Posted July 31, 2015 I vote for 'Set', it's snappy, a fairly good descriptive fit and it's different from anything else in Phaser so will be easy to remember. After that I would probably go for 'SubGroup' Link to comment Share on other sites More sharing options...
rich Posted July 31, 2015 Author Share Posted July 31, 2015 I considered 'set' but I'm not sure if that would screw with reserved words in TypeScript or ES6. Collection is quite nice, but too long. Would rather use Pool over Collection I think. kenshm 1 Link to comment Share on other sites More sharing options...
wayfinder Posted August 1, 2015 Share Posted August 1, 2015 I honestly think I'd actually prefer it if you renamed groups to layers and called the new thing a group, mostly because it would be the most accurate description of what's inside. But then again I haven't published any tutorials. What if you did a two step process where you vacated the Group moniker while you renamed the old Group to Layer, and only introduced the new Group in a later update? Maybe throw a little skeleton Group in there in the intermediate that does nothing but put out an alert "please use Layers" Link to comment Share on other sites More sharing options...
Tom Atom Posted August 1, 2015 Share Posted August 1, 2015 Collection, List, Set are words used for basic data collections - I would not mess it with names commonly understood by coders accross languages . I think here we are dealing with some more advanced class and also engine specific. So, what about "Pack"? Pack of objects... clark 1 Link to comment Share on other sites More sharing options...
tips4design Posted August 1, 2015 Share Posted August 1, 2015 What about Lot or Batch? Link to comment Share on other sites More sharing options...
gingerbeardman Posted August 1, 2015 Share Posted August 1, 2015 Pool or List Link to comment Share on other sites More sharing options...
_o0o_ Posted August 1, 2015 Share Posted August 1, 2015 Perhaps it's all just leading you to an entity component system. Link to comment Share on other sites More sharing options...
stupot Posted August 1, 2015 Share Posted August 1, 2015 a 'gang' makes me smile Link to comment Share on other sites More sharing options...
rich Posted August 1, 2015 Author Share Posted August 1, 2015 Nah it's absolute not going to turn into an ECS! I'm thinking Pool might be it. But I do like List too. Technically though it will be more like a Set (from a data structure pov) but it will have so many extra bits it won't be a traditional one either. Link to comment Share on other sites More sharing options...
d13 Posted August 1, 2015 Share Posted August 1, 2015 You can add objects to it and then use methods like 'getRandom' or 'getValue' or 'find' or all manner of searching methods to interrogate the contents of the Group and retrieve them.Could you not just use ordinary arrays and add a few custom convenience methods for working them? Link to comment Share on other sites More sharing options...
jeancode Posted August 2, 2015 Share Posted August 2, 2015 Cluster ! or pool, I like pool. Link to comment Share on other sites More sharing options...
darkraziel Posted August 3, 2015 Share Posted August 3, 2015 Pool sounds like an easy to remember and understand name. It is what most people would be using it for at the end~ Link to comment Share on other sites More sharing options...
Tanikaze Posted August 4, 2015 Share Posted August 4, 2015 My vote is for 'pool'. Otherwise... 'family' seems appropriate, but too long and sloppy on the keyboard. Maybe 'suite'? Link to comment Share on other sites More sharing options...
codevinsky Posted August 4, 2015 Share Posted August 4, 2015 "Pool" seems like it would automatically implement recycling, as that's generally where I've heard the term. If it doesn't then maybe something else. How about these suggestions:* Assembly* Bag* Cartel* Lot* Store* Batch* Cluster* Crowd* Stack* Heap* Pile* Kit I, personally, like "Stack", as it has a double meaning referencing an actual layered memory stack (which is, by definition, not a display element) as well as describing the exact function (stacking) that you're trying to implement. Link to comment Share on other sites More sharing options...
tips4design Posted August 4, 2015 Share Posted August 4, 2015 "Pool" seems like it would automatically implement recycling, as that's generally where I've heard the term. If it doesn't then maybe something else. How about these suggestions:* Assembly* Bag* Cartel* Lot* Store* Batch* Cluster* Crowd* Stack* Heap* Pile* Kit I, personally, like "Stack", as it has a double meaning referencing an actual layered memory stack (which is, by definition, not a display element) as well as describing the exact function (stacking) that you're trying to implement. The problem with Stack, is that you usually think to the stack data structures (with it's push and pop methods) Link to comment Share on other sites More sharing options...
mwatt Posted August 5, 2015 Share Posted August 5, 2015 I'll throw in three more: * Family* Bunch* Collective I don't care for pool because of the other software usage for it. Link to comment Share on other sites More sharing options...
rgk Posted August 5, 2015 Share Posted August 5, 2015 I like stack, but this sounds like it would be ordered. Collection also.But on a side note, would this new object allow grouping audio? Or does this feature exist, I'm currently trying to implement a FX sound volume setting and a background sound setting and it would be awesome to group them. Link to comment Share on other sites More sharing options...
quarks Posted August 6, 2015 Share Posted August 6, 2015 I'd go with Pool. Yeah, it maybe implies a few more semantics than you're talking about including, but I don't think it's so much as to be misleading. In any event, I think that having separate objects for display grouping and logical grouping is A Good Thing. Link to comment Share on other sites More sharing options...
Eraph Posted August 6, 2015 Share Posted August 6, 2015 I like Bunch. As in, a bunch of objects. Link to comment Share on other sites More sharing options...
_o0o_ Posted August 6, 2015 Share Posted August 6, 2015 object graph - graph. Link to comment Share on other sites More sharing options...
Recommended Posts