Change speed: Difference between revisions
Whirled vox (talk | contribs) m (Text replacement - """ to """) |
Whirled vox (talk | contribs) m (Text replacement - ">" to ">") |
||
| Line 1: | Line 1: | ||
'''Change Speed Code manually:''' | '''Change Speed Code manually:''' | ||
Use this code if you plan to only have one speed for the avatar, be sure to paste it after the "_crt" lines found in your avatars action script, you cal also paste this code into a state if you wish. Change the S in code to change the speed number. The number cannot be smaller then 50. | Use this code if you plan to only have one speed for the avatar, be sure to paste it after the "_crt" lines found in your avatars action script, you cal also paste this code into a state if you wish. Change the S in code to change the speed number. The number cannot be smaller then 50. | ||
<actionscript | <actionscript> _ctrl.setMoveSpeed(S); </actionscript> | ||
'''Change Speed Code with states''' | '''Change Speed Code with states''' | ||
The following code with automatically change the speed depending on the current state. The code goes like this: | The following code with automatically change the speed depending on the current state. The code goes like this: | ||
<actionscript | <actionscript> | ||
// This code will change the speed with the selected state | // This code will change the speed with the selected state | ||
import com.whirled.ControlEvent; | import com.whirled.ControlEvent; | ||
| Line 21: | Line 21: | ||
} | } | ||
} | } | ||
</actionscript | </actionscript> | ||
'''Breaking the code down:''' | '''Breaking the code down:''' | ||
Place the state's name where "statename" is located. Change "100" to the speed you want the state to have. Use this code for every state you want to have a selected speed. | Place the state's name where "statename" is located. Change "100" to the speed you want the state to have. Use this code for every state you want to have a selected speed. | ||
<actionscript | <actionscript> | ||
case "statename": | case "statename": | ||
_ctrl.setMoveSpeed(100); | _ctrl.setMoveSpeed(100); | ||
break; | break; | ||
</actionscript | </actionscript> | ||
This code will set that Default and any other state not located in the code will end up being the same speed selected in it. | This code will set that Default and any other state not located in the code will end up being the same speed selected in it. | ||
<actionscript | <actionscript> | ||
default: | default: | ||
_ctrl.setMoveSpeed(200); | _ctrl.setMoveSpeed(200); | ||
break; | break; | ||
</actionscript | </actionscript> | ||
Revision as of 09:06, 5 September 2018
Change Speed Code manually: Use this code if you plan to only have one speed for the avatar, be sure to paste it after the "_crt" lines found in your avatars action script, you cal also paste this code into a state if you wish. Change the S in code to change the speed number. The number cannot be smaller then 50. <actionscript> _ctrl.setMoveSpeed(S); </actionscript> Change Speed Code with states The following code with automatically change the speed depending on the current state. The code goes like this: <actionscript> // This code will change the speed with the selected state import com.whirled.ControlEvent;
_ctrl.addEventListener(ControlEvent.STATE_CHANGED, stateChanged);
function stateChanged(event:ControlEvent):void { switch(event.name) { case "statename": _ctrl.setMoveSpeed(150); break;
default: _ctrl.setMoveSpeed(200); break; } } </actionscript> Breaking the code down: Place the state's name where "statename" is located. Change "100" to the speed you want the state to have. Use this code for every state you want to have a selected speed. <actionscript>
case "statename":
_ctrl.setMoveSpeed(100); break;
</actionscript> This code will set that Default and any other state not located in the code will end up being the same speed selected in it. <actionscript>
default:
_ctrl.setMoveSpeed(200); break; </actionscript>