Change speed: Difference between revisions

From Whirled Club Wiki
Jump to navigation Jump to search
(Created page with "'''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 a...")
 
m (Reverted edits by 47.134.149.30 (talk) to last revision by Whirled vox)
Tag: Rollback
 
(4 intermediate revisions by 2 users not shown)
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> _ctrl.setMoveSpeed(S); </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:
&lt;actionscript&gt;
<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 12: Line 12:
function stateChanged(event:ControlEvent):void {
function stateChanged(event:ControlEvent):void {
switch(event.name) {
switch(event.name) {
case &quot;statename&quot;:
case "statename":
_ctrl.setMoveSpeed(150);
_ctrl.setMoveSpeed(150);
break;
break;
Line 21: Line 21:
}
}
}
}
&lt;/actionscript&gt;
</actionscript>
'''Breaking the code down:'''
'''Breaking the code down:'''
Place the state's name where &quot;statename&quot; is located. Change &quot;100&quot; 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.
&lt;actionscript&gt;
<actionscript>
               case &quot;statename&quot;:
               case "statename":
_ctrl.setMoveSpeed(100);
_ctrl.setMoveSpeed(100);
break;
break;
&lt;/actionscript&gt;
</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.
&lt;actionscript&gt;
<actionscript>
                 default:
                 default:
_ctrl.setMoveSpeed(200);
_ctrl.setMoveSpeed(200);
break;
break;
&lt;/actionscript&gt;
</actionscript>

Latest revision as of 09:29, 9 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>