Commit graph

99 commits

Author SHA1 Message Date
photonstorm
b3e6381a9e Tween.update wouldn't dispatch an onLoop signal for Tweens with just one child, such as those created via Tween.to with -1 as the repeat value (thanks @ForgeableSum #2407) 2016-04-05 01:11:50 +01:00
photonstorm
917d9c7060 TweenData.repeatTotal is a new property that keeps track of the total number of times the Tween should repeat. If TweenData.start is called, as a result of the Tween repeatCount being > 0 then the child tween resets its total before re-starting. 2016-04-05 01:06:05 +01:00
photonstorm
f40cfbe2ae 2015 - 2016. 2016-04-04 22:16:16 +01:00
photonstorm
12f3bd6cc5 The Destroy component will now call TweenManager.removeFrom, removing any active tweens from the TweenManager upon the Game Objects destructions (thanks @PokemonAshLovesMyTurkeyAndILikeYouTwo #2408)
Tween.update will now return `false` (flagging the Tween for destruction) should the Tween.target property every become falsey. This can happen if the object the Tween was tracking is destroyed, nulled or generally removed..
2016-04-04 22:06:16 +01:00
Richard Davey
15411f1e56 Tween.onLoop would be fired when a Tween repeated and Tween.onRepeat would be fired when a Tween looped. These are now reversed to fire correctly (thanks @vladkens #2024) 2016-02-17 02:57:45 +00:00
Richard Davey
e04504f481 Tweens with 'yoyo' set on them couldn't be re-used again because the start and end properties were left in a reversed state. When a yoyo tween ends it now restores the reversed values (thanks @SBCGames #2307) 2016-02-03 12:24:22 +00:00
Javier Alcantara
840b49b6cd Tween hasStarted parameter set to false when tween finishes 2015-11-11 18:39:05 +01:00
photonstorm
90a500ec1e Game.update could call updateLogic multiple times in a single frame when catching up with slow device frame rates. This would cause Tweens to advance at twice the speed they should have done (thanks @mkristo)
Time.desiredFpsMult is a pre-calculated multiplier used in Game.update.

Time.refresh updates the `Time.time` and `Time.elapsedMS` values and is called automatically by Game.update.
2015-09-09 12:09:18 +01:00
Richard Davey
d7a42370a4 BitmapData.move, moveH and moveV have a new optional wrap argument allowing you to control if the contents of the BitmapData are wrapped around the edges (true) or simply scrolled off (false). 2015-09-07 01:16:43 +01:00
Richard Davey
8210d4faa1 Removed tween console.log for now. 2015-09-07 00:26:03 +01:00
photonstorm
37fc327ea7 Tween elapsed debug. 2015-09-02 16:58:51 +01:00
photonstorm
22f7aacfcb Added frameBased to the TweenManager and made Tween.frameBased reference that setting, allowing you to set it once (#2015) 2015-08-20 12:59:06 +01:00
photonstorm
fc83dc6bdf 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. 2015-07-30 15:27:51 +01:00
photonstorm
f15fe6706c All undefined argument checks were changed from if (typeof x === 'undefined') to if (x === undefined) removing the typeof check and saving some bytes across the codebase in the process. 2015-07-22 10:37:15 +01:00
Richard Davey
356864ff8a TweenData.update now uses the Time.elapsedMS value for its delta calculation, instead of the physicsStep - this is because tweens are inherently time duration based and on a lagging system they were not properly completing when they should do (also addresses #1819) 2015-07-22 00:09:06 +01:00
Richard Davey
92f2742a26 When reusing a Tween created with an array of properties the values would get exponentially added to the TweenData internal array each time the tween was re-run (thanks @SBCGames #1747) 2015-07-07 04:21:55 +01:00
photonstorm
bdcb15fcde Tween.to and Tween.from can now accept null as the ease parameter value. If null it will use the default tween, as per the documentation (thanks @nkovacs #1817) 2015-05-26 20:01:57 +01:00
photonstorm
312c31b778 jsdoc and formatting fixes. 2015-05-21 11:53:18 +01:00
Rafael Barbosa Lopes
0a9ca57a8f Cleaning some white space. 2015-05-08 21:42:29 -03:00
Rafael Barbosa Lopes
29b22972ca Proper code formatting. 2015-05-08 21:35:35 -03:00
Rafael Barbosa Lopes
d19411e069 Assign the default value of 60 FPS to the optional frameRate parameter, when ommited.
This patch tries to prevent an issue in the tween timeline data generation
where an `undefined` value causes an unhandled type coercion when the program
calculate how many frames will be generated for a given `TweenData` timeline.
2015-05-08 19:39:13 -03:00
photonstorm
8519c9e394 The Tween.onStart signal wasn't dispatched if the Tween had a delay set. It's now dispatched immediately if no delay, or after the delay if set. It also respects the autoStart parameter and will still dispatch even if autoStart is true. 2015-04-27 16:22:35 +01:00
hardalias
4bd7a40e84 Fixes neverending tween when duration set to zero
* Passing a value of zero as the value of duration causes the
 calculations performed in Tween#update to divide by zero when
 calculating the next step for the tween. This causes the tweened
 property value to be set to NaN having undesireable results and
 also, causes the tween to never end since the ending criteria are
 never met.
2015-04-01 15:01:05 +03:00
photonstorm
a69e53f901 Copyright date change. 2015-02-25 03:36:23 +00:00
photonstorm
02ef1555c5 A TweenData wouldn't take into account the repeatDelay property when repeating the tween, but now does. A TweenData also has a new property yoyoDelay which controls the delay before the yoyo will start, allowing you to set both independently (thanks @DreadKnight #1469)
Tween.updateTweenData allows you to set a property to the given value across one or all of the current tweens. All of the Tween methods like Tween.delay and Tween.repeat have been updated to use this.

Tween.repeat has a new parameter `repeatDelay` which allows you to set the delay (in ms) before a tween will repeat itself.

Tween.yoyo has a new parameter `yoyoDelay` which allows you to set the delay (in ms) before a tween will start a yoyo.

Tween.interpolation has a new parameter `context` which allows you to define the context in which the interpolation function will run.
2015-02-19 00:51:32 +00:00
photonstorm
01a23b7d91 Tween.to now correctly accepts arrays are destination values, which makes the Tween interpolate through each value specified in the array using the defined Tween.interpolation method (see new example, thanks @FridayMarch26th #1619)
Tween.interpolationFunction was using the incorrect context to invoke the function. This is now defined in `TweenData.interpolationFunctionContext` and defaults to `Phaser.Math`. If you provide your own interpolation function then please adjust the context accordingly (thanks @FridayMarch26th #1618)
2015-02-16 12:23:54 +00:00
Jouni Airaksinen
11cf7c4923 Fix floating point inaccuracy in edge cases, behavior not consistent across different browsers and/or devices 2014-12-29 14:38:18 +02:00
photonstorm
5029427e14 Tween.stop fired a different set of onComplete parameters to Tween.update. Both now dispatch onComplete(target, tween) as the parameters in that order (thanks @P0rnflake #1450) 2014-12-15 09:42:18 +00:00
photonstorm
38a224df3e Tween.delay, Tween.repeat and Tween.yoyo will no longer throw an error if called before a TweenData object has been created (via Tween.to or Tween.from) (thanks @SomMeri #1419) 2014-12-07 11:31:48 +00:00
John Watson
fcca6ba730 Fixed TweenManager.isTweening() and .removeFrom()
Updated invalid reference Tween._object to .target
2014-12-03 10:20:29 -08:00
Paul
dab8772de0 Documentation - consistency updates
- Updated `readOnly` doclet to `readonly`

- `array` refined to `type[]`, where such information was immediately
determinable.

- Updated {Any}/{*} to {any}; {...*} is standard exception

- Udated {Object} to {object}
2014-11-30 04:03:35 -08:00
photonstorm
471ad20b4a Added Time.physicsElapsedMS and used in Sprite lifespan and Tweens. 2014-11-26 13:13:25 +00:00
photonstorm
5b757eaee7 jshint fix 2014-11-24 13:15:38 +00:00
photonstorm
06b2a2c6a0 Added Tween.generateData back in, now all the Particles and Tween examples work properly. 2014-11-24 12:34:42 +00:00
photonstorm
88ea3412dc Fixes issue where Tween.from didn't set the target properties until after the delay was up. 2014-11-20 20:42:10 +00:00
photonstorm
c909c29935 Undefined fix #1347 2014-11-20 10:00:08 +00:00
photonstorm
2589000435 Tweens have been completely rewritten. They're now much more flexible and efficient than before:
When specifying the ease in `Tween.to` or `Tween.from` you can now use a string instead of the Function. This makes your code less verbose. For example instead of `Phaser.Easing.Sinusoidal.Out` and you can now just use the string "Sine".The string names match those used by TweenMax and includes: "Linear", "Quad", "Cubic", "Quart", "Quint", "Sine", "Expo", "Circ", "Elastic", "Back", "Bounce", "Power0", "Power1", "Power2", "Power3" and "Power4". You can append ".easeIn", ".easeOut" and "easeInOut" variants. All are supported for each ease types.
Tweens now create a TweenData object. The Tween object itself acts like more of a timeline, managing multiple TweenData objects. You can now call `Tween.to` and each call will create a new child tween that is added to the timeline, which are played through in sequence.
Tweens are now bound to the new Time.desiredFps value and update based on the new Game core loop, rather than being bound to time calculations. This means that tweens are now running with the same update logic as physics and the core loop.
Tween.timeScale allows you to scale the duration of a tween (and any child tweens it may have). A value of 1.0 means it should play at the desiredFps rate. A value of 0.5 will run at half the frame rate, 2 at double and so on. You can even tween the timeScale value for interesting effects!
Tween.reverse allows you to instantly reverse an active tween. If the Tween has children then it will smoothly reverse through all child tweens as well.
Tween.repeatAll allows you to control how many times all child tweens will repeat before firing the Tween.onComplete event. You can set the value to -1 to repeat forever.
Tween.loop now controls the looping of all child tweens.
Tween.onRepeat is a new signal that is dispatched whenever a Tween repeats. If a Tween has many child tweens its dispatched once the sequence has repeated.
Tween.onChildComplete is a new signal that is dispatched whenever any child tweens have completed. If a Tween consists of 4 sections you will get 3 onChildComplete events followed by 1 onComplete event as the final tween finishes.
Chained tweens are now more intelligently handled. Because you can easily create child tweens (by simply calling Tween.to multiple times) chained tweens are now used to kick-off longer sequences. You can pass as many Tween objects to `Tween.chain` as you like as they'll all be played in sequence. As one Tween completes it passes on to the next until the entire chain is finished.
Tween.stop has a new `complete` parameter that if set will still fire the onComplete event and start the next chained tween, if there is one.
Tween.delay, Tween.repeat, Tween.yoyo, Tween.easing and Tween.interpolation all have a new `index` parameter. This allows you to target specific child tweens, or if set to -1 it will update all children at once.
Tween.totalDuration reports the total duration of all child tweens in ms.
There are new easing aliases:
* Phaser.Easing.Power0 = Phaser.Easing.Linear.None
* Phaser.Easing.Power1 = Phaser.Easing.Quadratic.Out
* Phaser.Easing.Power2 = Phaser.Easing.Cubic.Out
* Phaser.Easing.Power3 = Phaser.Easing.Quartic.Out
* Phaser.Easing.Power4 = Phaser.Easing.Quintic.Out
2014-11-20 06:06:26 +00:00
photonstorm
a952cd398d Final new tween system is in place (just generateData left to do). 2014-11-20 05:26:50 +00:00
photonstorm
a34824c5a3 Planning new vStart cache. 2014-11-20 05:26:50 +00:00
photonstorm
64cf3a6f5b repeatAll and loop support added back in. 2014-11-20 05:26:49 +00:00
photonstorm
4220382376 Evolving the Tween engine. TweenMax string syntax now supported. 2014-11-20 05:26:49 +00:00
photonstorm
ab114cc4a1 The start of TweenData. 2014-11-20 05:26:49 +00:00
photonstorm
49b1896189 Added Tween.percent variable and tidied up the time values. 2014-11-18 09:22:24 +00:00
Richard Davey
730f53c99e Merge pull request #1279 from lewster32/patch-1
Added TweenManager#removeFrom method
2014-11-16 18:58:43 +00:00
Lewis Lane
671d0072da Ensured removeFrom also removes from the _add array 2014-11-14 16:41:14 +00:00
photonstorm
a0cc4c3777 A large refactor to how the internal game timers and physics calculations has been made. We've now swapped to using a fixed time step internally across Phaser, instead of the variable one we had before that caused glitchse on low-fps systems. Thanks to pjbaron for his help with all of these related changes.
We have separated the logic and render updates to permit slow motion and time slicing effects. We've fixed time calling to fix physics problems caused by variable time updates (i.e. collisions sometimes missing, objects tunneling, etc)

Once per frame calling for rendering and tweening to keep things as smooth as possible

Calculates a `suggestedFps` value (in multiples of 5 fps) based on a 2 second average of actual elapsed time values in the `Time.update` method.  This is recalculated every 2 seconds so it could be used on a level-by-level basis if a game varies dramatically. I.e. if the fps rate consistently drops, you can adjust your game effects accordingly.

Game loop now tries to "catch up" frames if it is falling behind by iterating the logic update. This will help if the logic is occasionally causing things to run too slow, or if the renderer occasionally pushes the combined frame time over the FPS time. It's not a band-aid for a game that floods a low powered device however, so you still need to code accordingly. But it should help capture issues such as gc spikes or temporarily overloaded CPUs.

It now detects 'spiralling' which happens if a lot of frames are pushed out in succession meaning the CPU can never "catch up". It skips frames instead of trying to catch them up in this case. Note: the time value passed to the logic update functions is always constant regardless of these shenanigans.

Signals to the game program if there is a problem which might be fixed by lowering the desiredFps

Time.desiredFps is the new desired frame rate for your game.

Time.suggestedFps is the suggested frame rate for the game based on system load.

Time.slowMotion allows you to push the game into a slow motion mode. The default value is 1.0. 2.0 would be half speed, and so on.

Time.timeCap is no longer used and now deprecated. All timing is now handled by the fixed time-step code we've introduced.
2014-11-08 18:54:54 +00:00
Lewis Lane
1b1f78a331 Fixed some formatting/typos 2014-10-31 11:55:32 +00:00
Lewis Lane
bfb39a2864 Added removeFrom method
Allows the removal of all Tweens from a specific object, array of objects or group of objects.
2014-10-31 11:52:05 +00:00
photonstorm
1df98d82e3 You can now call Tween.to again on a Tween that has already completed. This will re-use the same tween, on the original object, without having to recreate the Tween again. This allows a single tween instance to be re-used multiple times, providing they are linked to the same object (thanks InsaneHero) 2014-10-28 01:49:20 +00:00
photonstorm
e5eea56c9b jsdoc updates. 2014-09-16 19:44:04 +01:00