Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix camera lerp and support easing functions #610

Merged
merged 9 commits into from
Jul 12, 2016
Merged
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
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
"editor.tabSize": 3,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
Expand Down
4 changes: 2 additions & 2 deletions GruntFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module.exports = function (grunt) {
// Execute TypeScript compiler against Excalibur core
//
tsc: {
command: '<%= tscCmd %> --sourcemap --declaration "./src/engine/Engine.ts" --out "./dist/<%= pkg.name %>-<%= version %>.js"',
command: '<%= tscCmd %> --sourcemap --declaration --target ES5 "./src/engine/Engine.ts" --out "./dist/<%= pkg.name %>-<%= version %>.js"',
options: {
stdout: true,
failOnError: true
Expand All @@ -104,7 +104,7 @@ module.exports = function (grunt) {
command: function () {
var files = grunt.file.expand("./src/spec/*.ts");

return '<%= tscCmd %> ' + files.join(' ') + ' --out ./src/spec/TestsSpec.js'
return '<%= tscCmd %> --target ES5 ' + files.join(' ') + ' --out ./src/spec/TestsSpec.js'
},
options: {
stdout: true,
Expand Down
Binary file modified dist/Excalibur.0.6.0.nupkg
Binary file not shown.
67 changes: 43 additions & 24 deletions dist/Excalibur.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1582,22 +1582,12 @@ declare module ex {
*
* ## Known Issues
*
* **Cameras do not support [[EasingFunctions]]**
* [Issue #320](https://github.com/excaliburjs/Excalibur/issues/320)
*
* Currently [[BaseCamera.lerp]] only supports `easeInOutCubic` but will support
* [[EasingFunctions|easing functions]] soon.
*
* **Actors following a path will wobble when camera is moving**
* [Issue #276](https://github.com/excaliburjs/Excalibur/issues/276)
*
*/
class BaseCamera {
protected _follow: Actor;
focus: Vector;
lerp: boolean;
x: number;
y: number;
z: number;
dx: number;
dy: number;
Expand All @@ -1607,24 +1597,43 @@ declare module ex {
az: number;
rotation: number;
rx: number;
private _x;
private _y;
private _cameraMoving;
private _currentLerpTime;
private _lerpDuration;
private _totalLerpTime;
private _lerpStart;
private _lerpEnd;
private _lerpPromise;
protected _isShaking: boolean;
private _shakeMagnitudeX;
private _shakeMagnitudeY;
private _shakeDuration;
private _elapsedShakeTime;
private _xShake;
private _yShake;
protected _isZooming: boolean;
private _currentZoomScale;
private _maxZoomScale;
private _zoomDuration;
private _elapsedZoomTime;
private _zoomIncrement;
private _easeInOutCubic(currentTime, startValue, endValue, duration);
private _easing;
/**
* Get the camera's x position
*/
/**
* Set the camera's x position (cannot be set when following an [[Actor]] or when moving)
*/
x: number;
/**
* Get the camera's y position
*/
/**
* Set the camera's y position (cannot be set when following an [[Actor]] or when moving)
*/
y: number;
/**
* Sets the [[Actor]] to follow with the camera
* @param actor The actor to follow
Expand All @@ -1635,12 +1644,15 @@ declare module ex {
*/
getFocus(): Vector;
/**
* Sets the focal point of the camera. This value can only be set if there is no actor to be followed.
* @param x The x coordinate of the focal point
* @param y The y coordinate of the focal point
* @deprecated
* This moves the camera focal point to the specified position using specified easing function. Cannot move when following an Actor.
*
* @param pos The target position to move to
* @param duration The duration in millseconds the move should last
* @param [easingFn] An optional easing function ([[ex.EasingFunctions.EaseInOutCubic]] by default)
* @returns A [[Promise]] that resolves when movement is finished, including if it's interrupted.
* The [[Promise]] value is the [[Vector]] of the target position. It will be rejected if a move cannot be made.
*/
setFocus(x: number, y: number): void;
move(pos: Vector, duration: number, easingFn?: EasingFunction): IPromise<Vector>;
/**
* Sets the camera to shake at the specified magnitudes for the specified duration
* @param magnitudeX The x magnitude of the shake
Expand All @@ -1660,11 +1672,12 @@ declare module ex {
*/
getZoom(): number;
private _setCurrentZoomScale(zoomScale);
update(engine: Engine, delta: number): void;
/**
* Applies the relevant transformations to the game canvas to "move" or apply effects to the Camera
* @param delta The number of milliseconds since the last update
*/
update(ctx: CanvasRenderingContext2D, delta: number): void;
draw(ctx: CanvasRenderingContext2D, delta: number): void;
debugDraw(ctx: CanvasRenderingContext2D): void;
private _isDoneShaking();
private _isDoneZooming();
Expand Down Expand Up @@ -2682,6 +2695,12 @@ declare module ex {
}
}
declare module ex {
/**
* A definition of an EasingFunction. See [[ex.EasingFunctions]].
*/
interface EasingFunction {
(currentTime: number, startValue: number, endValue: number, duration: number): number;
}
/**
* Standard easing functions for motion in Excalibur, defined on a domain of [0, duration] and a range from [+startValue,+endValue]
* Given a time, the function will return a value from postive startValue to postive endValue.
Expand Down Expand Up @@ -2723,13 +2742,13 @@ declare module ex {
* ```
*/
class EasingFunctions {
static Linear: (currentTime: number, startValue: number, endValue: number, duration: number) => number;
static EaseInQuad: (currentTime: number, startValue: number, endValue: number, duration: number) => void;
static EaseOutQuad: (currentTime: number, startValue: number, endValue: number, duration: number) => number;
static EaseInOutQuad: (currentTime: number, startValue: number, endValue: number, duration: number) => number;
static EaseInCubic: (currentTime: number, startValue: number, endValue: number, duration: number) => number;
static EaseOutCubic: (currentTime: number, startValue: number, endValue: number, duration: number) => number;
static EaseInOutCubic: (currentTime: number, startValue: number, endValue: number, duration: number) => number;
static Linear: EasingFunction;
static EaseInQuad: (currentTime: number, startValue: number, endValue: number, duration: number) => number;
static EaseOutQuad: EasingFunction;
static EaseInOutQuad: EasingFunction;
static EaseInCubic: EasingFunction;
static EaseOutCubic: EasingFunction;
static EaseInOutCubic: EasingFunction;
}
}
declare module ex {
Expand Down
Loading