how to del some instances

  • 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

  • Just check for overlap?

    Sprite is overlapping Sprite -> Sprite Destroy

  • When i check for overlap it�s 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 :)

  • 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

  • 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.

  • 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 ??

    dl.dropboxusercontent.com/u/164432510/gen5.capx

  • 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!

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

    it works perfect now

    thx again

  • 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)

  • wouah that' s almost instant build :) good job you've just optimised my code by 2000 percent lol

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hmm, do you need an instant generation? Take a look :)

    Tho it's not as good as it might be :( Size of the generated map is pretty random, also you'll need to sacrifice your "maxturns/turns" system.

  • I like that :) I will probably use this. it's always better players not hav to wait

  • JJLList I need some help again :p

    I've tried to use your tileset method but I'm lost again...

    here what I want to do : generate external colision wall.

    with old method I've almost succeded (I' m really bad with using condition and I've still the same problem with removing duplicates overlaps)

    dl.dropboxusercontent.com/u/164432510/almost.capx

    btw I don't know how to make this works with the tileset method. this gave me strange results and the wall tile fills everything so I can't use collision for my player sprite.

    here my last capx with tileset

    dl.dropboxusercontent.com/u/164432510/gen10.capx

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)