diff --git a/CHANGELOG.md b/CHANGELOG.md index bbba2a915..82ea8e52f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added +- Added new `actor.actions.flash(...)` `Action` to flash a color for a period of time - Added a new `ex.NineSlice` `Graphic` for creating arbitrarily resizable rectangular regions, useful for creating UI, backgrounds, and other resizable elements. ```typescript var nineSlice = new ex.NineSlice({ diff --git a/src/engine/Actions/ActionContext.ts b/src/engine/Actions/ActionContext.ts index c1bc79250..0644cde1f 100644 --- a/src/engine/Actions/ActionContext.ts +++ b/src/engine/Actions/ActionContext.ts @@ -22,6 +22,8 @@ import { Meet } from './Action/Meet'; import { Vector } from '../Math/vector'; import { Entity } from '../EntityComponentSystem/Entity'; import { Action } from './Action'; +import { Color } from '../Color'; +import { Flash } from './Action/Flash'; /** * The fluent Action API allows you to perform "actions" on @@ -327,10 +329,20 @@ export class ActionContext { * to the provided value by a specified time (in milliseconds). This method is * part of the actor 'Action' fluent API allowing action chaining. * @param opacity The ending opacity - * @param time The time it should take to fade the actor (in milliseconds) + * @param duration The time it should take to fade the actor (in milliseconds) */ - public fade(opacity: number, time: number): ActionContext { - this._queue.add(new Fade(this._entity, opacity, time)); + public fade(opacity: number, duration: number): ActionContext { + this._queue.add(new Fade(this._entity, opacity, duration)); + return this; + } + + /** + * This will cause an actor to flash a specific color for a period of time + * @param color + * @param duration The duration in milliseconds + */ + public flash(color: Color, duration: number = 1000) { + this._queue.add(new Flash(this._entity, color, duration)); return this; } @@ -338,10 +350,10 @@ export class ActionContext { * This method will delay the next action from executing for a certain * amount of time (in milliseconds). This method is part of the actor * 'Action' fluent API allowing action chaining. - * @param time The amount of time to delay the next action in the queue from executing in milliseconds + * @param duration The amount of time to delay the next action in the queue from executing in milliseconds */ - public delay(time: number): ActionContext { - this._queue.add(new Delay(time)); + public delay(duration: number): ActionContext { + this._queue.add(new Delay(duration)); return this; } diff --git a/src/engine/Actions/ActionsComponent.ts b/src/engine/Actions/ActionsComponent.ts index fa98cdfab..44a6c2591 100644 --- a/src/engine/Actions/ActionsComponent.ts +++ b/src/engine/Actions/ActionsComponent.ts @@ -9,6 +9,7 @@ import { EasingFunction } from '../Util/EasingFunctions'; import { ActionQueue } from './ActionQueue'; import { RotationType } from './RotationType'; import { Action } from './Action'; +import { Color } from '../Color'; export interface ActionContextMethods extends Pick {} @@ -225,20 +226,29 @@ export class ActionsComponent extends Component implements ActionContextMethods * to the provided value by a specified time (in milliseconds). This method is * part of the actor 'Action' fluent API allowing action chaining. * @param opacity The ending opacity - * @param time The time it should take to fade the actor (in milliseconds) + * @param duration The time it should take to fade the actor (in milliseconds) */ - public fade(opacity: number, time: number): ActionContext { - return this._getCtx().fade(opacity, time); + public fade(opacity: number, duration: number): ActionContext { + return this._getCtx().fade(opacity, duration); + } + + /** + * This will cause an actor to flash a specific color for a period of time + * @param color + * @param duration The duration in milliseconds + */ + public flash(color: Color, duration: number = 1000) { + return this._getCtx().flash(color, duration); } /** * This method will delay the next action from executing for a certain * amount of time (in milliseconds). This method is part of the actor * 'Action' fluent API allowing action chaining. - * @param time The amount of time to delay the next action in the queue from executing in milliseconds + * @param duration The amount of time to delay the next action in the queue from executing in milliseconds */ - public delay(time: number): ActionContext { - return this._getCtx().delay(time); + public delay(duration: number): ActionContext { + return this._getCtx().delay(duration); } /**