jeroencoessens Posted May 5, 2017 Share Posted May 5, 2017 Hi, I'm making a tile based mahjong clone, you can check the attached image for reference. basically I need a smart way to implement the mechanic of mahjong, that checks when I tap a tile if he has neighbours ( left or right ) and if he has a tile ontop of him. The way these are placed makes it very difficult for me to come up with a system. The sprites/buttons are all overlapping already I have my buttons(tiles) in an array and the references to which tile it is in a seperate array so I can create them easily for more levels. Is there someone who can help me tell phaser to check this without giving each tile in each level a reference to neighbours ( would take forever ) If you want me paste some code just ask Link to comment Share on other sites More sharing options...
samme Posted May 5, 2017 Share Posted May 5, 2017 Not sure how you have these arranged, but could you do something like var newTile = tiles[col][row][level] = { col: row, row: row, level: level }; Link to comment Share on other sites More sharing options...
jeroencoessens Posted May 8, 2017 Author Share Posted May 8, 2017 @samme I think that would work yes, I found a messy workaround for my specific situation which let me use my already existing arrays. For left and right checking I held 2 bools ( left and right ) in a forloop when checking the tiles, when both were true at the end of the forloop the tile would be locked, but only if they were on the same level: if(buttons[i].position.x <= buttons[card.index].position.x + tileWidth + offset && buttons[i].position.x >= buttons[card.index].position.x + tileWidth - offset) { if(buttons[i].visible) countRight = true; } It's messy because I'm not working with columns due to tile being able to get placed on halfway spots as well. This works though for the left and right checking but is not ideal. the reason I'm using an offset range is because my positions are not always that precise for some reason, don't know why. Link to comment Share on other sites More sharing options...
Recommended Posts