Change speed

From Whirled Club Wiki
Jump to navigation Jump to search

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>