PDA

View Full Version : [AS2] Deck of Card


jorawar
05-05-2009, 09:47 AM
Hi Everyone,

I am going to start a game which is based on solitaire game. I want to place the cards like a deck of cards, see the attached image...
The number of images are dynamic, it can be 5 or 50.. anything...

can anybody tell me what is the logic behind this ... i want to place the images just like shown in the attached image...

waiting for some responses... Plz help me out...

Playaction
05-06-2009, 09:44 AM
If you have a movieclip (with identifier "card"), and place the centre around the lower left corner, you could do something like this:

cardnumber = 5;
for (var i = 0; i<cardnumber; ++i) {
var cardname = "card"+i;
_root.attachMovie("card", cardname, i+100);
_root[cardname]._x = 200+(i*5);
_root[cardname]._y = 200;
_root[cardname]._rotation = -20+(i*10);
}

The card movieclip could then contain 52 frames with i card in each. Then you only need a random function to select which frame to display.

I hope this helps you get started.