How do I count instances overlapping one sprite?

Get help using Construct 2

Post » Sat Dec 17, 2016 9:02 am

Hey guys I want my sprite to count the number of instances of the laser beams overlapping it.
How do I do that?


http://s000.tinyupload.com/?file_id=233 ... 9905966696
Credits for laser beam capx go to @R0j0hound
I just modified the capx to generate multiple beams
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,244

Post » Sat Dec 17, 2016 9:21 am

If I understand your capx correct, at the moment your laser stops after overlapping one instance. So the maximum will be one.

Edit: Ahh now I get it. You can multiply the Laser. :) The solution with PickedCount should still work.

To look how many times an object overlap an other you could use 'pickedcount'.

Sprite2| Is overlapping laser -> Set text to sprite2.PickedCount.
Image
Last edited by Asmodean on Sat Dec 17, 2016 9:29 am, edited 1 time in total.
B
24
S
3
G
1
Posts: 454
Reputation: 2,171

Post » Sat Dec 17, 2016 9:28 am

I see. I didn't even know about "PickedCount." I'll try that out, thanks.
Actually, if you click the screen in the capx, more beams will be created. Then you can see the HP of each box decrease faster with multiple beams hitting it.
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,244

Post » Sat Dec 17, 2016 9:31 am

I saw that but to late. I edited my post. :)
B
24
S
3
G
1
Posts: 454
Reputation: 2,171

Post » Sat Dec 17, 2016 9:38 am

Asmodean wrote:I saw that but to late. I edited my post. :)


Hey sorry to bother you again but I'm having a hard time implementing the whole pickedcount thing.
I tried to set the Sprite2.Raycount variable to laser.pickedcount but it's only displaying "1"
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,244

Post » Sat Dec 17, 2016 10:14 am

https://www.dropbox.com/s/hivivub0ufn37 ... .capx?dl=0



@Asmodean -----> Edit: Ahh now I get it. You can multiply the Laser <----------- THANKS
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Dec 17, 2016 10:28 am

@99Instances2Go

nice and easy solution. I stuck because I tried to do it without loop. If the laser hit one specific object I could only count the total of lasers which hit all objects at this moment.
B
24
S
3
G
1
Posts: 454
Reputation: 2,171

Post » Sat Dec 17, 2016 11:40 am

Oh, but without your light, i would be still in the dark.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Yahoo [Bot] and 8 guests