A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Help please w/Taipei-type game

  1. #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.

    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!"

  2. #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:
    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

  3. #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. #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
    -The Dancin kidd

  5. #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;
    	//}
    //}
    }
    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!"

  6. #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!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center