Commit graph

607 commits

Author SHA1 Message Date
Richard Davey
497a9ecd70 Merge pull request #1328 from pnstickne/wip-device-to-1
Phaser.Device - inverted from Game
2014-11-14 18:34:38 +00:00
Richard Davey
cbaa36fdd6 Merge pull request #1291 from spayton/dev
Groups always had zero z index
2014-11-14 18:21:08 +00: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
Paul
aa3c21ade7 ArraySet/LinkedList - minor updates
- Renamed ArrayList to ArraySet
  - Added ArrayList is a deprecated proxy for compatibility
  - Updated internal code to use ArraySet

- ArraySet can be constructed with an array; if the caller is willing to
  accept some responsibility this can remove the O(n^2) behavior of
  repeatedly calling `add`.
  - Updated Group.filter to take advantage of this

- ArraySet.total is read-only proxy for for list.length

- Fixes ArraySet.setAll where it would only set properties with truthy
  values

- Updated documentation
2014-11-13 01:41:08 -08:00
Paul
794c9f65fe ArrayList/LinkedList - moved from core to utils
- ArrayList is also renamed to ArraySet to better reflect the nature
2014-11-13 00:59:42 -08:00
Sean
ef49f9bede Modify value of PIXI.scaleMode.DEFAULT instead of PIXI.scaleMode.LINEAR since LINEAR and NEAREST are constants 2014-11-13 15:01:44 +08:00
photonstorm
497b00d781 Tidying up a little. 2014-11-13 00:27:47 +00:00
photonstorm
e7356fc575 Pixi 2.1.1 merge. 2014-11-12 22:38:51 +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
Richard Davey
d786d4e455 Merge pull request #1317 from pjbaron/dev
prevent multiple catch-up frames which cause physics objects to 'tunnel'
2014-11-12 13:04:25 +00:00
Pete Baron
7bd0a8db71 Temporary fix to prevent huge numbers of catch-up frames happening all at once if the user navigates away from the game. Limits them to 3 now (which allows it to still detect and react to spiralling).
A proper fix involves putting the physics collision into the same update as the physics motion.
2014-11-13 00:00:13 +13:00
Richard Davey
26e74fef18 Merge pull request #1315 from pjbaron/dev
Minor logic fix and updateRender change
2014-11-12 09:18:36 +00:00
Richard Davey
b5ed3324b2 Merge pull request #1316 from pnstickne/wip-1306
ScaleManager - orientation updates/fixes
2014-11-12 09:17:47 +00:00
Paul
cf3bebd00c ScaleManager - orientation, minor 2014-11-11 23:02:43 -08:00
Paul
59dddece0b ScaleManager - orientation
- A few minor quibbles
2014-11-11 22:53:00 -08:00
Paul
e36027f599 ScaleManager - orientation
- Removed some "debug" logging, oops.

- And a dab of documentation updates while I'm at it..
2014-11-11 22:41:53 -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
Pete Baron
1c5a106b17 Modify updateRender call to use desiredFps rate when spiralling is detected. 2014-11-12 15:01:09 +13:00
photonstorm
da031d8bbb Phaser games should now work again from the CocoonJS Launcher. 2014-11-11 14:31:20 +00:00
photonstorm
e63988fe6e Additional RESIZE handler. 2014-11-11 13:59:56 +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
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
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
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
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
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
a7710c504e jshint fixes. 2014-11-08 14:04:17 +00:00
photonstorm
17de8fdcae ScaleManager updates and fixes
Conflicts:
	src/core/ScaleManager.js
2014-11-08 13:38:19 +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
Paul
7de70adf42 ScaleManager: more updates, fixes (eg. SHOW_ALL)
- NOTE: Changing `game.width/game.height` via user code was always
  problematic. This commit updates the documentation for such members as
  read-only. The only supported way to change the GAME SIZE after it is
  created is to use `ScaleManager#setGameDimensions`, which has been
  added.

