Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-02-2008, 04:53 PM   #1
bettypage222
Registered User
 
Join Date: Mar 2007
Posts: 39
Default Match Game help

Hi,

I have a program for a card match game... and I have a question... can anyone think of a solution for this? If two of the cards are matched, the code now removes the movie clips...

I would like to change it so that when a match is made, the movie clips ARE NOT removed, however I want them to NOT BE ENABLED either... that the card match is unclickable...

I'm not sure how to do that... thanks for any help

//<AS>


initGame();
stop();

function initGame() {
// make sorted list of cards
cardsListOrdered = [];
for(i=1;i<=8;i++) {
cardsListOrdered.push(i,i);
}

// shuffle list
cardsListSorted = [];
while (cardsListOrdered.length > 0) {
r = int(Math.random()*cardsListOrdered.length);
cardsListSorted.push(cardsListOrdered[r]);
cardsListOrdered.splice(r,1);
}

// create card clips and assign their location and picture
x = 0;
y = 0;
for(i=0;i<16;i++) {
attachMovie("Card","Card"+i,i);
_root["Card"+i].picture = cardsListSorted[i];
_root["Card"+i]._x = x*85+275;
_root["Card"+i]._y = y*85+80;

// move to next card spot
x++;
if (x > 3) {
x = 0;
y++;
}
}

firstclip = 0;
}

function clickCard(clip) {
// see whether two cards are showing
if (secondclip != 0) {

// turn those two cards back over
firstclip.gotoAndStop(1);
secondclip.gotoAndStop(1);
firstClip = 0;
secondClip = 0;
}

// see whether same card was clicked
if (firstclip == clip) {

// turn card back over
firstclip.gotoAndStop(1);
firstClip = 0;

// see whether no cards are showing
} else if (firstclip == 0) {

// turn first card over
clip.gotoAndStop(clip.picture+1);
firstclip = clip;

// must be one card showing
} else {

// turn second card over
clip.gotoAndStop(clip.picture+1);
secondClip = clip;

// see whether two cards match
if (firstclip.picture == secondClip.picture) {

// remove both cards
firstClip.removeMovieClip();
secondClip.removeMovieClip();
firstClip = 10;
secondClip = 20;
}
}

}
bettypage222 is offline   Reply With Quote
Old 07-02-2008, 06:56 PM   #2
CobaltBlueDW
Senior Member
 
CobaltBlueDW's Avatar
 
Join Date: Jun 2008
Posts: 166
Default

Some important code seems to be missing, but if I conjecture right using something like this would work:
ActionScript Code:
// remove both cards firstClip.onRelease = null; secondClip.onRelease = null;

I don't know if you used onRelease, there are so many different possibilities for that, so hoefully you get the idea.
CobaltBlueDW is offline   Reply With Quote
Old 07-02-2008, 07:28 PM   #3
bettypage222
Registered User
 
Join Date: Mar 2007
Posts: 39
Default

that worked perfect, thanks!

Actually, there is no code missing... that's all of it...the mc in the library are being exported for AS, that's probably what you mean?
bettypage222 is offline   Reply With Quote
Old 07-02-2008, 08:16 PM   #4
bettypage222
Registered User
 
Join Date: Mar 2007
Posts: 39
Default error

actually, I'm getting this error with the code

**Warning** The linkage identifier 'Card_Button' was already assigned to the symbol 'cbutton', and cannot be assigned to the symbol 'cbutton', since linkage identifiers must be unique.


Here is the code:

//<AS>

initGame();
stop();

function initGame() {
// make sorted list of cards
cardsListOrdered = [];
for(i=1;i<=8;i++) {
cardsListOrdered.push(i,i);
}

// shuffle list
cardsListSorted = [];
while (cardsListOrdered.length > 0) {
r = int(Math.random()*cardsListOrdered.length);
cardsListSorted.push(cardsListOrdered[r]);
cardsListOrdered.splice(r,1);
}

// create card clips and assign their location and picture
x = 0;
y = 0;
for(i=0;i<16;i++) {
attachMovie("Card","Card"+i,i);
_root["Card"+i].picture = cardsListSorted[i];
_root["Card"+i]._x = x*85+275;
_root["Card"+i]._y = y*85+80;

// move to next card spot
x++;
if (x > 3) {
x = 0;
y++;
}
}

firstclip = 0;
}

function clickCard(clip) {
// see whether two cards are showing
if (secondclip != 0) {

// turn those two cards back over
firstclip.gotoAndStop(1);
secondclip.gotoAndStop(1);
firstClip = 0;
secondClip = 0;
}

// see whether same card was clicked
if (firstclip == clip) {

// turn card back over
firstclip.gotoAndStop(1);
firstClip = 0;

// see whether no cards are showing
} else if (firstclip == 0) {

// turn first card over
clip.gotoAndStop(clip.picture+1);
firstclip = clip;

// must be one card showing
} else {

// turn second card over
clip.gotoAndStop(clip.picture+1);
secondClip = clip;

// see whether two cards match
if (firstclip.picture == secondClip.picture) {

// remove both cards
firstClip.onRelease = null;
secondClip.onRelease = null;
firstClip = 0;
secondClip = 0;
}
}

}
bettypage222 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
FlashGameLicense.com - virtual marketplace to connect game developers and buyers AdamSchroeder General Chat 0 12-18-2007 09:16 PM
Rate My Game, plz fill the questioner UzumakiJr Site Check 0 12-16-2006 08:48 PM
[AS2] how do I match "o" to "O" for proper nouns in a hangman game? neilmmm Gaming and Game Development 10 03-15-2006 04:12 PM
[AS2] Card Match Game, Colour Me In Pictures and Board Game Total Frigging Gaming and Game Development 4 02-21-2005 12:04 AM
[AS2] Memory game - match 2 different cards 550krokur Gaming and Game Development 0 03-27-2004 11:29 AM


All times are GMT. The time now is 08:33 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.