DonFrag Posted October 8, 2015 Author Share Posted October 8, 2015 if would be a way to add a sprite a collision check (not the body, the sprite) to any object and then heck if it is a block or whatever , that would be the solutionsomething like if(sprite.overlap(callbackFunction)) and inside callback check anything the sprite overlap examples and functions demands two objects. or one in the case of sprite.overlap. in any case case it demands to know the second object to test, and that, in this case, i don't know. i tried to check with a for every block in the array where they are stored and compare the overlap, but this is way too expensive in any case inside in a update. Link to comment Share on other sites More sharing options...
jmp909 Posted October 8, 2015 Share Posted October 8, 2015 i think sprite vs group uses some kind of internal optimsation to not have to check every sprite in the group.. since some will be too far anyway. same with group vs group... I've not checked those routines specifically as to how, but for instance i checked vs sprite vs tilelayer code and that only checks tiles around the sprite... the ones that it *could* be colliding with actually you can see in here it uses a QuadTree https://github.com/photonstorm/phaser/blob/master/src/physics/arcade/World.js eg look around line 700 collideSpriteVsGroup: Link to comment Share on other sites More sharing options...
DonFrag Posted October 8, 2015 Author Share Posted October 8, 2015 and how does quad tree works?i tried example http://phaser.io/examples/v2/arcade-physics/quadtree---collision-infos but it is broken :/ Link to comment Share on other sites More sharing options...
Recommended Posts