|
|
|
#1 |
|
Flash Explorer
Join Date: Sep 2005
Posts: 52
|
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.
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.
__________________
Pacem! --T "Clearly I cannot choose the cup in front of you!" |
|
|
|
|
|
#2 |
|
Senior Kid
Join Date: Jan 2002
Location: I am right behind ya
Posts: 274
|
I think you are doing stuff wrong with hitTest, try this:
is that what you want? |
|
|
|
|
|
#3 |
|
Flash Explorer
Join Date: Sep 2005
Posts: 52
|
I should paste this in the Main Stages's Actions layer?
__________________
Pacem! --T "Clearly I cannot choose the cup in front of you!" |
|
|
|
|
|
#4 |
|
Senior Kid
Join Date: Jan 2002
Location: I am right behind ya
Posts: 274
|
or you can use onClipevent on the mc
onClipEvent(mouseDown) { for (var cn = 0; cn<31; cn++) { if(this['Tile'+cn].hitTest(this._xmouse, this._ymouse)) { this.tileTouch ++; } } same difference |
|
|
|
|
|
#5 |
|
Flash Explorer
Join Date: Sep 2005
Posts: 52
|
Thank you for your help so far; I still can't get this to work.
What I have now is, in my "Taipei" mc, the following code: Code:
onClipEvent (load) {
cardTouch = 0;
}
onClipEvent(mouseDown) {
//for (var cn = 0; cn<31; cn++) {
//if (cn<=10) {
//if (this['Card0'+cn].hitTest(this._xmouse, this._ymouse)) {
//this.cardTouch++;
//}
//} else {
if (this['Card'+cn].hitTest(this._xmouse, this._ymouse)) {
this.cardTouch++;
}trace (cardTouch);
//cardTouch = 0;
//}
//}
}
Do you have any ideas what I'm doing wrong? Thanks!
__________________
Pacem! --T "Clearly I cannot choose the cup in front of you!" |
|
|
|
|
|
#6 |
|
Flash Explorer
Join Date: Sep 2005
Posts: 52
|
Arrgh! still not working! I tried ro a couple of hours last night before I wend to bed and managed to accomplish just about nothing. Anyone have and ideas that can help, please?
__________________
Pacem! --T "Clearly I cannot choose the cup in front of you!" |
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|