Z ordering

0 favourites
  • 12 posts
  • How will Construct 2 do the Z ordering? Is it possible to have it number based this time, instead of just the "bring to front" and "bring to back", or is that the only way it can work?

  • It could be number based, but then what do you do when two objects, or even 20 objects, have the same number?

    I thought layers were the best way to Z order things to their approximate location (background, mainground, foreground etc.), so that Z order within a layer isn't so important, so things like 'send to front/back' are sufficient. What are you trying to do that needs such fine control?

    Incidentally 0.x supports Z ordering by number as well - use an ordered for-each over a private variable to send each instance to back, and they'll end up Z ordered by the private variable.

  • You would want the fine control for stuff like card games, isometric, and even sprite chains.

    A floating point system like CC uses for z height might work, but it could use some organization like first object to a whole number remains on top, while the next sent there would go to 1.9, 1.8, etc, course that might be confusing at some point since logically those are bigger numbers.

  • I get a lot of slow down looping through all the objects all the time, ordering them (using the for each object, and bring to front/back). But having a number system would help to slot things in easier, especially when your creating/destroying a lot. Using layers helps, but its not always appropriate because of how dynamic you may want the sorting to be, such as with an isometric game.

  • If C2 implements the orthogonal projection feature C1 has, that could do the same thing (automatically sorted by Z value). With that, if two objects are on the same depth value, then it uses the regular sorting.

    Another benefit of that is depending on the situation, it might mean you don't have to run a for each loop through all the objects, making it more efficient. The only problem with that is it means you couldn't use that method of sorting and have z depth at the same time. Perhaps if orthogonal projection could be used on a per-layer basis, or does that get too weird?

  • HTML5 canvas doesn't really have anything corresponding to orthogonal projection - it just depends on the order you draw them.

    , how much slow down do you get? I thought the for-each-ordered and send-to-back conditions were efficiently coded. Does it really make a big fps difference toggling that one event?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Your right actually, maybe its because I was using a lot more sprites before but it seems to work fine now. My FPS only goes from about 1200 to 550 when I use always for each ordering (2000 objects and not much other code yet). I guess its fine the way it is, sorry.

  • Bump: z-ordering with foreach and "send to top of layer" may be just as efficient, but it sure makes a mess out of your code - especially if you have to order several different objects that aren't grouped into a family.

    With number based z-ordering, I can keep track of the numbers myself, and assure there is never a collision (order numbers being equal). Even if there is, construct could draw whatever first (the first one that gets called in the draw loop is behind) without any other special logic to handle such z-order collisions.

    It sounds exactly like the sort of problem a game creating engine should abstract away.

  • What about an Index, layer 1, all the sprites inside it will have an auto-increased index, so, my last sprite will be the 1.14, where 1 is from the layer, 14 is from his Z order in that layer. This way, none of them will have the same index and you'll fine control them.

    Sometimes I use Fireworks, Corel, etc, and there you can feel what the alspal is asking for. In Fireworks don't have the index, but have a list, where the top names are on the top of that specific layer, and top layer folders, where the top layer folder on the list is the top layer showing up.

    What it means is the easy of use. Clicking, dragging and dropping a layer folder is much more easy and intuitive than any other method. And when you place your sprites inside that layer, they will be show inside that layer as a list.

    So, I would suggest, why Our Layer List can't have a list listing all the sprites inside that layer, ordering them by his Z order, with unique Z order for each one?

    <img src="http://dl.dropbox.com/u/47035927/temp/Z-Ordering.png" border="0" />

    Taking advantage of this situation, what about the UID being show by his side, in (UID)? Because it being hard to remember or check everytime the UID, but using this, you will make sure to have the correctly UID at least of the objects on the canvas.

    More one suggestion, some drop-down menus by right clicking, like "blocking for edition" (that lock on the image), "hidden", etc.

    Edited: After testing how to reproduce adventure games with C2, believe me, the Z ordering system can difficult it near to the impossible.

    It's all because of the miss of an index where you can organize what is in the front and what is behind the player, who will walk around in a "perspective" World.

    I tried to fix the origin point in the bottom, and check if it's down or up the player origin, and it worked, but when you send the sprite from behind, it hidden behind all other sprites too, but to make it perfect, I tried to organize it with and Code Indexed for each sprite. At least now, with 10 game objects on the Canvas, I have written near to 200 lines of code only to organize what is behind and what is on the front of the player.

  • All we need is for each ordered. That will make it easy to do Z ordering in one event.

    For each ordered: sortfamily.y (ascending)

    • send to front

    Or use a instance variable instead for more custom stuff.

  • All we need is for each ordered. That will make it easy to do Z ordering in one event.

    For each ordered: sortfamily.y (ascending)

    - send to front

    Or use a instance variable instead for more custom stuff.

    Sometimes you need to think about beginners <img src="smileys/smiley2.gif" border="0" align="middle" /> Because are they easy of use and first impression what will make C2 sell more and be more and more successful.

    I agree, in other words, with you about how to make it. Using Z order right now is difficult, but not impossible for who know programming and eventing, not for who being use C2 and is learning.

    A mixed of visual and code features would be great, I hope this can be considered in the To Do list for a latter release.

  • Sorry, I think your suggestion is more complex. :/ Using for each ordered is one condition and action! And really, if people want to make a game, some amount of complexity is required.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)