7 Replies - 9032 Views - Last Post: 03 March 2006 - 02:00 AM

#1 murni  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-February 06

Matching game

Post icon  Posted 27 February 2006 - 10:19 PM

i need help for making the matching game.not know how to make it....please help me what action script should i use :P

This post has been edited by murni: 27 February 2006 - 10:20 PM

Is This A Good Question/Topic? 0
  • +

Replies To: Matching game

#2 pioSko  Icon User is offline

  • still.dreaming
  • member icon

Reputation: 23
  • View blog
  • Posts: 1,888
  • Joined: 06-June 03

Re: Matching game

Posted 28 February 2006 - 02:10 AM

What matching game?

Do you have any actionscript to show? With what in your actionscript do you have a problem with?

We can help with problems in your code, but we will not write it for you.
Was This Post Helpful? 0
  • +
  • -

#3 murni  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-February 06

Re: Matching game

Post icon  Posted 28 February 2006 - 09:15 PM

//INIT SOME SETTING
var tryCount=0;
var totalMatches=6;
var ourMatches=0;
var colWidth = 4;

//DEFINE THE BITMAP THAT WE'LL BE IMPORTING
var cardback = "matchgame_cardback.jpg";

//CREATE OUR SOUNDS
Snd_notAllowed = new Sound();
Snd_notAllowed.attachSound("Snd_notAllowed");
Snd_good = new Sound();
Snd_good.attachSound("Snd_good");

//DEFINE THE STARTING CARD POSITION AND OFFSETS
var origin_x = 46;
var origin_y = 50;
var offset_x = 80;
var offset_y = 110;

//CURRENT CARD POSITION
var pos_x = origin_x;
var pos_y = origin_y;

//CREATE AN MULTIDIMENSIONAL ARRAY OF THE POSITIONS
var posArr = new Array();
for (i=0;i<(totalMatches*2);i++){
    posArr[i]=new Array(pos_x,pos_y)
    if( (i==(colWidth-1)) || (i==((colWidth*2)-1))  ){
        //NEW ROW
        pos_x = origin_x;
        pos_y += offset_y;
    }else{
        pos_x += offset_x;
    }	
}

//CREATE THE 4 MATCHING PAIRS AND PLACE THEM USING OUR POSITION ARRAY
for (i=0;i<totalMatches;i++){
	
    //GET RANDOM SPOT FOR FIRST CARD FROM POS ARRAY
    var r = random(posArr.length-1);
    var randomPos = posArr[r];
    posArr.splice(r, 1);
	
    //CREATE CARD AND POSITION
    var cardname = "card_1_" + i;
    duplicateMovieClip("card_template", cardname, i);
    _root[cardname]._x = randomPos[0];
    _root[cardname]._y = randomPos[1];
    graphicname = "matchgame_" + (i+1) + ".jpg"
	
    //IMPORT THE GRAPHICS
    _root[cardname].card_placeholder.loadMovie(graphicname);
    _root[cardname].cardback_placeholder.loadMovie(cardback);
    _root[cardname].card_placeholder._visible = true;
    _root[cardname].mode = "norm";
    _root[cardname].cardID = i;
	
    //GET RANDOM SPOT FOR MATHCING CARD FROM POS ARRAY
    var r = random(posArr.length-1);
    var randomPos = posArr[r];
    posArr.splice(r, 1);
	
    //CREATE CARD AND POSITION
    var cardname = "card_2_"+ i;
    duplicateMovieClip("card_template", cardname, i+10);
    _root[cardname]._x = randomPos[0];
    _root[cardname]._y = randomPos[1];
	
    //IMPORT GRAPHICS
    _root[cardname].card_placeholder.loadMovie(graphicname);
    _root[cardname].cardback_placeholder.loadMovie(cardback);
    _root[cardname].card_placeholder._visible==true;
    _root[cardname].mode="norm";
    _root[cardname].cardID=i;
}

//CREATE HOLDER TO KEEP TRACK OF TURNED CARDS
var flippedcard_1 = "empty";
var flippedcard_name = "empty";

stop();



-this is the real coding,i try to do but went i publish it the picture not came out.where should i put the picture in card_placeholder or where.......please help me

This post has been edited by pioSko: 01 March 2006 - 02:13 AM

Was This Post Helpful? 0
  • +
  • -

#4 pioSko  Icon User is offline

  • still.dreaming
  • member icon

Reputation: 23
  • View blog
  • Posts: 1,888
  • Joined: 06-June 03

