m (ugly)
Line 1: Line 1:
There are many methods to make a script perform an action for a set amount of time - this tutorial will cover the simplest of them.
+
There are many methods to make a script perform an action for a set amount of time. This tutorial will cover the simplest of them.
  
This script uses the [[timer (value)|timer]] - it will repeat the action until the timer is greater than the set limit.
+
This script uses the [[timer (value)|timer]]. It will repeat the action until the timer is greater than the set limit.
  
These timer-based repeater scripts can be used in many different ways - the one pictured is for a [[sprite]] that will continuously move to the right for the set amount of time.
+
These timer-based repeater scripts can be used in many different ways. The one pictured is for a [[sprite]] that will continuously move to the right for the set amount of time.
  
 
[[File:A timer-based repeater script.png]]
 
[[File:A timer-based repeater script.png]]
  
*''x location'' is the x of where the sprite goes to before it starts
+
*''x location'' is the x of where the sprite goes to before it starts.
*''y location'' is the y of where the sprite goes to before it starts
+
*''y location'' is the y of where the sprite goes to before it starts.
*''limit'' is how long the action should be repeated for - eg. if the limit were ''10'', the sprite would drift to the right for 10 seconds.
+
*''limit'' is how long the action should be repeated for (e.g. if the limit were ''10'', the sprite would drift to the right for 10 seconds).
  
 
If the timer is already being used and cannot be reset without ruining the [[project]], a variable can be used instead of the timer:
 
If the timer is already being used and cannot be reset without ruining the [[project]], a variable can be used instead of the timer:

Revision as of 18:12, 21 June 2011

There are many methods to make a script perform an action for a set amount of time. This tutorial will cover the simplest of them.

This script uses the timer. It will repeat the action until the timer is greater than the set limit.

These timer-based repeater scripts can be used in many different ways. The one pictured is for a sprite that will continuously move to the right for the set amount of time.

File:A timer-based repeater script.png

  • x location is the x of where the sprite goes to before it starts.
  • y location is the y of where the sprite goes to before it starts.
  • limit is how long the action should be repeated for (e.g. if the limit were 10, the sprite would drift to the right for 10 seconds).

If the timer is already being used and cannot be reset without ruining the project, a variable can be used instead of the timer:

File:Time repeat until.png