Commit graph

63 commits

Author SHA1 Message Date
photonstorm
244372384e When an Animation completes playback and isn't set to loop it would change the currentFrame property to be the first frame in the set after the onComplete callback had fired. This meant if you set a Sprite to a new frame within an Animation onComplete callback then your change would have been overwritten by the animation itself. This is now no longer the case. 2015-03-24 23:17:13 +00:00
Paul
6225bb0e94 Animation - guard around destroy
- Allows sprites (and/or the animation) to be destroyed from within
  the onUpdate, onLoop, or onComplete events
2015-03-22 17:01:37 -07:00
photonstorm
a69e53f901 Copyright date change. 2015-02-25 03:36:23 +00:00
photonstorm
8d71e8a32c Animation.update skips ahead frames when the system is lagging, however it failed to set the animation to the final frame in the sequence if the animation skipped ahead too far (thanks @richpixel #1628) 2015-02-22 19:26:56 +00:00
photonstorm
823997744b Docs update. 2015-02-10 14:53:55 +00:00
Richard Davey
81f356c235 Merge pull request #1386 from pnstickne/wip-docs-1130
Assorted documentation/consistency updates
2014-12-01 12:07:10 +00:00
Paul
d15037e283 Event-Signal object count optimization
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.
2014-11-30 21:39:25 -08:00
Paul
dab8772de0 Documentation - consistency updates
- Updated `readOnly` doclet to `readonly`

- `array` refined to `type[]`, where such information was immediately
determinable.

- Updated {Any}/{*} to {any}; {...*} is standard exception

- Udated {Object} to {object}
2014-11-30 04:03:35 -08:00
photonstorm
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
59b25ab6bb Animation.setFrame used the wrong frames array if useLocalFrameIndex was false and a numeric frame ID was given (thanks @Skeptron #1284) 2014-11-02 11:04:03 +00:00
Bobby Wilson
42f53d6266 Merge commit '0482684dc864869397031994f7ba7d9f81721763' of https://github.com/bobbywilson0/phaser into dev 2014-10-10 22:01:34 -06:00
Bobby Wilson
0482684dc8 changed all typeof comparisons from == to === 2014-10-10 21:52:06 -06:00
photonstorm
022d7094d5 jsdoc fixes and frameRate change. 2014-10-10 14:49:01 +01:00
photonstorm
20551f9129 Lots of jsdocs fixes ready for the new doc generator. 2014-09-16 17:35:08 +01:00
Richard Davey
15a0ae6b4f jsdoc fix 2014-09-16 00:28:09 +01:00
photonstorm
32119e9892 Animation.onUpdate is a new event that is dispatched each time the animation frame changes. Due to its intensive nature it is disabled by default. Enable it with Animation.enableUpdate = true (#902) 2014-08-29 14:30:44 +01:00
Luc Bloom
ccd4b502d7 Fram data guards
Sometimes, this._frameData is null. Guard agains it.
Sometimes, we transfer to an animation that contains lesser frames.
Guard against it.
2014-07-16 12:00:30 +02:00
photonstorm
90eec97707 Animation.updateFrameData allows you to load a new FrameData object into an existing animation, even if currently running (based on #1029)
AnimationManager.loadFrameData will now update all existing Animations to use the newly loaded FrameData (based on #1029)
2014-07-16 00:55:12 +01:00
photonstorm
14109aeeb1 Animation.next will advance to the next frame in the animation, even if it's not currently playing. You can optionally define the number of frames to advance, but the default is 1. This is also aliased from the AnimationManager, so you can do Sprite.animations.next().
Animation.previous will rewind to the previous frame in the animation, even if it's not currently playing. You can optionally define the number of frames to rewind, but the default is 1. This is also aliased from the AnimationManager, so you can do `Sprite.animations.previous()`.
2014-07-03 16:23:36 +01:00
photonstorm
7c7d9153e6 Sprite.crop (and Image.crop) has been completely overhauled. You can now crop animated sprites (sprite sheet and texture atlas), you can define the x/y crop offset and the crop rectangle is exposed in the Sprite.cropRect property.
Sprite.updateCrop is available if you wish to update an externally referenced crop rectangle.
Sprites and Images now have their own textures objects, they are no longer references to those stored in the global Pixi.TextureCache. This allows you to redefine the texture frame dynamically without messing up any other Sprites in your game, such as via cropping. They still share global Base Textures, so image references are kept to a minimum.
Sprite.resetFrame will revert the Sprites texture frame back to its defaults dimensions. This is called when you call Sprite.crop with no rectangle, to reset the crop effect, but can be userful in other situations so we've left it as a public method.
2014-06-10 23:37:33 +01:00
photonstorm
622978fa77 Finally managed to get crop x/y/width/height working across all texture types. Needs optimising for the trim rect, but works. 2014-06-06 04:12:16 +01:00
photonstorm
b63900f669 Testing frame crop support. 2014-06-05 02:33:29 +01:00
photonstorm
b32312dca5 Animation.setFrame allows you to set the animation to a specific frame (thanks @adamholdenyall, #706) 2014-04-28 23:35:08 +01:00
photonstorm
f24622191d Small jsdoc fix. 2014-04-20 10:47:09 +01:00
Georgios Kaleadis
41095c2933 change order in destroy method, first clear references then null all values 2014-04-17 13:16:24 +02:00
photonstorm
563e581049 Tidied up jsdoc blocks. 2014-04-15 00:57:35 +01:00
photonstorm
5d0ea6453b AnimationManager.destroy now iterates through child animations calling destroy on all of them, avoiding a memory leak (thanks stauzs)
Animation.destroy didn't correctly clear the onStart, onLoop and onComplete signals.
2014-04-14 22:53:05 +01:00
Christian Wesselhoeft
9faa27ce4f Fix jshint issues in src/animation 2014-03-25 14:56:05 -07:00
Christian Wesselhoeft
61f18b675c Trim trailing whitespace. 2014-03-25 14:56:04 -07:00
photonstorm
22b1ce9b9d Added Phasers new Physics Manager and restored the pre-1.1.4 ArcadePhysics system. The new manager can handle multiple physics systems running in parallel, which could be extremely useful for lots of games. 2014-03-05 02:36:08 +00:00
photonstorm
833960b3c8 Animation.looped has been renamed to Animation.loop. It's a boolean you can toggle at run-time to turn on/off animation looping.
A single Animation object now has 3 new events: onStart, onLoop and onComplete.
Animation.loopCount holds the number of times the animation has looped since it last started.
Animation.stop has a new parameter: dispatchComplete. If true it'll dispatch an Animation.onComplete event.
2014-03-03 16:05:55 +00:00
photonstorm
8dc28f4800 Animation.speed added. You can now change the animation speed on the fly, without re-starting the animation (feature request #458) 2014-02-28 04:32:12 +00:00
photonstorm
beaac18b8f Active animations now monitor if the game pauses, and resume normally when the game un-pauses (fixes #179) 2014-02-24 23:06:45 +00:00
photonstorm
cf3796d60c Phaser.Animation.frame now returns the frame of the current animation, rather than the global frame from the sprite sheet / atlas (fix #466) 2014-02-21 10:31:17 +00:00
photonstorm
35e4c03bad TileSprites are now much more tidy and can run from a frame in a texture. They can also be animated. New TileSprite.autoScroll function added. 2014-02-13 23:13:10 +00:00
photonstorm
0896c2fac7 Updating copyright year and README. 2014-02-05 16:54:59 +00:00
photonstorm
ce4cf531d4 Added class constructors, fixed Stripshader, added relative Tween example and updated Tween source. 2013-12-30 16:54:00 +00:00
photonstorm
fdbdd81b7b Updated some docs, added the new renderHidden parameter for Canvas and updated the RenderTexture examples as a result. 2013-12-27 00:26:21 +00:00
photonstorm
d30e2974c4 Updated JSHint configuration, README and started working through source files against JSHint. 2013-11-24 12:51:20 +00:00
photonstorm
46cf024a35 filter test updates 2013-11-09 02:16:52 +00:00
photonstorm
7ceb11ae49 New: You'll now find a complete Basic project Template in the resources/Project Templates folder. Will add more complex ones soon. 2013-10-28 23:29:34 +00:00
photonstorm
a6fac64248 Loads of issues reported on Github resolved (sprite crop, music resume, etc). 2013-10-24 04:27:28 +01:00
photonstorm
f10f9324ad Animation.killOnComplete added and fixed a few issues in the Tanks game. 2013-10-09 13:36:57 +01:00
Richard Davey
96da57cac0 Fixed up the namespace in the documentation and finished off all sections other than Game Objects and Physics (yuck). 2013-10-03 02:38:35 +01:00
Richard Davey
852e82d0ca More docs. 2013-10-02 12:11:22 +01:00
Richard Davey
e5b1faace6 Preparing more documentation. 2013-10-02 01:16:40 +01:00
Richard Davey
9b4b267e7a Working through building the docs. 2013-10-01 16:15:45 +01:00
Richard Davey
305b12d76b Adding docs. 2013-10-01 15:01:46 +01:00
XekeDeath
62b5aa9bd9 Removed redundant assignment. 2013-09-30 13:28:17 +10:00
XekeDeath
ce3e1708e0 Merge branch 'dev' of https://github.com/XekeDeath/phaser into dev 2013-09-30 13:04:29 +10:00