DelegateInstruction
Introduction
The DelegateInstruction provides a quick way to call methods at a future time. The DelegateInstruction is similar in function to the MethodInstruction class; however, it has a simpler interface and can be easier to use for no-argument or one-argument methods. Note that the AddSafe method can be used to call delegate instructions on the primary thread: http://flatredball.com/documentation/api/flatredball/flatredball-instructions/flatredball-instructions-instructionmanager/flatredball-instructions-instructionmanager-addsafe/
Example Code
The DelegateInstruction constructor can take a 0-argument and 1-argument method. In the case of the 1-argument, you must pass an object to be passed as the argument. The following code shows how to call Emit on an Emitter in 2 seconds:
Calling Custom Methods
The DelegateInstruction method can be used to call any method (as long as it has the proper number of arguments). The following code shows how to destroy an object after a 1-second delay when the user presses the space button.
DelegateInstructions and lambda expressions
Lambda expressions can be used with delegate instructions. For example, the following shows how to create a delegate instruction which sets an object's X to 5.
Last updated