Recommended Posts


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


Share this post

Link to post
Share on other sites

@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)
                            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.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.