duckengine
Version:
A 2D Game Engine for the web.
44 lines (43 loc) • 1.41 kB
TypeScript
import Game from '../core/game';
/**
* @class Amount
* @classdesc Creates a DuckEngine Amount
* @description The Amount Class. A tool that can run a function a max amount of times even if it is in a loop
* @since 1.1.0
*/
export default class Amount {
protected func: (currentCount: number) => void;
reachedMaxAmount: boolean;
game: Game;
currentCount: number;
readonly maxAmount: number;
/**
* @constructor
* @description Creates an Amount instance.
* @param {(currentCount: number) => void} func Callback function
* @param {number} maxAmount Max amount of times the function can be called
* @param {Game} game Game instance
* @param {boolean} [run] Determines if function is run as soon as Amount class is constructed
* @since 1.1.0
*/
constructor(func: (currentCount: number) => void, maxAmount: number, game: Game, run?: boolean);
/**
* @memberof Amount
* @description Runs the function once if amount of times ran is not over the maxAmount
* @since 1.1.0
*/
run(): void;
/**
* @memberof Amount
* @description Resets the amount of times ran
* @since 1.1.0
*/
reset(): void;
/**
* @memberof Amount
* @description Sets the amount of times ran
* @param {number} currentCount Number of times ran
* @since 1.1.0
*/
set state(currentCount: number);
}