Commit graph

281 commits

Author SHA1 Message Date
photonstorm
9a83ddcab9 Updated to latest Creature runtimes, added to GameObjectFactory. 2015-07-23 13:25:08 +01:00
jamesgroat
10587e07ee Use _cacheMap to map from constant to _cache. 2015-07-22 16:53:07 -07:00
photonstorm
858ad51610 Phaser 2.4 release. 2015-07-22 15:31:30 +01:00
photonstorm
ffaa7d711f Removed BaseTextureCache requirement from BitmapData.
Fixed jshint.
Updated TS defs.
2015-07-22 13:23:40 +01:00
photonstorm
8eb34f96ce WebGL context loss and restoration is now handled directly by Phaser.
Cache.clearGLTextures empties out all of the GL Textures from Images stored in the cache. This is called automatically when the WebGL context is lost and then restored.
2015-07-22 12:59:32 +01:00
photonstorm
f28bc82fe3 Fixed packfiles undefined path error. 2015-07-22 10:53:15 +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
bb6c5bbbdc Key added to TextureAtlas and SpriteSheet, fixing the 'undefined' key error in LoadTexture. 2015-07-20 12:00:37 +01:00
photonstorm
45944d689c Fix for #1914 2015-07-16 22:45:25 +01:00
Richard Davey
fcaa6cec68 Merge pull request #1912 from Feenposhleen/feature/fixing-json-fonts
Improving JSON BitmapText implementation
2015-07-16 15:37:09 +01:00
photonstorm
7271eb5e2d Removed un-needed cache arguments and fixed jshint error. 2015-07-16 14:58:51 +01:00
Charlo
795a7c80a8 Improving JSON BitmapText implementation 2015-07-16 13:30:55 +02:00
Richard Davey
9314c5a767 LoaderParser.bitmapFont, xmlBitmapFont and jsonBitmapFont all now return the font data rather than write it to the now deprecated PIXI global font cache. 2015-07-16 01:17:03 +01:00
Richard Davey
3c7293ab57 Updated AnimationParser and fixed LoadTexture calls. 2015-07-16 01:02:59 +01:00
Richard Davey
bab50d7c88 * The Cache has been internally refactored considerably. Image data is now all stored in the same object, rather than being split across the PIXI global caches (such as PIXI.TextureCache and PIXI.BaseTextureCache), which are no longer used by Phaser.
* Internally the Cache now uses a single _cache object, which is partitioned to store the various different object types. Before the cache used lots of private objects, one per data type, but it's now a lot cleaner and we've managed to cut out hundreds of lines of duplicate code in the process.
* Cache.getImage has a new argument which lets you return either just the HTML Image element or the entire image cache object, which includes the baseTexture and frame data.
* Cache.getImage will return a __default image if the key isn't given, or a __missing image if the key is given but not found in the cache. This means it will always return a valid image and no longer cause Phaser to throw runtime errors deeper down with invalid image objects.
2015-07-16 00:46:28 +01:00
Richard Davey
5e33a2ea92 TS defs updates for the Cache changes. 2015-07-15 23:22:51 +01:00
Richard Davey
6921b30d94 The Loader can now load external fragment shaders (.frag files) 2015-07-15 23:22:25 +01:00
Richard Davey
1f66cdbcb5 Lots of jsdoc updates and small fixes. 2015-07-15 21:52:19 +01:00
photonstorm
f52b553eaf Loads more Cache optimisations and tweaks. 2015-07-15 17:06:29 +01:00
photonstorm
d663d290c2 hasFrameData added and some LoadTexture updates. 2015-07-15 16:33:01 +01:00
photonstorm
8dd3e06747 Loads of Cache optimisations and updates. 2015-07-15 15:00:21 +01:00
Richard Davey
502dd548fb Loader.path is a string and if set it is placed before any _relative_ file path given to the Loader. For example: load.path = "images/sprites/"; followed by load.image("ball", "ball.png"); and load.image("tree", "level1/oaktree.png"); would load the ball file from images/sprites/ball.png and the tree from images/sprites/level1/oaktree.png. The path is added before the filename but *after* the Loader.baseURL. The path _must_ end with a "/". Set it to nothing to disable the path. 2015-07-12 23:43:35 +01:00
Richard Davey
d027bf8ba7 BitmapData.generateTexture will take a snapshot of the BitmapDatas canvas at that moment in time and convert it into an Image, which is then stored in the Phaser image Cache based on the key given. You can then use the new texture for any future sprites or texture based objects. 2015-07-09 00:19:07 +01:00
photonstorm
102c74e121 Deprecated the following:
* Camera.screenView
* ScaleManager.maxIterations
* ScaleManager.enterPortrait (see onOrientationChange)
* ScaleManager.enterLandscape (see onOrientationChange)
* ScaleManager.enterFullScreen (see onFullScreenChange)
* ScaleManager.leaveFullScreen (see onFullScreenChange)
* ScaleManager.fullScreenFailed (see onFullScreenError)
* ScaleManager.checkResize
* ScaleManager.checkOrientation
* ScaleManager.setScreenSize (see updateLayout)
* ScaleManager.setSize (see reflowCanvas)
* ScaleManager.checkOrientationState (see reflowCanvas)
* ScaleManager.orientation (see screenOrientation)
* Gamepad.disabled (see enabled)
* Input.currentPointers (see totalActivePointers)
* Input.disabled (see enabled)
* Keyboard.disabled (see enabled)
* Mouse.disabled (see enabled)
* Mouse.mouseMoveCallback (see Input.addMoveCallback)
* MSPointer.disabled (see enabled)
* Touch.disabled (see enabled)
* Cache.getUrl (see getURL)
* Math.truncate (see Math.trunc)
* Math.snapToInArray (see Phaser.ArrayUtils.findClosest)
* Math.interpolateFloat (see Math.linear)
* Math.normalizeLatitude (use Phaser.Math.clamp(lat, -90, 90))
* Math.normalizeLongitude (use Phaser.Math.wrap(lng, -180, 180))
* Math.chanceRoll (use Phaser.Utils.chanceRoll)
* Math.numberArray (use Phaser.ArrayUtils.numberArray)
* Math.numberArrayStep (use Phaser.ArrayUtils.numberArrayStep)
* Math.limitValue (use Phaser.Math.clamp)
* Math.randomSign (use Phaser.Utils.randomChoice(-1, 1))
* Math.angleLimit (use Phaser.Math.clamp)
* Math.getRandom (use Phaser.ArrayUtils.getRandomItem)
* Math.removeRandom (use Phaser.ArrayUtils.removeRandomItem)
* Math.floor (use Math.trunc)
* Math.ceil (use Phaser.Math.roundAwayFromZero)
* Math.shift (use Phaser.ArrayUtils.rotate)
* Math.shuffleArray (use Phaser.ArrayUtils.shuffle)
* Math.distanceRounded (do the rounding locally)
* Canvas.getOffset (see Phaser.DOM.getOffset)
* Canvas.getAspectRatio (see Phaser.DOM.getAspectRatio)
* TilemapLayer.tileColor (use TilemapLayer.debugSettings.missingImageFill)
* Phaser.ArrayList alias removed, now use Phaser.ArraySet
* Utils.transposeArray (see Phaser.ArrayUtils.transposeMatrix)
* Utils.rotateArray (see Phaser.ArrayUtils.rotateMatrix)
* Utils.shuffle (see Phaser.ArrayUtils.shuffle)
2015-06-17 03:14:31 +01:00
Richard Davey
a7a74550a5 Merge pull request #1837 from Feenposhleen/dev
JSON support for BitmapFont atlases
2015-06-17 01:49:23 +01:00
Richard Davey
560f98b40b Merge pull request #1828 from luckylooke/patch-2
docs: parameter description augmented
2015-06-17 01:41:25 +01:00
Richard Davey
8a750a1f1e Merge pull request #1777 from boniatillo-com/assetpack_audiosprite
Load audiosprite from asset pack
2015-06-16 16:43:06 +01:00
photonstorm
8de9e0c076 Fixed loadEvent argument. 2015-06-13 02:30:00 +01:00
photonstorm
7d308a2169 Added loadEvent parameter to Loader.video. 2015-06-12 19:19:43 +01:00
photonstorm
af42f5d4c9 Cache.getJSON has a new parameter: clone. If set it will return a clone of the object stored in the Cache rather than a reference to it. 2015-06-12 12:16:58 +01:00
Charlo
70428fd39c Fixed linting errors 2015-06-06 12:54:14 +02:00
Charlo
17a8116382 Added JSON support for BitmapFont 2015-06-06 12:35:08 +02:00
photonstorm
ed82097151 Removed un-necessary PIXI.TextureCache pollution in Phaser.LoaderParser.bitmapFont. 2015-06-03 05:28:23 +01:00
luckylooke
ee22bbbd05 docs: parameter description augmented
addTilemap 'url' parameter text augmented
2015-05-31 13:21:33 +02:00
photonstorm
621e51d949 Docs update about the lovely 48000 Hz music bug. 2015-05-23 03:37:04 +01:00
photonstorm
d2bcb3562b If transformUrl is given an invalid URL it returns false. 2015-05-19 14:19:24 +01:00
photonstorm
4fa99f52c5 jsdocs fix and video loader fallback for Firefox. 2015-05-14 23:23:22 +01:00
photonstorm
aabeccbdac Working but needs refining. 2015-05-14 19:10:36 +01:00
photonstorm
71b242386d Added video loadeddata callback for Firefox (which doesn't throw the canplay event until you actually start to play the video.. awesome, thanks Firefox) 2015-05-14 16:52:09 +01:00
photonstorm
45278a1816 Tidied up the video loader. 2015-05-05 16:25:30 +01:00
photonstorm
d8c109b0a2 Tidying comments. 2015-05-05 14:00:05 +01:00
photonstorm
afb162849a Docs update. 2015-05-04 03:00:03 +01:00
photonstorm
9ee0de9192 Cache.addVideo allows you to add a loaded video into the Phaser Cache. This is called automatically by the Phaser Loader, but may be invoked directly as well.
Cache.checkVideoKey allows you to check if a video is stored in the cache based on the given key.

Cache.getVideo allows you to extract a video from the Cache based on its key. The video element itself (or the Blob is loaded with asBlob true) will be found in the `data` property of the returned object.

Cache.removeVideo will remove a video from the Cache based on the given key.
2015-05-03 13:53:03 +01:00
photonstorm
77468e7876 Loader.video allows you to load a video file into Phaser. It works in the same way as Loader.audio, allowing you to pass an array of video files - and it will load the first one the device is capable of playing back. You can optionally load the video via xhr where the video data is converted to a Blob upon successful load. 2015-05-03 13:53:03 +01:00
Boniatillo.com
9017081ef6 Fix to #1776: load audiosprite from assetpack
The loader process the asset pack but use the method "audio" instead of
"audiosprite". The fix is to call "audiosprite" with the right
arguments.
2015-05-02 10:40:38 +02:00
photonstorm
4c0e34e788 jsdoc fixes. 2015-04-29 13:13:47 +01:00
photonstorm
c6e9d7cad3 Removing PIXI.TextureCache calls as no longer used. 2015-04-27 16:22:35 +01:00
photonstorm
30450cb9bc Loader.atlas and Cache.addTextureAtlas will now automatically determine the format of the JSON data (array or hash) when added to the Cache. You no longer need to specify it explicitly if JSON, only if XML. 2015-04-23 02:35:09 +01:00
photonstorm
6c96568dd1 Files can now be added to the Loader with an absolute URL even if you have a Loader.baseURL set. In previous versions the baseURL would still be prepended to the file URL, but the Loader now checks if the a file URL begins with http or // and skips prepending the baseURL to it.
All calls to Loader methods that add files to the queue, such as `Loader.image` or `Loader.atlas`, now have the URL as an optional parameter. If not set Loader will assume the URL to be based on the key given. For example the following: `game.load.image("boom", "boom.png")` can now be expressed as just `game.load.image("boom")`, or `game.load.atlas("player", "player.png", "player.json")` can now be shortened to `game.load.atlas("player")`. Please see the freshly updated jsdocs for full details.
2015-04-21 02:14:41 +01:00
photonstorm
0ffa499bd0 Removed getJSON parse parameter. It's already parsed :) 2015-04-13 22:06:57 +01:00
photonstorm
e5f1f6f896 Cache.getPixiTexture will return a PIXI.Texture from the cache based on the given key. A PIXI Texture is created automatically for all images loaded and added to the cache.
Cache.getPixiBaseTexture will return a PIXI.BaseTexture from the cache based on the given key. A PIXI BaseTexture is created automatically for all images loaded and added to the cache.

Cache.getTexture has now been removed (it was deprecated several versions ago). Use Cache.getRenderTexture instead.

Cache.getJSON has a new optional parameter: `parse`. If `true` the method will pass the data through JSON.parse before returning it. The default is `false` to retain backwards compatibility.
2015-04-13 20:25:42 +01:00
photonstorm
79ace60997 Added guard around the xhr onload try / catch block, so it doesn't incorrectly report errors as being from the Loader when they may have been throw by the create method. 2015-03-25 16:13:52 +00:00
photonstorm
506ff8843e Fixed incorrect use of this.response which broke Binary files with callbacks. Should be all of them caught now - ProTracker example now works again as a result too. 2015-03-23 10:52:43 +00:00
photonstorm
35a9bdcfc9 Fixed loading of physics json data (old responseText reference) 2015-03-23 10:46:38 +00:00
photonstorm
a190823dad jsdoc fix. 2015-03-23 08:13:59 +00:00
Paul
cc5d1d02e5 Loader: loading from pack data
- Corrected logic where packs added via data would still try to be loaded.
  This makes the behavior correct per the documentation and v2.2
2015-03-15 20:26:37 -07:00
photonstorm
a69e53f901 Copyright date change. 2015-02-25 03:36:23 +00:00
photonstorm
466a4d11bb Loader.preloadSprite had an extra guard added to ensure it didn't try to updateCrop a non-existent sprite (thanks @noidexe #1636) 2015-02-25 03:08:37 +00:00
Paul
3e5c1532d8 Fixed jsdoc-abort bug with "||" in jsdoc type
- jsdoc aborts on x||y found in types..
2015-02-22 20:51:00 -08:00
photonstorm
9879fc6387 If you load an image and provide a key that was already in-use in the Cache, then the old image is now destroyed (via Cache.removeImage) and the new image takes its place. 2015-02-18 16:58:08 +00:00
photonstorm
5967f01a49 jshint fix. 2015-02-11 16:57:24 +00:00
photonstorm
599bcf5f97 Loader.audiosprite has a new jsonData parameter. It allows you to pass a pre-existing JSON object (or a string which will be parsed as JSON) to use as the audiosprite data, instead of specifying a URL to a JSON file on the server (thanks @jounii #1447)
Loader.audiosprite has a new `autoDecode` parameter. If `true` the audio file will be decoded immediately upon load.
2015-02-11 16:16:58 +00:00
photonstorm
ea86bc85b4 jsdoc typo / spelling fixes.
Also all audio decoding is now passed to the SoundManager to handle, rather than duplicate the effort in the Loader.
2015-02-11 05:18:52 +00:00
photonstorm
cc7096b045 jsdoc fix #1543 2015-02-10 21:22:36 +00:00
photonstorm
0054dc996b The Loader now directly calls StateManager.loadComplete rather than the StateManager listening for the loadComplete event, because Loader.reset unbinds this event (and it's easy to accidentally remove it too)
Loader.onLoadComplete is dispatched *before* the Loader is reset. If you have a `create` method in your State please note that the Loader will have been reset before this method is called. This allows you to immediately re-use the Loader without having to first reset it manually.
2015-02-10 17:04:04 +00:00
photonstorm
c154b8c785 Loader.resetLocked is a boolean that allows you to control what happens when the loader is reset, *which happens automatically on a State change*. If you set resetLocked to true it allows you to populate the loader queue in one State, then swap to another State without having the queue erased, and start the load going from there. After the load has completed you could then disable the lock again as needed.
Loader.reset has a new optional 2nd parameter `clearEvents` which if set to `true` (the default is false) will reset all event listeners bound to the Loader.
2015-02-10 11:58:17 +00:00
photonstorm
c42954ae59 Condensed Cache.destroy method. 2015-02-09 20:27:58 +00:00
photonstorm
2cb9ea312b extension URL fix, jsdoc fix and small format changes. 2015-02-09 20:27:47 +00:00
Paul
367d976061 Loader: documentation
- Corrected some documentation wrt. parallel downloading
2015-02-08 20:40:54 -08:00
Paul
b63f6873e5 Loader: better audio selection
- Fixed bug where `.` in query portion of URI could throw off
  auto-detection
- Allow `Loader#audio` to accept `{uri..,type..}` objects to blobs (and
  data) URIs can also be used to auto-format detection / fallbacks.
2015-02-08 20:22:09 -08:00
Paul
86dc43874c Loader: enabled parallel-by-default
- Minor cleanup to parallel: enabled by default, limit of 4 (hard-limit
  max 12)
2015-02-08 19:42:34 -08:00
Paul
8d61441844 Merge remote-tracking branch 'upstream/dev' into wip-loader
- Added changes/support for 'blob:' uri's in upstream, extended to 'data:'
- Added upstream documentation
- Some small fixes for XHD from upstream

Conflicts:
	src/loader/Loader.js
2015-02-08 19:42:22 -08:00
Mark Wecke
3a70677a05 use XDomainRequest in Loader.xhrLoad 2015-02-06 13:52:24 +01:00
Richard Davey
41d9a42a02 Merge pull request #1565 from abtion/master
Fix CORS loading BitmapFonts with IE9
2015-02-03 21:14:45 +00:00
jeppester
b29d2b8b23 Missing semicolons added 2015-01-24 19:48:52 +01:00
jeppester
242e3cc7c3 Indentation errors fixed 2015-01-24 19:43:49 +01:00
jeppester
d7cd76efe7 More cosmetic changes 2015-01-24 18:36:58 +01:00
jeppester
a722293786 Cosmetic pull request preparations 2015-01-24 18:31:02 +01:00
jeppester
067dcc4332 Fix CORS loading BitmapFonts with IE9 2015-01-23 17:17:50 +01:00
photonstorm
48f590c180 Added tools links. 2015-01-10 00:30:13 +00:00
photonstorm
801f387f75 Updated docs. 2015-01-08 01:28:38 +00:00
aressler38
c9984633b5 fixing documentation typo 2014-12-15 14:12:09 -08:00
aressler38
f1bdd174b2 [ISSUE 1458] Allow BLOB urls when loading audio files 2014-12-15 12:57:30 -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
Paul
e8da5e73f8 Loader - IE9 XDR used for all XHR when requested
Previously XHD was special-cased for 'json' file assets, but not all JSON
requests. Now it is used for all XHR transfers when `useXDomainRequest` is
enabled.

If XDR is used outside of IE 9 then a warning is emitted to the console.
The `useXDomainRequest` property has also been deprecated

This may address consistency issues as mentioned in
https://github.com/photonstorm/phaser/issues/1361
2014-11-28 04:21:17 -08:00
Paul
6aa5d9ba90 Loader - prep/cleanups
- Cleaned up abnormal case handling
- Disabled parallel loading by default; it can be enabled with
  `enableParallel`.
- Minor quibbles
- Removed unused `dataLoadError`
2014-11-23 11:02:24 -08:00
Paul
d8227cdceb Loader - documentation
Additional documentation updates.
2014-11-22 20:57:42 -08:00
Paul
1062b7330e Loader - fix/update for getAssetIndex
Loaded/loading assets are skipped if they have been superceded. This makes
the behavior consistent with respect to `addToFileList`, if the queue is
inspected or modified while loading.
2014-11-22 17:42:12 -08:00
Paul
d94321702a Loader - corrected tag error handling 2014-11-22 15:09:07 -08:00
Paul
609d77faba Loader - added means to add synchronization points
- Added `withSyncPoint` and `addSyncPoint` methods to allow explicit
  adding of synchronization points (synchronization points are explained
  in `withSyncPoint`.

- Changed the file/asset `sync` attribute to `syncPoint` to reflect
  terminology.
2014-11-22 14:42:27 -08:00
Paul
a6116b3832 Loader - fixes
- `onLoadComplete` will fire, even when loading is interrupted
- Context default to `this` on application.
2014-11-22 13:55:32 -08:00
Paul
9995edbe3f Loader - documentation
Updated/corrected various documentation.
2014-11-22 13:53:51 -08:00
Paul
7889739485 Loader - added enabledParallelDownloads
Added method to enable/disable parallel downloading in general.
2014-11-22 13:49:18 -08:00
Paul
1c000949cb Loader - transformUrl
Pulled out baseURL extension into method.
2014-11-22 13:46:14 -08:00
Paul
7116d0716d Loader - fast image-from-cache path
Employee the use of image.complete and a width/height check to detect when
it is available "from cache" and skip having to run though the
onload/onerror cases.
2014-11-21 22:38:32 -08:00
Paul
b00c4ad222 Loader - state bug fixes
More updates for https://github.com/photonstorm/phaser/issues/1330

Fixed several issues with state clearing (or lack of) resulting in
incorrect behavior if the loader was re-used.
2014-11-21 12:06:44 -08:00
Paul
4d16af0e0f Loader - parallel loading
Parallel loading is now supported, configured by
`loader.concurrentRequestCount`. Each file (a pack is now considered a
type of file) asset can be marked with `sync`, which is done for both pack
files and script files.

When a `sync` asset is encountered it must be loaded before any previous
resource any following resource is loaded (but it doesn't have to wait for
previous resources). Pack files are an exception in that they can download
(but are not processed) and they can fetch-around other `sync` assets.

Because of the concurrent nature there is no guarantee of the order in
which the individual events will file in relation to eachother, but local
ordering (e.g. onFileError always before onFileComplete) and overall
ordering (e.g. onLoadStart .. onFile? .. onLoadComplete) is preserved.

There is also increased error hardening and a few previous edge-cases
fixed (and likely a few bugs added).
2014-11-21 10:58:00 -08:00
Paul
930fc46649 Loader 2014-11-20 17:51:30 -08:00
Utkarsh Upadhyay
b084f42aa8 Fix documentation for Cache.addPhysicsData
The comment referred to the incorrect method name (`addTilemap` instead of `addPhysicsData`).
2014-11-16 15:01:23 +01:00
photonstorm
7c9dfefc8f Loader resize handler. 2014-11-11 14:00:07 +00:00