What is the best way to ysort in this particular case?

Not favoritedFavorited Favorited 0 favourites
  • 2 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • So basically, this is just an example situation, though a real one I'm currently working with. How would I ysort a large object that repeats, for example, a fence, when working also with other object types? So I know how to ysort sprites, using the sorting method. But if I were to have place a ton of sprites on a large map for the fence, that seems..impractical?

    Solution 1: Use a tiled bg object and just stretch the fence. That gets the object in the layout, effectively, but how would I ysort it since I cannot add it the family for sprites to be ysorted? How would I effectivey ysort both the sprites and the tiled bgs?

    Solution 2: Use a tilemap. Problem would be same as above.

    Solution 3: Manually place all the sprites for the fence. Very time consuming, but would work.

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are actions to change the zorder of objects. So even though you can’t sort by y with one action like you can with sprites, there are other ways.

    One way could be two use an array to store the y and uid of all the objects you want to sort. Then you’d sort the array and loop over it and pick the objects by uid and move them to front.

    Another way could be to zsort all the sprites, then loop over the tiledbg objects by y and pick the sprite with the lowest y greater than the tiledbg y. Then you’d set the zorder to be behind the sprite.

    There may be other schemes you could try too.

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