Z-sorting (Explanation for Yann video)

0 favourites
  • 6 posts
From the Asset Store
A master sorting Puzzle fun and addictive puzzle game! A challenging yet relaxing game to exercise your brain!
  • Hey :)

    I'm trying to catch up with the archived University of Reddit class that Yann and Kyatric did for Construct 2.

    In this video, he is explaining Z-sorting through For Each (ordered):

    youtube.com/watch

    I thought I was understanding what he was trying to achieve, but I evidently didn't. I thought that the sprites were going to be ordered in the Z axis according to their Y position in the layout.

    But instead, the result is that when the player sprite is over the lower part of the tree sprites, he is in front of them and when he is in the upper part he gets behind them

    I'm not understanding how this is happening, even after playing with the capx. Anybody care to explain, please?

    Thanks!

    dl.dropboxusercontent.com/u/23551572/C2Class/example/zSorting.capx

  • In order for this way of sorting to work, all objects must be the same size.

  • What I'm trying to understand is what's happening behind what Yann did, newt. I'm not sure what you meant with your reply.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Never mind my previous comment, you've adjusted with hotspots.

    Any way, the way it works is like a deck of cards.

    The cards on the bottom of the deck would have a lower y value than the cards going to the top.

    If you look at the for each you will see it has the ability to do the order ascending, that is to say low to high.

    So the loop starts with the lowest y value object and sends it to the top of the layer, and then goes to the object that was just above that one, and then sends it to the top. That object is now visually on top of the first object.

    This is repeated for all the objects so in the end you have basically stacked a bunch of cards in order.

  • I thought I was understanding what he was trying to achieve, but I evidently didn't. I thought that the sprites were going to be ordered in the Z axis according to their Y position in the layout.

    sorting by Y takes the origin point of the tree/player. As soon as the Y of the origin point of the player is lower than the origin point of the tree, the player is put behind the tree.

    But instead, the result is that when the player sprite is over the lower part of the tree sprites, he is in front of them and when he is in the upper part he gets behind them

    You should look again, as soon as the foot of the player sprite passes the foot of the tree, it is sent to the front/back of the tree, depending if the Y is lower or higher. There is no leeway like you claim.

  • Thanks guys! With your help I think I've got the concept now. Cheers.

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