drspock11 Posted March 18, 2017 Share Posted March 18, 2017 How can I check if a sprite will collide with anything already on the screen prior to adding it? I add the sprite in the update loop, and game.physics.arcade.overlap or game.physics.arcade.collide does not detect the collision until after the sprite has been added and the update loop has exited at least once. I've been searching extensively but cannot find the answer to this seemingly simple question. Thanks for any help. Link to comment Share on other sites More sharing options...
squilibob Posted March 19, 2017 Share Posted March 19, 2017 you can use any object with a public x and y property with game.world.getClosestTo to find the closest gameobject to a point. You can then test if that gameobject would overlap your new sprite by comparing against it's xy co-ordinates and its width and height against the new sprite var closest = game.world.getClosestTo({x:500, y:500}); samme 1 Link to comment Share on other sites More sharing options...
Recommended Posts