Order by Z over different object types

0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Let's say I have two object types, Sprite & Tiled Background, which I want to z-sort using the system's order by z action. Since we can't have two different object types in the same family, how would I do that?

    I already tried putting a helper sprite & tiled BG in a container and do it like order by Z family-wise, then set tiled BG behind helper sprite, but this is a real performance killer.

    Any suggestions would be highly appreciated.

    Cheers!

  • Yeah that's a tough one.

    We have no non object specific sorter.

    Other than a loop that is. If you did it that way I would guarantee it would be slow.

  • Yeah, I was just getting the hang of offsetting tiled BGs for the raycast engine which basically allows float texture scrolling (instead of slicing the texture to 1px frame and storing it in sprites), later realizing I might have a problem with the z sorting.

    Another workaround would be making the billboard sprites also tiled BGs. But then we'd have a tedious workflow when it animating them.

    Guess it'll be sprites only then.

  • How did you resolve it technically? I need to test & sort multiple overlapping objects by an arbitrary value ( Z depth ), so using e.g. Y as reference wouldn't work for me.

  • I've done it with an array. That zorder action wont really work here. Say you have an instance variable "z" for both sprite and tiledbg.

    Every tick

    -- array: set size to (0, 2, 1)

    for each sprite

    -- array: push sprite.z to front x

    -- array: set at (0,1) to sprite.uid

    for each tiledbg

    -- array: push tiledbg.z to front x

    -- array: set at (0,1) to tiledbg.uid

    every tick

    -- array: sort x

    array: for each x

    -- sprite: pick by uid array.at(array.curx,1)

    ----- sprite: send to front

    -- tiledbg: pick by uid array.at(array.curx,1)

    ----- tiledbg: send to front

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Would be nice if Array had sort ascending / descending.

    Than again families that can use all world types might be more welcome.

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