Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add stop/reset functionality to RepeatForever action #3280

@dmytropaduchak

Description

@dmytropaduchak

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();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureLabel applied to new feature requestsstaleThis issue or PR has not had any activity recently

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions