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?
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
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.
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
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.
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"