2013-10-02 14:05:55 +00:00
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "utf-8" >
2014-11-15 20:01:46 +00:00
< title > Phaser Source: D:/wamp/www/phaser/src/loader/Loader.js< / title >
2013-10-02 14:05:55 +00:00
<!-- [if lt IE 9]>
< script src = "//html5shiv.googlecode.com/svn/trunk/html5.js" > < / script >
<![endif]-->
2014-11-15 20:01:46 +00:00
< link type = "text/css" rel = "stylesheet" href = "styles/default.css" >
2013-10-02 14:05:55 +00:00
< link type = "text/css" rel = "stylesheet" href = "styles/sunlight.default.css" >
< link type = "text/css" rel = "stylesheet" href = "styles/site.cerulean.css" >
< / head >
< body >
2014-11-25 00:23:44 +00:00
2013-10-02 14:05:55 +00:00
< div class = "container-fluid" >
< div class = "navbar navbar-fixed-top navbar-inverse" >
2014-11-25 00:23:44 +00:00
< div style = "position: absolute; width: 143px; height: 31px; right: 10px; top: 10px; z-index: 1050" > < a href = "http://phaser.io" > < img src = "img/phaser.png" border = "0" / > < / a > < / div >
2013-10-02 14:05:55 +00:00
< div class = "navbar-inner" >
2014-11-25 00:23:44 +00:00
< a class = "brand" href = "index.html" > Phaser API< / a >
2013-10-02 14:05:55 +00:00
< ul class = "nav" >
2014-11-25 00:23:44 +00:00
2013-10-02 14:05:55 +00:00
< li class = "dropdown" >
2013-10-03 01:38:35 +00:00
< a href = "namespaces.list.html" class = "dropdown-toggle" data-toggle = "dropdown" > Namespaces< b
2013-10-02 14:05:55 +00:00
class="caret">< / b > < / a >
< ul class = "dropdown-menu " >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-0" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.html" > Phaser< / a >
2013-10-02 14:05:55 +00:00
< / li >
2014-11-15 20:01:46 +00:00
< li class = "class-depth-0" >
< a href = "PIXI.html" > PIXI< / a >
< / li >
2013-10-02 14:05:55 +00:00
< / ul >
< / li >
< li class = "dropdown" >
< a href = "classes.list.html" class = "dropdown-toggle" data-toggle = "dropdown" > Classes< b
class="caret">< / b > < / a >
< ul class = "dropdown-menu " >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Animation.html" > Animation< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.AnimationManager.html" > AnimationManager< / a >
2013-10-02 14:05:55 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.AnimationParser.html" > AnimationParser< / a >
2013-10-02 14:05:55 +00:00
< / li >
2014-04-29 14:39:02 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.ArrayList.html" > ArrayList< / a >
< / li >
2014-11-25 00:23:44 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.ArraySet.html" > ArraySet< / a >
< / li >
2014-11-15 20:01:46 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.ArrayUtils.html" > ArrayUtils< / a >
< / li >
2014-10-09 15:12:53 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.AudioSprite.html" > AudioSprite< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.BitmapData.html" > BitmapData< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.BitmapText.html" > BitmapText< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.Button.html" > Button< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Cache.html" > Cache< / a >
2013-10-02 14:05:55 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Camera.html" > Camera< / a >
2013-10-02 14:05:55 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Canvas.html" > Canvas< / a >
2013-10-02 14:05:55 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Circle.html" > Circle< / a >
2013-10-02 14:05:55 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Color.html" > Color< / a >
2013-10-03 00:21:08 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Device.html" > Device< / a >
2013-10-02 14:05:55 +00:00
< / li >
2014-11-15 20:01:46 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.DOM.html" > DOM< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Easing.html" > Easing< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-18 03:01:51 +00:00
< a href = "Phaser.Ellipse.html" > Ellipse< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.Events.html" > Events< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.Filter.html" > Filter< / a >
< / li >
2014-09-09 14:36:56 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.FlexGrid.html" > FlexGrid< / a >
< / li >
< li class = "class-depth-1" >
< a href = "Phaser.FlexLayer.html" > FlexLayer< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Frame.html" > Frame< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.FrameData.html" > FrameData< / a >
2013-10-03 00:21:08 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Game.html" > Game< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-21 15:37:26 +00:00
< a href = "Phaser.GameObjectCreator.html" > GameObjectCreator< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.GameObjectFactory.html" > GameObjectFactory< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-05 06:29:17 +00:00
< a href = "Phaser.Gamepad.html" > Gamepad< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-05 06:29:17 +00:00
< a href = "Phaser.GamepadButton.html" > GamepadButton< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.Graphics.html" > Graphics< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Group.html" > Group< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-08 07:24:22 +00:00
< a href = "Phaser.Image.html" > Image< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Input.html" > Input< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.InputHandler.html" > InputHandler< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Key.html" > Key< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Keyboard.html" > Keyboard< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-05 06:29:17 +00:00
< a href = "Phaser.Line.html" > Line< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.LinkedList.html" > LinkedList< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Loader.html" > Loader< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.LoaderParser.html" > LoaderParser< / a >
2013-10-02 14:05:55 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Math.html" > Math< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Mouse.html" > Mouse< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.MSPointer.html" > MSPointer< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 19:18:24 +00:00
< a href = "Phaser.Net.html" > Net< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.Particle.html" > Particle< / a >
< / li >
< li class = "class-depth-1" >
2013-10-02 19:18:24 +00:00
< a href = "Phaser.Particles.html" > Particles< / a >
< / li >
2014-10-09 15:12:53 +00:00
< li class = "class-depth-2" >
< a href = "Phaser.Particles.Arcade.html" > Arcade< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2013-10-02 19:18:24 +00:00
< a href = "Phaser.Particles.Arcade.Emitter.html" > Emitter< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.Physics.html" > Physics< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-2" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.Physics.Arcade.html" > Arcade< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.Arcade.Body.html" > Body< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-2" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.Ninja.html" > Ninja< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.Ninja.AABB.html" > AABB< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.Ninja.Body.html" > Body< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.Ninja.Circle.html" > Circle< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.Ninja.Tile.html" > Tile< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-2" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.html" > P2< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.Body.html" > Body< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.BodyDebug.html" > BodyDebug< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.CollisionGroup.html" > CollisionGroup< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.ContactMaterial.html" > ContactMaterial< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.DistanceConstraint.html" > DistanceConstraint< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-11 12:09:28 +00:00
< li class = "class-depth-3" >
< a href = "Phaser.Physics.P2.FixtureList.html" > FixtureList< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.GearConstraint.html" > GearConstraint< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.InversePointProxy.html" > InversePointProxy< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.LockConstraint.html" > LockConstraint< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.Material.html" > Material< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.PointProxy.html" > PointProxy< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.PrismaticConstraint.html" > PrismaticConstraint< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.RevoluteConstraint.html" > RevoluteConstraint< / a >
< / li >
2014-09-09 14:36:56 +00:00
< li class = "class-depth-3" >
< a href = "Phaser.Physics.P2.RotationalSpring.html" > RotationalSpring< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.Spring.html" > Spring< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Plugin.html" > Plugin< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.PluginManager.html" > PluginManager< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Point.html" > Point< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Pointer.html" > Pointer< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-07 06:10:15 +00:00
< a href = "Phaser.Polygon.html" > Polygon< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.QuadTree.html" > QuadTree< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.RandomDataGenerator.html" > RandomDataGenerator< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Rectangle.html" > Rectangle< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.RenderTexture.html" > RenderTexture< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 00:21:08 +00:00
< a href = "Phaser.RequestAnimationFrame.html" > RequestAnimationFrame< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.RetroFont.html" > RetroFont< / a >
< / li >
2014-09-09 14:36:56 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.Rope.html" > Rope< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.ScaleManager.html" > ScaleManager< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Signal.html" > Signal< / a >
< / li >
2014-04-11 12:09:28 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.SignalBinding.html" > SignalBinding< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-05 06:29:17 +00:00
< a href = "Phaser.SinglePad.html" > SinglePad< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 00:21:08 +00:00
< a href = "Phaser.Sound.html" > Sound< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 00:21:08 +00:00
< a href = "Phaser.SoundManager.html" > SoundManager< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.Sprite.html" > Sprite< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-18 03:01:51 +00:00
< a href = "Phaser.SpriteBatch.html" > SpriteBatch< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Stage.html" > Stage< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.State.html" > State< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.StateManager.html" > StateManager< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.Text.html" > Text< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.Tile.html" > Tile< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.Tilemap.html" > Tilemap< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.TilemapLayer.html" > TilemapLayer< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.TilemapParser.html" > TilemapParser< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.Tileset.html" > Tileset< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.TileSprite.html" > TileSprite< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Time.html" > Time< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.Timer.html" > Timer< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-05 06:29:17 +00:00
< a href = "Phaser.TimerEvent.html" > TimerEvent< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.Touch.html" > Touch< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Tween.html" > Tween< / a >
< / li >
2014-11-25 00:23:44 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.TweenData.html" > TweenData< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.TweenManager.html" > TweenManager< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Utils.html" > Utils< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-2" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Utils.Debug.html" > Debug< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-02 14:05:55 +00:00
< a href = "Phaser.World.html" > World< / a >
< / li >
2014-11-15 20:01:46 +00:00
< li class = "class-depth-1" >
< a href = "PIXI.AbstractFilter.html" > AbstractFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.AjaxRequest.html" > AjaxRequest< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.AlphaMaskFilter.html" > AlphaMaskFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.AsciiFilter.html" > AsciiFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.AssetLoader.html" > AssetLoader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.AtlasLoader.html" > AtlasLoader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.BaseTexture.html" > BaseTexture< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.BitmapFontLoader.html" > BitmapFontLoader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.BitmapText.html" > BitmapText< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.BlurFilter.html" > BlurFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.BlurXFilter.html" > BlurXFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.BlurYFilter.html" > BlurYFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.CanvasBuffer.html" > CanvasBuffer< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.CanvasGraphics.html" > CanvasGraphics< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.CanvasMaskManager.html" > CanvasMaskManager< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.CanvasRenderer.html" > CanvasRenderer< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.CanvasTinter.html" > CanvasTinter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Circle.html" > Circle< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.ColorMatrixFilter.html" > ColorMatrixFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.ColorStepFilter.html" > ColorStepFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.ComplexPrimitiveShader.html" > ComplexPrimitiveShader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.ConvolutionFilter.html" > ConvolutionFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.CrossHatchFilter.html" > CrossHatchFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.DisplacementFilter.html" > DisplacementFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.DisplayObject.html" > DisplayObject< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.DisplayObjectContainer.html" > DisplayObjectContainer< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.DotScreenFilter.html" > DotScreenFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Ellipse.html" > Ellipse< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Event.html" > Event< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.EventTarget.html" > EventTarget< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.FilterBlock.html" > FilterBlock< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.FilterTexture.html" > FilterTexture< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Graphics.html" > Graphics< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.GraphicsData.html" > GraphicsData< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.GrayFilter.html" > GrayFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.ImageLoader.html" > ImageLoader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.InteractionData.html" > InteractionData< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.InteractionManager.html" > InteractionManager< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.InvertFilter.html" > InvertFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.JsonLoader.html" > JsonLoader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Matrix.html" > Matrix< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.MovieClip.html" > MovieClip< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.NoiseFilter.html" > NoiseFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.NormalMapFilter.html" > NormalMapFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.PixelateFilter.html" > PixelateFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.PIXI.html" > PIXI< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.PixiFastShader.html" > PixiFastShader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.PixiShader.html" > PixiShader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Point.html" > Point< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Polygon.html" > Polygon< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.PolyK.html" > PolyK< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.PrimitiveShader.html" > PrimitiveShader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Rectangle.html" > Rectangle< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.RenderTexture.html" > RenderTexture< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.RGBSplitFilter.html" > RGBSplitFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Rope.html" > Rope< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.RoundedRectangle.html" > RoundedRectangle< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.SepiaFilter.html" > SepiaFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.SmartBlurFilter.html" > SmartBlurFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Spine.html" > Spine< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.SpineLoader.html" > SpineLoader< / a >
< / li >
2014-11-25 00:23:44 +00:00
< li class = "class-depth-1" >
< a href = "PIXI.SpineTextureLoader.html" > SpineTextureLoader< / a >
< / li >
2014-11-15 20:01:46 +00:00
< li class = "class-depth-1" >
< a href = "PIXI.Sprite.html" > Sprite< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.SpriteBatch.html" > SpriteBatch< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.SpriteSheetLoader.html" > SpriteSheetLoader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Stage.html" > Stage< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Strip.html" > Strip< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.StripShader.html" > StripShader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Text.html" > Text< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Texture.html" > Texture< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.TilingSprite.html" > TilingSprite< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.TiltShiftFilter.html" > TiltShiftFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.TiltShiftXFilter.html" > TiltShiftXFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.TiltShiftYFilter.html" > TiltShiftYFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.TwistFilter.html" > TwistFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.VideoTexture.html" > VideoTexture< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.WebGLBlendModeManager.html" > WebGLBlendModeManager< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.WebGLFastSpriteBatch.html" > WebGLFastSpriteBatch< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.WebGLFilterManager.html" > WebGLFilterManager< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.WebGLRenderer.html" > WebGLRenderer< / a >
< / li >
2013-10-02 14:05:55 +00:00
< / ul >
< / li >
2014-11-25 00:23:44 +00:00
2014-11-15 20:01:46 +00:00
< li class = "dropdown" >
2014-11-25 00:23:44 +00:00
< a href = "#" class = "dropdown-toggle" data-toggle = "dropdown" > Core< b class = "caret" > < / b > < / a >
< ul class = "dropdown-menu " >
2014-12-03 10:39:11 +00:00
< li class = "class-depth-1" > < a href = "Phaser.Game.html" > Game< / a > < / li >
2014-11-25 00:23:44 +00:00
< li class = "class-depth-1" > < a href = "Phaser.Group.html" > Group< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.World.html" > World< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Loader.html" > Loader< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Time.html" > Time< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Camera.html" > Camera< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.StateManager.html" > State Manager< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.TweenManager.html" > Tween Manager< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.SoundManager.html" > Sound Manager< / a > < / li >
2015-01-06 06:57:25 +00:00
< li class = "class-depth-1" > < a href = "Phaser.Input.html" > Input Manager< / a > < / li >
2014-11-25 00:23:44 +00:00
< li class = "class-depth-1" > < a href = "Phaser.ScaleManager.html" > Scale Manager< / a > < / li >
< / ul >
< / li >
2014-11-15 20:01:46 +00:00
2014-11-25 00:23:44 +00:00
< li class = "dropdown" >
< a href = "#" class = "dropdown-toggle" data-toggle = "dropdown" > Game Objects< b class = "caret" > < / b > < / a >
2014-11-15 20:01:46 +00:00
< ul class = "dropdown-menu " >
2014-11-25 00:23:44 +00:00
< li class = "class-depth-1" > < a href = "Phaser.GameObjectFactory.html" > Factory (game.add)< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.GameObjectCreator.html" > Creator (game.make)< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Sprite.html" > Sprite< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Image.html" > Image< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Sound.html" > Sound< / a > < / li >
2015-01-06 06:57:25 +00:00
< li class = "class-depth-1" > < a href = "Phaser.Particles.Arcade.Emitter.html" > Particle Emitter< / a > < / li >
2014-12-03 10:39:11 +00:00
< li class = "class-depth-1" > < a href = "Phaser.Particle.html" > Particle< / a > < / li >
2014-11-25 00:23:44 +00:00
< li class = "class-depth-1" > < a href = "Phaser.Text.html" > Text< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Tween.html" > Tween< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.BitmapText.html" > BitmapText< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Tilemap.html" > Tilemap< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.BitmapData.html" > BitmapData< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.RetroFont.html" > RetroFont< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Button.html" > Button< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Animation.html" > Animation< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Graphics.html" > Graphics< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.RenderTexture.html" > RenderTexture< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.TileSprite.html" > TileSprite< / a > < / li >
< / ul >
< / li >
< li class = "dropdown" >
< a href = "#" class = "dropdown-toggle" data-toggle = "dropdown" > Geometry< b class = "caret" > < / b > < / a >
< ul class = "dropdown-menu " >
< li class = "class-depth-1" > < a href = "Phaser.Circle.html" > Circle< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Rectangle.html" > Rectangle< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Point.html" > Point< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Line.html" > Line< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Ellipse.html" > Ellipse< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Polygon.html" > Polygon< / a > < / li >
< / ul >
< / li >
2014-11-15 20:01:46 +00:00
2014-11-25 00:23:44 +00:00
< li class = "dropdown" >
< a href = "#" class = "dropdown-toggle" data-toggle = "dropdown" > Physics< b class = "caret" > < / b > < / a >
< ul class = "dropdown-menu " >
< li class = "class-depth-1" > < a href = "Phaser.Physics.Arcade.html" > Arcade Physics< / a > < / li >
< li class = "class-depth-2" > < a href = "Phaser.Physics.Arcade.Body.html" > Body< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Physics.P2.html" > P2 Physics< / a > < / li >
< li class = "class-depth-2" > < a href = "Phaser.Physics.P2.Body.html" > Body< / a > < / li >
< li class = "class-depth-2" > < a href = "Phaser.Physics.P2.Spring.html" > Spring< / a > < / li >
< li class = "class-depth-2" > < a href = "Phaser.Physics.P2.CollisionGroup.html" > CollisionGroup< / a > < / li >
< li class = "class-depth-2" > < a href = "Phaser.Physics.P2.ContactMaterial.html" > ContactMaterial< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Physics.Ninja.html" > Ninja Physics< / a > < / li >
< li class = "class-depth-2" > < a href = "Phaser.Physics.Body.html" > Body< / a > < / li >
2014-11-15 20:01:46 +00:00
< / ul >
< / li >
2014-11-25 00:23:44 +00:00
< li class = "dropdown" >
< a href = "#" class = "dropdown-toggle" data-toggle = "dropdown" > Input< b class = "caret" > < / b > < / a >
< ul class = "dropdown-menu " >
< li class = "class-depth-1" > < a href = "Phaser.InputHandler.html" > Input Handler< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Pointer.html" > Pointer< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Mouse.html" > Mouse< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Keyboard.html" > Keyboard< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Key.html" > Key< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Gamepad.html" > Gamepad< / a > < / li >
< / ul >
< / li >
< li class = "dropdown" >
< a href = "#" class = "dropdown-toggle" data-toggle = "dropdown" > Community< b class = "caret" > < / b > < / a >
< ul class = "dropdown-menu " >
2015-01-06 06:57:25 +00:00
< li class = "class-depth-1" > < a href = "https://leanpub.com/u/photonstorm" > Phaser Books< / a > < / li >
2014-11-25 00:23:44 +00:00
< li class = "class-depth-1" > < a href = "https://github.com/photonstorm/phaser" > Phaser Github< / a > < / li >
< li class = "class-depth-1" > < a href = "http://examples.phaser.io" > Phaser Examples< / a > < / li >
< li class = "class-depth-1" > < a href = "https://github.com/photonstorm/phaser-plugins" > Phaser Plugins< / a > < / li >
< li class = "class-depth-1" > < a href = "http://www.html5gamedevs.com/forum/14-phaser/" > Forum< / a > < / li >
< li class = "class-depth-1" > < a href = "http://stackoverflow.com/questions/tagged/phaser-framework" > Stack Overflow< / a > < / li >
< li class = "class-depth-1" > < a href = "https://confirmsubscription.com/h/r/369DE48E3E86AF1E" > Newsletter< / a > < / li >
< li class = "class-depth-1" > < a href = "https://twitter.com/photonstorm" > Twitter< / a > < / li >
< li class = "class-depth-1" > < a href = "http://www.html5gamedevs.com/topic/4470-official-phaserio-irc-channel-phaserio-on-freenode/" > IRC< / a > < / li >
< li class = "class-depth-1" > < a href = "https://www.gittip.com/photonstorm/" > GitTip< / a > < / li >
< / ul >
< / li >
2013-10-02 14:05:55 +00:00
< / ul >
< / div >
< / div >
< div class = "row-fluid" >
< div class = "span12" >
< div id = "main" >
2014-11-15 20:01:46 +00:00
< h1 class = "page-title" > Source: D:/wamp/www/phaser/src/loader/Loader.js< / h1 >
2013-10-02 14:05:55 +00:00
< section >
< article >
2014-03-28 01:42:49 +00:00
< pre class = "sunlight-highlight-javascript linenums" > /* jshint wsh:true */
/**
2013-10-02 14:05:55 +00:00
* @author Richard Davey < rich@photonstorm.com>
2014-02-05 06:29:17 +00:00
* @copyright 2014 Photon Storm Ltd.
2013-10-02 14:05:55 +00:00
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files.
* It uses a combination of Image() loading and xhr and provides progress and completion callbacks.
2014-10-09 15:12:53 +00:00
*
2013-10-02 14:05:55 +00:00
* @class Phaser.Loader
* @constructor
* @param {Phaser.Game} game - A reference to the currently running game.
*/
Phaser.Loader = function (game) {
2013-11-28 15:57:09 +00:00
/**
2013-10-02 14:05:55 +00:00
* @property {Phaser.Game} game - Local reference to game.
2013-11-28 15:57:09 +00:00
*/
this.game = game;
2013-10-02 14:05:55 +00:00
2013-11-28 15:57:09 +00:00
/**
* @property {boolean} isLoading - True if the Loader is in the process of loading the queue.
* @default
*/
this.isLoading = false;
/**
* @property {boolean} hasLoaded - True if all assets in the queue have finished loading.
* @default
*/
this.hasLoaded = false;
/**
2014-02-05 06:29:17 +00:00
* @property {number} progress - The rounded load progress percentage value (from 0 to 100)
2013-11-28 15:57:09 +00:00
* @default
*/
this.progress = 0;
2014-02-05 06:29:17 +00:00
/**
* @property {number} progressFloat - The non-rounded load progress value (from 0.0 to 100.0)
* @default
*/
this.progressFloat = 0;
2013-11-28 15:57:09 +00:00
/**
* You can optionally link a sprite to the preloader.
2014-02-18 03:01:51 +00:00
* If you do so the Sprites width or height will be cropped based on the percentage loaded.
2014-09-09 14:36:56 +00:00
* This property is an object containing: sprite, rect, direction, width and height
2014-10-09 15:12:53 +00:00
*
2014-09-09 14:36:56 +00:00
* @property {object} preloadSprite
2013-11-28 15:57:09 +00:00
*/
this.preloadSprite = null;
/**
2014-04-10 22:13:43 +00:00
* @property {boolean|string} crossOrigin - The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'.
2014-02-18 03:01:51 +00:00
* @default
2013-11-28 15:57:09 +00:00
*/
2014-02-18 03:01:51 +00:00
this.crossOrigin = false;
2013-11-28 15:57:09 +00:00
/**
* If you want to append a URL before the path of any asset you can set this here.
* Useful if you need to allow an asset url to be configured outside of the game code.
* MUST have / on the end of it!
* @property {string} baseURL
* @default
*/
this.baseURL = '';
/**
2014-04-15 14:39:23 +00:00
* @property {Phaser.Signal} onLoadStart - This event is dispatched when the loading process starts, before the first file has been requested.
2013-11-28 15:57:09 +00:00
*/
2014-04-15 14:39:23 +00:00
this.onLoadStart = new Phaser.Signal();
2014-03-28 01:42:49 +00:00
2013-11-28 15:57:09 +00:00
/**
2014-04-15 14:39:23 +00:00
* @property {Phaser.Signal} onFileStart - This event is dispatched immediately before a file starts loading. It's possible the file may still error (404, etc) after this event is sent.
2013-11-28 15:57:09 +00:00
*/
2014-04-15 14:39:23 +00:00
this.onFileStart = new Phaser.Signal();
2014-03-28 01:42:49 +00:00
2013-11-28 15:57:09 +00:00
/**
2014-04-15 14:39:23 +00:00
* @property {Phaser.Signal} onFileComplete - This event is dispatched when a file completes loading successfully.
2013-11-28 15:57:09 +00:00
*/
2014-04-15 14:39:23 +00:00
this.onFileComplete = new Phaser.Signal();
2014-03-28 01:42:49 +00:00
2013-11-28 15:57:09 +00:00
/**
2014-04-15 14:39:23 +00:00
* @property {Phaser.Signal} onFileError - This event is dispatched when a file errors as a result of the load request.
*/
this.onFileError = new Phaser.Signal();
/**
* @property {Phaser.Signal} onLoadComplete - This event is dispatched when the final file in the load queue has either loaded or failed.
2013-11-28 15:57:09 +00:00
*/
this.onLoadComplete = new Phaser.Signal();
2013-10-02 14:05:55 +00:00
2014-07-18 11:45:51 +00:00
/**
2014-10-09 15:12:53 +00:00
* @property {Phaser.Signal} onPackComplete - This event is dispatched when an asset pack has either loaded or failed.
2014-07-18 11:45:51 +00:00
*/
this.onPackComplete = new Phaser.Signal();
2014-10-09 15:12:53 +00:00
2014-09-09 14:36:56 +00:00
/**
2014-11-15 20:01:46 +00:00
* @property {boolean} useXDomainRequest - If true and if the browser supports XDomainRequest, it will be used in preference for xhr when loading json files. This is only relevant for IE9 when you know your server/CDN requires it.
2014-09-09 14:36:56 +00:00
*/
2014-11-15 20:01:46 +00:00
this.useXDomainRequest = false;
2014-09-09 14:36:56 +00:00
2014-07-10 19:31:11 +00:00
/**
* @property {array} _packList - Contains all the assets packs.
* @private
*/
this._packList = [];
/**
* @property {number} _packIndex - The index of the current asset pack.
* @private
*/
this._packIndex = 0;
/**
* @property {array} _fileList - Contains all the assets file infos.
* @private
*/
this._fileList = [];
/**
* @property {number} _fileIndex - The index of the current file being loaded.
* @private
*/
this._fileIndex = 0;
/**
* @property {number} _progressChunk - Indicates the size of 1 file in terms of a percentage out of 100.
* @private
* @default
*/
this._progressChunk = 0;
/**
* @property {XMLHttpRequest} - An XMLHttpRequest object used for loading text and audio data.
* @private
*/
this._xhr = new XMLHttpRequest();
/**
* @property {XDomainRequest} - An ajax request used specifically by IE9 for CORs loading issues.
* @private
*/
this._ajax = null;
2013-10-02 14:05:55 +00:00
};
/**
* @constant
* @type {number}
*/
Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY = 0;
/**
* @constant
* @type {number}
*/
Phaser.Loader.TEXTURE_ATLAS_JSON_HASH = 1;
/**
* @constant
* @type {number}
*/
Phaser.Loader.TEXTURE_ATLAS_XML_STARLING = 2;
2014-02-18 03:01:51 +00:00
/**
* @constant
* @type {number}
*/
2014-04-10 22:13:43 +00:00
Phaser.Loader.PHYSICS_LIME_CORONA_JSON = 3;
/**
* @constant
* @type {number}
*/
Phaser.Loader.PHYSICS_PHASER_JSON = 4;
2014-02-18 03:01:51 +00:00
2013-10-02 14:05:55 +00:00
Phaser.Loader.prototype = {
2013-11-28 15:57:09 +00:00
/**
* You can set a Sprite to be a "preload" sprite by passing it to this method.
* A "preload" sprite will have its width or height crop adjusted based on the percentage of the loader in real-time.
2014-02-24 12:14:30 +00:00
* This allows you to easily make loading bars for games. Note that Sprite.visible = true will be set when calling this.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#setPreloadSprite
2014-03-24 12:41:45 +00:00
* @param {Phaser.Sprite|Phaser.Image} sprite - The sprite or image that will be cropped during the load.
* @param {number} [direction=0] - A value of zero means the sprite will be cropped horizontally, a value of 1 means its will be cropped vertically.
2013-10-02 14:05:55 +00:00
*/
2013-11-28 15:57:09 +00:00
setPreloadSprite: function (sprite, direction) {
direction = direction || 0;
2014-03-24 12:41:45 +00:00
this.preloadSprite = { sprite: sprite, direction: direction, width: sprite.width, height: sprite.height, rect: null };
2013-11-28 15:57:09 +00:00
if (direction === 0)
{
2014-03-24 12:41:45 +00:00
// Horizontal rect
this.preloadSprite.rect = new Phaser.Rectangle(0, 0, 1, sprite.height);
2013-11-28 15:57:09 +00:00
}
else
{
2014-03-24 12:41:45 +00:00
// Vertical rect
this.preloadSprite.rect = new Phaser.Rectangle(0, 0, sprite.width, 1);
2013-11-28 15:57:09 +00:00
}
2014-03-24 12:41:45 +00:00
sprite.crop(this.preloadSprite.rect);
2013-11-28 15:57:09 +00:00
2014-02-24 12:14:30 +00:00
sprite.visible = true;
2013-11-28 15:57:09 +00:00
},
2014-11-15 20:01:46 +00:00
/**
* Called automatically by ScaleManager when the game resizes in RESIZE scalemode.
* We use this to adjust the height of the preloading sprite, if set.
*
* @method Phaser.Loader#resize
* @param {number} width - The new width of the game in pixels.
* @param {number} height - The new height of the game in pixels.
*/
resize: function () {
if (this.preloadSprite & & this.preloadSprite.height !== this.preloadSprite.sprite.height)
{
this.preloadSprite.rect.height = this.preloadSprite.sprite.height;
}
},
2013-11-28 15:57:09 +00:00
/**
* Check whether asset exists with a specific key.
2014-05-20 09:12:48 +00:00
* Use Phaser.Cache to access loaded assets, e.g. Phaser.Cache#checkImageKey
2014-10-09 15:12:53 +00:00
*
2013-11-28 15:57:09 +00:00
* @method Phaser.Loader#checkKeyExists
* @param {string} type - The type asset you want to check.
* @param {string} key - Key of the asset you want to check.
* @return {boolean} Return true if exists, otherwise return false.
*/
checkKeyExists: function (type, key) {
if (this._fileList.length > 0)
{
for (var i = 0; i < this._fileList.length; i++)
{
2014-04-11 12:09:28 +00:00
if (this._fileList[i].type === type & & this._fileList[i].key === key)
2013-11-28 15:57:09 +00:00
{
return true;
}
}
}
return false;
2014-03-28 01:42:49 +00:00
2013-11-28 15:57:09 +00:00
},
2014-03-14 06:36:05 +00:00
/**
* Gets the fileList index for the given key.
*
* @method Phaser.Loader#getAssetIndex
* @param {string} type - The type asset you want to check.
* @param {string} key - Key of the asset you want to check.
* @return {number} The index of this key in the filelist, or -1 if not found.
*/
getAssetIndex: function (type, key) {
if (this._fileList.length > 0)
{
for (var i = 0; i < this._fileList.length; i++)
{
2014-04-11 12:09:28 +00:00
if (this._fileList[i].type === type & & this._fileList[i].key === key)
2014-03-14 06:36:05 +00:00
{
return i;
}
}
}
return -1;
2014-03-28 01:42:49 +00:00
2014-03-14 06:36:05 +00:00
},
2013-11-28 15:57:09 +00:00
/**
* Gets the asset that is queued for load.
*
* @method Phaser.Loader#getAsset
* @param {string} type - The type asset you want to check.
* @param {string} key - Key of the asset you want to check.
* @return {any} Returns an object if found that has 2 properties: index and file. Otherwise false.
*/
getAsset: function (type, key) {
if (this._fileList.length > 0)
{
for (var i = 0; i < this._fileList.length; i++)
{
2014-04-11 12:09:28 +00:00
if (this._fileList[i].type === type & & this._fileList[i].key === key)
2013-11-28 15:57:09 +00:00
{
return { index: i, file: this._fileList[i] };
}
}
}
return false;
2014-03-28 01:42:49 +00:00
2013-11-28 15:57:09 +00:00
},
/**
* Reset loader, this will remove the load queue.
*
* @method Phaser.Loader#reset
*/
reset: function () {
this.preloadSprite = null;
this.isLoading = false;
2014-07-10 19:31:11 +00:00
this._packList.length = 0;
this._packIndex = 0;
2013-11-28 15:57:09 +00:00
this._fileList.length = 0;
this._fileIndex = 0;
},
/**
* Internal function that adds a new entry to the file list. Do not call directly.
*
* @method Phaser.Loader#addToFileList
2014-07-10 19:31:11 +00:00
* @protected
2013-11-28 15:57:09 +00:00
* @param {string} type - The type of resource to add to the list (image, audio, xml, etc).
* @param {string} key - The unique Cache ID key of this resource.
* @param {string} url - The URL the asset will be loaded from.
* @param {object} properties - Any additional properties needed to load the file.
*/
addToFileList: function (type, key, url, properties) {
var entry = {
type: type,
key: key,
url: url,
data: null,
error: false,
loaded: false
};
if (typeof properties !== "undefined")
{
for (var prop in properties)
{
entry[prop] = properties[prop];
}
}
if (this.checkKeyExists(type, key) === false)
{
this._fileList.push(entry);
}
},
/**
* Internal function that replaces an existing entry in the file list with a new one. Do not call directly.
*
* @method Phaser.Loader#replaceInFileList
* @param {string} type - The type of resource to add to the list (image, audio, xml, etc).
* @param {string} key - The unique Cache ID key of this resource.
* @param {string} url - The URL the asset will be loaded from.
* @param {object} properties - Any additional properties needed to load the file.
* @protected
*/
replaceInFileList: function (type, key, url, properties) {
var entry = {
type: type,
key: key,
url: url,
data: null,
error: false,
loaded: false
};
if (typeof properties !== "undefined")
{
for (var prop in properties)
{
entry[prop] = properties[prop];
}
}
2014-03-14 06:36:05 +00:00
var index = this.getAssetIndex(type, key);
if (index === -1)
2013-11-28 15:57:09 +00:00
{
this._fileList.push(entry);
}
2014-03-14 06:36:05 +00:00
else
{
this._fileList[index] = entry;
}
2013-11-28 15:57:09 +00:00
},
2014-07-10 19:31:11 +00:00
/**
* Add an image to the Loader.
*
* @method Phaser.Loader#pack
* @param {string} key - Unique asset key of this image file.
* @param {string} [url] - URL of the Asset Pack JSON file. If you wish to pass a json object instead set this to null and pass the object as the data parameter.
* @param {object} [data] - The Asset Pack JSON data. Use this to pass in a json data object rather than loading it from a URL. TODO
* @param {object} [callbackContext] - Some Loader operations, like Binary and Script require a context for their callbacks. Pass the context here.
* @return {Phaser.Loader} This Loader instance.
*/
pack: function (key, url, data, callbackContext) {
if (typeof url === "undefined") { url = null; }
if (typeof data === "undefined") { data = null; }
if (typeof callbackContext === "undefined") { callbackContext = this; }
if (url === null & & data === null)
{
console.warn('Phaser.Loader.pack - Both url and data are null. One must be set.');
return this;
}
// A data object has been given
if (data)
{
if (typeof data === 'string')
{
data = JSON.parse(data);
}
}
this._packList.push( { key: key, url: url, data: data, loaded: false, error: false, callbackContext: callbackContext } );
return this;
},
2013-11-28 15:57:09 +00:00
/**
* Add an image to the Loader.
*
* @method Phaser.Loader#image
* @param {string} key - Unique asset key of this image file.
* @param {string} url - URL of image file.
* @param {boolean} [overwrite=false] - If an unloaded file with a matching key already exists in the queue, this entry will overwrite it.
* @return {Phaser.Loader} This Loader instance.
*/
image: function (key, url, overwrite) {
if (typeof overwrite === "undefined") { overwrite = false; }
if (overwrite)
{
this.replaceInFileList('image', key, url);
}
else
{
this.addToFileList('image', key, url);
}
return this;
},
/**
* Add a text file to the Loader.
*
* @method Phaser.Loader#text
* @param {string} key - Unique asset key of the text file.
* @param {string} url - URL of the text file.
* @param {boolean} [overwrite=false] - If an unloaded file with a matching key already exists in the queue, this entry will overwrite it.
* @return {Phaser.Loader} This Loader instance.
*/
text: function (key, url, overwrite) {
if (typeof overwrite === "undefined") { overwrite = false; }
if (overwrite)
{
this.replaceInFileList('text', key, url);
}
else
{
this.addToFileList('text', key, url);
}
return this;
},
2014-02-24 12:14:30 +00:00
/**
* Add a json file to the Loader.
*
* @method Phaser.Loader#json
* @param {string} key - Unique asset key of the json file.
* @param {string} url - URL of the json file.
* @param {boolean} [overwrite=false] - If an unloaded file with a matching key already exists in the queue, this entry will overwrite it.
* @return {Phaser.Loader} This Loader instance.
*/
json: function (key, url, overwrite) {
if (typeof overwrite === "undefined") { overwrite = false; }
if (overwrite)
{
this.replaceInFileList('json', key, url);
}
else
{
this.addToFileList('json', key, url);
}
return this;
},
2014-10-09 15:12:53 +00:00
/**
* Add an XML file to the Loader.
*
* @method Phaser.Loader#xml
* @param {string} key - Unique asset key of the xml file.
* @param {string} url - URL of the xml file.
* @param {boolean} [overwrite=false] - If an unloaded file with a matching key already exists in the queue, this entry will overwrite it.
* @return {Phaser.Loader} This Loader instance.
*/
xml: function (key, url, overwrite) {
if (typeof overwrite === "undefined") { overwrite = false; }
if (overwrite)
{
this.replaceInFileList('xml', key, url);
}
else
{
this.addToFileList('xml', key, url);
}
return this;
},
2013-11-28 15:57:09 +00:00
/**
* Add a JavaScript file to the Loader. Once loaded the JavaScript file will be automatically turned into a script tag (and executed), so be careful what you load!
2014-03-14 06:36:05 +00:00
* You can also specify a callback. This will be executed as soon as the script tag has been created.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#script
* @param {string} key - Unique asset key of the script file.
* @param {string} url - URL of the JavaScript file.
2014-03-14 06:36:05 +00:00
* @param {function} [callback] - Optional callback that will be called after the script tag has loaded, so you can perform additional processing.
* @param {function} [callbackContext] - The context under which the callback will be applied. If not specified it will use the callback itself as the context.
2013-11-28 15:57:09 +00:00
* @return {Phaser.Loader} This Loader instance.
*/
2014-03-14 06:36:05 +00:00
script: function (key, url, callback, callbackContext) {
2013-11-28 15:57:09 +00:00
2014-03-14 06:36:05 +00:00
if (typeof callback === 'undefined') { callback = false; }
2014-04-11 12:09:28 +00:00
if (callback !== false & & typeof callbackContext === 'undefined') { callbackContext = callback; }
2014-03-14 06:36:05 +00:00
this.addToFileList('script', key, url, { callback: callback, callbackContext: callbackContext });
2013-11-28 15:57:09 +00:00
return this;
},
/**
2014-02-05 06:29:17 +00:00
* Add a binary file to the Loader. It will be loaded via xhr with a responseType of "arraybuffer". You can specify an optional callback to process the file after load.
* When the callback is called it will be passed 2 parameters: the key of the file and the file data.
* WARNING: If you specify a callback, the file data will be set to whatever your callback returns. So always return the data object, even if you didn't modify it.
2013-11-28 15:57:09 +00:00
*
2014-02-05 06:29:17 +00:00
* @method Phaser.Loader#binary
* @param {string} key - Unique asset key of the binary file.
* @param {string} url - URL of the binary file.
* @param {function} [callback] - Optional callback that will be passed the file after loading, so you can perform additional processing on it.
* @param {function} [callbackContext] - The context under which the callback will be applied. If not specified it will use the callback itself as the context.
2013-11-28 15:57:09 +00:00
* @return {Phaser.Loader} This Loader instance.
*/
2014-02-05 06:29:17 +00:00
binary: function (key, url, callback, callbackContext) {
2013-11-28 15:57:09 +00:00
2014-02-05 06:29:17 +00:00
if (typeof callback === 'undefined') { callback = false; }
2014-04-11 12:09:28 +00:00
if (callback !== false & & typeof callbackContext === 'undefined') { callbackContext = callback; }
2013-11-28 15:57:09 +00:00
2014-02-05 06:29:17 +00:00
this.addToFileList('binary', key, url, { callback: callback, callbackContext: callbackContext });
2013-11-28 15:57:09 +00:00
return this;
},
/**
2014-02-05 06:29:17 +00:00
* Add a new sprite sheet to the loader.
2013-11-28 15:57:09 +00:00
*
2014-02-05 06:29:17 +00:00
* @method Phaser.Loader#spritesheet
* @param {string} key - Unique asset key of the sheet file.
* @param {string} url - URL of the sheet file.
* @param {number} frameWidth - Width of each single frame.
* @param {number} frameHeight - Height of each single frame.
* @param {number} [frameMax=-1] - How many frames in this sprite sheet. If not specified it will divide the whole image into frames.
* @param {number} [margin=0] - If the frames have been drawn with a margin, specify the amount here.
* @param {number} [spacing=0] - If the frames have been drawn with spacing between them, specify the amount here.
2013-11-28 15:57:09 +00:00
* @return {Phaser.Loader} This Loader instance.
*/
2014-02-05 06:29:17 +00:00
spritesheet: function (key, url, frameWidth, frameHeight, frameMax, margin, spacing) {
2013-11-28 15:57:09 +00:00
2014-02-05 06:29:17 +00:00
if (typeof frameMax === "undefined") { frameMax = -1; }
if (typeof margin === "undefined") { margin = 0; }
if (typeof spacing === "undefined") { spacing = 0; }
2013-11-28 15:57:09 +00:00
2014-02-05 06:29:17 +00:00
this.addToFileList('spritesheet', key, url, { frameWidth: frameWidth, frameHeight: frameHeight, frameMax: frameMax, margin: margin, spacing: spacing });
2013-11-28 15:57:09 +00:00
return this;
},
/**
* Add a new audio file to the loader.
*
* @method Phaser.Loader#audio
* @param {string} key - Unique asset key of the audio file.
2015-01-06 06:57:25 +00:00
* @param {Array|string} urls - An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ] or a single string containing just one URL. BLOB urls are supported, but note that Phaser will not validate the audio file's type if a BLOB is provided; the user should ensure that a BLOB url is playable.
2013-11-28 15:57:09 +00:00
* @param {boolean} autoDecode - When using Web Audio the audio files can either be decoded at load time or run-time. They can't be played until they are decoded, but this let's you control when that happens. Decoding is a non-blocking async process.
* @return {Phaser.Loader} This Loader instance.
*/
audio: function (key, urls, autoDecode) {
if (typeof autoDecode === "undefined") { autoDecode = true; }
this.addToFileList('audio', key, urls, { buffer: null, autoDecode: autoDecode });
return this;
},
2014-10-09 15:12:53 +00:00
/**
* Add a new audiosprite file to the loader. Audio Sprites are a combination of audio files and a JSON configuration.
* The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite
*
* @method Phaser.Loader#audiosprite
* @param {string} key - Unique asset key of the audio file.
* @param {Array|string} urls - An array containing the URLs of the audio files, i.e.: [ 'audiosprite.mp3', 'audiosprite.ogg', 'audiosprite.m4a' ] or a single string containing just one URL.
* @param {string} atlasURL - The URL of the audiosprite configuration json.
* @return {Phaser.Loader} This Loader instance.
*/
audiosprite: function(key, urls, atlasURL) {
this.audio(key, urls);
this.json(key + '-audioatlas', atlasURL);
return this;
},
2013-11-28 15:57:09 +00:00
/**
* Add a new tilemap loading request.
*
* @method Phaser.Loader#tilemap
* @param {string} key - Unique asset key of the tilemap data.
2014-07-10 19:31:11 +00:00
* @param {string} [url] - The url of the map data file (csv/json)
* @param {object} [data] - An optional JSON data object. If given then the url is ignored and this JSON object is used for map data instead.
2014-03-14 06:36:05 +00:00
* @param {number} [format=Phaser.Tilemap.CSV] - The format of the map data. Either Phaser.Tilemap.CSV or Phaser.Tilemap.TILED_JSON.
2013-11-28 15:57:09 +00:00
* @return {Phaser.Loader} This Loader instance.
*/
2014-07-10 19:31:11 +00:00
tilemap: function (key, url, data, format) {
2013-11-28 15:57:09 +00:00
2014-07-10 19:31:11 +00:00
if (typeof url === "undefined") { url = null; }
if (typeof data === "undefined") { data = null; }
2013-11-28 15:57:09 +00:00
if (typeof format === "undefined") { format = Phaser.Tilemap.CSV; }
2014-07-10 19:31:11 +00:00
if (url == null & & data == null)
2013-11-28 15:57:09 +00:00
{
2014-07-10 19:31:11 +00:00
console.warn('Phaser.Loader.tilemap - Both url and data are null. One must be set.');
2013-11-28 15:57:09 +00:00
return this;
}
// A map data object has been given
2014-07-10 19:31:11 +00:00
if (data)
2013-11-28 15:57:09 +00:00
{
switch (format)
{
// A csv string or object has been given
case Phaser.Tilemap.CSV:
break;
// An xml string or object has been given
case Phaser.Tilemap.TILED_JSON:
2014-07-10 19:31:11 +00:00
if (typeof data === 'string')
2013-11-28 15:57:09 +00:00
{
2014-07-10 19:31:11 +00:00
data = JSON.parse(data);
2013-11-28 15:57:09 +00:00
}
break;
}
2014-07-10 19:31:11 +00:00
this.game.cache.addTilemap(key, null, data, format);
2013-11-28 15:57:09 +00:00
}
else
{
2014-07-10 19:31:11 +00:00
this.addToFileList('tilemap', key, url, { format: format });
2013-11-28 15:57:09 +00:00
}
return this;
},
2014-02-18 03:01:51 +00:00
/**
* Add a new physics data object loading request.
* The data must be in Lime + Corona JSON format. Physics Editor by code'n'web exports in this format natively.
*
* @method Phaser.Loader#physics
* @param {string} key - Unique asset key of the physics json data.
2014-07-10 19:31:11 +00:00
* @param {string} [url] - The url of the map data file (csv/json)
* @param {object} [data] - An optional JSON data object. If given then the url is ignored and this JSON object is used for physics data instead.
2014-02-18 03:01:51 +00:00
* @param {string} [format=Phaser.Physics.LIME_CORONA_JSON] - The format of the physics data.
* @return {Phaser.Loader} This Loader instance.
*/
2014-07-10 19:31:11 +00:00
physics: function (key, url, data, format) {
2014-02-18 03:01:51 +00:00
2014-07-10 19:31:11 +00:00
if (typeof url === "undefined") { url = null; }
if (typeof data === "undefined") { data = null; }
2014-02-18 03:01:51 +00:00
if (typeof format === "undefined") { format = Phaser.Physics.LIME_CORONA_JSON; }
2014-07-10 19:31:11 +00:00
if (url == null & & data == null)
2014-02-18 03:01:51 +00:00
{
2014-07-10 19:31:11 +00:00
console.warn('Phaser.Loader.physics - Both url and data are null. One must be set.');
2014-02-18 03:01:51 +00:00
return this;
}
// A map data object has been given
2014-07-10 19:31:11 +00:00
if (data)
2014-02-18 03:01:51 +00:00
{
2014-07-10 19:31:11 +00:00
if (typeof data === 'string')
2014-02-18 03:01:51 +00:00
{
2014-07-10 19:31:11 +00:00
data = JSON.parse(data);
2014-02-18 03:01:51 +00:00
}
2014-07-10 19:31:11 +00:00
this.game.cache.addPhysicsData(key, null, data, format);
2014-02-18 03:01:51 +00:00
}
else
{
2014-07-10 19:31:11 +00:00
this.addToFileList('physics', key, url, { format: format });
2014-02-18 03:01:51 +00:00
}
return this;
},
2013-11-28 15:57:09 +00:00
/**
* Add a new bitmap font loading request.
*
* @method Phaser.Loader#bitmapFont
* @param {string} key - Unique asset key of the bitmap font.
* @param {string} textureURL - The url of the font image file.
* @param {string} [xmlURL] - The url of the font data file (xml/fnt)
* @param {object} [xmlData] - An optional XML data object.
2014-02-18 03:01:51 +00:00
* @param {number} [xSpacing=0] - If you'd like to add additional horizontal spacing between the characters then set the pixel value here.
* @param {number} [ySpacing=0] - If you'd like to add additional vertical spacing between the lines then set the pixel value here.
2013-11-28 15:57:09 +00:00
* @return {Phaser.Loader} This Loader instance.
*/
2014-02-18 03:01:51 +00:00
bitmapFont: function (key, textureURL, xmlURL, xmlData, xSpacing, ySpacing) {
2013-11-28 15:57:09 +00:00
if (typeof xmlURL === "undefined") { xmlURL = null; }
if (typeof xmlData === "undefined") { xmlData = null; }
2014-02-18 03:01:51 +00:00
if (typeof xSpacing === "undefined") { xSpacing = 0; }
if (typeof ySpacing === "undefined") { ySpacing = 0; }
2013-11-28 15:57:09 +00:00
// A URL to a json/xml file has been given
if (xmlURL)
{
2014-02-18 03:01:51 +00:00
this.addToFileList('bitmapfont', key, textureURL, { xmlURL: xmlURL, xSpacing: xSpacing, ySpacing: ySpacing });
2013-11-28 15:57:09 +00:00
}
else
{
// An xml string or object has been given
if (typeof xmlData === 'string')
{
var xml;
try {
if (window['DOMParser'])
{
var domparser = new DOMParser();
xml = domparser.parseFromString(xmlData, "text/xml");
}
else
{
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = 'false';
xml.loadXML(xmlData);
}
}
catch (e)
{
xml = undefined;
}
if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length)
{
throw new Error("Phaser.Loader. Invalid Bitmap Font XML given");
}
else
{
2014-02-18 03:01:51 +00:00
this.addToFileList('bitmapfont', key, textureURL, { xmlURL: null, xmlData: xml, xSpacing: xSpacing, ySpacing: ySpacing });
2013-11-28 15:57:09 +00:00
}
}
}
return this;
},
/**
* Add a new texture atlas to the loader. This atlas uses the JSON Array data format.
*
* @method Phaser.Loader#atlasJSONArray
* @param {string} key - Unique asset key of the texture atlas file.
* @param {string} textureURL - The url of the texture atlas image file.
* @param {string} [atlasURL] - The url of the texture atlas data file (json/xml). You don't need this if you are passing an atlasData object instead.
* @param {object} [atlasData] - A JSON or XML data object. You don't need this if the data is being loaded from a URL.
* @return {Phaser.Loader} This Loader instance.
*/
atlasJSONArray: function (key, textureURL, atlasURL, atlasData) {
return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY);
},
/**
* Add a new texture atlas to the loader. This atlas uses the JSON Hash data format.
*
* @method Phaser.Loader#atlasJSONHash
* @param {string} key - Unique asset key of the texture atlas file.
* @param {string} textureURL - The url of the texture atlas image file.
* @param {string} [atlasURL] - The url of the texture atlas data file (json/xml). You don't need this if you are passing an atlasData object instead.
* @param {object} [atlasData] - A JSON or XML data object. You don't need this if the data is being loaded from a URL.
* @return {Phaser.Loader} This Loader instance.
*/
atlasJSONHash: function (key, textureURL, atlasURL, atlasData) {
return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_HASH);
},
/**
* Add a new texture atlas to the loader. This atlas uses the Starling XML data format.
*
* @method Phaser.Loader#atlasXML
* @param {string} key - Unique asset key of the texture atlas file.
* @param {string} textureURL - The url of the texture atlas image file.
* @param {string} [atlasURL] - The url of the texture atlas data file (json/xml). You don't need this if you are passing an atlasData object instead.
* @param {object} [atlasData] - A JSON or XML data object. You don't need this if the data is being loaded from a URL.
* @return {Phaser.Loader} This Loader instance.
*/
atlasXML: function (key, textureURL, atlasURL, atlasData) {
return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
},
/**
* Add a new texture atlas to the loader.
*
* @method Phaser.Loader#atlas
* @param {string} key - Unique asset key of the texture atlas file.
* @param {string} textureURL - The url of the texture atlas image file.
* @param {string} [atlasURL] - The url of the texture atlas data file (json/xml). You don't need this if you are passing an atlasData object instead.
* @param {object} [atlasData] - A JSON or XML data object. You don't need this if the data is being loaded from a URL.
* @param {number} [format] - A value describing the format of the data, the default is Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY.
* @return {Phaser.Loader} This Loader instance.
*/
atlas: function (key, textureURL, atlasURL, atlasData, format) {
if (typeof atlasURL === "undefined") { atlasURL = null; }
if (typeof atlasData === "undefined") { atlasData = null; }
if (typeof format === "undefined") { format = Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY; }
// A URL to a json/xml file has been given
if (atlasURL)
{
this.addToFileList('textureatlas', key, textureURL, { atlasURL: atlasURL, format: format });
}
else
{
switch (format)
{
// A json string or object has been given
case Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY:
if (typeof atlasData === 'string')
{
atlasData = JSON.parse(atlasData);
}
break;
// An xml string or object has been given
case Phaser.Loader.TEXTURE_ATLAS_XML_STARLING:
if (typeof atlasData === 'string')
{
var xml;
try {
if (window['DOMParser'])
{
var domparser = new DOMParser();
xml = domparser.parseFromString(atlasData, "text/xml");
}
else
{
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = 'false';
xml.loadXML(atlasData);
}
}
catch (e)
{
xml = undefined;
}
if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length)
{
throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");
}
else
{
atlasData = xml;
}
}
break;
}
this.addToFileList('textureatlas', key, textureURL, { atlasURL: null, atlasData: atlasData, format: format });
}
return this;
},
/**
* Remove loading request of a file.
*
* @method Phaser.Loader#removeFile
* @param {string} type - The type of resource to add to the list (image, audio, xml, etc).
* @param {string} key - Key of the file you want to remove.
*/
removeFile: function (type, key) {
var file = this.getAsset(type, key);
if (file !== false)
{
this._fileList.splice(file.index, 1);
}
},
/**
* Remove all file loading requests.
*
* @method Phaser.Loader#removeAll
*/
removeAll: function () {
this._fileList.length = 0;
},
/**
* Start loading the assets. Normally you don't need to call this yourself as the StateManager will do so.
*
* @method Phaser.Loader#start
*/
start: function () {
if (this.isLoading)
{
return;
}
2014-07-10 19:31:11 +00:00
if (this._packList.length > 0)
{
this._packIndex = 0;
this.loadPack();
}
else
{
this.beginLoad();
}
},
/**
* Starts off the actual loading process after the asset packs have been sorted out.
*
* @method Phaser.Loader#beginLoad
* @private
*/
beginLoad: function () {
2013-11-28 15:57:09 +00:00
this.progress = 0;
2014-02-05 06:29:17 +00:00
this.progressFloat = 0;
2013-11-28 15:57:09 +00:00
this.hasLoaded = false;
this.isLoading = true;
this.onLoadStart.dispatch(this._fileList.length);
if (this._fileList.length > 0)
{
this._fileIndex = 0;
this._progressChunk = 100 / this._fileList.length;
this.loadFile();
}
else
{
this.progress = 100;
2014-02-05 06:29:17 +00:00
this.progressFloat = 100;
2013-11-28 15:57:09 +00:00
this.hasLoaded = true;
2014-07-10 19:31:11 +00:00
this.isLoading = false;
2013-11-28 15:57:09 +00:00
this.onLoadComplete.dispatch();
}
},
2014-07-10 19:31:11 +00:00
/**
* Loads the current asset pack in the queue.
*
* @method Phaser.Loader#loadPack
* @private
*/
loadPack: function () {
if (!this._packList[this._packIndex])
{
console.warn('Phaser.Loader loadPackList invalid index ' + this._packIndex);
return;
}
2014-10-09 15:12:53 +00:00
2014-07-10 19:31:11 +00:00
var pack = this._packList[this._packIndex];
if (pack.data !== null)
{
this.packLoadComplete(this._packIndex, false);
}
else
{
// Load it
this.xhrLoad(this._packIndex, this.baseURL + pack.url, 'text', 'packLoadComplete', 'packLoadError');
}
},
/**
* Handle the successful loading of a JSON asset pack.
*
* @method Phaser.Loader#packLoadComplete
* @private
* @param {number} index - The index of the file in the file queue that loaded.
* @param {boolean} [parse=true] - Automatically parse the JSON data?
*/
packLoadComplete: function (index, parse) {
if (typeof parse === 'undefined') { parse = true; }
if (!this._packList[index])
{
console.warn('Phaser.Loader packLoadComplete invalid index ' + index);
return;
}
var pack = this._packList[index];
pack.loaded = true;
if (parse)
{
var data = JSON.parse(this._xhr.responseText);
}
else
{
var data = this._packList[index].data;
}
if (data[pack.key])
{
var file;
for (var i = 0; i < data[pack.key].length; i++)
{
file = data[pack.key][i];
switch (file.type)
{
case "image":
this.image(file.key, file.url, file.overwrite);
break;
case "text":
this.text(file.key, file.url, file.overwrite);
break;
case "json":
this.json(file.key, file.url, file.overwrite);
break;
2014-10-09 15:12:53 +00:00
case "xml":
this.xml(file.key, file.url, file.overwrite);
break;
2014-07-10 19:31:11 +00:00
case "script":
this.script(file.key, file.url, file.callback, pack.callbackContext);
break;
case "binary":
this.binary(file.key, file.url, file.callback, pack.callbackContext);
break;
case "spritesheet":
this.spritesheet(file.key, file.url, file.frameWidth, file.frameHeight, file.frameMax, file.margin, file.spacing);
break;
case "audio":
this.audio(file.key, file.urls, file.autoDecode);
break;
case "tilemap":
this.tilemap(file.key, file.url, file.data, Phaser.Tilemap[file.format]);
break;
case "physics":
this.physics(file.key, file.url, file.data, Phaser.Loader[file.format]);
break;
case "bitmapFont":
this.bitmapFont(file.key, file.textureURL, file.xmlURL, file.xmlData, file.xSpacing, file.ySpacing);
break;
case "atlasJSONArray":
this.atlasJSONArray(file.key, file.textureURL, file.atlasURL, file.atlasData);
break;
case "atlasJSONHash":
this.atlasJSONHash(file.key, file.textureURL, file.atlasURL, file.atlasData);
break;
case "atlasXML":
this.atlasXML(file.key, file.textureURL, file.atlasURL, file.atlasData);
break;
case "atlas":
this.atlas(file.key, file.textureURL, file.atlasURL, file.atlasData, Phaser.Loader[file.format]);
break;
}
}
}
this.nextPack(index, true);
},
/**
* Error occured when loading an asset pack.
*
* @method Phaser.Loader#packError
* @private
* @param {number} index - The index of the file in the file queue that errored.
*/
packError: function (index) {
this._packList[index].loaded = true;
this._packList[index].error = true;
this.onFileError.dispatch(this._packList[index].key, this._packList[index]);
console.warn("Phaser.Loader error loading pack file: " + this._packList[index].key + ' from URL ' + this._packList[index].url);
2014-07-18 11:45:51 +00:00
this.nextPack(index, false);
2014-07-10 19:31:11 +00:00
},
/**
* Handle loading the next asset pack.
*
* @method Phaser.Loader#nextPack
* @private
*/
nextPack: function (index, success) {
this.onPackComplete.dispatch(this._packList[index].key, success, this.totalLoadedPacks(), this._packList.length);
this._packIndex++;
if (this._packIndex < this._packList.length)
{
this.loadPack();
}
else
{
this.beginLoad();
}
},
2013-11-28 15:57:09 +00:00
/**
* Load files. Private method ONLY used by loader.
*
* @method Phaser.Loader#loadFile
* @private
*/
loadFile: function () {
if (!this._fileList[this._fileIndex])
{
console.warn('Phaser.Loader loadFile invalid index ' + this._fileIndex);
return;
}
2014-10-09 15:12:53 +00:00
2013-11-28 15:57:09 +00:00
var file = this._fileList[this._fileIndex];
var _this = this;
2014-10-09 15:12:53 +00:00
this.onFileStart.dispatch(this.progress, file.key, file.url);
2014-04-15 14:39:23 +00:00
2013-11-28 15:57:09 +00:00
// Image or Data?
switch (file.type)
{
case 'image':
case 'spritesheet':
case 'textureatlas':
case 'bitmapfont':
file.data = new Image();
file.data.name = file.key;
file.data.onload = function () {
return _this.fileComplete(_this._fileIndex);
};
file.data.onerror = function () {
return _this.fileError(_this._fileIndex);
};
2014-02-18 03:01:51 +00:00
if (this.crossOrigin)
{
file.data.crossOrigin = this.crossOrigin;
}
2013-11-28 15:57:09 +00:00
file.data.src = this.baseURL + file.url;
break;
case 'audio':
file.url = this.getAudioURL(file.url);
if (file.url !== null)
{
// WebAudio or Audio Tag?
if (this.game.sound.usingWebAudio)
{
2014-07-10 19:31:11 +00:00
this.xhrLoad(this._fileIndex, this.baseURL + file.url, 'arraybuffer', 'fileComplete', 'fileError');
2013-11-28 15:57:09 +00:00
}
else if (this.game.sound.usingAudioTag)
{
if (this.game.sound.touchLocked)
{
// If audio is locked we can't do this yet, so need to queue this load request. Bum.
file.data = new Audio();
file.data.name = file.key;
file.data.preload = 'auto';
file.data.src = this.baseURL + file.url;
this.fileComplete(this._fileIndex);
}
else
{
file.data = new Audio();
file.data.name = file.key;
file.data.onerror = function () {
return _this.fileError(_this._fileIndex);
};
file.data.preload = 'auto';
file.data.src = this.baseURL + file.url;
2014-10-09 15:12:53 +00:00
file.data.addEventListener('canplaythrough', function () { Phaser.GAMES[_this.game.id].load.fileComplete(_this._fileIndex); }, false);
2013-11-28 15:57:09 +00:00
file.data.load();
}
}
}
else
{
this.fileError(this._fileIndex);
}
break;
2014-02-24 12:14:30 +00:00
case 'json':
2014-04-29 14:39:02 +00:00
2014-09-09 14:36:56 +00:00
if (this.useXDomainRequest & & window.XDomainRequest)
2014-04-29 14:39:02 +00:00
{
this._ajax = new window.XDomainRequest();
2014-09-09 14:36:56 +00:00
// XDomainRequest has a few quirks. Occasionally it will abort requests
2014-04-29 14:39:02 +00:00
// A way to avoid this is to make sure ALL callbacks are set even if not used
// More info here: http://stackoverflow.com/questions/15786966/xdomainrequest-aborts-post-on-ie-9
this._ajax.timeout = 3000;
this._ajax.onerror = function () {
return _this.dataLoadError(_this._fileIndex);
};
2014-10-09 15:12:53 +00:00
2014-04-29 14:39:02 +00:00
this._ajax.ontimeout = function () {
return _this.dataLoadError(_this._fileIndex);
};
this._ajax.onprogress = function() {};
this._ajax.onload = function(){
return _this.jsonLoadComplete(_this._fileIndex);
};
this._ajax.open('GET', this.baseURL + file.url, true);
2014-10-09 15:12:53 +00:00
// Note: The xdr.send() call is wrapped in a timeout to prevent an issue with the interface where some requests are lost
2014-09-09 14:36:56 +00:00
// if multiple XDomainRequests are being sent at the same time.
setTimeout(function () {
2014-11-15 20:01:46 +00:00
_this._ajax.send();
2014-09-09 14:36:56 +00:00
}, 0);
2014-04-29 14:39:02 +00:00
}
else
{
2014-07-10 19:31:11 +00:00
this.xhrLoad(this._fileIndex, this.baseURL + file.url, 'text', 'jsonLoadComplete', 'dataLoadError');
2014-04-29 14:39:02 +00:00
}
2014-02-24 12:14:30 +00:00
break;
2014-10-09 15:12:53 +00:00
case 'xml':
this.xhrLoad(this._fileIndex, this.baseURL + file.url, 'text', 'xmlLoadComplete', 'dataLoadError');
break;
2013-11-28 15:57:09 +00:00
case 'tilemap':
if (file.format === Phaser.Tilemap.TILED_JSON)
{
2014-07-10 19:31:11 +00:00
this.xhrLoad(this._fileIndex, this.baseURL + file.url, 'text', 'jsonLoadComplete', 'dataLoadError');
2013-11-28 15:57:09 +00:00
}
else if (file.format === Phaser.Tilemap.CSV)
{
2014-07-10 19:31:11 +00:00
this.xhrLoad(this._fileIndex, this.baseURL + file.url, 'text', 'csvLoadComplete', 'dataLoadError');
2013-11-28 15:57:09 +00:00
}
else
{
throw new Error("Phaser.Loader. Invalid Tilemap format: " + file.format);
}
break;
case 'text':
2014-02-05 06:29:17 +00:00
case 'script':
2014-02-18 03:01:51 +00:00
case 'physics':
2014-07-10 19:31:11 +00:00
this.xhrLoad(this._fileIndex, this.baseURL + file.url, 'text', 'fileComplete', 'fileError');
2013-11-28 15:57:09 +00:00
break;
2014-02-05 06:29:17 +00:00
case 'binary':
2014-07-10 19:31:11 +00:00
this.xhrLoad(this._fileIndex, this.baseURL + file.url, 'arraybuffer', 'fileComplete', 'fileError');
2013-11-28 15:57:09 +00:00
break;
}
},
2014-07-10 19:31:11 +00:00
/**
* Starts the xhr loader.
2014-10-09 15:12:53 +00:00
*
2014-07-10 19:31:11 +00:00
* @method Phaser.Loader#xhrLoad
* @private
* @param {number} index - The index of the file to load from the file list.
* @param {string} url - The URL of the file.
* @param {string} type - The xhr responseType.
* @param {string} onload - A String of the name of the local function to be called on a successful file load.
* @param {string} onerror - A String of the name of the local function to be called on a file load error.
*/
xhrLoad: function (index, url, type, onload, onerror) {
this._xhr.open("GET", url, true);
this._xhr.responseType = type;
var _this = this;
this._xhr.onload = function () {
return _this[onload](index);
};
this._xhr.onerror = function () {
return _this[onerror](index);
};
this._xhr.send();
},
2013-11-28 15:57:09 +00:00
/**
* Private method ONLY used by loader.
2014-10-09 15:12:53 +00:00
*
2013-11-28 15:57:09 +00:00
* @method Phaser.Loader#getAudioURL
* @private
2014-07-10 19:31:11 +00:00
* @param {array|string} urls - Either an array of audio file URLs or a string containing a single URL path.
2013-11-28 15:57:09 +00:00
*/
getAudioURL: function (urls) {
var extension;
if (typeof urls === 'string') { urls = [urls]; }
for (var i = 0; i < urls.length; i++)
{
extension = urls[i].toLowerCase();
2015-01-06 06:57:25 +00:00
if (extension.substr(0,5) === "blob:")
{
return urls[i];
}
2013-11-28 15:57:09 +00:00
extension = extension.substr((Math.max(0, extension.lastIndexOf(".")) || Infinity) + 1);
2014-10-22 20:49:44 +00:00
if (extension.indexOf("?") >= 0)
{
extension = extension.substr(0, extension.indexOf("?"));
}
2013-11-28 15:57:09 +00:00
if (this.game.device.canPlayAudio(extension))
{
return urls[i];
}
}
return null;
},
/**
* Error occured when loading a file.
*
* @method Phaser.Loader#fileError
* @param {number} index - The index of the file in the file queue that errored.
*/
fileError: function (index) {
this._fileList[index].loaded = true;
this._fileList[index].error = true;
this.onFileError.dispatch(this._fileList[index].key, this._fileList[index]);
console.warn("Phaser.Loader error loading file: " + this._fileList[index].key + ' from URL ' + this._fileList[index].url);
this.nextFile(index, false);
},
/**
* Called when a file is successfully loaded.
*
* @method Phaser.Loader#fileComplete
* @param {number} index - The index of the file in the file queue that loaded.
*/
fileComplete: function (index) {
if (!this._fileList[index])
{
console.warn('Phaser.Loader fileComplete invalid index ' + index);
return;
}
var file = this._fileList[index];
file.loaded = true;
var loadNext = true;
switch (file.type)
{
case 'image':
this.game.cache.addImage(file.key, file.url, file.data);
break;
case 'spritesheet':
2014-02-05 06:29:17 +00:00
this.game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax, file.margin, file.spacing);
2013-11-28 15:57:09 +00:00
break;
case 'textureatlas':
if (file.atlasURL == null)
{
this.game.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format);
}
else
{
// Load the JSON or XML before carrying on with the next file
loadNext = false;
if (file.format == Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY || file.format == Phaser.Loader.TEXTURE_ATLAS_JSON_HASH)
{
2014-07-10 19:31:11 +00:00
this.xhrLoad(this._fileIndex, this.baseURL + file.atlasURL, 'text', 'jsonLoadComplete', 'dataLoadError');
2013-11-28 15:57:09 +00:00
}
else if (file.format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING)
{
2014-07-10 19:31:11 +00:00
this.xhrLoad(this._fileIndex, this.baseURL + file.atlasURL, 'text', 'xmlLoadComplete', 'dataLoadError');
2013-11-28 15:57:09 +00:00
}
else
{
throw new Error("Phaser.Loader. Invalid Texture Atlas format: " + file.format);
}
}
break;
case 'bitmapfont':
if (file.xmlURL == null)
{
2014-02-18 03:01:51 +00:00
this.game.cache.addBitmapFont(file.key, file.url, file.data, file.xmlData, file.xSpacing, file.ySpacing);
2013-11-28 15:57:09 +00:00
}
else
{
// Load the XML before carrying on with the next file
loadNext = false;
2014-07-10 19:31:11 +00:00
this.xhrLoad(this._fileIndex, this.baseURL + file.xmlURL, 'text', 'xmlLoadComplete', 'dataLoadError');
2013-11-28 15:57:09 +00:00
}
break;
case 'audio':
if (this.game.sound.usingWebAudio)
{
file.data = this._xhr.response;
this.game.cache.addSound(file.key, file.url, file.data, true, false);
if (file.autoDecode)
{
var that = this;
var key = file.key;
2014-03-28 01:42:49 +00:00
this.game.cache.updateSound(key, 'isDecoding', true);
2013-11-28 15:57:09 +00:00
this.game.sound.context.decodeAudioData(file.data, function (buffer) {
if (buffer)
{
that.game.cache.decodedSound(key, buffer);
2014-02-05 06:29:17 +00:00
that.game.sound.onSoundDecode.dispatch(key, that.game.cache.getSound(key));
2013-11-28 15:57:09 +00:00
}
});
}
}
else
{
file.data.removeEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete);
this.game.cache.addSound(file.key, file.url, file.data, false, true);
}
break;
case 'text':
file.data = this._xhr.responseText;
this.game.cache.addText(file.key, file.url, file.data);
break;
2014-02-18 03:01:51 +00:00
case 'physics':
var data = JSON.parse(this._xhr.responseText);
this.game.cache.addPhysicsData(file.key, file.url, data, file.format);
break;
2013-11-28 15:57:09 +00:00
case 'script':
file.data = document.createElement('script');
file.data.language = 'javascript';
file.data.type = 'text/javascript';
2014-02-05 06:29:17 +00:00
file.data.defer = false;
2013-11-28 15:57:09 +00:00
file.data.text = this._xhr.responseText;
document.head.appendChild(file.data);
2014-03-14 06:36:05 +00:00
if (file.callback)
{
file.data = file.callback.call(file.callbackContext, file.key, this._xhr.responseText);
}
2013-11-28 15:57:09 +00:00
break;
2014-02-05 06:29:17 +00:00
case 'binary':
if (file.callback)
{
file.data = file.callback.call(file.callbackContext, file.key, this._xhr.response);
}
else
{
file.data = this._xhr.response;
}
this.game.cache.addBinary(file.key, file.data);
break;
2013-11-28 15:57:09 +00:00
}
if (loadNext)
{
this.nextFile(index, true);
}
},
/**
* Successfully loaded a JSON file.
*
* @method Phaser.Loader#jsonLoadComplete
* @param {number} index - The index of the file in the file queue that loaded.
*/
jsonLoadComplete: function (index) {
if (!this._fileList[index])
{
console.warn('Phaser.Loader jsonLoadComplete invalid index ' + index);
return;
}
var file = this._fileList[index];
2014-09-09 14:36:56 +00:00
if (this._ajax & & this._ajax.responseText)
{
var data = JSON.parse(this._ajax.responseText);
}
else
{
var data = JSON.parse(this._xhr.responseText);
}
2013-11-28 15:57:09 +00:00
file.loaded = true;
if (file.type === 'tilemap')
{
this.game.cache.addTilemap(file.key, file.url, data, file.format);
}
2014-02-24 12:14:30 +00:00
else if (file.type === 'json')
{
this.game.cache.addJSON(file.key, file.url, data);
}
2013-11-28 15:57:09 +00:00
else
{
this.game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format);
}
this.nextFile(index, true);
},
/**
* Successfully loaded a CSV file.
*
* @method Phaser.Loader#csvLoadComplete
* @param {number} index - The index of the file in the file queue that loaded.
*/
csvLoadComplete: function (index) {
if (!this._fileList[index])
{
console.warn('Phaser.Loader csvLoadComplete invalid index ' + index);
return;
}
var file = this._fileList[index];
var data = this._xhr.responseText;
file.loaded = true;
this.game.cache.addTilemap(file.key, file.url, data, file.format);
this.nextFile(index, true);
},
/**
* Error occured when load a JSON.
*
* @method Phaser.Loader#dataLoadError
* @param {number} index - The index of the file in the file queue that errored.
*/
dataLoadError: function (index) {
var file = this._fileList[index];
file.loaded = true;
file.error = true;
console.warn("Phaser.Loader dataLoadError: " + file.key);
this.nextFile(index, true);
},
/**
* Successfully loaded an XML file.
*
* @method Phaser.Loader#xmlLoadComplete
* @param {number} index - The index of the file in the file queue that loaded.
*/
xmlLoadComplete: function (index) {
2014-10-09 15:12:53 +00:00
if (this._xhr.responseType !== '' & & this._xhr.responseType !== 'text')
{
console.warn('Invalid XML Response Type', this._fileList[index]);
console.warn(this._xhr);
}
2013-11-28 15:57:09 +00:00
var data = this._xhr.responseText;
var xml;
try
{
if (window['DOMParser'])
{
var domparser = new DOMParser();
xml = domparser.parseFromString(data, "text/xml");
}
else
{
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = 'false';
xml.loadXML(data);
}
}
catch (e)
{
xml = undefined;
}
if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length)
{
throw new Error("Phaser.Loader. Invalid XML given");
}
var file = this._fileList[index];
file.loaded = true;
2014-10-09 15:12:53 +00:00
if (file.type === 'bitmapfont')
2013-11-28 15:57:09 +00:00
{
2014-02-18 03:01:51 +00:00
this.game.cache.addBitmapFont(file.key, file.url, file.data, xml, file.xSpacing, file.ySpacing);
2013-11-28 15:57:09 +00:00
}
2014-10-09 15:12:53 +00:00
else if (file.type === 'textureatlas')
2013-11-28 15:57:09 +00:00
{
this.game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format);
}
2014-10-09 15:12:53 +00:00
else if (file.type === 'xml')
{
this.game.cache.addXML(file.key, file.url, xml);
}
2013-11-28 15:57:09 +00:00
this.nextFile(index, true);
},
/**
* Handle loading next file.
*
2014-07-10 19:31:11 +00:00
* @method Phaser.Loader#nextFile
* @private
2013-11-28 15:57:09 +00:00
* @param {number} previousIndex - Index of the previously loaded asset.
* @param {boolean} success - Whether the previous asset loaded successfully or not.
*/
nextFile: function (previousIndex, success) {
2014-02-05 06:29:17 +00:00
this.progressFloat += this._progressChunk;
this.progress = Math.round(this.progressFloat);
2013-11-28 15:57:09 +00:00
if (this.progress > 100)
{
this.progress = 100;
}
if (this.preloadSprite !== null)
{
if (this.preloadSprite.direction === 0)
{
2014-03-24 12:41:45 +00:00
this.preloadSprite.rect.width = Math.floor((this.preloadSprite.width / 100) * this.progress);
2013-11-28 15:57:09 +00:00
}
else
{
2014-03-24 12:41:45 +00:00
this.preloadSprite.rect.height = Math.floor((this.preloadSprite.height / 100) * this.progress);
2013-11-28 15:57:09 +00:00
}
2014-09-09 14:36:56 +00:00
this.preloadSprite.sprite.updateCrop();
2013-11-28 15:57:09 +00:00
}
this.onFileComplete.dispatch(this.progress, this._fileList[previousIndex].key, success, this.totalLoadedFiles(), this._fileList.length);
if (this.totalQueuedFiles() > 0)
{
this._fileIndex++;
this.loadFile();
}
else
{
this.hasLoaded = true;
this.isLoading = false;
2014-03-28 01:42:49 +00:00
2013-11-28 15:57:09 +00:00
this.removeAll();
this.onLoadComplete.dispatch();
}
},
/**
* Returns the number of files that have already been loaded, even if they errored.
*
2014-07-10 19:31:11 +00:00
* @method Phaser.Loader#totalLoadedFiles
2013-11-28 15:57:09 +00:00
* @return {number} The number of files that have already been loaded (even if they errored)
*/
totalLoadedFiles: function () {
var total = 0;
for (var i = 0; i < this._fileList.length; i++)
{
if (this._fileList[i].loaded)
{
total++;
}
}
return total;
},
/**
2014-07-10 19:31:11 +00:00
* Returns the number of files still waiting to be processed in the load queue. This value decreases as each file in the queue is loaded.
2013-11-28 15:57:09 +00:00
*
2014-07-10 19:31:11 +00:00
* @method Phaser.Loader#totalQueuedFiles
2013-11-28 15:57:09 +00:00
* @return {number} The number of files that still remain in the load queue.
*/
totalQueuedFiles: function () {
var total = 0;
for (var i = 0; i < this._fileList.length; i++)
{
if (this._fileList[i].loaded === false)
{
total++;
}
}
return total;
2014-07-10 19:31:11 +00:00
},
/**
* Returns the number of asset packs that have already been loaded, even if they errored.
*
* @method Phaser.Loader#totalLoadedPacks
* @return {number} The number of asset packs that have already been loaded (even if they errored)
*/
totalLoadedPacks: function () {
var total = 0;
for (var i = 0; i < this._packList.length; i++)
{
if (this._packList[i].loaded)
{
total++;
}
}
return total;
},
/**
* Returns the number of asset packs still waiting to be processed in the load queue. This value decreases as each pack in the queue is loaded.
*
* @method Phaser.Loader#totalQueuedPacks
* @return {number} The number of asset packs that still remain in the load queue.
*/
totalQueuedPacks: function () {
var total = 0;
for (var i = 0; i < this._packList.length; i++)
{
if (this._packList[i].loaded === false)
{
total++;
}
}
return total;
2013-11-28 15:57:09 +00:00
}
};
2014-02-05 06:29:17 +00:00
Phaser.Loader.prototype.constructor = Phaser.Loader;
2013-11-28 15:57:09 +00:00
< / pre >
2013-10-02 14:05:55 +00:00
< / article >
< / section >
< / div >
< div class = "clearfix" > < / div >
< footer >
< span class = "copyright" >
2014-02-05 06:29:17 +00:00
Phaser Copyright © 2012-2014 Photon Storm Ltd.
2013-10-02 14:05:55 +00:00
< / span >
< br / >
< span class = "jsdoc-message" >
2014-04-11 12:09:28 +00:00
Documentation generated by < a href = "https://github.com/jsdoc3/jsdoc" > JSDoc 3.3.0-dev< / a >
2015-01-06 06:57:25 +00:00
on Tue Jan 06 2015 06:31:48 GMT-0000 (GMT) using the < a href = "https://github.com/terryweiss/docstrap" > DocStrap template< / a > .
2013-10-02 14:05:55 +00:00
< / span >
< / footer >
< / div >
< br clear = "both" >
< / div >
< / div >
< script src = "scripts/sunlight.js" > < / script >
< script src = "scripts/sunlight.javascript.js" > < / script >
< script src = "scripts/sunlight-plugin.doclinks.js" > < / script >
< script src = "scripts/sunlight-plugin.linenumbers.js" > < / script >
< script src = "scripts/sunlight-plugin.menu.js" > < / script >
< script src = "scripts/jquery.min.js" > < / script >
< script src = "scripts/jquery.scrollTo.js" > < / script >
< script src = "scripts/jquery.localScroll.js" > < / script >
< script src = "scripts/bootstrap-dropdown.js" > < / script >
< script src = "scripts/toc.js" > < / script >
< script > Sunlight . highlightAll ( { lineNumbers : true , showMenu : true , enableDoclinks : true } ) ; < / script >
< script >
$( function () {
$( "#toc" ).toc( {
2014-04-10 22:13:43 +00:00
anchorName : function(i, heading, prefix) {
2014-03-14 06:36:05 +00:00
return $(heading).attr("id") || ( prefix + i );
},
2013-10-02 14:05:55 +00:00
selectors : "h1,h2,h3,h4",
showAndHide : false,
scrollTo : 60
} );
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
} );
< / script >
< / body >
< / html >