Search the Community
Showing results for tags 'quad trees'.
-
Hi all, I'm making a mobile game and looking for the most efficient way of going about coding the following. Any comments would be most welcome 1. A solid background image Is this just a sprite of an optimized bitmap? Or is there a special method for bg images that keeps them as efficient as possible. 2. Generate a lot of balls (sprites) that bounce around the screen (Currently created a group for the balls and MANUALLY checking for boundary collisions to avoid the overhead of any physics engine). Am I being too harsh here? Will ARCADE physics do a better job of it, efficiency wise? 3. I need to check collisions with the touch/click co-ordinates at a given moment with all these balls, even if they overlap, a click will be detected regardless of layers. My initial thoughts are to engage quad trees to elect candidates for running collision detection on. I have this function too, to detect clicks in a circle: // Check if the input is within a circular radiuscheckCollision: function(ball, inputX, inputY) {var radius = ball.width/2var centerX = ball.x+radius;var centerY = ball.y+radius;if(Math.sqrt((inputX-centerX)*(inputX-centerX) + (inputY-centerY)*(inputY-centerY)) < radius) {return true;} else {return false;}},I'm having trouble relating the sprites in a group to candidates that are retrieved from a quadtree, is the quadtree built into groups? Say if a candidate came back from the quadtree, and collision was true, how would I kill the sprite from the group? Any pointers would be great! Thanks guys, Phaser is really great to work with.