- The GAME SIZE will be reset to the initial (or as set by
  `setGameDimensions`) values upon changing the scale mode or
  entering/leaving full screen. This may be a breaking from 2.1.2 (but
  many mode changes acted oddly prior).

- SHOW_ALL will now EXPAND it's parent container if it can. As per
  @tjkopena 's notes, this should more closely represented the expected
  behavior.
  - SHOW_ALL will first try to expand by the OVERFLOW AXIS and then
    attempt to resize to fit into the possibly larger area; use the
    parent's max-height/max-width properties to limit how far SHOW_ALL can
    expand.
  - RE-BREAKING: This changes the behavior from 2.1.4 and makes it more like
    2.1.3, with fixes.

- As per previous commit the ScaleManager _owns_ the margins and size of
  the GAME CANVAS. To control the dimensions of the GAME CANVAS, use the min/max
  height/width of the parent. Setting padding on the parent is _NOT_
  supported.

- Fixes various issues with switching between Scale Modes
2014-11-07 23:24:57 -08:00
Paul
10d0f1943a ScaleManager - scaling consistency and bug-fixes
This includes some minor breaking changes.

- Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE
  - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you
    need to place the element you want to present inside another
    element.."
  - This done via an (overwritable) `createFullScreenTarget` function.
    The (new) DOM element returned from this is placed into the DOM and
    the canvas is added to (and later removed) as the full screen mode
    changes.
  - MINOR BREAK: may affect code that assumes the Phaser canvas has a
    fixed DOM/CSS path (which should hopefully be nobody).  To use to the
    original behavior, where the canvas is not moved, simply set
    `this.fullScreenTarget = game.canvas` manually.

- Updates the refresh/queue to be unified and uses a smarter back-off to
  detect and react to parent dimension changes
  - Cleans up some odd browser issues; not tried on mobile
  - Fixes an issue were update might be called too much and spend time
    doing nothing useful.
  - `maxIterations` is no longer user and marked as deprecated
  - MINOR BREAK: previous approach would occasionally (but not always)
    back off updates the entire iteration/setTimeout sequence; under the
    new approach "onResize" may be called more frequently.

- Fixes a number various transition issues, mostly around RESIZE
  - MINOR BREAK, but correct: leaving RESIZE restores the original game
    size possible
  - Fixes assorted quirks with scales not being updated

- Layout
  - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They
    will be reset in all modes as appropriate. This is for consistency
    fixes as well as coping with the updated full screen.
  - MINOR BREAK: Canvas right/bottom margins are set to negative margins
    to counter left/top margins. This prevents Canvas margin adjustments
    from affecting the flow .. much.
  - `getParentBounds` rounds to the nearest pixel to avoid "close to"
    value propagation from CSS.
  - Fixes page-align center pushing canvas out of parent

- Misc.
  - MINOR BREAK: `setScreenSize` will update the game size if the mode is
    RESIZE. User-code shoulde use `refresh` instead to ensure that any
    relevant changes are propagated.

- Corrected incorrect documentation
2014-11-07 16:06:33 -08:00
photonstorm
2469e45649 Rounding out new dimensions. 2014-11-04 23:57:21 +00:00
photonstorm
b6b478f214 Small jsdoc fixes. 2014-11-04 23:57:21 +00:00
spayton
5b6671a634 removed this.z =0, missed from last push 2014-11-03 20:24:56 +00:00
spayton
b51c162b4d Fixed new groups incorrectly always adding with a z index of 0 2014-11-03 18:19:41 +00:00
Richard Davey
fc0d423a7b Merge pull request #1278 from pnstickne/wip-1255
ScaleManager - bugfixes and updates for #1255
2014-11-02 14:01:23 +00:00
photonstorm
65618a7ec6 docs fix. 2014-11-02 12:08:54 +00:00
Paul
5b16bd45a5 ScaleManager - minor fullscreenerror fixes
- IE9 compatibility (no setWindow arguments)
- And removed code that assumpted event.target was the canvas..

