There are a bunch of signals added for Sprites; more when input is
enabled. However, very few of these signals are ever actually used. While
the previous performance update related to Signals addressed the size of
each Signal object, this update is to reduce the number of Signal objects
as used by the Events type.
As a comparison the "Particle: Random Sprite" demo creates 3200+ Signals;
with this change there less than 70 signals created when running the same
demo. (Each Event creates at 8 signals by default, and there is an Event
for each of the 400 particles.) While this is an idealized scenario, a
huge amount (of albeit small) object reduction should be expected.
It does this by creating a signal proxy property getter and a signal
dispatch proxy. When the event property (eg. `onEvent`) is accessed a new
Signal object is created (and cached in `_onEvent`) as required. This
ensures that no user code has to perform an existance-check on the event
property first: it just continues to use the signal property as normal.
When the Phaser game code needs to dispatch the event it uses
`event.onEvent$dispath(..)` instead of `event.onEvent.dispatch(..)`. This
special auto-generated method automatically takes care of checking for if
the Signal has been created and only dispatches the event if this is the
case. (If the game code used the `onEvent` property itself the event
deferal approach would be defeated.)
This approach is designed to require minimal changes, not negatively
affect performance, and reduce the number of Signal objects and
corresponding Signal/Event resource usage.
The only known user-code change is that code can add to signal (eg.
onInput) events even when input is not enabled - this will allow some
previously invalid code run without throwing an exception.
- 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}
The substraction of `physicsElapsedMS` needs to be done for all individual
updates. (When current FPS ~ target FPS this is a 1-1 mapping, but catchup
updates can throw off the calculations.)
Also renamed `Game#updateNumber` (a poor initial name on my part) to
`currentUpdateID`. This matches the naming of
`Stage#currentRenderOrderID`.
- Changed `count` from 0d9678e512 to
`updateNumber` and expanded documentation; also moved primary usage back
to local variable.
- Added `updatesThisFrame` which allows (logic) code to detect if it is
the last update, or if there are pending updates the same frame. While
it could be adventageous in certain cases it will be problematic if such
update logic relies in the supplied delta time, as such should change if
fixed-timing is deviated from or extended updates are done.
- Formatting and documentation.
There are a fair amount of Signal objects created. In the current
implementation these are somewhat "fat" objects for two reasons:
- A closure / ad-hoc `dispatch` is created for each new Signal - this
increases the retained size by 138+ bytes/Signal in Chrome.
- There are a number of instance variables that never change from their
default value, and the bindings array is always created, even if never
used.
This change "lightens" the Signals such that there is significantly less
penalty for having many (unusued) signals.
As an example of how much this _does_ play a role, in the "Random Sprite"
demo ~2000 Signals are created, with only 12 of these signals being
subscribed to. This results in a shallow size of ~300K and a retained size
of ~600K (which is almost as much memory as required by the
Sprites/Sprites themselves!) for .. nothing.
With these changes the shallow and retained sizes are less than 50K each -
and this is with only ~200 sprites!
This change addresses these issues by
- Changing it so there is _no_ `dispatch` closure created. This is a
_breaking change_ (although there is no usage of such in core where it
breaks); the code referenced "#24", but no such issue could be found on
github.
In the rare case that code needs to obtain a dispatch-closure, the
`boundDispatch` property can be used to trivially obtain a (cached)
closure.
- The properties and default values are moved into the prototype; and the
`_bindings` array creation is deferred. This change, coupled with the
removal of the automatic closure, results in a very lightweight
~24bytes/object (in Chrome) for unbound signals.
This is minor breaking change, as per the removal of the automatic
closure; but no such need/usage was found in the core. (There may be cases
in the examples, which were not checked.)
If merely opting for the array creation delay and keeping the default
properties in the prototype the shallow size is still halved; less
significant but still a consideration.
This de-optimization occurred between 2.0.7 and 2.1.0 and is currently
present through dev.
`Group.forEach`, which is used by QuadTree, had an extreme de-optimization
in assigning to `arguments` - _CPU profiling showed as much as 50% of the
time was used by Group.forEach_ (after the correction it is not
registered) due to this de-optimization making the "When Particles
Collide" demo run with an unsatisfactory performance, even on a Desktop.
The fix uses a separate array and push (which is optimizable; the previous
implementation was not optimizable in Chrome, FF, or IE!).
This also fixes usages of `slice(arguments,..); ushift` elsewhere in
Group, using the same convention. It applies the same update for `iterate`
as does https://github.com/photonstorm/phaser/pull/1353 so it can also
accept null/undefined for `args` from the invoking functions.
Update iterate documentation to cover usage of `args` and added a guard so
that the callback can be used without requiring that `args` is specified.
Ref. https://github.com/photonstorm/phaser/issues/1352
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
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..)
"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
- Added `onFullScreenInit` signal which is the correct place for a client
to alter the FS target element, such as to set a background color or add
a CSS class.
- Increased documentation overview and specificity including expected
Parent behavior, sizing calculations, and when `refresh` may be required.
- Grouped documentation for scale modes (in 'scaleMode')
- Separated out internal/deprecated `setScreenSize` method from
`updateLayout`.
There are no known breaking changes.
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
- 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
- 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>
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
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
- 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.
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.
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.
- 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`
- 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
- 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
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
- 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
- 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
- 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)`.
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.
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.
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.
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.
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.
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)
Input.Gamepad.destroy now destroys all connected SinglePads and clears event listeners.
SinglePad.destroy now clears all associated GamepadButton objects and signals.
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)
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.
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)
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.
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.
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.
Group.sendToBack (and consequently Sprite.sendToBack) no longer removes the child from the InputManager if enabled.
Group.add has a new optional boolean parameter: `silent`. If set to `true` the child will not dispatch its `onAddedToGroup` event.
Group.addAt has a new optional boolean parameter: `silent`. If set to `true` the child will not dispatch its `onAddedToGroup` event.
Group.remove has a new optional boolean parameter: `silent`. If set to `true` the child will not dispatch its `onRemovedFromGroup` event.
Group.removeBetween has a new optional boolean parameter: `silent`. If set to `true` the children will not dispatch their `onRemovedFromGroup` events.
Group.removeAll has a new optional boolean parameter: `silent`. If set to `true` the children will not dispatch their `onRemovedFromGroup` events.
Internal child movements in Group (such as bringToTop) now uses the new `silent` parameter to avoid the child emitting incorrect Group addition and deletion events.
Pointer.withinGame is now accurate based on game scale and updated as the Pointer moves.
Stage.bounds is now updated if the game canvas offset changes position. Note that it gives the un-scaled game dimensions.
P2.Body.applyForce should have used pxmi instead of pxm (thanks @Trufi, fix#776)
P2 fixed creation of RevoluteConstraint by passing maxForce in the options (thanks @woutercommandeur, fix#783)
Input and Pointer now use the new ArrayList instead of a LinkedList, which resolve list item removable during callback issues.
Input.reset no longer resets every interactive item it knows of, because they are removed during the destroy phase and can now persist between States if needed.
Game checks if window.console exists before using it (should fix IE9 issues when dev tools are closed), however it is still used deeper in Pixi.
Body.loadData flagged as deprecated.
InputHandler._setHandCursor private var wasn't properly set, meaning the hand cursor could sometimes remain (during destroy sequence for example)
All Game Objects have a new property: destroyPhase (boolean) which is true if the object is in the process of being destroyed, otherwise false.
The PIXI.AbstractFilter is now included in the Phaser Pixi build by default, allowing for easier use of external Pixi Filters.
World.shutdown now removes all children iteratively, calling destroy on each one, ultimately performing a soft reset of the World.
Objects with a scale.x or y of 0 are no longer considered valid for input (fix#602)
InputHandler will set the browser pointer back to default if destroyed while over (fix#602)
Group.destroy has a new parameter: `soft`. A soft destruction won't remove the Group from its parent or null game references. Default is `false`.
InputHandler.validForInput is a new method that checks if the handler and its owner should be considered for Pointer input handling or not.
Group.replace will now return the old child, the one that was replaced in the Group.