A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Best way to make a character select ?

  1. #1
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976

    Best way to make a character select ?

    What i have at the moment works but its very basic and is too long for something so simple and has way too many if statements. Would anyone be able to help me in a better way to do a character select. What i have is the script create 3 clank mc's on the stage and attaches the corroresponding character to the each of the mcs. I also have created another blank mc and attached the arrow mc to it. What my script does is checks which mc is currently selected and move to the other mcs when you press up and down.

    So just say the arrow mc is aboce character 1 if i press the left button it will go and select character 3 and if i had of press the right button it would select character 2.

    Thats what i have working but the script is too long and theirs too many if statements. Does anyone have a better way to do this?

    [h]ooligan

  2. #2
    Senior Member mbenney's Avatar
    Join Date
    Mar 2001
    Posts
    2,744
    if it works well, who cares! if its only a character select screen all the ifs wont affect the rest of the game
    [m]

  3. #3
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Its an in game selection thing. I have a thing wbout useing big scripts for simple things. Id rather it be small and complex and easy to edit apposed to huge and full of if statements and imposible to edit. My version has too many varibles also

  4. #4
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    here's the method i used for the character changes in my unreleased RPG/quest game:

    > use only 1 variable.
    player="hobbit" or
    player="magician"
    etc...
    that var player is defined when you push your accept key while choosing your player.

    > interactions:
    normally, they look like this:
    if(Key.isDown(Key.DOWN)){
    _root.player.gotoAndStop("wak_down")
    }
    change them depending on the character, here the hobbit:
    if(Key.isDown(Key.DOWN)){
    _root.player.gotoAndStop("hobbit_wak_down")
    }

    > look for the character selected:
    if(Key.isDown(Key.DOWN)){
    _root.player.gotoAndStop(player+"_wak_down")
    }

    ^ what it means; all your character's MCs are in the same MC, and their labels are something like:
    "hobbit_attack" or
    "magician_attack"
    etc...
    then let the var player do the rest
    player+"_attack"

    that's it ^^

    you can also have one MC for each player, in that case use the var player differently, and check it only when you attach your selected character MC... in that case be sure to have all the labels for each character the same.

    hope it helps.
    Last edited by marmotte; 03-14-2003 at 09:35 AM.

  5. #5
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Thats not really what i wanted. But thanks anyway marmotte

    Anyone else???

  6. #6
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Here i quickly whiped up an example

    click here

    This version doesnt work very well. But its an example of what i want. And also just say i have character 1 selected and i press left i want it to go and select character 3. and vice versu for character 3. I have that working but its bodgy and thiers too much script for something so simple

  7. #7
    Senior Member Kirill M.'s Avatar
    Join Date
    May 2002
    Location
    Toronto, Canada
    Posts
    711
    For one make an array and put your character mc's in it. Make the arrow mc and have it maintain a variable 'ind' inside, which will hold the index of the character over which it is currently located. Put an invisible button inside the arrow and have it on Right key press check whether ind is less than the length of the char array -1. If true then increment ind and read the _x coordinate of the mc in your array at index ind and assign that value to the _x attribute of your arrow. Same with Left key press, except you check whether 'ind' is greater than 0 and if so decrement it and assign the _x value of the char mc at index 'ind' to the _x of your arrow.

    That's one array, one variable, and two if statements.

  8. #8
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Thats exactly what i was looking for. Thanks heaps Kirill M.

  9. #9
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    I just tried quickly and i cant get it to work. Its probally something small im missing but i cant work it out

  10. #10
    Originally posted by marmotte
    [B]here's the method i used for the character changes in my unreleased RPG/quest game:

    > use only 1 variable.
    player="hobbit" or
    player="magician"
    etc...
    that var player is defined when you push your accept key while choosing your player.

    > interactions:
    normally, they look like this:
    if(Key.isDown(Key.DOWN)){
    _root.player.gotoAndStop("wak_down")
    }
    change them depending on the character, here the hobbit:
    if(Key.isDown(Key.DOWN)){
    _root.player.gotoAndStop("hobbit_wak_down")
    }
    Personally I would prolly keep the actions at
    gotoAndStop("walk_down")

    But depending on what character then choose use .attachMovie to place a different character. That way you dont have 1 mc holding all the characters animations. So my way if you had 3 different characters you could choose you would have 3 different mc's with each different characters poses housed in their own mc.

    Just a matter of preference. I dont think eigther way would be faster then the other.
    Unless you wanted each character to be able to move or "think" differently with seperate mc's you could create seperate "brains"

  11. #11
    Senior Member Kirill M.'s Avatar
    Join Date
    May 2002
    Location
    Toronto, Canada
    Posts
    711
    I'll see if I can put something together for you. It should take too long.

  12. #12
    Senior Member Kirill M.'s Avatar
    Join Date
    May 2002
    Location
    Toronto, Canada
    Posts
    711
    Here
    Attached Files Attached Files

  13. #13
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    But depending on what character then choose use .attachMovie to place a different character
    that's also what i wrote at the end of the thread ^^

  14. #14
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Thanks heaps Kirill M.

    And you to xMCNUGGETx, marmotte

  15. #15
    lol... sorry maramotte... read how you were doin it and skipped right over that last sentance =)

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