Commit graph

3089 commits

Author SHA1 Message Date
photonstorm
7de47fd80a Template update. 2014-11-25 00:24:29 +00:00
photonstorm
1a313415e3 Tidying up. 2014-11-25 00:24:29 +00:00
photonstorm
04160c31b0 Moved docgen into the Resources folder. 2014-11-25 00:24:29 +00:00
photonstorm
f8a1632450 Grunt task updates. 2014-11-25 00:24:28 +00:00
photonstorm
c4b81ff6ea jsdoc fixes. 2014-11-25 00:24:28 +00:00
photonstorm
0e73a6428a RC11. 2014-11-25 00:24:28 +00:00
photonstorm
2579a67d78 RequireJS Template fix. 2014-11-25 00:24:28 +00:00
Richard Davey
6247a19180 Merge pull request #1360 from clark-stevenson/dev
Definition Updates
2014-11-24 16:08:12 +00:00
Clark Stevenson
3c860a4ad5 Definition Updates 2014-11-24 15:53:47 +00:00
Richard Davey
386c6df4fc Merge pull request #1359 from pnstickne/wip-optimize-signal
Signal - memory optimization / reductions
2014-11-24 13:35:29 +00:00
photonstorm
5b757eaee7 jshint fix 2014-11-24 13:15:38 +00:00
Paul
e62442bcb7 Signal - memory optimization / reductions
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.
2014-11-24 04:55:29 -08:00
photonstorm
2d50334cd3 Updated lifeSpan to use elapsedMS instead. 2014-11-24 12:54:39 +00:00
photonstorm
aa62eb94fc Added Time.elapsedMS (as Time.elapsed isn't always an ms value) 2014-11-24 12:54:27 +00:00
photonstorm
06b2a2c6a0 Added Tween.generateData back in, now all the Particles and Tween examples work properly. 2014-11-24 12:34:42 +00:00
photonstorm
af8167258e Moving doc build to grunt. 2014-11-24 11:12:09 +00:00
photonstorm
4ecd7f99a8 Docs update. 2014-11-24 11:12:09 +00:00
Richard Davey
c2a4a7b3f8 Merge pull request #1357 from pnstickne/wip-optimize-group2
Group - fix extreme 'forEach' de-optimization
2014-11-24 10:56:58 +00:00
Paul
beeda75ff5 Signal - object optimizations
Optimizing object creation, mainly of the backing array in situations when
there is no backing array.
2014-11-24 02:43:56 -08:00
Paul
859e8f9f07 Group - fix extreme 'forEach' de-optimization
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.
2014-11-24 01:55:16 -08:00
photonstorm
0ff7fbbe42 Merged latest Pixi fixes. 2014-11-23 12:47:55 +00:00
photonstorm
1928427bcb Phaser TypeScript defs fixes. 2014-11-23 11:32:13 +00:00
Paul
68f436ace8 Group - additional documentation refinement
General tidying/corrections of Group documentation.
2014-11-22 01:29:19 -08:00
Paul
946bb19dd7 Group - 'iterate' documentation and guard
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
2014-11-22 00:55:52 -08:00
photonstorm
874f60c1bc Removed CocoonJS hack - woohoo! 2014-11-21 10:40:18 +00:00
photonstorm
69b57073f2 Added missing duration parameter. 2014-11-20 21:19:09 +00:00
photonstorm
7e4a494f13 Keyboard.justPressed has bee renamed to Keyboard.downDuration which is a much clearer name for what the method actually does.
Keyboard.justReleased has bee renamed to Keyboard.upDuration which is a much clearer name for what the method actually does.
Keyboard.downDuration, Keyboard.upDuration and Keyboard.isDown now all return `null` if the Key wasn't found in the local keys array.
2014-11-20 20:55:51 +00:00
photonstorm
88ea3412dc Fixes issue where Tween.from didn't set the target properties until after the delay was up. 2014-11-20 20:42:10 +00:00
Richard Davey
ca3ecd796e Merge pull request #1346 from pnstickne/wip-scalemanager-windowbounds2
ScaleManager + DOM - window constraint updates
2014-11-20 20:34:24 +00:00
Richard Davey
dab26a65fa Merge pull request #1349 from neurofuzzy/patch-1
Keyboard.js does not reflect Phaser.Key changes
2014-11-20 20:33:44 +00:00
Geoff Gaudreault
dbde5ee913 Keyboard.js does not reflect Phaser.Key changes
Calling justPressed or justReleased on Phaser.Keyboard throws an exception. Changed to reflect new method names in Phaser.Key

I imagine you'd want these methods renamed as well, but it appears to be called by a few other classes and I didn't want a huge pull-request.
2014-11-20 11:23:43 -08:00
photonstorm
c909c29935 Undefined fix #1347 2014-11-20 10:00:08 +00:00
photonstorm
2589000435 Tweens have been completely rewritten. They're now much more flexible and efficient than before:
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
2014-11-20 06:06:26 +00:00
photonstorm
a952cd398d Final new tween system is in place (just generateData left to do). 2014-11-20 05:26:50 +00:00
photonstorm
2a7c0058e6 Tidied up code formatting. 2014-11-20 05:26:50 +00:00
photonstorm
a34824c5a3 Planning new vStart cache. 2014-11-20 05:26:50 +00:00
photonstorm
64cf3a6f5b repeatAll and loop support added back in. 2014-11-20 05:26:49 +00:00
photonstorm
4220382376 Evolving the Tween engine. TweenMax string syntax now supported. 2014-11-20 05:26:49 +00:00
photonstorm
ab114cc4a1 The start of TweenData. 2014-11-20 05:26:49 +00: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
Richard Davey
babb8687c8 Merge pull request #1345 from clark-stevenson/dev
Definition Updates
2014-11-19 10:29:17 +00:00
photonstorm
aa72cf63c1 Emitter.setScale fixed minX minY order presedence (thanks spayton) 2014-11-18 15:38:08 +00:00
Clark Stevenson
1f39f7e3ec Definition Updates 2014-11-18 12:54:07 +00:00
photonstorm
07d43934c6 Docs update. 2014-11-18 12:43:26 +00:00
photonstorm
8e109b072a Updated RC version. 2014-11-18 12:36:35 +00:00
photonstorm
1d2b36fa1b Camera.preUpdate. 2014-11-18 12:36:25 +00:00
photonstorm
395171b660 Added renderable check to Pixi.Sprite. 2014-11-18 12:36:11 +00:00
photonstorm
683f1a3a10 Tiny bit of tidying up. 2014-11-18 12:30:14 +00:00
photonstorm
21479acd8e Sprite.autoCull now properly works if the camera moves around the world.
Sprite.inCamera uses a much faster check if auto culling or world bounds checks are enabled and properly adjusts for camera position.
2014-11-18 12:29:55 +00:00
Clark Stevenson
423342afd0 Merge remote-tracking branch 'clark/dev' into dev 2014-11-18 11:43:06 +00:00