bettypage222
07-02-2008, 05:53 PM
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;
}
}
}
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;
}
}
}