Hi in my game i have sprites who are spawned every 3sec, pink diamonds,
the diamonds follow the x scroll
It's a flappy bird style game, but i have a problem HOW to DESTROY the pink diamonds if they are too close to my obstacles ?
Use distance(x1, y1, x2, y2) Calculate distance between two points.
On second thoughts you could also compare the Bounding Boxes.
Or use Overlapping at Offset,
There are Many different ways...
thanks so much !
Develop games in your browser. Powerful, performant & highly capable.
You could also create an invisible sprite as a range sprite and use the mentioned on collision or on overlapping on that if you want to go further than the bounding box. Probably a circle would be ideal. :)
Pin that sprite to the player at the beginning of the layout after positioning it where you want it.
Thanks a lot, i used your advice of that round sprite for collisions, work perfectly !
Awesome! Glad it worked! I use that all the time for ranging things, like detections and such. Very powerful and in fact you can better its performance if we have the ability to detect collisions with tiled backgrounds instead since they use less memory.
Also, if you have an issue where setting visible to invisible, then instead just change opacity to like 1 or something so collisions still work. :)