Commit graph

151 commits

Author SHA1 Message Date
photonstorm
389b6dd1aa Fixed for jshint. 2015-09-22 12:07:14 +01:00
photonstorm
d16de32fe3 Device.iOSVersion now contains the major version number of iOS. 2015-09-22 11:46:20 +01:00
photonstorm
4c5dfc4847 Optimised getSmoothingEnabled, setSmoothingEnabled and setImageRenderingCrisp. 2015-09-15 14:18:00 +01:00
photonstorm
646380f710 Tweaked Canvas.getSmoothingEnabled and Canvas.setSmoothingEnabled to early out on more common browsers.
Added Canvas.getSmoothingPrefix
2015-09-15 13:43:52 +01:00
photonstorm
226b7070a8 Fixed issue with an extra 4px being added to the canvas elements because the display type wasn't set. 2015-08-24 11:32:32 +01:00
photonstorm
f4a1f11429 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.
Sprite.setTexture has a new `destroyBase` parameter - set this to `true` if you know the base used a generated texture that isn't being used by any other sprites. This will free-up the canvas for further re-use by other calls to generateTexture or Text objects.
2015-08-03 16:09:16 +01:00
photonstorm
e901fb80f6 Merging in the CanvasPool changes to the core. 2015-08-03 14:46:55 +01:00
photonstorm
50516e3d34 Testing CanvasPool. 2015-08-03 14:33:12 +01:00
Richard Davey
1f73bbbe94 Device.canPlayVideo now checks for ogv as a valid file extension for OGG video files (thanks @JB-Tellez #1928) 2015-07-26 13:19:05 +01:00
photonstorm
858ad51610 Phaser 2.4 release. 2015-07-22 15:31:30 +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
Markus Kristo
da6d7a58e3 Fix reference error for process
process was defined, while window.process wasn't.
2015-07-21 13:53:18 +02:00
Richard Davey
8e92c13412 Canvas.setSmoothingEnabled only applies the value of the property exists, which avoids the Chrome webkit prefix deprecation warnings. 2015-07-10 04:02:21 +01:00
photonstorm
0f31358724 Device.windowsPhone should now correctly identify Windows Phone 8.1 devices, which also think they are iOS and Androids. If you find a device that gets around this check please send us its ua string! (thanks @jounii #1496) 2015-07-08 15:22:32 +01:00
photonstorm
102c74e121 Deprecated the following:
* Camera.screenView
* ScaleManager.maxIterations
* ScaleManager.enterPortrait (see onOrientationChange)
* ScaleManager.enterLandscape (see onOrientationChange)
* ScaleManager.enterFullScreen (see onFullScreenChange)
* ScaleManager.leaveFullScreen (see onFullScreenChange)
* ScaleManager.fullScreenFailed (see onFullScreenError)
* ScaleManager.checkResize
* ScaleManager.checkOrientation
* ScaleManager.setScreenSize (see updateLayout)
* ScaleManager.setSize (see reflowCanvas)
* ScaleManager.checkOrientationState (see reflowCanvas)
* ScaleManager.orientation (see screenOrientation)
* Gamepad.disabled (see enabled)
* Input.currentPointers (see totalActivePointers)
* Input.disabled (see enabled)
* Keyboard.disabled (see enabled)
* Mouse.disabled (see enabled)
* Mouse.mouseMoveCallback (see Input.addMoveCallback)
* MSPointer.disabled (see enabled)
* Touch.disabled (see enabled)
* Cache.getUrl (see getURL)
* Math.truncate (see Math.trunc)
* Math.snapToInArray (see Phaser.ArrayUtils.findClosest)
* Math.interpolateFloat (see Math.linear)
* Math.normalizeLatitude (use Phaser.Math.clamp(lat, -90, 90))
* Math.normalizeLongitude (use Phaser.Math.wrap(lng, -180, 180))
* Math.chanceRoll (use Phaser.Utils.chanceRoll)
* Math.numberArray (use Phaser.ArrayUtils.numberArray)
* Math.numberArrayStep (use Phaser.ArrayUtils.numberArrayStep)
* Math.limitValue (use Phaser.Math.clamp)
* Math.randomSign (use Phaser.Utils.randomChoice(-1, 1))
* Math.angleLimit (use Phaser.Math.clamp)
* Math.getRandom (use Phaser.ArrayUtils.getRandomItem)
* Math.removeRandom (use Phaser.ArrayUtils.removeRandomItem)
* Math.floor (use Math.trunc)
* Math.ceil (use Phaser.Math.roundAwayFromZero)
* Math.shift (use Phaser.ArrayUtils.rotate)
* Math.shuffleArray (use Phaser.ArrayUtils.shuffle)
* Math.distanceRounded (do the rounding locally)
* Canvas.getOffset (see Phaser.DOM.getOffset)
* Canvas.getAspectRatio (see Phaser.DOM.getAspectRatio)
* TilemapLayer.tileColor (use TilemapLayer.debugSettings.missingImageFill)
* Phaser.ArrayList alias removed, now use Phaser.ArraySet
* Utils.transposeArray (see Phaser.ArrayUtils.transposeMatrix)
* Utils.rotateArray (see Phaser.ArrayUtils.rotateMatrix)
* Utils.shuffle (see Phaser.ArrayUtils.shuffle)
2015-06-17 03:14:31 +01:00
Richard Davey
88524cd1ce Merge pull request #1851 from rblopes/detect-nwjs-electro
Changes for nw.js-like environment detection code
2015-06-17 01:35:16 +01:00
photonstorm
30a35227da Formatting update. 2015-06-16 20:38:18 +01:00
photonstorm
f5369628ce Device.chromeVersion will return the major version number of Chrome. 2015-06-16 14:16:04 +01:00
Rafael Barbosa Lopes
b64d817913 Refactoring the boolean expressions. 2015-06-12 15:17:26 -03:00
Rafael Barbosa Lopes
3f5691ecdd Add detection for GitHub Electron. 2015-06-12 15:08:54 -03:00
Rafael Barbosa Lopes
bf9d516ef4 Simplify detection of nw.js (formerly Node-WebKit). 2015-06-12 15:06:22 -03:00
photonstorm
0b6bf3f52f Extended getUserMedia check. 2015-06-11 06:01:40 +01:00
photonstorm
734fbfea9e The mp4Video check includes h264 now. 2015-05-19 14:18:57 +01:00
photonstorm
0f6dd1a1a6 Device.firefoxVersion is a new property that contains the major Firefox version number if running within Firefox, otherwise zero. 2015-05-18 14:51:25 +01:00
photonstorm
b91387c9a6 Extended the getUserMedia and window.URL check. 2015-05-14 23:20:52 +01:00
photonstorm
f0ac93ea62 Device.oggVideo indicates if the browser can play back ogg video files.
Device.h264Video indicates if the browser can play back H264 (mp4) video files.
Device.mp4Video indicates if the browser can play back H264 (mp4) video files.
Device.webmVideo indicates if the browser can play back webm video files with the vp8 codec.
Device.vp9Video indicates if the browser can play back webm video files with the vp9 codec.
Device.hlsVideo indicates if the browser can play back mpeg video files.
2015-05-03 13:53:02 +01:00
photonstorm
a69e53f901 Copyright date change. 2015-02-25 03:36:23 +00:00
photonstorm
9cdcdc7bc5 Device.touch checks if window.navigator.maxTouchPoints is >= 1 rather than > 1, which now allows touch events to work properly in Chrome mobile emulation. 2015-02-05 06:12:20 +00:00
vulvulune
8ef32f044c Correct comments
Correct comments:
-Phaser.Camera: checkWorldBounds =>checkBounds
-Phaser.RetroFont: Set correct @name for name and smoothed
-Phaser.DOM: inViewport => inLayoutViewport
2015-01-27 13:46:18 +01:00
Richard Davey
ebf650c1a1 Merge pull request #1498 from pnstickne/wip-tilelayer-safaribug
Fix / double-copy for Safari tilemap bug when rendering with delta scrolling
2015-01-05 11:11:40 +00:00
Paul
2bbbc64830 Device update for canvasBitBltShift - real
(Previous changeset not pushed correctly)
2015-01-01 17:38:22 -08:00
Paul
7213bb1b5e Device update for canvasBitBltShift
The `canvasBitBltShift` detection is updated not to pick up any iOS
browsers. This should eliminate false-positives for Chrome for iOS, eg.

Defaulting to using the double-copy is "safer", even if slightly less
optimal.

(A proper feature check should still be added.)
2015-01-01 16:16:13 -08:00
Richard Davey
da27373c90 Device.webAudio check inversed to avoid throwing a warning in Chrome. 2015-01-01 21:38:02 +00:00
Paul
76aa601d47 TilemapLayer rendering double-copy
- Memory optimization of delta-scroll shifting.
  - The copy canvas is shared between all TilemapLayers
  - The copy is done in segments to reduce the memory usage of the copy
  canvas. Currently this is a 1/4 ratio.

- Device has the feature (by browser) check to see if bitblt works
  - TilemapLayer will automatically enable the double-copy as needed
  - Device.whenReady can be used to override the device value
2014-12-31 09:54:37 -08:00
Paul
8b513b842c DOM.visualBounds now includes scrollbars
- While not ideal this fixes most (if not all) of the ScaleManager issue
  pointed out in #1400. This issue should be addressed later. As of now,
  as an interim fix, this avoids the reported issue entirely (or at least
  I have not been able to reproduce it), as well as assorted artifacts
  when resizign a window while scaling.

- The is is the 2.1 behavior: In certain cases this can result in the
  right or bottom of the Game being cut-off slightly (the width of a
  scrollbar) instead of scaled, which is why it was originally changed.
2014-12-08 18:40:00 -08:00
photonstorm
03ebb8d11c Docs update. 2014-12-02 09:03:55 +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
photonstorm
cfbad72881 Documentation - general
Updated some documentation for formatting, consistency, and minor
corrections.
2014-11-30 04:02:45 -08:00
Paul
e7fd527c72 ScaleManager + DOM - window constraint updates
ScaleManager.windowContraints now allows specifing 'visual' or 'layout' as
the constraint. Using the 'layout' constraint should prevent a mobile
device from trying to resize the game when zooming.

Including the the new changes the defaults have been changed to

   windowContraints = { right: 'layout', bottom: '' }

This changes the current scaling behavior as seen in "Game Scaling" (as it
will only scale for the right edge) but also prevents such scaling from
going wonkers in some mobile environtments like the newer Android browser.
(Automatic scroll-to-top, albeit configurable, enabled for non-desktop by
default is not a fun situation here.)

To obtain the current semantics on a desktop the bottom should be changed
to 'layout'; although this will result in different behavior depending on
mobile device. To make the sizing also follow mobile zooming they should
be changed to 'visual'.

Also added temp Rectangle re-used for various internal calculations.

---

Phaser.DOM now also special-cases desktops to align the layout bounds
correctly (this may disagree with CSS breakpoints but it aligns the with
actual CSS width), without applying a window height/width expansion as
required on mobile browsers.

(And the jshint error isn't mine..)
2014-11-19 15:42:08 -08:00
Paul
644f87b15d ScaleManager + DOM 2014-11-17 23:56:30 -08:00
Paul
884353d71e ScaleManager + DOM
"Final" changes for a solid 2.2-worthy ScaleManager.

This adds in official support for USER_SCALE, which allows a flexible way
to control the scaling dynamically.

It fixes a visible display bug in desktop browsers (viewport clipping was
off) and mitigates some potential issues all around by using a unified
visualBound calculations in Phaser.DOM.

It applies some protected/deprecated attributes, but does not remove any
behavior of already-established (as in, outside-dev) means.

There are no known [signficant] breaking changes; any known breaks (not
considered fixes) are constrained to dev with no known consumers.

Phaser.DOM

  There are no known significant breaking changes; Phaser.DOM was
  internal.

  - Added visualBounds; this should be the true visual area, minus the
    scrollbars. This should be used instead of clientWidth/clientHeight to
    detect the visual viewport.

  - Expose various viewport sizes as dynamically updated properties on
    Rectangle objects. These are visualBounds, layoutBounds,
    documentBounds.

  - Updated documentation the different bounds; in particular drawing
    distinction between viewport/layout bounds and visual bounds.

  - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior.
    - Minor breaking, but dev-only

  - Changed `getAspectRatio` to work on Visual viewport. This will yield
    the expected behavior on mobiles.
    - Minor breaking, but dev-only

  - Removed some quirks-mode and legacy-browser special casing

Phaser.ScaleManager

  There are no known significant breaking changes.

  - USER_SCALE is 'made public'. It can used to flexibly configure any
    custom-yet-dynamic scaling requirements; it should now be able to
    replace any sane usage of manual sizing invoking the deprecated
    setSize/setScreenSize.
    - Added additional usage documentation and links to such
    - Added the ability to specify a post-scale trim factor.

  - Change the arguments the resize callback and document what is passed
    - Minor breaking, but the previous arguments were undocumented

  - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made
    generalized over possibly-expanding scaling.
    - Minor breaking, dev-only, for coding changing this settin

  - Switched from direct usage of of window innerWidth/Heigth to
    Phaser.DOM visualViewport - this change correctly accounts for
    scrollbars in desktop environments
    - Although it does slightly alter the behavior, this is a fix.

  - Removed usage of window outerWidth/outerHeight which didn't make much
    sense where it was used for desktops and was catostrophic for mobile
    browser
    - Although it may slightly alter the behavior, this is a fix.

  - Removed `aspect` and `elementBounds` because they are duplicative of
    Phaser.DOM (which can not be accessed as `scale.dom`).
    - Minor breaking, but internal methods on dev-only

  - Marked the minWidth/maxWidth/minHeight/maxHeight properties as
    protected. They are not removed/obsoleted, but should be revised later
    for more flexibility.

  - Orientation handling; non-breaking forward deprecations
    - Added `onOrientationChange` and deprecated the 4 separate leave,
      enter, landscape and portrait signals. They are not removed, so this
      is a future-migration change.
    - Fixed issue where state not updated prior to callback
    - Fixed issue where orientation callbacks were not always delayed

  - Fullscreen events: non-breaking forward deprecations
    - Added `onFullScreenChange` and deprecated `enterFullScreen` and
      `leaveFullScreen`.
    - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`.

Phaser.Device

  - Improved `whenReady` to support Phaser.DOM better
    - Allows a ready handler to be added without starting the
      device-detection proccess. This allows it to be registered to
      internally (eg. from System.DOM) without affecting current behavior.
    - Passes the device object as the first parameter to the callback
      function.

  - Fixed code where Silk detection not applied to `desktop` detection.

Manifest: System.Device moved before System.DOM
2014-11-17 23:48:06 -08:00
Paul
fb8917658f Phaser.Device - quibbles
- Removed useless arguments
2014-11-13 19:31:35 -08:00
Paul
599479dfdf Phaser.Device - inverted from Game
The only known breaking change is if user-code relied on `device.game` or
manually called `checkFullScreenSupport`, as both have been removed.

- Phaser.Device is now a singleton object that does not belong to a
  particular game. The only thing that it belongs to is the window/host
  context.
  - `game.device` (shared between all games) and `Phaser.Device` are the
    same object.
  - There is no more `Device#game` property.

- The specific device-ready detection is moved out of Game into the Device
  code
  - It is possible for multiple Games (or even non-Games) to use
    `Device.whenReady`.
  - Initialization is done immediately upon device-ready; there is an
    onInitialized signal that is dispatched that can be subscribed to
    extend the default initialization.

- The fullscreen-detection code (that was the only dependent of game) now
  uses an new element.

- Updated jsdoc documentation
2014-11-13 18:21:28 -08:00
Richard Davey
824c0e2be7 Merge pull request #1318 from pnstickne/wip-wheel-scroll-updates
Mouse Scroll Events - added support for WheelEvent, fixes
2014-11-12 22:10:52 +00:00
Paul
7004d68cbd Mouse Scroll Events - device separation
- The wheel event type is now determined in by Device

- The various input checking in Device have been moved to a new function
2014-11-12 13:24:03 -08:00
Paul
cf3bebd00c ScaleManager - orientation, minor 2014-11-11 23:02:43 -08:00
Paul
0fd6a4a5b6 ScaleManager - orientation
- FIX #1306, hopefully, where an orientation change did not correclty
  cause a screen/layout update.

- FIX/CHANGE where Paused games would not update the scale
  - The new behavior "runs" the ScaleManager in a paused state via
    `pauseUpdate`; a User paused game will now correctly track scale
    changes. This is closer to the 2.1.3 behavior in some cases, such as
    window resizing, when the updates were done in the DOM event.
  - This change also affects device orientation change monitoring and
    events, which are also deferred to the update cycle
  - The update cycle is set to the maximum and is still dependent on the
    RAF / primary loop running, so it should not affect background
    apps/tabs

- FIX/CHANGE New better backoff timing; ie. continuous window resizing is
  limited to ~10 fps update calculations. This makes it much harder to
  crash Chrome by rapidly and continously resizing the window.  Also
  increases the scaling from 0..10..20..40 to 0..25..50..100.

- FIX an issue where the incorrect orientation was "one frame behind" the
  scaling.

- UPDATE The contract for when the change orientation events occurs is
  better defined - it now always happens in the update context as with
  game sizing.

- UPDATE Unifies orientation-change code / handling and duplicate.

- CHANGE Added DOM.getScreenOrientation which obtains the orientation via
  the Device Orientation API (WD) and provides comprehensive fallbacks
  - This should cover all modern browsers
  - FIX: Orientation on desktops now computed as screen ratio by default
    which fixesi the false-portrait chain/detection when the page is made
    more narrow than it is tall.
  - CHANGE/FIX: window.orientation is now only used as fallback, if
    requested (due to device differences). It may be appropriate to enable
    this (via `scale.compatibility` on boot, for instance) in some
    environments.

Signed-off-by: Paul <pstickne@gmail.com>
2014-11-11 22:30:07 -08: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
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
5d84f38f6e Device.canPlayAudio now supports the opus files directly, as well as opus encoded audio stored in ogg containers (#1232) 2014-10-13 13:52:41 +01:00