(Actually adding the changes this time..)
2014-11-01 01:23:14 -07:00
Paul
d89c709020 ScaleManager - minor fullscreenerror fixes
- IE9 compatibility (no setWindow arguments)
- And removed code that assumpted event.target was the canvas..
2014-10-31 19:41:55 -07:00
Paul
9b319019e7 ScaleManager - backport for API compatibility
- "Backported" some changed API, all marked as @deprecated
- Minor regression fix for `supportsFullScreen`.
2014-10-31 18:06:36 -07:00
Paul
6e9f435245 ScaleManager - IE11 & Fullscreen error updates
- Added prefixed event handlers for IE; it still doesn't work in IE, but that is for other reasons
- Added monitoring of the fullscreenerror event, exposed as a fullScreenFailed signal
- Added `supportsFullScreen` a read-only flag that indicates that this ScaleManager even attempts to support such
2014-10-31 15:31:03 -07:00
Paul
6144b57651 ScaleManager - documentation updates 2014-10-31 03:29:54 -07:00
Paul
53541529e9 ScaleManager
- Specific bug fixes (example)
   - Scale modes can now be set independently
   - Switching between fullscreen and normal correctly restores modes
   - Alignment does not incorrectly offset in fullscreen mode
   - Changing scale/alignment promptly refreshes layout
   - `isFullScreen` returns a boolean, as it should
   - Faster parent checks (if required)
   - NO_SCALE should not not scale (vs previous behavior of having no behavior)
   - Correct usage of scaleMode depending on mode

 - Removed / unified code-paths, which helped address several issues
 - fullScreenTarget adjustment/restoration is less brutal
 - Updated documentation
 - pageAlign* works as alignment on the containing element. It should still work were it worked before (so this is not a breaking change) as well as being more universal.
 - Added @protected and @private attributes
   - Some methods were (implicitly) @public even though using them out of context is invalid

 - API Breaking:
   - Renamed some INTERNAL/@private methods
     - Should only affect methods that were not valid/sane to use publically
     - Event callbacks (ie. checkResize changed to resizeWindow) renamed for meaning
   - Changed some INTERNAL semantics to better align with usage
     - eg. `check*` methods separated from response-to-check
2014-10-31 01:41:06 -07:00
Paul
3cfe200ed1 Minor documentation cleanup 2014-10-28 06:12:48 -07:00
Paul
37a77c674f Add support for "rgba" to Phaser.Stage.backgroundColor
- backgroundColor now uses valueToColor which supports hex strings, web/rgba strings, and hex numbers.
 - valueToColor normalizes across hexToColor/webToColor/getRGB; see comments
 - hexToColor now documents the prefix being optional and allows the `0x` prefix.
 - webToColor now exctracts an alpha channel if present - as a slight misfeature it will also accept `rgb(..,a)`.
