Commit graph

114 commits

Author SHA1 Message Date
Richard Davey
4548d70369 Experimenting with new MainLoop + position interpolation. (reverted from commit e49d45e278) 2016-07-13 02:44:35 +01:00
Richard Davey
e49d45e278 Experimenting with new MainLoop + position interpolation. 2016-07-12 03:05:29 +01:00
Sean Irby
3c2003365d Update docstring for TimerEvent
I think the TimerEvent lifecycle could use some clarification so I updated the docstring to explain what happens when they are finished firing.
2016-06-02 17:47:31 -07:00
photonstorm
7afe087c3d Docs fix. 2016-04-29 17:46:44 +01:00
photonstorm
f40cfbe2ae 2015 - 2016. 2016-04-04 22:16:16 +01:00
thiagojobson
58817869dc Fixed links in documentation 2016-03-25 18:08:29 -03:00
photonstorm
79d6993f26 Fixed issue with Time.update not being properly set in IE9 / setTimeout environments. 2015-10-13 14:23:36 +01:00
Richard Davey
5f704f0b0f Merge pull request #2130 from noidexe/patch-5
Better default value for suggestedFps
2015-10-13 13:47:15 +03:00
Lisandro Lorea
dea95ec6f6 Better default value for suggestedFps
In any game that handles fps issues as seen in http://phaser.io/examples/v2/time/slow-down-time the game will hang if game.fpsProblemNotifier fires early on, before game.time.suggestedFps has any value other than null. 

The docs recommend waiting a few seconds before accesing suggestedFps. Since it's hard to tell exactly how long "a few seconds" is, shouldn't suggestedFps be initialized to the same value as desidedFps? 

I think it's better to get an inaccurate value for a few frames than an invalid value. It means users don't have to care about the specifics of how and when suggestedFps gets its value.
2015-10-09 16:14:52 -03:00
Paul
9733fb4ec2 Updated documentation to clarify 'types' of time
- Added 'Types of time' description and cross-links
- Also some general documentation update for Timer
  - Type specialization

