Thoughts on pseudo Depth.

Get help using Construct 2

Post » Wed Feb 11, 2015 4:26 pm

Rather than just lazily ask for an answer , I'm currently experimenting with creating pseudo depth to a scene and was wondering if anyone else wants to know the same and explore a solution with me.

Here are the Goals:
To spawn character sprites in the game and then based on their hight in the view ( or screen ) The smaller or larger the scale, but also they need to be placed behind (Z Order?) the lower and so larger characters, this will create the illusion that the smaller characters in the view are behind and further away than the larger characters in the scene.

The Solution: Some how I'm thinking maybe track the characters Y position and preform some maths on the characters overall size based off that, so the higher in the frame the smaller it gets, and then some how preform a test that checks each characters y position on spawn and sets its Z Order accordingly. Not sure if you can number the Z Order though so may need to look for a different solution to that problem.

This seem like a good way to go?

Regards
Joel
B
7
Posts: 61
Reputation: 417

Post » Wed Feb 11, 2015 5:45 pm

For a single object of instances you can check each using a loop, and comparing its y to the loopindex.
If they meet the criteria, send that one to the front.

Or you can just do a "for each object" (ordered) by y ascending, send to front.
Image Image
B
164
S
49
G
125
Posts: 7,796
Reputation: 85,046

Post » Thu Feb 12, 2015 9:41 am

newt wrote:For a single object of instances you can check each using a loop, and comparing its y to the loopindex.
If they meet the criteria, send that one to the front.

Or you can just do a "for each object" (ordered) by y ascending, send to front.


Yes I thought that might work, but sending to the front would only work for 2 objects or if the objects were spawned in a sequence, what if you had lets say 3 characters and wanted them to sit in order? As far as I have seen there is no way to specify that Character 2 who's Y position is between 1 and 3 be placed in between them in terms of Z Order ( So in front of character 3 but behind character 1 ). Or would your solution account for that? Maybe I'm just missing something obvious? :S
B
7
Posts: 61
Reputation: 417

Post » Thu Feb 12, 2015 10:00 am

I think you're missing something a little obvious- if I put Character 3 on top, then 2 on top, then 1 on top, what order are the characters in?
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Thu Feb 12, 2015 11:16 am

Unnatural20 wrote:I think you're missing something a little obvious- if I put Character 3 on top, then 2 on top, then 1 on top, what order are the characters in?



I know that but if you have characters randomly spawning in then it does not work, for example if a character in front spawns then a character in the background spawns but I need the one in the background to be behind one but in front of one it is not so easy. Its easy to solve if your characters are a set amount and all spawn in order but if I want to make a random small crowd the method you suggest will not work :) I didn't mean that obvious ;) but thank you for the reply :)
B
7
Posts: 61
Reputation: 417

Post » Thu Feb 12, 2015 3:56 pm

Actually, the method can work, because you can rerun that loop whenever you need.
Take a look at this .capx.

In this case, I'm running the algorithm every tick until I'm done spawning. You could run it exactly once every time you spawn a new character, instead, and the end-user would never see it.
You do not have the required permissions to view the files attached to this post.
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Thu Feb 12, 2015 5:23 pm

Keep in mind its a loop, and will eat up cpu.
Every tick, even for a short period may be a bit much.
Image Image
B
164
S
49
G
125
Posts: 7,796
Reputation: 85,046

Post » Thu Feb 12, 2015 7:09 pm

But if I run it on create, it doesn't seem to 'catch' until the next tick?
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Thu Feb 12, 2015 8:48 pm

Unnatural20 wrote:But if I run it on create, it doesn't seem to 'catch' until the next tick?


Ahh I see what you mean now , I forget the Y value could be done by acending, which negates any problems with them being on top of each other. I stand corrected. Yes I suppose then all that would need to be addressed would be the memory issue, maybe spawning them all at once or get it to run 1 loop store it in an array then use the array info to spawn the sprites. Hmm will look into that and let you guys know the results. Thanks so much for helping work through this, appreciate it.
B
7
Posts: 61
Reputation: 417


Return to How do I....?

Who is online

Users browsing this forum: Phoenixbowman and 8 guests