Commit graph

2686 commits

Author SHA1 Message Date
photonstorm
da031d8bbb Phaser games should now work again from the CocoonJS Launcher. 2014-11-11 14:31:20 +00:00
photonstorm
7c9dfefc8f Loader resize handler. 2014-11-11 14:00:07 +00:00
photonstorm
e63988fe6e Additional RESIZE handler. 2014-11-11 13:59:56 +00:00
photonstorm
b6001c8f21 Latest Pixi v2 fixes. 2014-11-11 13:59:43 +00:00
photonstorm
642d5355d6 Added missing DOM.js 2014-11-11 06:01:34 +00:00
photonstorm
042ceeb59d Docs update. 2014-11-11 05:56:38 +00:00
photonstorm
bc5a3287a6 Added DOM.js 2014-11-11 05:56:32 +00:00
photonstorm
bf70df2658 Game.forceSingleUpdate will force just a single logic update, regardless of the delta timer values. You can use this in extremely heavy CPU situations where you know you're about to flood the CPU but don't want Phaser to get stuck in a spiral. 2014-11-11 05:51:56 +00:00
Richard Davey
0504fa7969 Merge pull request #1309 from pnstickne/wip-scalemanager-bp2
DOM Functions - their own space
2014-11-11 01:31:39 +00:00
photonstorm
dbd2957884 Phaser 2.2.0 RC2 build. 2014-11-11 01:10:47 +00:00
photonstorm
a2aa987920 jshint fixes 2014-11-11 01:09:57 +00:00
photonstorm
d37fdd4217 Latest Pixi dev release. 2014-11-11 01:07:52 +00:00
photonstorm
9606384598 Added RC version. 2014-11-11 01:05:59 +00:00
photonstorm
a2b7d339a2 Tilemap.createFromTiles will convert all tiles matching the given tile index (or an array of indexes) into Sprites. You can optionally then replace these tiles if you wish. This is perfect for games when you want to turn specific tiles into Sprites for extra control. The Sprites have an optional properties object which they can be populated with. 2014-11-11 01:05:59 +00:00
photonstorm
347978679d docs update 2014-11-11 01:05:59 +00:00
photonstorm
8bf93fb658 ArcadePhysics.skipQuadTree is now set to true by default. A QuadTree is a wonderful thing if the objects in your game are well spaced out. But in tightly packed games, especially those with tilemaps or single-screen games, they are a considerable performance drain and eat up CPU. We've taken the decision to disable the Arcade Physics QuadTree by default. It's all still in there and can be re-enabled via game.physics.arcade.skipQuadTree = false, but please only do so if you're sure your game benefits from this. 2014-11-11 01:05:58 +00:00
Richard Davey
1de09ed20f Merge pull request #1311 from clark-stevenson/dev
Pixi updates now includes Spine. Phaser updates.
2014-11-10 22:18:06 +00:00
Clark Stevenson
1ba17ae086 Pixi updates now includes Spine. Phaser updates. 2014-11-10 21:15:52 +00:00
Paul
50729b33a2 DOM Functions
No known breaking changes - as it's still dev/internal stuff.

- Added Phaser.DOM to house new DOM functions, moved stuff
  over from ScaleManager as appropriate

- Fixed a fiew cases of missing functions

- Changed some of the new signatures to protected for the interim.
  (Maybe a `beta` tag would fit better? Public is promises!)

- Moved generic support from Canvas to DOM and added proxy/notes
  - Updated internal usages

- Updated some comments for consistency
  - Access always on bottom for members/properties, public assumed
2014-11-10 00:45:13 -08:00
photonstorm
69ec5efc29 Phaser 2.2.0-Release Candidate build. 2014-11-10 01:41:41 +00:00
photonstorm
547e7a4d1d docs update 2014-11-09 23:15:30 +00:00
Richard Davey
88df59a17d Merge pull request #1302 from pnstickne/wip-scalemanager
ScaleManager: more cleanup, pre-merged
2014-11-09 23:06:22 +00:00
Richard Davey
8e328df93f Merge pull request #1305 from Matoking/dev
Make cache getters return null on missing entry
2014-11-09 22:54:31 +00:00
Janne Pulkkinen
3208e44d64 Make cache getters return null on missing entry
Some cache getters returned nothing on a missing entry (which is evaluated to undefined). 

This fixes the issue by making the getters return null, as is the case with other functions in Phaser.Cache.
2014-11-09 22:06:02 +02:00
Paul
24c4cf2be3 Merge remote-tracking branch 'upstream/dev' into wip-scalemanager
Conflicts:
	src/core/ScaleManager.js
2014-11-08 19:29:47 -08:00
Paul
f5b9d4067e ScaleManager: additional cleanup
- Added `compatibility` settings
  - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it
  - Added additional properties for greater control and up-front settings.
    - `scrollTo`: where the browser will scrollTo, if anywhere
    - `forceMinimumDocumentHeight`: apply document element style?
    - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already
      could, this allows configuration.)

- Removed `windowConstraints.top/left`. This may be a feature in the
  future, but scrubbed for now.

- Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off
  of a user-specified scale factor, as set by `setUserScale`. This is
  marked as "experimental" as the exactly semantics of non-adjusting modes
  (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps
  need to be re-examined.

- FIX: `onSizeChange` now works as documented, which means it is also
  fired if the game size changes even though the game canvas size does
  not.

- CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle
  that uses top/left/bottom/right properties (any quasi-updated x/y). This
  is to get around the issue that Rectangle is only designed for positive
  width/height cases.

- Cleaned up property access / quotes for consistency

- Various documentation cleanup and consistency

- Fixed issue with not clearing an unparented `_createdFullScreenTarget`

- Added Phaser.Rectangle.sameDimensions which does a strict equality check
  over the `width` and `height` properties of two objects, perhaps
  Rectangles.
2014-11-08 18:17:30 -08:00
photonstorm
0fc70db14c this._gameSize wasn't being populated other than via setSize, which broke games using dimensions set in the constructor that used FlexGrid for scaling. 2014-11-09 01:43:28 +00: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
a74a181074 New build files for RC testing. 2014-11-08 19:26:34 +00:00
photonstorm
c47d9ea238 Integrated latest development build of Pixi (lots of v2 specific bugs fixed) 2014-11-08 19:26:16 +00:00
photonstorm
71507c5487 Moving to 2.2.0 release version. 2014-11-08 19:25:47 +00:00
photonstorm
88eae3aed0 Build files for testing. 2014-11-08 19:11:28 +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
photonstorm
55953078d0 FrameData.clone fixed when cloning data using frame names rather than indexes (thanks pjbaron) 2014-11-08 17:08:29 +00:00
photonstorm
6d8fb60f77 Removed TilemapLayer.index getter as it incorrectly refereneced a property that didn't exist, breaking most demos. Couldn't see an obvious reason for the getter so restored previous property and tested all examples, and all run now (and faster too thanks to the rest of the changes made in TilemapLayer). 2014-11-08 14:50:00 +00:00
Richard Davey
b250e6153d Merge pull request #1250 from pnstickne/wip-tilelayer
TilemapLayer / Tileset performance and documentation
2014-11-08 14:13:45 +00:00
photonstorm
0f3849491d P2.BodyDebug circles were drawing at half widths (thanks @enriqueto #1288) 2014-11-08 14:09:26 +00:00
photonstorm
a7710c504e jshint fixes. 2014-11-08 14:04:17 +00:00
photonstorm
19d8773ca6 readme updates. 2014-11-08 13:42:23 +00:00
Richard Davey
f06f78412b Merge pull request #1300 from pnstickne/wip-1294b
Cache: addBitmapData can auto-create FrameData, fixes 1294
2014-11-08 13:40:28 +00:00
photonstorm
17de8fdcae ScaleManager updates and fixes
Conflicts:
	src/core/ScaleManager.js
2014-11-08 13:38:19 +00:00
photonstorm
d6297884e6 Added Sprite.setScaleMinMax for testing. 2014-11-08 13:31:35 +00:00
photonstorm
e5810f1316 Added DisplayObject.transformCallback 2014-11-08 13:31:35 +00:00
photonstorm
f9d899ba1b Tidying up FlexGrid. 2014-11-08 13:31:35 +00:00
photonstorm
2777c2a463 ScaleManager.elementBounds is a cross-browser element.getBoundingClientRect method with optional cushion.
ScaleManager.calibrate is a private method that calibrates element coordinates for viewport checks.
ScaleManager.aspect gets the viewport aspect ratio (or the aspect ratio of an object or element)
ScaleManager.inViewport tests if the given DOM element is within the viewport, with an optional cushion parameter that allows you to specify a distance.
ScaleManager.scaleSprite takes a Sprite or Image object and scales it to fit the given dimensions. Scaling happens proportionally without distortion to the sprites texture. The letterBox parameter controls if scaling will produce a letter-box effect or zoom the sprite until it fills the given values.
ScaleManager.viewportWidth returns the viewport width in pixels.
ScaleManager.viewportHeight returns the viewport height in pixels.
ScaleManager.documentWidth returns the document width in pixels.
ScaleManager.documentHeight returns the document height in pixels.
2014-11-08 13:31:35 +00:00
Paul
910627df8a ScaleManager: (passing jshint) 2014-11-08 05:29:12 -08:00
Paul
e075a735e3 ScaleManager: back-port of "window constraints".
- Adds `ScaleManager#windowContraints`
  - In 2.1.3 and prior the scale modes (EXACT_FIT, SHOW_ALL) were actually
    based off the window dimensions, even though the parent element did
    not correctly reflect this nature.
  - When set (the default now is that right and bottom are set) the
    behavior will mostly correctly mimic the 2.1.3 (minus bugs) and
    before.
  - CHANGE (from 2.1.3): The window constraints also affect the RESIZE
    mode, arguably this is more consistent.
  - To disable this "constrain to window" behavior, simply set the
    appropriate property to false, as in:
    `game.scale.windowConstraints.bottom = false`
2014-11-08 05:21:13 -08:00
Paul
223d444f16 ScaleManager: additional cleanup / fixes
- Sizing events:
  - CHANGE: The `onResize` callback is called only from `preUpdate` (which
    may be triggered from a window resize) and it will be called on
    refreshes even if the parent size has not actually changed.
  - A new `onSizeChange` Signal has been added. It is called _only_ when
    the Game size or Game canvas size has changed and is generally more
    applicable for performing layout updates.

- Game documentation now links to ScaleManager#setGameSize (which was
  renamed from #setGameDimensions)

- Removed extra/legacy full-screen restore code

- Margins:
  - Added `noMargins` flag; if set to true the Canvas margins will never
    be altered. This also means that
  - Margins are now set/cleared individually to avoid conflict with
    'margins' style compound property

- Code consistency updates
2014-11-08 04:35:42 -08:00