Re: Matching game

Posted 01 March 2006 - 02:28 AM

There are elements missing from this script... did you get this from a book.. or tutorial.. or something? I suggest you read it carefully and see if you didn't miss anything.

From that script I can tell you that the images have to be named:

matchgame_1.jpg
matchgame_2.jpg
matchgame_3.jpg
matchgame_4.jpg
matchgame_5.jpg
matchgame_6.jpg

and one named matchgame_cardback.jpg

They must be located in the same directory as the game.

Also, there is line which duplicates a movieClip, therefore one has to be on the stage in order to be duplicated. I'm guessing that movieClip has certain other elements that will make the game work. Check the source of this script.
Was This Post Helpful? 0
  • +
  • -

#5 murni  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-February 06

Re: Matching game

Posted 01 March 2006 - 07:23 PM

i get the code from book,have make all the point you said,but still can't work,you mean the file should name
matchgame_1.jpg
matchgame_2.jpg
matchgame_3.jpg
matchgame_4.jpg
matchgame_5.jpg
matchgame_6.jpg
matchgame_cardback.jpg
or .jpg is file extension for the picture.

in the book just have short explanation for this code.i get the code from the sample file from cd of that book.and i have try name the file as you say but get some error ,the eror is
Error opening URL "file:///C|/Documents%20and%20Settings/Danau1/Desktop/Chapter%2012/matchgame_1.jpg" the error occur for all the picture,can you tell what really wrong with this code.

This post has been edited by murni: 01 March 2006 - 07:30 PM

Was This Post Helpful? 0
  • +
  • -

#6 pioSko  Icon User is offline

  • still.dreaming
  • member icon

Reputation: 23
  • View blog
  • Posts: 1,888
  • Joined: 06-June 03

Re: Matching game

Posted 02 March 2006 - 01:32 AM

The image files have to be named like I said. They have to be in the same place where you .FLA file is.

And there HAS TO be more to that file than just actionScript. It is missing important information. In the movie there has to be a movieClip on the stage. The duplicateMovieClip function will not work if there is nothing to duplicate.

Check the CD if there are other versions of the file... and check the files in Flash to see if there are any symbols in the movies library.
Was This Post Helpful? 0
  • +
  • -

#7 murni  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-February 06

Re: Matching game

Post icon  Posted 02 March 2006 - 08:02 PM

all the picture i have put in same directory as .fla file,but the picture still not came out.i want as you,from that actionscript you said the movieclip have to be in the stage,i also have make it still not work.and just one more question,do i need to import the picture on the stage,because what can i really understand from the explanation from the book,no need to that because the actionscript allow the picture load automatically from the same directory.and one more thing,do i need do something to that picture....what i understand from the file is nothing wrong what i have done,i do exactly the same from the original file.what confius me is why the picture not appear.went i change the picure with original picture(from the original file) the picture came out,went use my own picture ,picture not appear.
Was This Post Helpful? 0
  • +
  • -

#8 pioSko  Icon User is offline

  • still.dreaming
  • member icon

Reputation: 23
  • View blog
  • Posts: 1,888
  • Joined: 06-June 03

Re: Matching game

Posted 03 March 2006 - 02:00 AM

Quote

went i change the picure with original picture(from the original file) the picture came out,went use my own picture ,picture not appear.


So it has worked??

The actionScript loads the images from the folder. You do not have to import them into the FLA.

_root[cardname].card_placeholder.loadMovie(graphicname);
_root[cardname].cardback_placeholder.loadMovie(cardback);


These two lines load the images. In the line you have _root[cardname].. cardname being a dynamicaly modified variable. This "links" with the movieclip on stage.

For example: if cardname is equal to "card_1_0", then the line _root[cardman] is the same as _root.card_1_0.

The next part of those lines link to movieClips WITHIN that movieClip. So, if on stage you have a movieClip named card_1_0, inside it you should have movieClips named card_placeholder and cardback_placeholder

The images are loaded into those two movieClips.

-//-

Now, you don't have to create all the cards, because the actionScript copies and duplicates and places them on the stage in a grid.

What you do need is ONE card on stage, named "card_template". The actionScript, using this line...
duplicateMovieClip("card_template", cardname, i);
... duplicates that card, gives it a new name and places it on the stage.


All you have to do is:
1. Have the images (.jpg) named like I said before
2. Place one card on stage and name it "card_template"
3. Make sure that the card has TWO movieClips inside named card_placeholder and cardback_placeholder
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1