kogen Posted February 14, 2014 Share Posted February 14, 2014 Hei Phaser-Folks, finally I had to register and now I really would like starting asking questions I've been playing around with Phaser for like a month and came to a point today where I could need some help. Here is the problem:I have a checker board and two different groups of figures (let's say black and white).Now I want to check if any of those figures is surrounded by four other figures of the other group, like one black is surrounded by one white (left, right, up and down).Since I have them in a group I cannot do a simple distance check like if white.x - black.x < x1 do...I thought it is possible to use collision handlers using the "touching" property, but that does not work either. I can only check if they collide but not how many of those collide with one of the other group. So I don't know how to go on now and would appreciate any hint. Thanks in advance kogen. Link to comment Share on other sites More sharing options...
rich Posted February 15, 2014 Share Posted February 15, 2014 Are you not storing the game 'board' data in an array? like a grid array? Then you can check easily which items are occupying which elements of the grid. This definitely sounds like a grid / logic problem to me, rather than one you'd use a distance/collision check for. Link to comment Share on other sites More sharing options...
kogen Posted February 16, 2014 Author Share Posted February 16, 2014 Hi Richard, I thought of the idea of having the whole game stored in an array and do the whole math on that array just showing the graphics as a visual representation... but I'm not sure if this is such a good idea. I would have to loop every update-cycle through the whole array and check if there is something near to my figures. I've figured out another way: I am looping through all living black figures, calling another loop in each black figure on each living white figure. Then I can check if it is within a specific circle that has its center in the center of the black figure. Thus I can check for 4-neighboring or by expanding the circle for 8-neighboring white figures. Another advantage of this method is that I could also translate the current idea from the raster approach to a non-raster approach and it would still work. Thank you. kogen Link to comment Share on other sites More sharing options...
Recommended Posts