How do I Sort Container components order using values?

0 favourites
  • 4 posts
From the Asset Store
A master sorting Puzzle fun and addictive puzzle game! A challenging yet relaxing game to exercise your brain!
  • I am making my own Z order system, its not working the way I had imagined it. However you cant physically manage a container using Z Order functions without first calling them from another object, so I was wondering if anyone had managed to do something like this? I am trying to manage them via values but its not working.

    In fact this code doesnt work either:

    If Group.Families Value < Group.Families Value

    Group.Families Sort to Back of Object Group.Families

    I mean it SHOULD work, but it doesnt? I dont understand. Even For Each loops doesnt fix this.

    I want each object of the loop to check if its value is less than another member of its own families Z order value and then move behind it. It should work. And I even tried selecting the container from another object to move behind it, or above it based on its values however you still need to pick its components and move them to the layer value of the container HOWEVER the objects contained WITHIN the container lose their bloody family grouping when attached to it!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I must be a tad tired as I can't follow that at all. I'll try again later... After which maybe some clarifying thoughts will have been posted.

  • When you're comparing the variables, each object is comparing with itself.

    To compare values of two different instances of the same object you either:

    1 put the object type in a family so you can pick two separate instances independently. Ex:

    For each sprite

    For each family1

    Sprite.value < family1.value

    2 pick one object, save its value to a variable and then "pick all" and pick the other instance.

    3 use the sprite(0).value expression where 0 is the instance number. That way you can access separate instances from the same expression. You will need to loop over each pair of instances though.

    What I usually opt to do for sorting like you're doing is just to use a "for each ordered" condition which will do the sorting for you.

    For each sprite ordered by sprite.z acending

    --- sprite: move to front

  • I actually figured out the equation its; WidthScreen * Object.Variable1 + Object.OtherFactor (whatever that may be, in this case it could be Y. or some other math)

    As for what to do in C2 I did what you said r0j0hound, so thanks for confirming that. Its nice that there is atleast a built in way to do it with this engine. Not bad considering most engines cant handle that with a simple for each ordered command.

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