2014-10-28 05:45:00 -07:00
photonstorm
08a2b12d7d Tidied up the jsdocs. 2014-10-28 01:48:56 +00:00
photonstorm
9efa5efa0f Tidied up the Signal class and added a call counter to SignalBinding. 2014-10-28 01:48:24 +00:00
photonstorm
a471cfc235 Game.destroy now destroys either the WebGLRenderer or CanvasRenderer, whichever Pixi was using. 2014-10-27 22:09:39 +00:00
photonstorm
474fd8e055 JSDoc fixes. 2014-10-21 23:08:16 +01:00
Alvin
7f31cfba62 fixed type in the cached previous point in mouse uniform (filter) 2014-10-20 14:39:16 +02:00
photonstorm
35d29170d0 Lots of small jsdoc fixes and DocGen updates. 2014-10-20 00:54:56 +01:00
photonstorm
d70406588c Filter.update now caches the previous pointer position to avoid flooding the uniform. Also the mouse uniform is now a value between 0 and 1 depending on the position within the game view. 2014-10-17 19:29:50 +01:00
photonstorm
52f1663642 Fixed the Filter mouse uniform value population. 2014-10-17 16:52:28 +01:00
photonstorm
967497c572 Added a few new uniforms and tidied things up. 2014-10-15 19:35:45 +01:00
photonstorm
3f43637782 Happily removed the IE11 WebGL lock as Pixi now fully supports it :) 2014-10-14 01:10:17 +01:00
photonstorm
ac27f12c95 Fixes for Pixi update WebGL UV calls. 2014-10-11 04:18:42 +01:00
photonstorm
0c5438038d Allowed the orientation checks to still work when using RESIZE scale mode. 2014-10-10 20:35:50 +01:00
Richard Davey
bc16c7876f Merge pull request #1187 from codevinsky/feature/group-filter
Group.filter
2014-10-09 14:08:51 +01:00
Richard Davey
9546fc2959 Merge pull request #1222 from englercj/camera-follow-fix
Fix camera follow when in a scaled parent
2014-10-09 14:07:40 +01:00
photonstorm
08c6106c35 Fixed issue with textureLine creating white blocks in iOS. 2014-10-09 02:30:31 +01:00
Chad Engler
4d2e60348f fix camera follow when in a scaled parent 2014-10-04 20:14:46 -07:00
photonstorm
d7f8e11d21 Removed the customBounds layer. 2014-09-24 06:52:22 +01:00
photonstorm
597b828d7a StateManager.boot would call start on a State twice if it was added to the game and started before the DOM load had completed. This didn't cause an error but was duplicating function calls needlessly. 2014-09-18 05:14:44 +01:00
photonstorm
426b43cc9f Removed console.log calls. 2014-09-18 05:12:35 +01:00
photonstorm
d68ed61999 If you called StateManager.start from within a states init method which also had a preload method it would fail to start the next State. 2014-09-18 05:11:58 +01:00
photonstorm
756561920f Group.ignoreDestroy boolean will bail out early from any call to Group.destroy. Handy if you need to create a global Group that persists across States. 2014-09-18 05:11:48 +01:00
photonstorm
20551f9129 Lots of jsdocs fixes ready for the new doc generator. 2014-09-16 17:35:08 +01:00
photonstorm
fc6b7dd36c StateManager.unlink will null all State-level Phaser properties, such as game, add, etc. Useful if you never need to return to the State again. 2014-09-15 13:19:01 +01:00
Jeremy Dowell
83007878fc updated: Group.filter documentation 2014-09-11 13:09:52 -05:00
Jeremy Dowell
298622f65f added: Group.filter
takes a predicate function and passes child, index, and the entire child array to it.

