Overlapping and changing order

Get help using Construct 2

Post » Fri Jun 28, 2013 8:00 pm

How do I:

In the context of spawning and then having the sprite with the heighest Y value go above a sprite with a lower Y value on the Z axis (eg it looks on top of it,) ? Thanks.
B
20
S
7
G
4
Posts: 322
Reputation: 4,521

Post » Fri Jun 28, 2013 8:25 pm

Worth noting that all these sprites are off the same instance eg: "Enemy 1" and are spawned in masses and walk in one fixed direction.

There is no way of setting them to say "Enemy X"

Thanks.
B
20
S
7
G
4
Posts: 322
Reputation: 4,521

Post » Fri Jun 28, 2013 8:38 pm

Just one event needed. Two conditions: System: On start of layout (or whenever) and System: For each (Sprite) order by Sprite.Y -> (Sprite) Move to top of layer.

Just be sure you set your origin points correctly.

Example capx.GeometriX2013-06-28 20:41:00
B
57
S
15
G
11
Posts: 912
Reputation: 12,581

Post » Fri Jun 28, 2013 8:46 pm

just like this sample?

http://goo.gl/1a3Jt

Use a family and sort with 'FOR EACH" the Y to be on top of each other.
ImageImageImageImageImageImage
Image
B
98
S
22
G
16
Posts: 1,338
Reputation: 21,202

Post » Fri Jun 28, 2013 9:17 pm

@GeometriX [email protected]

Thank you guys. GeometriX' worked the best-- another question is:

My sprites tend to stack up; important things to know:
They all walk at the same pace and towards the same direction,so I can have about 3 pretty much on top of eachother but give or take a few pixels...

I want to know, how:
At spawn time, to create a scenario where "If there is a zombie at that Y coordinate within 5 pixels of wherever it was thinking of spawning, do not spawn!"

:P Thanks
B
20
S
7
G
4
Posts: 322
Reputation: 4,521

Post » Fri Jun 28, 2013 9:35 pm

As always, you've got a lot of options. I'd suggest that, instead of spawning your sprites directly, use a "scouting" object to test the waters. Spawn those randomly, then, if they're not overlapping anything, it's safe to spawn an enemy or whatever. If it is overlapping then go find somewhere else to spawn.

Here's an example capx. It'll generate new blocks until it can't any more, at which point it simply crashes when it runs out of space.

If you want to allow some overlapping, just set the scouting object to be smaller than the objects you're spawning.
B
57
S
15
G
11
Posts: 912
Reputation: 12,581

Post » Fri Jun 28, 2013 9:40 pm

theres lot of options, but i guess you could even do it with the line of sight behavior on the spawnbox, adjust the range, and then inverse is in sight, could be that youl need some "for each" zombie and spawnbox
ImageImage
B
65
S
19
G
7
Posts: 814
Reputation: 9,691

Post » Fri Jun 28, 2013 10:03 pm

@GeometriX thanks buddy!

Saved me a good few hours there haha! You don't happen to know how to create a range saying

"Create object ZombieSpawner on layer 0 at (0.1, random(Y AMOUNT *SOMETHING* 450))

Basically I don't want them spawning below an amount of 'Y amount'

Thanks
B
20
S
7
G
4
Posts: 322
Reputation: 4,521

Post » Fri Jun 28, 2013 10:09 pm

Random(100,450), for example, will spawn it between 100 and 450 - it's in the manual under system expressions.
B
57
S
15
G
11
Posts: 912
Reputation: 12,581

Post » Fri Jun 28, 2013 10:17 pm

@GeometriX ahhhhh thank you! I was looking under sprite expressions and I couldn't find it!

Thanks again; I couldn't remember if it was a comma or a semi-colon :)
B
20
S
7
G
4
Posts: 322
Reputation: 4,521

Next

Return to How do I....?

Who is online

Users browsing this forum: BloodFoxStudios, Fenix18, oosyrag, waguilar and 11 guests