Commit graph

79 commits

Author SHA1 Message Date
gotenxds
d4636e9e81 Added a reverseOnce method. 2016-05-27 17:58:54 +03:00
gotenxds
b0c4f3bc4c Added a convenient function. 2016-05-27 17:48:06 +03:00
gotenxds
bb7cbb36f6 If animation is reversed it should start from last frame. 2016-05-27 17:43:36 +03:00
John Doe
11805b311d Added a reverse functionality to animations. 2016-05-27 02:24:23 +03:00
photonstorm
f40cfbe2ae 2015 - 2016. 2016-04-04 22:16:16 +01:00
Richard Davey
ded2f72768 Docs update #2243 2016-02-02 23:04:54 +00:00
photonstorm
ddbc72cbf4 Docs update #2265 2016-02-02 16:26:20 +00:00
photonstorm
832034af94 Typo fix. 2015-09-23 14:04:04 +01:00
Richard Davey
af194d447c jsdoc fix #2049 2015-08-31 10:57:54 +01:00
photonstorm
f15fe6706c All undefined argument checks were changed from if (typeof x === 'undefined') to if (x === undefined) removing the typeof check and saving some bytes across the codebase in the process. 2015-07-22 10:37:15 +01:00
photonstorm
f41f806b99 Fixed issue with looped animations skipping last frame (or getting stuck on a single frame in 2 frame anims) 2015-07-14 13:47:25 +01:00
photonstorm
7c9db8f632 jshint fixes. 2015-05-18 13:36:22 +01:00
photonstorm
2e6af02f86 AnimationManager.add no longer sets the currentFrame property when just adding an Animation to a Sprite. The currentFrame property is now only set when the animation begins playing. This avoids the Sprite.frame and Sprite.frameName properties from returning incorrect results after adding (but not playing) an Animation. It also allows very short animations (2 frames) to play correctly without needing to loop. 2015-05-18 12:55:48 +01:00
photonstorm
3d75902a67 Removed all calls to TilingTexture because it's now handled in the setFrame component. 2015-04-21 15:55:40 +01:00
photonstorm
8981e9603e Removed Frame.uuid and updating TileSprite to work with animated sprites. 2015-04-21 05:11:19 +01:00
photonstorm
aa13ec0165 Animation.play wouldn't correctly set the play state on the Game Objects AnimationManager causing the animation to fail to start (calling AnimationManager.play did work however), now they're both consistently working. 2015-03-25 03:59:36 +00:00
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