Excalibur icon indicating copy to clipboard operation
Excalibur copied to clipboard

Add stop/reset functionality to RepeatForever action

Open dmytropaduchak opened this issue 1 year ago • 2 comments

Context

The RepeatForever action in Excalibur.js currently loops indefinitely, providing no built-in mechanism for resetting the action once it is in progress. In scenarios where more control over the flow of repeated actions is required (e.g., restarting the animation after a specific event or condition), developers are left without an efficient way to manage these actions.

  • The current implementation of RepeatForever does not allow for resetting the action, which can be limiting for game developers who need more flexibility in controlling repeated actions.
  • Developers may need to manually recreate or manage actions outside the RepeatForever context, leading to extra complexity and potential bugs.

Proposal

stop method

  • This method will stop all actions in the repeat cycle, preventing further execution of the repeated actions while maintaining the current state of the actor.
  • Once stopped, the action should remain halted until explicitly resumed or reset.
public stop(): void {
  this._stopped = true;
  this._actionQueue.getActions().forEach((i) => i.stop());
}

reset method

  • This method will reset the RepeatForever action, allowing it to restart from its initial state. The actor will return to its default position, and the repeated actions will be reinitialized.
  • After calling reset(), the repeated actions should begin again from the start, as if it was newly created.
public reset(): void {
  this._stopped = false;  
  this._actionQueue.reset();
}

dmytropaduchak avatar Nov 17 '24 02:11 dmytropaduchak

@dmytropaduchak I think this is a great idea! I fully support this feature

eonarheim avatar Nov 17 '24 02:11 eonarheim

This issue hasn't had any recent activity lately and is being marked as stale automatically.

github-actions[bot] avatar Jan 19 '25 00:01 github-actions[bot]