how to determine when an area is already populated

Get help using Construct 2

Post » Fri Mar 21, 2014 10:44 am

https://db.tt/4sRWDHHW

I have 6 sprites ( invisible) ( yellow boxes)
I also have 6 sprites ( numbered 1-6 ) ( various colors)
The 6 invisible sprites are placed on my layout at specific locations. ( I have them close to each other for this question)

The 6 invisible sprites are also 1 single sprite copied 6 times

The 6 colored sprites are set to appear on top of any of the 6 invisible sprites randomly
They appear for a few seconds and then disappear.
There is no set pattern of where any of the 6 sprites appear which is what I want, however, that also means that any of the 6 sprites could appear together on top of each other.

Right now I am using overlap to determine if a sprite is already in that position and then destroying one of the sprites.
( If sprite 1 is overlapping sprite 2 then destroy sprite 2)
That seems like a waste of time.
What I would like to know is how I can tell when any of my 6 sprites are already being occupied on top of any of the 6 sprites.

Something that knows when there is already a sprite on top of one of the invisible sprites and won't let any other sprites go into that position.

This is the way I have my sprites show up on top of the invisible boxes:
https://db.tt/FzUiGDM3
B
7
S
2
Posts: 158
Reputation: 1,021

Post » Fri Mar 21, 2014 12:59 pm

update: I've tried some boolean variables but an't get the hang of it.
I'll keep trying
B
7
S
2
Posts: 158
Reputation: 1,021

Post » Fri Mar 21, 2014 2:25 pm

You can add all your 6 sprites into a Family.
Then use Family is overlaping 'spriteHolder' (sprite holder being the invisible sprites)
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Fri Mar 21, 2014 2:46 pm

families is not available in free version
B
7
S
2
Posts: 158
Reputation: 1,021

Post » Fri Mar 21, 2014 3:40 pm

c'mon now. 33 views as of now and only 1 response?
I'm still playing around using variables which is what I think I need to do. I am slowly learning how they work but still don't know how to get this to work the way I want.
B
7
S
2
Posts: 158
Reputation: 1,021

Post » Fri Mar 21, 2014 4:54 pm

When you pick the invisible sprite you want to spawn on, couldn't you check to see if it's overlapping before spawning the new one, and then look for a different one if it is occupied?

Another way is to put a Boolean variable on the invisible sprite, marking if its "on" for spawning. when you spawn one there, turn it off. when that one no longer overlaps, turn it on.

Edit:
Oh, are they separate sprites or all animations in the same sprite?
That may be what you are looking for, put all those sprites in the same sprite with different instances playing the different animations. It's how we used to do that before we had families.

(pick an invisible sprite, check if it's overlapping that sprite holding all the animations, and if not spawn it and pick an animation to play.)
If you need to check for a specific one, you can check which animation is playing.
B
239
S
62
G
33
Posts: 903
Reputation: 40,562

Post » Fri Mar 21, 2014 5:26 pm

"Another way is to put a Boolean variable on the invisible sprite, marking if its "on" for spawning. when you spawn one there, turn it off. when that one no longer overlaps, turn it on."

That's what I'm trying to do but I can't wrap my head around it. I'm not sure how to word it

they are all separate sprites with no animations.
I've tried the overlapping bit but it just seems like there is a better way.
Basically, I'm just looking for a way to tell the invisible sprite that if it already has an object overlapping it to not let anything else overlap.
Not sure if I need to use variables or not.
I am trying different options but so far I can't figure it out
B
7
S
2
Posts: 158
Reputation: 1,021

Post » Fri Mar 21, 2014 6:21 pm

I have a variable attached to my invisible sprites called 'occupied"
value is zero
I I set a condition of:
box equal to or less than 0...do something

I can get that to work
What I can't figure out is how to tell it that if something is there already, prevent anything else from going there....
My brain hurts but I'll keep trying
B
7
S
2
Posts: 158
Reputation: 1,021

Post » Fri Mar 21, 2014 7:23 pm

bumpitty bump
B
7
S
2
Posts: 158
Reputation: 1,021

Post » Fri Mar 21, 2014 11:08 pm

ok.Maybe this will help someone help me.
This is a trimmed down basic idea of what I'm talking about.

https://db.tt/SgcnlgN1
B
7
S
2
Posts: 158
Reputation: 1,021

Next

Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 8 guests