Skip to content

Commit

Permalink
clarify callback is optional for flicker()
Browse files Browse the repository at this point in the history
  • Loading branch information
obiot committed Aug 28, 2024
1 parent c5d50d6 commit 4b1da51
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/melonjs/src/renderable/sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export default class Sprite extends Renderable {
/**
* make the object flicker
* @param {number} duration - expressed in milliseconds
* @param {Function} callback - Function to call when flickering ends
* @param {Function} [callback] - Function to call when flickering ends
* @returns {Sprite} Reference to this object for method chaining
* @example
* // make the object flicker for 1 second
Expand All @@ -324,11 +324,11 @@ export default class Sprite extends Renderable {
* world.removeChild(this);
* });
*/
flicker(duration, callback) {
flicker(duration, callback = undefined) {
this._flicker.duration = duration;
if (this._flicker.duration <= 0) {
this._flicker.isFlickering = false;
this._flicker.callback = null;
this._flicker.callback = undefined;
} else if (!this._flicker.isFlickering) {
this._flicker.callback = callback;
this._flicker.isFlickering = true;
Expand Down

0 comments on commit 4b1da51

Please sign in to comment.