PDA

View Full Version : Memory Game


natedogg1994
12-03-2007, 11:28 PM
Hello all,

I need help creating a memory game. Right now i need help on the card reset. I have it so that when you click on it, it will show the piture. The problem is that when you press the wrong on i need it ti reset. Or in other words, turn around again. I need to remind you that im still on AS 2.0.

If you have any idea pleez post.

Thanks all,

natedogg1994 OUT!!!:cool:

rrh
12-04-2007, 03:43 PM
Well, how are you currently making it show the picture?

natedogg1994
12-05-2007, 02:46 AM
I am making it show the picture by a movie clip.

Here is the script:

on(rollOver){
gotoandstop(2);
}
on(press){
gotoandstop(3);
}
on(rollOut){
stop();
}

Slide 1= Regular card
Slide 2= Different color
Slide 3= Show picture

I have come across yet, another problem and would appreciate if you could answer them as well as this. These are the other problems:

When I click on the card the card changes, but when I put my mouse back on it turns back.

Thanks
Natedog1994 :)

rrh
12-05-2007, 03:53 PM
on(rollOver){
if (_currentframe==1)
gotoandstop(2);
}

Do you have a variable in the card that keeps track of what value the card is? You need something you can compare so you know whether two cards are the same.

If you have a whole bunch of cards, you might want to learn another form of applying actions to something that will make it a little easier:
card.onRollOver = function () {
if (this._currentframe==1)
this.gotoandstop(2);
} This is the same as I did above, only you put it in the base timeline, rather than on the card itself. And if you name all the cards "card1, card2, card3," etc. you can do something like this:

for (var count=1;count<20;count++) {
_root["card"+count].cardValue=Math.ceil(count/2);
_root["card"+count].onRollOver = function () {
if (this._currentframe==1)
this.gotoandstop(2);
}
}
And it applies the same function to every card without so much copying an pasting. (Also gives each one a "cardValue" with matching pairs.)

natedogg1994
12-05-2007, 09:46 PM
Thanks RRH a lot. Now everything works properly.
I will post again if I need anymore help.
:eek:

Thanks again,

Natedogg1994 OUT:rolleyes:

natedogg1994
12-12-2007, 09:47 PM
Hy RRH I am back again.
I need help with a second script for a card reset. When I press one card with a circle and then I press one with the wrong shape I need the cards to reset. Hence, The MEMORY Game.

Thanks for your help.:p

Natedogg1994 OUT:o

rrh
12-13-2007, 03:11 PM
Did you use this code from earlier?

for (var count=1;count<=20;count++) {
_root["card"+count].cardValue=Math.ceil(count/2);
_root["card"+count].onRollOver = function () {
if (this._currentframe==1)
this.gotoandstop(2);
}
}
This will result in pairs with matching values of .cardValue

1 and 2 match, 3 and 4 match, and so on.

Then you need a variable (firstCard) to keep track of the first card picked, and when you pick a card, if firstCard is null, set it to the card you just picked. If it is not null, compare it to the card you just picked, and if they don't match, flip them back over. And then set firstCard back to null.

natedogg1994
12-13-2007, 10:06 PM
Yes,
I have tried the code it still doesn't work.:confused: