BUG with JSON?

Discussion and feedback on Construct 2

Post » Tue Nov 14, 2017 8:15 pm

Hello, why does the sprite not recover its initial Z ?.
Initially the sprite was behind the other sprites but although I reorder its ZIndex, now the sprite appears in front.

https://www.dropbox.com/s/amvfnuxteajdjwl/testJSON2.capx?dl=0

Image

Image
B
30
S
13
G
21
Posts: 838
Reputation: 14,656

Post » Tue Nov 14, 2017 11:24 pm

I think it's because you're not sorting the other two purple Sprites along with the blue Sprite.

If you put Sprite and Sprite2 into a family, and then apply the ZIndex based on your variable, and then sort the family, you should get the expected result.

Image
B
42
S
12
G
1
Posts: 74
Reputation: 2,992

Post » Wed Nov 15, 2017 11:46 am

faulknermano wrote:I think it's because you're not sorting the other two purple Sprites along with the blue Sprite.

If you put Sprite and Sprite2 into a family, and then apply the ZIndex based on your variable, and then sort the family, you should get the expected result.

Image


But I have objects of various types.
Tilemap and sprites.
Would I have to create families for everything just to order the Z axis ?.
B
30
S
13
G
21
Posts: 838
Reputation: 14,656

Post » Thu Nov 16, 2017 10:34 am

I think Families can only hold one type of object, so sorting via the System plugin is limited to that. Are you saying that, for example, a Tilemap object can be on top of a Sprite?

If so, the only thing I can think of is to use Rex's ZSorter, which enables you to sort for the whole layer. However, I myself haven't tried this with multiple object types but I think it might work. You also must use the Sort by Function feature, as you are using instance variables as a basis for sorting. However, in my experience, ZSorter is slower than C2's sorter.

You may want to compromise mixing object types and keep it simply to Sprites when it comes to sorting. Let Tilemaps sit on the bottom or at the top, and not in between.

On the other hand, if you had a simple situation where you had a TilemapSortFamily and a SpriteSortFamily, then perhaps you can do a System sort on the SpriteSortFamily first, and then loop through the TilemapSortFamily which checks each SpriteSortFamily's z-index. Then if it finds the proper z-index to insert itself you can 'Move to object > SpriteSortFamily > In front/behind'.
B
42
S
12
G
1
Posts: 74
Reputation: 2,992

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests