Piccolo.NET

PActivity Class

PActivity controls some time dependent aspect of Piccolo, such as animation.

For a list of all members of this type, see PActivity Members.

System.Object
   PActivity

public class PActivity

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

Once created activities must be scheduled with the PActivityScheduler managed by the PRoot to run. They are automatically removed from the scheduler when the animation has finished.

Example

There are several ways to be notfied of changes in an activity's state. You can extend PActivity and override the OnActivityStarted(), OnActivityStep(), and OnActivityFinished() methods. You can instantiate a PActivity and set its ActivityDelegate to a class that implements the PActivityDelegate interface methods (ActivityStarted(), ActivityStepped(), and ActivityFinished()). Or, if you only wish to be notified of some of these changes you can directly set any of the individual delegates (ActivityStarted, ActivityStepped and ActivityFinished). Each of these approaches are illustrated below:

Extend PActivity

public class MyActivity : PActivity {

    ...
    
    protected override void OnActivityStarted() {
        base.OnActivityStarted ();
        // Do something when the activity starts.
    }
                
    protected override void OnActivityStep(long elapsedTime) {
        base.OnActivityStep (elapsedTime);
        // Do something while the activity is running.
    }
                
    protected override void OnActivityFinished() {
        base.OnActivityFinished ();
        // Do something when the activity finishes.
    }
    
    ...
    
}

Set the ActivityDelegate

...
    
PActivty activity = new PActivity();
activity.ActivityDelegate = new MyActivityDelegate();
    
...
    
public class MyActivityDelegate : PActivity.PActivityDelegate {
    public void ActivityStarted(PActivity activity) {
        // Do something when the activity starts.
    }
        
    public void ActivityStepped(PActivity activity) {
        // Do something while the activity is running.
    }
        
    public void ActivityFinished(PActivity activity) {
        // Do something when the activity finishes.
    }
}    

Set an Individual Delegate

...

PActivity activity = new PActivity();
activity.ActivityStepped = new ActivitySteppedDelegate(MySteppedDelegate);

...

protected void MySteppedDelegate(PActivity activity) {
    // Do something while the activity is running.
}

See the PNode.Animate*() methods for more examples of how to setup and run different activities.

Requirements

Namespace: UMD.HCIL.Piccolo.Activities

Assembly: UMD.HCIL.Piccolo (in UMD.HCIL.Piccolo.dll)

See Also

PActivity Members | UMD.HCIL.Piccolo.Activities Namespace


Web Accessibility