Skip to content

Commit 22f7aac

Browse files
committed
Added frameBased to the TweenManager and made Tween.frameBased reference that setting, allowing you to set it once (phaserjs#2015)
1 parent a9354d4 commit 22f7aac

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
263263
### New Features
264264

265265
* Loader.images is a new method that allows you to pass an array of image keys, and optionally the urls, to the Loader and have them all added to the load queue in one go.
266-
* Tween.frameBased allows you to control if a Tween updates based on the physics step (i.e. frame based) or the system clock (time based). A frame based tween will use the physics elapsed timer when updating. This means it will retain the same consistent frame rate, regardless of the speed of the device. The duration value given should be given in frames. If the Tween uses a time based update (which is the default) then the duration is given in milliseconds. In this situation a 2000ms tween will last exactly 2 seconds, regardless of the device and how many visual updates the tween has actually been through.
266+
* TweenManager.frameBased allows you to control if all newly created Tweens update based on the physics step (i.e. frame based) or the system clock (time based). A frame based tween will use the physics elapsed timer when updating. This means it will retain the same consistent frame rate, regardless of the speed of the device. The duration value given should be given in frames. If the Tween uses a time based update (which is the default) then the duration is given in milliseconds. In this situation a 2000ms tween will last exactly 2 seconds, regardless of the device and how many visual updates the tween has actually been through.
267+
* Tween.frameBased does the same as TweenManager.frameBased but allows you to set the value on a per-tween basis.
267268
* BitmapText.smoothed is a new boolean property that allows you to set texture smoothing on a bitmap font or not. By default smoothing is always on, but you can turn it off which helps for bitmap fonts created from pixel art style character sets.
268269
* Text.addFontStyle and Text.addFontWeight allow you to apply font weights and styles to specific characters in a Text object. For example you can now include bold or italics within single Text objects (thanks @jdnichollsc #1950)
269270
* PIXI.CanvasPool is a new static global created to deal with the issue of resource leaks and continuous DOM node build-up when creating lots of Text or BitmapData objects, or when calling `generateTexture` on any display object. The CanvasPool will do its best to re-use out dated canvas elements rather than filling up the DOM with new ones.

src/tween/Tween.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,13 @@ Phaser.Tween = function (target, game, manager) {
142142
* If the Tween uses a time based update (which is the default) then the duration is given in milliseconds.
143143
* In this situation a 2000ms tween will last exactly 2 seconds, regardless of the device and how many visual updates the tween
144144
* has actually been through. For very short tweens you may wish to experiment with a frame based update instead.
145+
*
146+
* The default value is whatever you've set in TweenManager.frameBased.
147+
*
145148
* @property {boolean} frameBased
146149
* @default
147150
*/
148-
this.frameBased = false;
151+
this.frameBased = manager.frameBased;
149152

150153
/**
151154
* @property {function} _onUpdateCallback - An onUpdate callback.

src/tween/TweenManager.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ Phaser.TweenManager = function (game) {
2424
*/
2525
this.game = game;
2626

27+
/**
28+
* Are all newly created Tweens frame or time based? A frame based tween will use the physics elapsed timer when updating. This means
29+
* it will retain the same consistent frame rate, regardless of the speed of the device. The duration value given should
30+
* be given in frames.
31+
*
32+
* If the Tween uses a time based update (which is the default) then the duration is given in milliseconds.
33+
* In this situation a 2000ms tween will last exactly 2 seconds, regardless of the device and how many visual updates the tween
34+
* has actually been through. For very short tweens you may wish to experiment with a frame based update instead.
35+
* @property {boolean} frameBased
36+
* @default
37+
*/
38+
this.frameBased = false;
39+
2740
/**
2841
* @property {array<Phaser.Tween>} _tweens - All of the currently running tweens.
2942
* @private

typescript/phaser.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference path="pixi.d.ts" />
22
/// <reference path="p2.d.ts" />
33

4-
// Type definitions for Phaser 2.4.3 2015-Jul-31
4+
// Type definitions for Phaser 2.4.3 2015-Aug-20
55
// Project: https://github.com/photonstorm/phaser
66

77
declare class Phaser {
@@ -251,6 +251,7 @@ declare module Phaser {
251251
copyPixels(source: any, area: Phaser.Rectangle, x: number, y: number, alpha?: number): void;
252252
copyRect(source: any, area: Phaser.Rectangle, x?: number, y?: number, alpha?: number, blendMode?: number, roundPx?: boolean): Phaser.BitmapData;
253253
draw(source: any, x?: number, y?: number, width?: number, height?: number, blendMode?: number, roundPx?: boolean): Phaser.BitmapData;
254+
drawFull(parent: any, blendMode?: number, roundPx?: boolean): Phaser.BitmapData;
254255
drawGroup(group: Phaser.Group, blendMode?: number, roundPx?: boolean): Phaser.BitmapData;
255256
extract(destination: Phaser.BitmapData, r: number, g: number, b: number, a?: number, resize?: boolean, r2?: number, g2?: number, b2?: number): Phaser.BitmapData;
256257
fill(r: number, g: number, b: number, a?: number): Phaser.BitmapData;
@@ -5147,6 +5148,7 @@ declare module Phaser {
51475148

51485149
constructor(game: Phaser.Game);
51495150

5151+
frameBased: boolean;
51505152
game: Phaser.Game;
51515153

51525154
add(tween: Phaser.Tween): Phaser.Tween;

0 commit comments

Comments
 (0)