Keeping player's order to front

For questions about using Classic.

Post » Sat Aug 01, 2009 4:57 am

This is probably another embarrassingly easy question, but I've tried to fix this for an hour to no luck.

Here is the problem. I have the player and all other sprites all on the same layer. They need to be on the same layer because sometimes the player will appear behind trees/walls and other times in front of them. I have the event logic to handle that. What is not working is the stupid ground tiles are appearing above the player. I can't send the tiles to the back because of the way I have setup the layout, it would be a pain to fix. I've tried everything I can think of.. putting the ground sprites in a family and then saying "send player to front of family".. doesn't work. That actually made it worse and made him appear behind some of the tiles!!

I also tried a simple send player to front at the start of the layout, but I have a feeling that that only sends him to the front of the current tile he is on.

What is an easy way to get the player to always appear in front? ... with of course the ability like I am doing to put him behind trees and stuff like i'm doing.
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Sat Aug 01, 2009 5:17 am

when zorder changes reset the order for all sprites to what you want. how is it set up in the layout
B
2
S
2
G
4
Posts: 259
Reputation: 1,968

Post » Sat Aug 01, 2009 5:37 am

I don't think I can automatically reset all sprites. The reason is because of the tileset
I'm using. To give the appearane of 3d the tiles can interlock with any others. So some water, or grass sprites for example, will be lower z order than others.
If I was to automatically reset them there would be no way to know which water sprites would go ontop
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Sat Aug 01, 2009 6:10 am

Why don't you just use separate layers? One for the ground and background, one for the player, then one for the foreground.
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Sat Aug 01, 2009 7:51 am

player is overlapping floor: place floor behind player
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

Post » Sat Aug 01, 2009 8:36 am

store zorder in pvariable at startup when player changes zorder reset the objects to keep their orders. so when player is sent to front the privable still has original order so you can use for each ordered by pvariable on family and send player to front last
B
2
S
2
G
4
Posts: 259
Reputation: 1,968

Post » Sat Aug 01, 2009 4:50 pm

I finally got this to work. Thanks for all of the input guys. I swear there is some weird intermittent bugs that were making this harder, or I just was working on it too long. :? For example, you would think that the following would place the player in front of the ground:

If Player overlapping ground
- Place in front of floor

That actually put the player behind the floor!!

Separate layers wasn't an option because for example the same tree had to appear behind or in front of the player depending on if the player approached the tree from the top or bottom.

A side effect of what I was doing before was causing the order of the player to move behind the floor. The new solution doesn't have that problem. Placing the floor beneath the player didn't work in the earlier case.. it ended up causing this crazy rippling effect in the tiles.. pretty cool actually.

So what ended up working was:

I changed all of the trees, walls, rocks to sprites.... left the floor as tile background. Put each in families, terrain and floor. Then..
---------------------------------------------
Start of layout: Send player to front

If player overlapping at offset (0,100) place player behind terrain
Else Send player to front
----------------------------------------------
No other combination worked... so simple I'm kicking myself
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Sat Aug 01, 2009 5:19 pm

Post a cap, there's a number of ways to deal with this, but without knowing exactly what your doing its pretty hard to tell you what to do.
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Sat Aug 01, 2009 5:31 pm

@newt.. It's working now, but if I run into complex problems like this in the future I'll post a cap. Should save a lot of confusion! Thanks again for all of the replies!
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Sun Aug 02, 2009 2:09 am

you could always do something like this, makes it easy

http://files.getdropbox.com/u/1024727/ordering.cap
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests