Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Breaking Changes

- Behavior change - TileMap now uses 'separate' as the `compositeStrategy` as a better default. Commonly TileMap is used to build levels, so this default aligns with the common use.
- Removed old legacy `ex.EasingFunctions` in favor of the [0, 1] common easing functions
- Removed EaseTo/EaseBy/actor.actions.(easeTo|easeBy) Action in favor of MoveTo/MoveBy/actor.actions.(moveTo|moveBy) Action with easing support
- Removed `body.sleeping` in favor of `isSleeping`
- Removed `entity.active` in favor of `isActive`
- Removed `actor.getGlobalPos()` in favor of `actor.globalPos` getter/setter
- Removed `actor.getGlobalRotation()` in favor of `actor.globalRotation` getter/setter
- Removed `actor.getGlobalScale()` in favor of `actor.globalScale` getter/setter
- Removed `BoundingBox.draw` in favor of `BoundingBox.debug`
- Removed typo in `engine.isFullScreen` now `engine.isFullscreen`
- Removed unused `tag-query.ts`
- Removed `world.queryTags`, `world.query(...)` can query tags
- Removed `Animation.durationPerFrameMs` in favor of `Animation.durationPerFrame`
- Removed `Vector.size` in favor of `Vector.magnitude`

### Deprecated

Expand Down
4 changes: 2 additions & 2 deletions site/docs/02-fundamentals/05-transitions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const transition = new ex.Transition({
/**
* Optionally specify a easing function, by default linear
*/
easing: ex.EasingFunctions.Linear,
easing: ex.linear,
/**
* Optionally specify a transition direction, by default 'out'
*
Expand Down Expand Up @@ -226,4 +226,4 @@ export class CrossFade extends Transition {
this.graphics.opacity = progress;
}
}
```
```
2 changes: 1 addition & 1 deletion site/docs/04-graphics/examples/animation-coords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const runSheet = ex.SpriteSheet.fromImageSource({

const runAnim = ex.Animation.fromSpriteSheetCoordinates({
spriteSheet: runSheet,
durationPerFrameMs: 200,
durationPerFrame: 200,
frameCoordinates: [
{x: 1, y: 0},
{x: 2, y: 0},
Expand Down
85 changes: 0 additions & 85 deletions src/engine/actions/action-context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { EasingFunction } from '../util/easing-functions';
import { EasingFunctions } from '../util/easing-functions';
import { ActionQueue } from './action-queue';
import { Repeat } from './action/repeat';
import { RepeatForever } from './action/repeat-forever';
Expand All @@ -16,8 +14,6 @@ import { isScaleToOptions, ScaleTo, ScaleToWithOptions } from './action/scale-to
import type { ScaleByOptions } from './action/scale-by';
import { isScaleByOptions, ScaleBy, ScaleByWithOptions } from './action/scale-by';
import { CallMethod } from './action/call-method';
import { EaseTo } from './action/ease-to';
import { EaseBy } from './action/ease-by';
import { Blink } from './action/blink';
import { Fade } from './action/fade';
import { Delay } from './action/delay';
Expand Down Expand Up @@ -91,87 +87,6 @@ export class ActionContext {
return this;
}

/**
* This method will move an actor to the specified `x` and `y` position over the
* specified duration using a given {@apilink EasingFunctions} and return back the actor. This
* method is part of the actor 'Action' fluent API allowing action chaining.
* @param pos The x,y vector location to move the actor to
* @param duration The time it should take the actor to move to the new location in milliseconds
* @param easingFcn Use {@apilink EasingFunction} or a custom function to use to calculate position, Default is {@apilink EasingFunctions.Linear}
* @deprecated use new moveTo({pos: Vector, duration: number, easing: EasingFunction})
*/
public easeTo(pos: Vector, duration: number, easingFcn?: EasingFunction): ActionContext;
/**
* This method will move an actor to the specified `x` and `y` position over the
* specified duration using a given {@apilink EasingFunctions} and return back the actor. This
* method is part of the actor 'Action' fluent API allowing action chaining.
* @param x The x location to move the actor to
* @param y The y location to move the actor to
* @param duration The time it should take the actor to move to the new location in milliseconds
* @param easingFcn Use {@apilink EasingFunction} or a custom function to use to calculate position, Default is {@apilink EasingFunctions.Linear}
* @deprecated use new moveTo({pos: Vector, duration: number, easing: EasingFunction})
*/
public easeTo(x: number, y: number, duration: number, easingFcn?: EasingFunction): ActionContext;
public easeTo(...args: any[]): ActionContext {
let x = 0;
let y = 0;
let duration = 0;
let easingFcn = EasingFunctions.Linear;
if (args[0] instanceof Vector) {
x = args[0].x;
y = args[0].y;
duration = args[1];
easingFcn = args[2] ?? easingFcn;
} else {
x = args[0];
y = args[1];
duration = args[2];
easingFcn = args[3] ?? easingFcn;
}

this._queue.add(new EaseTo(this._entity, x, y, duration, easingFcn));
return this;
}

/**
* This method will move an actor by a specified vector offset relative to the current position given
* a duration and a {@apilink EasingFunction}. This method is part of the actor 'Action' fluent API allowing action chaining.
* @param offset Vector offset relative to the current position
* @param duration The duration in milliseconds
* @param easingFcn Use {@apilink EasingFunction} or a custom function to use to calculate position, Default is {@apilink EasingFunctions.Linear}
* @deprecated use new moveBy({offset: Vector, duration: number, easing: EasingFunction})
*/
public easeBy(offset: Vector, duration: number, easingFcn?: EasingFunction): ActionContext;
/**
* This method will move an actor by a specified x and y offset relative to the current position given
* a duration and a {@apilink EasingFunction}. This method is part of the actor 'Action' fluent API allowing action chaining.
* @param offset Vector offset relative to the current position
* @param duration The duration in milliseconds
* @param easingFcn Use {@apilink EasingFunction} or a custom function to use to calculate position, Default is {@apilink EasingFunctions.Linear}
* @deprecated use new moveBy({offset: Vector, duration: number, easing: EasingFunction})
*/
public easeBy(offsetX: number, offsetY: number, duration: number, easingFcn?: EasingFunction): ActionContext;
public easeBy(...args: any[]): ActionContext {
let offsetX = 0;
let offsetY = 0;
let duration = 0;
let easingFcn = EasingFunctions.Linear;
if (args[0] instanceof Vector) {
offsetX = args[0].x;
offsetY = args[0].y;
duration = args[1];
easingFcn = args[2] ?? easingFcn;
} else {
offsetX = args[0];
offsetY = args[1];
duration = args[2];
easingFcn = args[3] ?? easingFcn;
}

this._queue.add(new EaseBy(this._entity, offsetX, offsetY, duration, easingFcn));
return this;
}

/**
* Moves an actor to a specified {@link Vector} in a given duration in milliseconds.
* You may optionally specify an {@link EasingFunction}
Expand Down
87 changes: 0 additions & 87 deletions src/engine/actions/action/ease-by.ts

This file was deleted.

85 changes: 0 additions & 85 deletions src/engine/actions/action/ease-to.ts

This file was deleted.

23 changes: 4 additions & 19 deletions src/engine/actions/action/move-by.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ import type { Entity } from '../../entity-component-system/entity';
import type { Easing } from '../../math';
import { clamp, lerp, linear, remap } from '../../math';
import { Vector, vec } from '../../math/vector';
import type { EasingFunction } from '../../util/easing-functions';
import { EasingFunctions, isLegacyEasing } from '../../util/easing-functions';
import { Logger } from '../../util/log';
import type { Action } from '../action';
import { nextActionId } from '../action';

export interface MoveByOptions {
offset: Vector;
duration: number;
easing?: Easing | EasingFunction;
easing?: Easing;
}

/**
Expand All @@ -34,20 +32,14 @@ export class MoveByWithOptions implements Action {
private _stopped: boolean = false;
private _motion: MotionComponent;
private _offset: Vector;
private _legacyEasing: EasingFunction = EasingFunctions.Linear;
private _easing: Easing = linear;
private _useLegacyEasing = false;
constructor(
public entity: Entity,
options: MoveByOptions
) {
this._offset = options.offset;

this._easing = options.easing ?? this._easing;
if (isLegacyEasing(options.easing)) {
this._legacyEasing = options.easing;
this._useLegacyEasing = true;
}
this._tx = entity.get(TransformComponent);
this._motion = entity.get(MotionComponent);
if (!this._tx) {
Expand All @@ -66,15 +58,8 @@ export class MoveByWithOptions implements Action {
const t = clamp(remap(0, this._durationMs, 0, 1, this._durationMs - this._currentMs), 0, 1);
const currentPos = this._tx.pos;

let newPosX = 0;
let newPosY = 0;
if (this._useLegacyEasing) {
newPosX = this._legacyEasing(t, this._start.x, this._end.x, 1);
newPosY = this._legacyEasing(t, this._start.y, this._end.y, 1);
} else {
newPosX = lerp(this._start.x, this._end.x, this._easing(t));
newPosY = lerp(this._start.y, this._end.y, this._easing(t));
}
const newPosX = lerp(this._start.x, this._end.x, this._easing(t));
const newPosY = lerp(this._start.y, this._end.y, this._easing(t));

const seconds = elapsed / 1000;
const velX = seconds === 0 ? 0 : (newPosX - currentPos.x) / seconds;
Expand All @@ -88,7 +73,7 @@ export class MoveByWithOptions implements Action {
}
}
public isComplete(entity: Entity): boolean {
return this._stopped || this._currentMs < 0;
return this._stopped || this._currentMs <= 0;
}

public stop(): void {
Expand Down
Loading