Using an ActionScheduler

Elliot Ford edited this page Jun 28, 2015 · 4 revisions

What is an ActionScheduler?

An ActionScheduler is a way to schedule Actions using an ActionEngine for a specific actor. Within the JALSE system Entity is an ActionScheduler.

JALSE offers a default implementation, DefaultActionScheduler, that takes in an actor and is backed by the default ActionEngine (see Picking an ActionEngine implementation).

ActionScheduler<String> scheduler = new DefaultActionScheduler<>("Ellzord");

Scheduling Actions for an actor

Scheduling Actions using an SchedulableActionContext provides the same execution control that is reflected in ActionScheduler's schedule(...) methods. Every one of these methods will schedule the action with the actor bound.

 // Immediately schedule action
scheduler.scheduleForActor(/* Some action */);

// Schedule action 100 ms in the future
scheduler.scheduleForActor(/* Some action */, 100, TimeUnit.MILLISECONDS);

// Schedule action for periodic execution every 500 ms
scheduler.scheduleForActor(/* Some action */, 0, 500, TimeUnit.MILLISECONDS);

Cancelling all Actions

All currently scheduled or execution Actions by the scheduler can be cancelled:

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.