return an ArrayList containing all children that the predicate returns true for.
2014-09-11 13:06:38 -05:00
photonstorm
5b922be56e Version 2.1.1. of Phaser is an emergency point release. It addresses a potential race condition that could happen in States that tried to change state from the create method but had an empty preloader or pre-cached assets. 2014-09-11 10:38:40 +01:00
photonstorm
33d9b19e29 The Debug canvas is now cleared on State swap. 2014-09-09 15:28:58 +01:00
photonstorm
a1c9b64327 Now bails out of a few methods if RESIZE is set. 2014-09-09 12:48:21 +01:00
photonstorm
2e9dc682a1 Tidied up a redundant if call. 2014-09-09 12:47:59 +01:00
photonstorm
b4e7da78ed jsdocs updated. 2014-09-09 12:47:39 +01:00
photonstorm
c40c140631 Camera.roundPx is a new boolean. If set to true it will call view.floor as part of its update loop, keeping its boundary to integer values. Set to false to disable this from happening (#1141) 2014-09-09 12:47:27 +01:00
photonstorm
79d873f47b If you are using CocoonJS, please set your game render type to CANVAS and not WEBGL or AUTO. You should also disable any of the ScaleManager screen resizing or margin setting code. By default in this mode CocoonJS will now set 'screencanvas=true' which helps with performance significantly. 2014-09-08 22:34:53 +01:00
photonstorm
09915ebfde Tidying up debug. 2014-09-08 22:34:53 +01:00
Richard Davey
3102ad534d Swapped the order of the Camera.view floor to avoid the 1px jitter effect on the right of maps. 2014-09-06 10:26:54 +01:00
photonstorm
7c02358eed More FlexGrid updates. 2014-09-05 16:19:32 +01:00
photonstorm
22df587bd3 Swapped to using FlexLayers. 2014-09-05 15:46:21 +01:00
photonstorm
ff07317120 First version of the FlexLayer class. 2014-09-05 15:46:10 +01:00
photonstorm
72c0f50b6b Lots of small enhancements and layer types. 2014-09-05 08:02:44 +01:00
photonstorm
0af4ec4da2 The StateManager will now check if a State has a method called resize. If it does, and if the game is running in the RESIZE Scale Mode then this method will be called whenever the game resizes. It will be passed two parameters: width and height that will match the games new dimensions. Resizing can happen as a result of either the parent container changing shape, or the browser window resizing. 2014-09-05 06:22:10 +01:00
photonstorm
0c9eef8a91 FlexGrid added to the ScaleManager. 2014-09-05 06:02:25 +01:00
photonstorm
07f529bf12 First experimental build of FlexGrid. 2014-09-05 06:01:48 +01:00
photonstorm
f2a8a927f9 Group.addMultiple allows you to pass an array of game objects and they'll all be added to the Group in turn. 2014-09-05 06:01:25 +01:00
photonstorm
ac9c9a1f9b Fixed the assignment of the fullScreenTarget so FS mode works again now. 2014-09-05 01:07:51 +01:00
Richard Davey
7ee1564f2e Signal.removeAll would ignore the context parameter and remove all bindings regardless (thanks @alect #1168) 2014-09-04 22:24:47 +01:00
photonstorm
cbc6ac8e7d New debug header. 2014-09-04 05:05:05 +01:00
Carlos Martinez
94f9c0906f this fixes the camera judders when following with float values. 2014-09-01 14:49:44 +01:00
photonstorm
2cc8e57808 Fixed issue with the ScaleManager. 2014-09-01 08:19:43 +01:00
photonstorm
7fc37751b2 ScaleManager.orientationSprite has been removed because it never displayed correctly anyway (it would be distorted by the game scale), it will be bought back in a future version by way of a custom orientation state. 2014-09-01 03:30:02 +01:00
photonstorm
047839d806 Fixed preUpdate so that the offset is reset regardless of the RESIZE scaleMode. 2014-09-01 03:20:09 +01:00
photonstorm
80d1df4705 ScaleManager.setMinMax(minWidth, minHeight, maxWidth, maxHeight) is a handy function to allow you to set all the min/max dimensions in one call. 2014-09-01 03:07:17 +01:00
photonstorm
2f1f680d73 Docs fixes. 2014-09-01 02:59:24 +01:00
photonstorm
c6493b59c3 Removed use of _startHeight, left over from the Phaser v1 days that's no longer required. 2014-09-01 02:44:35 +01:00
photonstorm
fe9dbd15e5 The World bounds can now be set to any size, including smaller than the game dimensions. Before it was locked to a minimum size of the game canvas, but it can now be anything. 2014-09-01 02:41:07 +01:00
photonstorm
1a60d641b1 Canvas.removeFromDOM(canvas) will remove a canvas element from the DOM.
Game.destroy now removes the games canvas element from the DOM.
2014-09-01 02:38:21 +01:00
photonstorm
97d771c4e8 ScaleManager has a new scaleMode called RESIZE which will tell Phaser to track the size of the parent container (either a dom element or the browser window if none given) and set the canvas size to match it. If the parent changes size the canvas will resize as well, keeping a 1:1 pixel ratio. There is also a new ScaleManager.setResizeCallback method which will let you define your own function to handle resize events from the game, such as re-positioning sprites for a fluid responsive layout (#642)
The width and height given to the Phaser.Game constructor can now be numbers or strings in which case the value is treated as a percentage. For example a value of "100%" for the width and height will tell Phaser to size the game to match the parent container dimensions exactly (or the browser window if no parent is given). Equally a size of "50%" would tell it to be half the size of the parent. The values are retained even through resize events, allowing it to maintain a percentage size based on the parent even as it updates.
2014-09-01 01:52:04 +01:00
photonstorm
5fb8c7eb85 ScaleManager window.resize handler would constantly dispatch enterPortrait and enterLandscape events on window resizing, regardless if it actually entered that orientation or not.
Stage.offset has been moved to ScaleManager.offset
Stage.bounds has been removed, you can access it via Stage.getBounds.
Stage.checkOffsetInterval has been moved to ScaleManager.trackParentInterval
ScaleManager.hasResized signal has been removed. Use ScaleManager.setResizeCallback instead.
2014-09-01 01:02:48 +01:00
photonstorm
004deff508 Note: This commit will break all input, don't pull it down until I finish this work off later today please!
Moved the DOM offset from Stage to ScaleManager (a more logical location for it) and updated Pointer to use that.
Moved the Pointer offset check to look at the ScaleManager.
Used getBoundingClientRect(), will see if that works better than Phaser.Canvas.getOffset.
2014-08-31 12:17:07 +01:00
photonstorm
8c7a699f74 Getting ready to test auto resizing renderer. 2014-08-31 11:09:27 +01:00
photonstorm
4d0cae0e2d jshint fixes for CocoonJS.App and continuing work on the new ScaleManager. 2014-08-31 10:17:02 +01:00
photonstorm
3e1eb10673 First pass at fully resizable canvas tracking and parenting. 2014-08-31 10:17:02 +01:00
Dan Cox
cccaa30459 CocoonJSApp 'onSuspended' and 'onActivated' events
This PR depends on [#1150] (https://github.com/photonstorm/phaser/pull/1150)!

(I apologize for all the different pull requests in a short time period. I finally got some time to do some development tonight and have been making my way through many of my TODO items.)

This adds support for CocoonJS.App's 'onSuspended' and 'onActivated' events, making it so that the timers and sounds are stopped/started and muted/unmuted when the user swaps an app from the background to the fore or the reverse.

Because neither ['onActivated'] (http://doc.ludei.com/2.0.2/CocoonJS_App/symbols/CocoonJS.App.html#.event:onActivated) nor ['onSuspended'] (http://doc.ludei.com/2.0.2/CocoonJS_App/symbols/CocoonJS.App.html#.event:onSuspended) send an Event object themselves, this patch fakes sending an object by creating one during the function call and giving it a 'type' property for visibilityChange() to check against.
2014-08-29 23:13:13 -04:00
photonstorm
26a55bd202 SoundManager.destroy is a new method that will destroy all current sounds and reset any callbacks.
StateManager.clearCurrentState now handles the process of clearing down the current state and is now called if the Game is destroyed.
Game.destroy now clears the current state, activating its shutdown callback if it had one. It also now destroys the SoundManager, stopping any currently running sounds (#1092)
2014-08-29 11:37:47 +01:00
Richard Davey
ffb413b741 Fixed issue with callbacks not having the correct context. 2014-08-28 21:54:30 +01:00
photonstorm
0c88ba041a If you used a single Game configuration object and didn't specify the enableDebug property it would crash on Debug.preUpdate (thanks @luizbills #1053) 2014-08-28 04:19:10 +01:00
photonstorm
6e2cd37776 ScaleManager.destroy now removes the window and document event listeners, which are no longer created anonymously (thanks @eguneys #1092)
Input.Gamepad.destroy now destroys all connected SinglePads and clears event listeners.
SinglePad.destroy now clears all associated GamepadButton objects and signals.
2014-08-28 03:31:47 +01:00
photonstorm
fa45d7feff Events.onDestroy is a new signal that is dispatched whenever the parent is being destroyed. It's dispatched at the start of the destroy process, allowing you to perform any additional house cleaning needed (thanks @jonkelling #1084)
Group.onDestroy is a new signal that is dispatched whenever the Group is being destroyed. It's dispatched at the start of the destroy process, allowing you to perform any additional house cleaning needed (thanks @jonkelling #1084)
2014-08-28 02:56:06 +01:00
photonstorm
d7f8950758 Debug.cameraInfo no longer crashes if the camera bounds are nulled (thanks @wayfu #1143)
Camera.setBoundsToWorld no longer crashes if the camera bounds are nulled (thanks @wayfu #1143)
2014-08-28 02:13:51 +01:00
Richard Davey
50179d76fb Merge pull request #1015 from Zielak/dev
Phaser.Camera.position for quick access
2014-08-28 02:02:40 +01:00
Richard Davey
6a314a60d1 Merge pull request #1142 from darfux/dev
Fixed Group.removeBetween's default endIndex bug
2014-08-28 01:44:01 +01:00
Richard Davey
cc69a4bf2c Merge pull request #1127 from FedeOmoto/dev
Game configuration object "renderer" property wrongly assigned to Game.r...
2014-08-28 01:36:49 +01:00
darfux
abdf54858c Fixed Group.removeBetween's default endIndex bug 2014-08-26 21:02:13 +08:00
Alvin
c7e256245a Merge pull request #1107 from gamedolphin/test
Fixed Point.rotate bug . Also added a little documentation for world wrap.
2014-08-22 12:32:06 +02:00
Federico Omoto
14028cafbc Game configuration object "renderer" property wrongly assigned to Game.renderer 2014-08-21 17:57:07 -03:00
Dan Cox
fbd2de5b23 Cordova 'deviceready' event check
A slightly obnoxious but necessary hack to prevent a race condition between the loading of Apache Cordova and Phaser itself. 

Without waiting for the 'deviceready' event, Phaser can often load first, preventing any console messages from appearing to the user. Because Cordova writes to the platform's console (via CordovaLog), it must first be loaded and signal its own 'deviceready' event before console or plugin usage can occur. Otherwise, all messages and functionality is ignored.
2014-08-21 00:11:41 -04:00
Sandeep Nambiar
9977d5e204 World Wrap and P2
Changes only to documentation for clarity.
2014-08-13 04:10:37 +05:30
Sam MacPherson
3b69c7ede1 group swap fix 2014-08-05 19:39:21 -04:00
Txus Ordorika
b952884d9d Fix for scale issues in CocoonJS using webgl renderer and screencanvas 2014-07-23 17:16:25 +02:00
Richard Davey
d8c755a544 Merge pull request #1017 from devinb83/dev-codepaused
codePaused should be set if manually called
2014-07-18 11:57:37 +01:00
photonstorm
24527eac3e Group.checkAll allows you to check if the same property exists across all children of the Group and is set to the given value (thanks @codevinsky #1013)
Group.checkProperty allows you to check if the property exists on the given child of the Group and is set to the value specified (thanks @codevinsky #1013)
Phaser.Utils.setProperty will set an Objects property regardless of depth (thanks @codevinsky #1013)
Phaser.Utils.setProperty will set an Objects property regardless of depth (thanks @codevinsky #1013)
Phaser.Utils.getProperty will get an Objects property regardless of depth (thanks @codevinsky #1013)
2014-07-18 11:52:39 +01:00
Richard Davey
3da788bd1d Merge pull request #1013 from codevinsky/group-checkall
added: Phaser.Utils.getProperty / Phaser.Utils.setProperty; added: Phase...
2014-07-18 11:37:38 +01:00
Johan Rosén
ba62326ce7 OritentationSprite fix, not using PIXI.TextureCache anymore 2014-07-16 17:07:53 +02:00
Darek Zieliński
64ae6c6ba7 "Reuse a single Point object rather than creating a new one each time" 2014-07-15 18:32:20 +02:00
Richard Davey
afb379f2dd Merge pull request #1024 from lucbloom/if-onShutDownCallback
Add a check around this optional function
2014-07-15 16:21:35 +01:00
photonstorm
538425193a World.wrap when using the bounds of the object wouldn't adjust the bounds correctly, meaning wrapping outside the camera failed (thanks @jackrugile #1020) 2014-07-15 14:22:24 +01:00
Richard Davey
f77b4d4e8f Merge pull request #1014 from Dumtard/dev
Group create was not creating with p2 debug flag
2014-07-15 12:39:53 +01:00
Luc Bloom
f1cb146c10 Add a check around an optional function
My game crashes here if I update phaser.js to a new version. It happens
when my game switches to another State object.
2014-07-15 13:02:44 +02:00
photonstorm
f78a527ad5 Prevented objects with pixel perfect checks from over-riding other higher priority ID items (#983)
Rebuilt the way items are polled for Pointer events (drag, click, move). Now faster and more efficient, especially when some items in the stack require pixel perfect checks.
2014-07-15 11:20:57 +01:00
devinb83
4a632ed3a0 codePaused should be set if manually called
If pause is called manually, codePaused should be set regardless of whether the game is currently paused or not. This would fix issues where a developer might not want the game to automatically resume when the screen regains focus.
2014-07-14 12:57:37 -07:00
Darek Zieliński
852054b772 Plus validation of non-point objects 2014-07-14 20:09:22 +02:00
Charles Black
7107d73188 group create with p2 debug 2014-07-14 14:05:44 -04:00
Darek Zieliński
ee1df55d84 Added position Point object for quick x/y coordinates access. 2014-07-14 20:03:34 +02:00
jdowell
aad74ff4d5 added: Phaser.Utils.getProperty / Phaser.Utils.setProperty; added: Phaser.Group.checkAll
Added deep-property getting and setting via strings:

Phaser.Util.getProperty(someObj, 'foo.bar.baz');

Phaser.Util.setProperty(someObj, 'foo.bar.baz', 'lol');

Added a "checkAll" method to Phaser.Group that returns true/false if all of the children's given properties match the value passed in.

this.someGroup.checkAll('foo.bar.baz', 'lol'); // will return true if child[n].foo.bar.baz === 'lol'

Comes with standard 'force' ability.
2014-07-14 12:33:13 -05:00
photonstorm
2c421d27ce GameObjectFactory.spriteBatch now lets you specify null as a parameter for the parent and automatically adds the batch to game.world as a result. Also fixed jsdocs issues (@petarov #1000) 2014-07-14 12:56:05 +01:00
photonstorm
74679922d1 Debug.preUpdate was still being called in the Game Loop even if enableDebug was set to false (thanks @qdrj, #995) 2014-07-11 11:52:48 +01:00
photonstorm
d11d8051b1 You can now prevent the Debug class from being created or booted by using the Game configuration setting: enableDebug. By default it is true, set to false to prevent the class from being created. Please note you are responsible for checking if this class exists before calling it, but you can do that via if (game.debug) { ... } (request #984) 2014-07-10 10:46:18 +01:00
photonstorm
a182598c65 Using a Game configuration object you can now specify the value of the preserveDrawingBuffer flag for the WebGL renderer. By default this is disabled for performance reasons. But if you need to be able to take screen shots of your WebGL games using toDataUrl on the game canvas then you'll need to set this to true (#987) 2014-07-10 10:46:18 +01:00
jackrugile
42df8356e7 Added options to disable horizontal and vertical world wrapping individually 2014-07-10 00:05:50 -06:00
photonstorm
a70a938505 docs fix 2014-07-09 05:38:59 +01:00