Ref #2088
2015-09-14 20:21:47 -07:00
photonstorm
a8e972b25a Under setTimeOut (or when forceSetTimeOut was true) the Time was incorrectly setting Time.timeExpected causing game updates to lag (thanks @satan6 #2087) 2015-09-14 16:31:16 +01:00
photonstorm
816bcaca75 Missing physicsElapsed value reset. 2015-09-10 16:05:15 +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
photonstorm
2de83328d9 Testing Tween timer fix. 2015-09-08 17:44:28 +01:00
photonstorm
dbcff585e0 Time.desiredFps has moved to a getter / setter.
Time.physicsElapsed and Time.physicsElapsedMS are no longer calculated every frame, but only when the desiredFps is changed.
Time.update has been streamlined and the `updateSetTimeout` and `updateRAF` methods merged and duplicate code removed.
2015-09-08 15:56:19 +01:00
Paul
26a6338072 Change splice.call(arguments, ..) to use slice
- Bypasses issue of usage incorrectly omitting 2nd argument to `splice`

- More clear of intent; `slice` does not modifify `arguments`

- `slice` is faster across all desktop browsers, by varying degrees
  - Probably due to parameter-aliasing and de-opts when modified.
  - Both `slice` and `splice` create a new Array object
2015-08-26 23:50:16 -07: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
b906463189 Internally the Time class has been updated to split out the RAF and SetTimeout implementations. This cuts down the update loop workload significantly, which was causing a performance optimization bottleneck in V8. 2015-07-21 21:41:26 +01:00
photonstorm
ce405acb02 jsdoc update #1864 2015-07-02 13:31:26 +01:00
breakosaur
bb600b4319 Fixed a few documentation typos. 2015-03-18 21:07:36 +00:00
photonstorm
a69e53f901 Copyright date change. 2015-02-25 03:36:23 +00:00
photonstorm
6b8622a336 Timer.update was calling the TimerEvent callback even if TimerEvent.pendingDelete was already set to true, causing timer events to stack-up in cases where a new TimerEvent was generated in the callback (thanks @clowerweb #838) 2015-02-11 14:43:23 +00:00
photonstorm
d6ea8fb956 jsdoc updates (spelling mistakes, code formatting, etc) 2015-01-28 17:18:33 +00:00
photonstorm
a6c6bf8e06 Time.reset would incorrectly reset the _started property, now maps it to Time.time (thanks @XekeDeath #1467) 2014-12-18 08:07:38 +00: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
Paul
fb5a1b9946 TimerEvent - tabs to spaces
Converted tabs to spaces, for consistency
2014-11-27 23:57:42 -08:00
Paul
c5381f96ef Time/Time - documentation updates and minor cleanup
- Removed `Time.pausedTime`

  Time.pausedTime has not been used / updated since
  b255fea85f in Feb 2014.

  There might be a case to re-explore how pause time is
  reported/observable, possibly with a distinction of 'current' and 'last'
  and the semantics of such. For instance, pause duration is only updated
  after the resume occurs and reflects the duration-of-the-last-pause..

- Removed `Time` _i and _len properties These are better suited by local
  variables.

- General documentation updates.

- Marked several methods such as `Timer.order` as protected - there are
  advanced use-cases for them, but different user-facing methods and
  documentations are likely in order. Also marked `Timer.sortHandler` as
  private; but did not change any interfaces.
2014-11-27 23:54:42 -08:00
photonstorm
471ad20b4a Added Time.physicsElapsedMS and used in Sprite lifespan and Tweens. 2014-11-26 13:13:25 +00:00
Paul
e28197e6fa Time - documentation
- Removed previous elapsed/elapsedMS deprecation as they act differently
  when the game has been resumed, assuming that it has been properly
  paused.

- Refined documentation

- Moved a few properties for better logical grouping

- Annotated timeToCall and timeExpected as protected
2014-11-25 01:46:30 -08:00
Paul
fb6e602d60 Time - documentation
- Updating documentation for clarity, esp. wrt the now / elapsed /
  physicsTime.

- Marked elapsedMS as deprecated as it is just elapsed based on Date.now
  instead of the high-res timer; both provide roughly equivalent behavior,
  with elapsedMS just falling back to worse-case behavior.
2014-11-25 00:33:06 -08:00
photonstorm
aa62eb94fc Added Time.elapsedMS (as Time.elapsed isn't always an ms value) 2014-11-24 12:54:27 +00:00
photonstorm
8a45ad2ebd jsdoc fixes 2014-11-18 09:22:24 +00:00
Richard Davey
7366854f9b Merge pull request #1307 from pnstickne/wip-math-util-cleanup
Math/Utils - various cleanup and deprecations/moves
2014-11-12 22:21:34 +00:00
Pete Baron
4d0fcd2165 Paste over to fix unwanted HEAD entries 2014-11-12 13:26:12 +13:00
Pete Baron
1c7059ea6c Merge remote-tracking branch 'phaser-github/dev' into dev
Conflicts:
	src/animation/FrameData.js
	src/core/Game.js
	src/particles/arcade/Emitter.js
	src/time/Time.js
	src/tween/Tween.js
2014-11-12 13:03:52 +13:00
Paul
a6d2da2a8a Math/Utils - various cleanup and deprecations/moves
There are no known breaking changes.

- Timer
  - Uses standard Math.min/Math.max (it's better 2, 3 items).

- Math
  - Updated documentation
  - Marked various Math functions as deprecated, proxying as appropriate
    - Array-based functions -> ArrayUtils
    - RNG-based functions -> Utils
    - Updated core-usage
    - floor/ceil should not be used (alternatives provided)
  - Altered for some equivalencies
  - Also fixes some assorted issues
  - Marked a few internal functions as private

- Utils
  - Moved polyfills to their own file for better visibility
  - Moved array functions to ArrayUtils and marked proxies as deprecated

- Created Phaser.ArrayUtils for array-related functions

- polyfills moved to their own file
  - Functions given function names
  - Added Math.trunc
2014-11-09 16:17:18 -08:00
photonstorm
afd6c968e9 Fixed internal timing values. 2014-11-08 20:27:36 +00:00
photonstorm
0a86a7ef51 Time.now can no longer be relied upon to contain a timestamp value. If the browser supports requestAnimationFrame then Time.now will contain the high resolution timer value that rAf generates. Otherwise it will contain the value of Date.now. If you require the actual time value (in milliseconds) then please use Time.time instead. Note that all Phaser sub-systems that used to rely on Time.now have been updated, so if you have any code that extends these please be sure to check it. 2014-11-08 20:01:10 +00:00
photonstorm
719ebcd5a8 Small fix for elapsed values. 2014-11-08 19:46:40 +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
Pete Baron
7d6126799e Bug fix: this.time needs the Date.now() value, not the function! 2014-11-03 17:00:10 +13:00
Pete Baron
64682857ac Calculate suggestedFps.
Deprecated timeCap.
2014-11-03 16:25:43 +13:00
Pete Baron
c38f4802ea Fixed pause/resume time incompatibilities (RAF time and Date.now() can't be mixed) which has fixed the problem with tweens disappearing when paused. 2014-11-03 13:59:40 +13:00
Pete Baron
0da8c6cb1a Established fixed steps for logic update with catch-up for dropped frames.
Render update runs every frame.
Tweens moved into render update to maintain smooth motion.
Added Time.slowMotion factor, integrated with logic/render updates and tweens.
2014-11-03 12:02:43 +13:00
Pete Baron
7bf529b817 RAF timer being used when RAF controlling loops.
Time.time used for Date.now but Time.now may hold RAF hi-res value.
Start of separation of game/render update.
Minor adjustments to Time.update for clarity.
2014-10-31 16:59:55 +13:00
photonstorm
c0b752e0a6 Put the Timer.timeCap back to 1000 as this will be a major breaking change to existing code otherwise. It may be incorrect, but it can't happen in this point release. 2014-10-15 21:37:17 +01:00
photonstorm
3997a7c372 Time.prevTime is a new property that contains the raw value of the game timer from the previous update.
Timer.timeCap has been changed from `1000` to `1 / 60 * 1000` to bring it in line with Time.timeCap.
2014-10-13 16:18:42 +01:00
photonstorm
ccc4e42e03 A Timer with a delay value that was a float and not an integer would not loop correctly. Timer delay values are now passed through Math.round to avoid this (thanks @osmanzeki #1196) 2014-09-29 22:15:41 +01:00
photonstorm
e5eea56c9b jsdoc updates. 2014-09-16 19:44:04 +01:00
photonstorm
0284d0b98c If Time.elapsed was > Time.timeCap it would reset the elapsed value to be 1 / 60. It's now set to Time.timeCap and Time.timeCap defaults to 1 / 60 * 1000 as it's a ms value (thanks @casensiom #899) 2014-08-29 16:37:57 +01:00