dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Heaps of characters in one movie? Best way about it

Hybrid View

  1. #1
    Dance Monkey Dance! Doush.'s Avatar
    Join Date
    Jun 2004
    Posts
    254

    Heaps of characters in one movie? Best way about it

    Ok heres the scenario. I have a game which at the moment has lets say 30 characters in it each character movieclip has several frames in it all consisting of different walk animation directions. So up, down, left, and right (Its in isometric view i am using the outside of society tutorials).Each frame has an appropriate lable. Now the problem is that in the outside of society tutorial the character is attached to the stage. Now what i have is that when a certian criteria is met i want the character that is currently on the stage to be removed and the next character to be attached to the stage in the same location. Now i thaught about this 2 ways but i cant comprehend on how it would be coded.

    1/ Option one, i keep all the movieclips in the library seperate, with linkage names like char1 char2 char3 and so on and attach and remove them. From the stage.

    or

    2/ Option two, i place them all in a main container clip and tell the clip to goto frame char1 and tell the movie in char1 to goto and stop in lets say "down".

    Which option of the two would be the best and how would i structure it going by the outside of society tuts. Dont really need to much code (but examples do help) just some comments that i can sort of work out myself. Ow and if their is a better way to do it then please tell.

    Thanks in Advance
    "I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"

  2. #2
    Farmer divillysausages's Avatar
    Join Date
    Mar 2004
    Location
    ireland
    Posts
    251
    mightn't be the best approach, but i'm always fond of a bit of oop. make a object for each one of your 30 chars holding information such as it _x postion, _y position, current direction/frame it's facing, the clip it's referencing, and stuff of the like.

    then, when you're removing one clip and attaching the next, you can say
    code:

    game.char2.clip._x = game.char1.clip._x;
    game.char2.clip._y = game.char1.clip._y;
    game.char2.dir = game.char1.dir;
    game.char2.clip.gotoAndStop(game.char2.dir);


    as i said, it mightn't be the most practical for what you want - maybe you could hold all the info you need in variables that keep updating as you need them rather than 30 objects, but anyway, there you go

  3. #3
    Dance Monkey Dance! Doush.'s Avatar
    Join Date
    Jun 2004
    Posts
    254
    Yeh i thaught about that but thats alot of coding for something that should be prtyy simple. Now i am thinking that the have one main character mc idea would be the best idea. That way the main mc is always on the stage and its x and y properties dont have to be store because they all ready are. But i dont know how to structure it properly.
    "I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"

  4. #4
    one BAD mutha FK'er astrocalder's Avatar
    Join Date
    Oct 2004
    Location
    LA
    Posts
    221
    yeah 2 sounds better, the number of characters you have is just a matter of seperating them into different frames. on the event it would skip to that frame no problem.

    astrocalder

  5. #5
    Dance Monkey Dance! Doush.'s Avatar
    Join Date
    Jun 2004
    Posts
    254
    Yeh i figured that might be the best of the two. But still confuessed. So far i tell the char movie to goto its up down left and right frames,
    Code:
    _root.clip.char.gotoAndStop("Up");
    so for char1 it would look like this right
    Code:
    _root.clip.char.char1.gotoAndStop("Up");
    but i have to make sure im on the char1 frame in the char movie.
    I figure i would just set a varible onload that has the frame number of the current character and set the char movie to this onload. And then just change this varible when i change character.

    But that would mean i would have to re-write
    Code:
    _root.clip.char.char1.gotoAndStop("Up");
    Because their not all called char1 so. Lets say i make the on load var be charMe = 1;

    Would that line look like this now ?
    Code:
    _root.clip.char[charMe].gotoAndStop("Up");
    Think i have answered my own question but would be nice if someone could read through and tell me if this would work or not. Thanks.
    "I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"

  6. #6
    the Dervish of Q??
    Join Date
    Mar 2004
    Location
    Abbotsford, BC
    Posts
    103
    Yes, you basically did answer your own question, but to simplify it even further, you could just give all the MC's the same instance name. That way
    code:
    clip.char.char.gotoAndStop("Up");

    would work for everyone. That way you avoid as much confusion as is possible. This way you don't always have to be checking the charMe variable, and there's no chance that it will be wrong. It's just this way you have to make sure you have no typos, and then you get big long things like
    code:

    clip.char.char.char.play();


    with 3 "char"s in a row.

    Anyways, hope this helps.

    Derek

  7. #7
    Dance Monkey Dance! Doush.'s Avatar
    Join Date
    Jun 2004
    Posts
    254
    Thanks for that guys i got it working really nicely.
    "I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center