To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Search this Thread Display Modes
Old 09-29-2005, 02:59 PM   #1
designerTrevor
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.

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.
__________________
Pacem!
--T
"Clearly I cannot choose the cup in front of you!"
designerTrevor is offline   Reply With Quote
Old 09-29-2005, 03:22 PM   #2
dancinkid6
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:
code:


Taipei.onMouseDown = function()
{

for (var cn = 0; cn<31; cn++)
{
if(this['Tile'+cn].hitTest(this._xmouse, this._ymouse))
{
this.tileTouch ++;
}
}




is that what you want?
__________________
-The Dancin kidd
dancinkid6 is offline   Reply With Quote
Old 09-29-2005, 03:38 PM   #3
designerTrevor
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!"
designerTrevor is offline   Reply With Quote
Old 09-29-2005, 03:42 PM   #4
dancinkid6
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
__________________
-The Dancin kidd
dancinkid6 is offline   Reply With Quote
Old 09-29-2005, 04:06 PM   #5
designerTrevor
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;
	//}
//}
}
But variable 'cn' still does not increment. I clicked on the "Taipei" window twice and my trace command traced 40 zeroes..
Do you have any ideas what I'm doing wrong?

Thanks!
__________________
Pacem!
--T
"Clearly I cannot choose the cup in front of you!"
designerTrevor is offline   Reply With Quote
Old 09-30-2005, 11:26 AM   #6
designerTrevor
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!"
designerTrevor is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:32 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.