Help please w/Taipei-type game
So I'm coding a Taipei/MahJongg-style game (although a scaled-down version of one), and gotten fairly far along by modeling my code after William Warby's well-documented "Matching Pairs" card game (and the apparently identical game that 'Joe banner' has posted as his own as well).
I need, however, to get the "tiles" in the Taipei game to only match up when they have three or more sides free and if there are no tiles stacked on top of them. I figured that a hitTest loop wouldn't be too processor demanding if it only tested when the user activated the mouseDown state, so I made a little loop to test if the clicked tile touched any other tiles on the board, and if so to increment a variable by 1.
The tiles are all in a movie clip called "Taipei" that is on the main stage. Each of the 30 tiles is named "Tile"+n.
code:
onClipEvent (load) {
tileTouch = 0;
}
onClipEvent (mouseDown) {
for (var cn = 0; cn<31; cn++) {
if (cn<10) {
if (this.hitTest(_parent.Card0+"cn")) {
tileTouch = tileTouch+1;
}
} else {
if (this.hitTest(_parent.Card+"cn")) {
tileTouch = tileTouch+1;
}
}trace(cardTouch);
tileTouch = 0;
}
}
The problem is, even though I have made sure that the tiles overlap slightly, I never get a value for "cn" except for 0, so I can't eventually make the tileSelect function reject any tiles with a tileTouch >1.
I've tried my best to make this clear as possible; if it's not clear enough, please leave a reply and I'll try to clear any fuzzy spots up.
I'm truly puzzled here, so any help would be appreciated.