Overlapping question

Get help using Construct 2

Post » Wed Oct 24, 2012 12:26 am

Have a quick question about overlapping, that i hope someone can explain to me.

So i have this event:

X = 10
Event:
For 1 to X
Spawn family1 at random(1000), random(1000)

subevent:
family1 is overlapping family1
family1 destroy
add 1 to X
              
However they are still ending up overlapping at some point.
I read in the tutorial section about picking newly created instances, and i cant see why this shouldnt work, as the newly created family instances are within the scope. Anyone know what im doing wrong?            
B
40
S
10
G
2
Posts: 1,148
Reputation: 6,495

Post » Wed Oct 24, 2012 5:57 pm

For those that cares :)

I did some more testing of this, trying to figure it out. And based on the article - "Understand the picking of newly created/spawn instances since R101" I cant see why it shouldnt work as its pretty much an exact copy of that. But for some reason the newly created instances doesnt seem to work with the overlapping test, when its added as a subevent. As im setting lots of other values as part of these subevents which works fine.

However if you move the overlapping test into its own event it works fine, and do some workaround, i think you can get it to work kinda the same way.

The purpose of this is to make a part of a random map generator that add X amount of different graphic elements to a map, but at the same time makes sure that if these elements are not overlapping, they are destroyed and a new one is made.nimos1002012-10-24 18:12:41
B
40
S
10
G
2
Posts: 1,148
Reputation: 6,495

Post » Wed Oct 24, 2012 11:26 pm

When you create a new object then that object is picked. So in the subevent when you have 'family1 is overlapping family1', you only have the last created family1 object picked. You're checking for overlaps with just one sprite.

In the past you'd put a 'pick all' condition in there but I was just trying it and putting 'pick all' after creating a sprite only picks the old sprites and doesn't include the newly created one.
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Thu Oct 25, 2012 1:36 am

So if i understand you correct it just doesnt work in a subevent, due to that?

I have no clue how the overlapping check is done, but thought that it was done by taking each instance, in this case only the newly created one and just go through each of the elements that its told to check for overlapping and see if its true or not.

But if i understand you correct its done in some way where it picks 2 instances that are overlapping and then return true, and since it only picks one instance in my subevent it will always return false?
B
40
S
10
G
2
Posts: 1,148
Reputation: 6,495

Post » Thu Oct 25, 2012 12:51 pm

If you have 10 sprites and have an event:
[code]
sprite is overlapping sprite
[/code]
that will check for overlaps between any of the 10.

Say if half of them have 50% opacity so
[code]
sprite opacity = 50
   sprite is overlapping sprite
[/code]
The first condition picks the 5 sprites with 50% opacity and then the subevent is only checking for overlaps within that group of 5.

If you have:
[code]
system create sprite
   sprite is overlapping sprite
[/code]
Create sprite picks only the newly created sprite so the subevent is checking for collisions within this group of 1.   
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Thu Oct 25, 2012 1:51 pm

Ahh ok i see.

Thanks for clearing it up for me :)
B
40
S
10
G
2
Posts: 1,148
Reputation: 6,495


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, jeffige, TheHat and 1 guest