Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/excaliburjs/Excalibur. 🎮 Your friendly TypeScript 2D game engine for the web 🗡️ excaliburjs.com
excalibur excaliburjs game-development game-engine game-framework gamedev games html5-canvas typescript
Something went wrong. Try again.
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import type { Entity } from '../../entity-component-system/entity';import type { Action } from '../action';import { nextActionId } from '../action';import { ActionContext } from '../action-context';import type { ActionQueue } from '../action-queue';
/** * RepeatForever Action implementation, it is recommended you use the fluent action * context API. * * */export class RepeatForever implements Action { id = nextActionId(); private _actionQueue: ActionQueue; private _stopped: boolean = false; private _repeatContext: ActionContext; private _repeatBuilder: (repeatContext: ActionContext) => any; constructor(entity: Entity, repeatBuilder: (repeatContext: ActionContext) => any) { this._repeatBuilder = repeatBuilder; this._repeatContext = new ActionContext(entity); this._actionQueue = this._repeatContext.getQueue();
this._repeatBuilder(this._repeatContext); }
public update(elapsed: number): void { if (this._stopped) { return; }
if (this._actionQueue.isComplete()) { this._actionQueue.clearActions(); this._repeatBuilder(this._repeatContext); }
this._actionQueue.update(elapsed); }
public isComplete(): boolean { return this._stopped; }
public stop(): void { this._stopped = true; this._actionQueue.clearActions(); }
public reset(): void { return; }}