how to del some instances

Get help using Construct 2

Post » Sat Dec 21, 2013 5:43 pm

hello,

I try to generate some sprites in random but I want to keep only 1 instance on the same location. because of random sometimes there is a lot sprites generated on the same place

as I am not a coder it's a bit hard to find a way to code what I have in mind :)
I would like to find an easy way to :

- delete the instances that are generated on top of the others (but keep the first 1 active)
or
- do not create instance on top of others

in my example the sprite got half opacity to see the problem...
h ttps://dl.dropboxusercontent.com/u/164432510/gen.capx
B
5
Posts: 19
Reputation: 313

Post » Sat Dec 21, 2013 6:49 pm

Just check for overlap?

Sprite is overlapping Sprite -> Sprite Destroy
B
17
S
6
Posts: 348
Reputation: 2,608

Post » Sat Dec 21, 2013 7:03 pm

When i check for overlap its ok but if i use destroy it kill all my instances . I think there is a way but i dont really know how to code this :)
B
5
Posts: 19
Reputation: 313

Post » Sun Dec 22, 2013 3:21 am

I have cleaned my capx and try many things (mostly with variables) but i always come to the same result :( I don't figure how to remove these instances.

here is my new capx
h ttps://dl.dropboxusercontent.com/u/164432510/gen2.capx
B
5
Posts: 19
Reputation: 313

Post » Sun Dec 22, 2013 1:46 pm

I think you need to check if your floormarker is overlapping floortile every turn, before spawning a new floortile.
Something like This, I guess.
This is just one way to prevent spawning several tiles at same location.
Also, preventing your floormarker from going on a location that is not empty (already has a floortile there) might be another way to solve your issue. All you need is to check if location is empty before moving floormarker there.JJList2013-12-22 13:57:43
B
17
S
5
G
1
Posts: 74
Reputation: 2,647

Post » Sun Dec 22, 2013 3:07 pm

Thanks a lot JJList you're the best !

I've seen you'd corrected my counter too ! great
I've tried to make the same changes on my capx but still not working the same way as your capx
what magic trix have you done ??

https://dl.dropboxusercontent.com/u/164432510/gen5.capx
B
5
Posts: 19
Reputation: 313

Post » Sun Dec 22, 2013 3:35 pm

You're welcome:)
Oh, right, forgot to mention!
C2 seems to have a weird "overlap" detection.. objects count as "overlapping" even if they are just "back to back"..
hmmm, not sure how to explain it:(
Just look at the floormarker's collision box, you'll see that "magic trick" is to make it a bit smaller than sprite itself :)
Hope that helps!JJList2013-12-22 15:40:51
B
17
S
5
G
1
Posts: 74
Reputation: 2,647

Post » Sun Dec 22, 2013 4:19 pm

sure it helps ! I will probably never find such a trick like this by myself :)
it works perfect now

thx again
B
5
Posts: 19
Reputation: 313

Post » Sun Dec 22, 2013 8:50 pm

Anytime, mate:)
Btw, I've been playing around with your capx recently and tried to add 3 more floormarkers.. Got a noticable FPS dropdown : way too many individual sprites.
Using TileMaps is waaay more efficient FPS/CPU-wise.
Take a look at this example!
Actually, it's first time I've tried tilemaps, and I see a HUGE perfomance boost:P
Yet another little "magic trick", thought it might be helpful;)

(P.S. Omg, THIS is hot :D)JJList2013-12-22 21:17:18
B
17
S
5
G
1
Posts: 74
Reputation: 2,647

Post » Sun Dec 22, 2013 11:23 pm

wouah that' s almost instant build :) good job you've just optimised my code by 2000 percent lol
B
5
Posts: 19
Reputation: 313

Next

Return to How do I....?

Who is online

Users browsing this forum: el3um4s and 8 guests