2013-10-02 14:05:55 +00:00
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "utf-8" >
2015-03-23 23:46:30 +00:00
< title > Phaser Source: 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-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 >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-2" >
< a href = "Phaser.Component.Angle.html" > Angle< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.Animation.html" > Animation< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.AutoCull.html" > AutoCull< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.Bounds.html" > Bounds< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.BringToTop.html" > BringToTop< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.Core.html" > Core< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.Crop.html" > Crop< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.Delta.html" > Delta< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.Destroy.html" > Destroy< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.FixedToCamera.html" > FixedToCamera< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.Health.html" > Health< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.InCamera.html" > InCamera< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.InputEnabled.html" > InputEnabled< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.InWorld.html" > InWorld< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.LifeSpan.html" > LifeSpan< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.LoadTexture.html" > LoadTexture< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.Overlap.html" > Overlap< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.PhysicsBody.html" > PhysicsBody< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.Reset.html" > Reset< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.ScaleMinMax.html" > ScaleMinMax< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Component.Smoothed.html" > Smoothed< / a >
< / li >
2015-07-22 14:31:30 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.Create.html" > Create< / a >
< / li >
< li class = "class-depth-1" >
< a href = "Phaser.Creature.html" > Creature< / 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.Device.html" > Device< / a >
2013-10-02 14:05:55 +00:00
< / li >
2015-07-22 14:31:30 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.DeviceButton.html" > DeviceButton< / a >
< / 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 >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-2" >
< a href = "Phaser.Easing.Back.html" > Back< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Easing.Bounce.html" > Bounce< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Easing.Circular.html" > Circular< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Easing.Cubic.html" > Cubic< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Easing.Elastic.html" > Elastic< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Easing.Exponential.html" > Exponential< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Easing.Linear.html" > Linear< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Easing.Quadratic.html" > Quadratic< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Easing.Quartic.html" > Quartic< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Easing.Quintic.html" > Quintic< / a >
< / li >
< li class = "class-depth-2" >
< a href = "Phaser.Easing.Sinusoidal.html" > Sinusoidal< / 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" >
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 >
2015-07-22 14:31:30 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.ImageCollection.html" > ImageCollection< / 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 >
2015-07-22 14:31:30 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.Matrix.html" > Matrix< / 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 >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-3" >
< a href = "Phaser.Physics.Arcade.html#TilemapCollision" > TilemapCollision< / 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 >
2015-07-22 14:31:30 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.RoundedRectangle.html" > RoundedRectangle< / 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" >
2015-07-22 14:31:30 +00:00
< a href = "Phaser.Video.html" > Video< / a >
2013-10-02 14:05:55 +00:00
< / li >
2014-11-15 20:01:46 +00:00
< li class = "class-depth-1" >
2015-07-22 14:31:30 +00:00
< a href = "Phaser.World.html" > World< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-07-22 14:31:30 +00:00
< a href = "PIXI.AbstractFilter.html" > AbstractFilter< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-07-22 14:31:30 +00:00
< a href = "PIXI.BaseTexture.html" > BaseTexture< / a >
2014-11-15 20:01:46 +00:00
< / 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.ComplexPrimitiveShader.html" > ComplexPrimitiveShader< / 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.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.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" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.PIXI.html" > PIXI< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.PixiFastShader.html" > PixiFastShader< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.PixiShader.html" > PixiShader< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.PolyK.html" > PolyK< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.PrimitiveShader.html" > PrimitiveShader< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.RenderTexture.html" > RenderTexture< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.Rope.html" > Rope< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.Sprite.html" > Sprite< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.SpriteBatch.html" > SpriteBatch< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.Stage.html" > Stage< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.Strip.html" > Strip< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.StripShader.html" > StripShader< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.Texture.html" > Texture< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.TilingSprite.html" > TilingSprite< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.WebGLBlendModeManager.html" > WebGLBlendModeManager< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.WebGLFastSpriteBatch.html" > WebGLFastSpriteBatch< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.WebGLFilterManager.html" > WebGLFilterManager< / a >
2014-11-15 20:01:46 +00:00
< / li >
< li class = "class-depth-1" >
2015-03-23 23:46:30 +00:00
< a href = "PIXI.WebGLRenderer.html" > WebGLRenderer< / a >
2014-11-15 20:01:46 +00:00
< / li >
2015-03-23 23:46:30 +00:00
< / ul >
< / li >
< li class = "dropdown" >
< a href = "global.html" class = "dropdown-toggle" data-toggle = "dropdown" > Global< b
class="caret">< / b > < / a >
< ul class = "dropdown-menu " >
2014-11-15 20:01:46 +00:00
2015-03-23 23:46:30 +00:00
< li class = "class-depth-0" >
2015-07-22 14:31:30 +00:00
< a href = "global.html#AUTO" > AUTO< / a >
2014-11-15 20:01:46 +00:00
< / li >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-0" >
2015-07-22 14:31:30 +00:00
< a href = "global.html#BITMAPDATA" > BITMAPDATA< / a >
2014-11-15 20:01:46 +00:00
< / li >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-0" >
2015-07-22 14:31:30 +00:00
< a href = "global.html#BITMAPTEXT" > BITMAPTEXT< / a >
2014-11-15 20:01:46 +00:00
< / li >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-0" >
< a href = "global.html#blendModes" > blendModes< / a >
2014-11-15 20:01:46 +00:00
< / li >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-0" >
2015-07-22 14:31:30 +00:00
< a href = "global.html#BUTTON" > BUTTON< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#CANVAS" > CANVAS< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#CANVAS_FILTER" > CANVAS_FILTER< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#CIRCLE" > CIRCLE< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#CREATURE" > CREATURE< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#DOWN" > DOWN< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#ELLIPSE" > ELLIPSE< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#EMITTER" > EMITTER< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#GAMES" > GAMES< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#GRAPHICS" > GRAPHICS< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#GROUP" > GROUP< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#HEADLESS" > HEADLESS< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#IMAGE" > IMAGE< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#LEFT" > LEFT< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#LINE" > LINE< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#MATRIX" > MATRIX< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#NONE" > NONE< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#POINT" > POINT< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#POINTER" > POINTER< / a >
2014-11-15 20:01:46 +00:00
< / li >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-0" >
2015-07-22 14:31:30 +00:00
< a href = "global.html#POLYGON" > POLYGON< / a >
2014-11-15 20:01:46 +00:00
< / li >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-0" >
2015-07-22 14:31:30 +00:00
< a href = "global.html#RECTANGLE" > RECTANGLE< / a >
2014-11-15 20:01:46 +00:00
< / li >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-0" >
2015-07-22 14:31:30 +00:00
< a href = "global.html#RENDERTEXTURE" > RENDERTEXTURE< / a >
2014-11-15 20:01:46 +00:00
< / li >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-0" >
2015-07-22 14:31:30 +00:00
< a href = "global.html#RETROFONT" > RETROFONT< / a >
2014-11-15 20:01:46 +00:00
< / li >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-0" >
2015-07-22 14:31:30 +00:00
< a href = "global.html#RIGHT" > RIGHT< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#ROPE" > ROPE< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#ROUNDEDRECTANGLE" > ROUNDEDRECTANGLE< / a >
2014-11-15 20:01:46 +00:00
< / li >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-0" >
< a href = "global.html#scaleModes" > scaleModes< / a >
2014-11-15 20:01:46 +00:00
< / li >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-0" >
2015-07-22 14:31:30 +00:00
< a href = "global.html#SPRITE" > SPRITE< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#SPRITEBATCH" > SPRITEBATCH< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#TEXT" > TEXT< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#TILEMAP" > TILEMAP< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#TILEMAPLAYER" > TILEMAPLAYER< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#TILESPRITE" > TILESPRITE< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#UP" > UP< / a >
2014-11-15 20:01:46 +00:00
< / li >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-0" >
2015-07-22 14:31:30 +00:00
< a href = "global.html#VERSION" > VERSION< / a >
2014-11-15 20:01:46 +00:00
< / li >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-0" >
2015-07-22 14:31:30 +00:00
< a href = "global.html#VIDEO" > VIDEO< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#WEBGL" > WEBGL< / a >
< / li >
< li class = "class-depth-0" >
< a href = "global.html#WEBGL_FILTER" > WEBGL_FILTER< / a >
2014-11-15 20:01:46 +00:00
< / 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 >
2015-07-22 14:31:30 +00:00
< li class = "class-depth-1" > < a href = "Phaser.Cache.html" > Cache< / a > < / li >
2014-11-25 00:23:44 +00:00
< 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-07-22 14:31:30 +00:00
< li class = "class-depth-1" > < a href = "Phaser.Video.html" > Video< / 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.Ellipse.html" > Ellipse< / a > < / li >
2015-07-22 14:31:30 +00:00
< li class = "class-depth-1" > < a href = "Phaser.Line.html" > Line< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Matrix.html" > Matrix< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Point.html" > Point< / a > < / li >
2014-11-25 00:23:44 +00:00
< li class = "class-depth-1" > < a href = "Phaser.Polygon.html" > Polygon< / a > < / li >
2015-07-22 14:31:30 +00:00
< li class = "class-depth-1" > < a href = "Phaser.Rectangle.html" > Rectangle< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.RoundedRectangle.html" > Rounded Rectangle< / a > < / li >
2014-11-25 00:23:44 +00:00
< / 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 >
2015-07-22 14:31:30 +00:00
< li class = "class-depth-1" > < a href = "Phaser.DeviceButton.html" > Device Button< / a > < / li >
2014-11-25 00:23:44 +00:00
< 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-03-26 02:55:18 +00:00
< li class = "class-depth-1" > < a href = "http://phaser.io" > Phaser Web Site< / 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 >
2015-03-26 02:55:18 +00:00
< li class = "class-depth-1" > < a href = "http://phaser.io/examples" > Phaser Examples< / a > < / li >
2014-11-25 00:23:44 +00:00
< 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 >
2015-07-22 14:31:30 +00:00
< li class = "class-depth-1" > < a href = "http://phaser.io/learn" > Tutorials< / a > < / li >
2014-11-25 00:23:44 +00:00
< li class = "class-depth-1" > < a href = "https://confirmsubscription.com/h/r/369DE48E3E86AF1E" > Newsletter< / a > < / li >
2015-03-26 02:55:18 +00:00
< li class = "class-depth-1" > < a href = "http://phaser.io/community/twitter" > Twitter< / a > < / li >
< li class = "class-depth-1" > < a href = "http://phaser.io/community/irc" > IRC< / a > < / li >
2015-03-23 23:46:30 +00:00
< li class = "class-depth-1" > < a href = "https://www.codeandweb.com/texturepacker/phaser" > Texture Packer< / a > < / li >
2014-11-25 00:23:44 +00:00
< / ul >
< / li >
2013-10-02 14:05:55 +00:00
< / ul >
< / div >
< / div >
< div class = "row-fluid" >
< div class = "span12" >
< div id = "main" >
2015-03-23 23:46:30 +00:00
< h1 class = "page-title" > Source: 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>
2015-03-23 23:46:30 +00:00
* @copyright 2015 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.
2015-03-23 23:46:30 +00:00
*
* The loader uses a combination of tag loading (eg. Image elements) and XHR and provides progress and completion callbacks.
*
* Parallel loading (see {@link #enableParallel}) is supported and enabled by default.
* Load-before behavior of parallel resources is controlled by synchronization points as discussed in {@link #withSyncPoint}.
*
* Texture Atlases can be created with tools such as [Texture Packer](https://www.codeandweb.com/texturepacker/phaser) and
* [Shoebox](http://renderhjs.net/shoebox/)
2014-10-09 15:12:53 +00:00
*
2013-10-02 14:05:55 +00:00
* @class Phaser.Loader
* @param {Phaser.Game} game - A reference to the currently running game.
*/
Phaser.Loader = function (game) {
2013-11-28 15:57:09 +00:00
/**
2015-03-23 23:46:30 +00:00
* Local reference to game.
* @property {Phaser.Game} game
* @protected
2013-11-28 15:57:09 +00:00
*/
this.game = game;
2013-10-02 14:05:55 +00:00
2015-07-22 14:31:30 +00:00
/**
* Local reference to the Phaser.Cache.
* @property {Phaser.Cache} cache
* @protected
*/
this.cache = game.cache;
2013-11-28 15:57:09 +00:00
/**
2015-03-23 23:46:30 +00:00
* If true all calls to Loader.reset will be ignored. Useful if you need to create a load queue before swapping to a preloader state.
* @property {boolean} resetLocked
2013-11-28 15:57:09 +00:00
* @default
*/
2015-03-23 23:46:30 +00:00
this.resetLocked = false;
2013-11-28 15:57:09 +00:00
/**
2015-03-23 23:46:30 +00:00
* True if the Loader is in the process of loading the queue.
* @property {boolean} isLoading
2013-11-28 15:57:09 +00:00
* @default
*/
2015-03-23 23:46:30 +00:00
this.isLoading = false;
2013-11-28 15:57:09 +00:00
2014-02-05 06:29:17 +00:00
/**
2015-03-23 23:46:30 +00:00
* True if all assets in the queue have finished loading.
* @property {boolean} hasLoaded
2014-02-05 06:29:17 +00:00
* @default
*/
2015-03-23 23:46:30 +00:00
this.hasLoaded = false;
2014-02-05 06:29:17 +00:00
2013-11-28 15:57:09 +00:00
/**
2015-03-23 23:46:30 +00:00
* You can optionally link a progress sprite with {@link Phaser.Loader#setPreloadSprite setPreloadSprite}.
*
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
*
2015-03-23 23:46:30 +00:00
* @property {?object} preloadSprite
* @protected
2013-11-28 15:57:09 +00:00
*/
this.preloadSprite = null;
/**
2015-03-23 23:46:30 +00:00
* The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'.
* @property {boolean|string} crossOrigin
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.
2015-03-23 23:46:30 +00:00
* Useful if allowing the asset base url to be configured outside of the game code.
* The string _must_ end with a "/".
*
2013-11-28 15:57:09 +00:00
* @property {string} baseURL
*/
this.baseURL = '';
2015-07-22 14:31:30 +00:00
/**
* The value of `path`, if set, is placed before any _relative_ file path given. For example:
*
* `load.path = "images/sprites/";
* load.image("ball", "ball.png");
* load.image("tree", "level1/oaktree.png");
* load.image("boom", "http://server.com/explode.png");`
*
* Would load the `ball` file from `images/sprites/ball.png` and the tree from
* `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL
* given as it's an absolute URL.
*
* Please note that the path is added before the filename but *after* the baseURL (if set.)
*
* The string _must_ end with a "/".
*
* @property {string} path
*/
this.path = '';
2013-11-28 15:57:09 +00:00
/**
2015-03-23 23:46:30 +00:00
* This event is dispatched when the loading process starts: before the first file has been requested,
* but after all the initial packs have been loaded.
*
* @property {Phaser.Signal} onLoadStart
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
/**
2015-03-23 23:46:30 +00:00
* This event is dispatched when the final file in the load queue has either loaded or failed.
*
* @property {Phaser.Signal} onLoadComplete
*/
this.onLoadComplete = new Phaser.Signal();
/**
* This event is dispatched when an asset pack has either loaded or failed to load.
*
* This is called when the asset pack manifest file has loaded and successfully added its contents to the loader queue.
*
* Params: `(pack key, success?, total packs loaded, total packs)`
*
* @property {Phaser.Signal} onPackComplete
*/
this.onPackComplete = new Phaser.Signal();
/**
* This event is dispatched immediately before a file starts loading.
* It's possible the file may fail (eg. download error, invalid format) after this event is sent.
*
* Params: `(progress, file key, file url)`
*
* @property {Phaser.Signal} onFileStart
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
/**
2015-03-23 23:46:30 +00:00
* This event is dispatched when a file has either loaded or failed to load.
*
2015-07-22 14:31:30 +00:00
* Any function bound to this will receive the following parameters:
*
* progress, file key, success?, total loaded files, total files
*
* Where progress is a number between 1 and 100 (inclusive) representing the percentage of the load.
2015-03-23 23:46:30 +00:00
*
* @property {Phaser.Signal} onFileComplete
2013-11-28 15:57:09 +00:00
*/
2014-04-15 14:39:23 +00:00
this.onFileComplete = new Phaser.Signal();
2015-03-23 23:46:30 +00:00
2013-11-28 15:57:09 +00:00
/**
2015-03-23 23:46:30 +00:00
* This event is dispatched when a file (or pack) errors as a result of the load request.
*
* For files it will be triggered before `onFileComplete`. For packs it will be triggered before `onPackComplete`.
*
* Params: `(file key, file)`
*
* @property {Phaser.Signal} onFileError
2014-04-15 14:39:23 +00:00
*/
this.onFileError = new Phaser.Signal();
/**
2015-03-23 23:46:30 +00:00
* If true and if the browser supports XDomainRequest, it will be used in preference for XHR.
*
* This is only relevant for IE 9 and should _only_ be enabled for IE 9 clients when required by the server/CDN.
*
* @property {boolean} useXDomainRequest
* @deprecated This is only relevant for IE 9.
*/
this.useXDomainRequest = false;
/**
* @private
* @property {boolean} _warnedAboutXDomainRequest - Control number of warnings for using XDR outside of IE 9.
2013-11-28 15:57:09 +00:00
*/
2015-03-23 23:46:30 +00:00
this._warnedAboutXDomainRequest = false;
/**
* If true (the default) then parallel downloading will be enabled.
*
* To disable all parallel downloads this must be set to false prior to any resource being loaded.
*
* @property {integer} enableParallel
*/
this.enableParallel = true;
2013-10-02 14:05:55 +00:00
2014-07-18 11:45:51 +00:00
/**
2015-03-23 23:46:30 +00:00
* The number of concurrent / parallel resources to try and fetch at once.
*
* Many current browsers limit 6 requests per domain; this is slightly conservative.
*
* @property {integer} maxParallelDownloads
* @protected
2014-07-18 11:45:51 +00:00
*/
2015-03-23 23:46:30 +00:00
this.maxParallelDownloads = 4;
2014-10-09 15:12:53 +00:00
2014-09-09 14:36:56 +00:00
/**
2015-03-23 23:46:30 +00:00
* A counter: if more than zero, files will be automatically added as a synchronization point.
* @property {integer} _withSyncPointDepth;
2014-09-09 14:36:56 +00:00
*/
2015-03-23 23:46:30 +00:00
this._withSyncPointDepth = 0;
2014-09-09 14:36:56 +00:00
2014-07-10 19:31:11 +00:00
/**
2015-03-23 23:46:30 +00:00
* Contains all the information for asset files (including packs) to load.
*
* File/assets are only removed from the list after all loading completes.
*
* @property {file[]} _fileList
2014-07-10 19:31:11 +00:00
* @private
*/
2015-03-23 23:46:30 +00:00
this._fileList = [];
2014-07-10 19:31:11 +00:00
/**
2015-03-23 23:46:30 +00:00
* Inflight files (or packs) that are being fetched/processed.
*
* This means that if there are any files in the flight queue there should still be processing
* going on; it should only be empty before or after loading.
*
* The files in the queue may have additional properties added to them,
* including `requestObject` which is normally the associated XHR.
*
* @property {file[]} _flightQueue
2014-07-10 19:31:11 +00:00
* @private
*/
2015-03-23 23:46:30 +00:00
this._flightQueue = [];
2014-07-10 19:31:11 +00:00
/**
2015-03-23 23:46:30 +00:00
* The offset into the fileList past all the complete (loaded or error) entries.
*
* @property {integer} _processingHead
2014-07-10 19:31:11 +00:00
* @private
*/
2015-03-23 23:46:30 +00:00
this._processingHead = 0;
2014-07-10 19:31:11 +00:00
/**
2015-03-23 23:46:30 +00:00
* True when the first file (not pack) has loading started.
* This used to to control dispatching `onLoadStart` which happens after any initial packs are loaded.
*
* @property {boolean} _initialPacksLoaded
2014-07-10 19:31:11 +00:00
* @private
*/
2015-03-23 23:46:30 +00:00
this._fileLoadStarted = false;
2014-07-10 19:31:11 +00:00
/**
2015-03-23 23:46:30 +00:00
* Total packs seen - adjusted when a pack is added.
* @property {integer} _totalPackCount
2014-07-10 19:31:11 +00:00
* @private
*/
2015-03-23 23:46:30 +00:00
this._totalPackCount = 0;
2014-07-10 19:31:11 +00:00
/**
2015-03-23 23:46:30 +00:00
* Total files seen - adjusted when a file is added.
* @property {integer} _totalFileCount
* @private
*/
this._totalFileCount = 0;
/**
* Total packs loaded - adjusted just prior to `onPackComplete`.
* @property {integer} _loadedPackCount
2014-07-10 19:31:11 +00:00
* @private
*/
2015-03-23 23:46:30 +00:00
this._loadedPackCount = 0;
2014-07-10 19:31:11 +00:00
/**
2015-03-23 23:46:30 +00:00
* Total files loaded - adjusted just prior to `onFileComplete`.
* @property {integer} _loadedFileCount
2014-07-10 19:31:11 +00:00
* @private
*/
2015-03-23 23:46:30 +00:00
this._loadedFileCount = 0;
2014-07-10 19:31:11 +00:00
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
/**
2015-03-23 23:46:30 +00:00
* Set a Sprite to be a "preload" sprite by passing it to this method.
*
2013-11-28 15:57:09 +00:00
* A "preload" sprite will have its width or height crop adjusted based on the percentage of the loader in real-time.
2015-03-23 23:46:30 +00:00
* This allows you to easily make loading bars for games.
*
* The sprite will automatically be made visible 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.
2015-03-23 23:46:30 +00:00
*
* This can be used to adjust the preloading sprite size, eg.
2014-11-15 20:01:46 +00:00
*
* @method Phaser.Loader#resize
2015-03-23 23:46:30 +00:00
* @protected
2014-11-15 20:01:46 +00:00
*/
resize: function () {
2015-03-23 23:46:30 +00:00
if (this.preloadSprite & & this.preloadSprite.height !== this.preloadSprite.sprite.height)
2014-11-15 20:01:46 +00:00
{
this.preloadSprite.rect.height = this.preloadSprite.sprite.height;
}
},
2013-11-28 15:57:09 +00:00
/**
2015-03-23 23:46:30 +00:00
* Check whether a file/asset with a specific key is queued to be loaded.
*
* To access a loaded asset use Phaser.Cache, eg. {@link 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) {
2015-03-23 23:46:30 +00:00
return this.getAssetIndex(type, key) > -1;
2014-03-28 01:42:49 +00:00
2013-11-28 15:57:09 +00:00
},
2014-03-14 06:36:05 +00:00
/**
2015-03-23 23:46:30 +00:00
* Get the queue-index of the file/asset with a specific key.
*
* Only assets in the download file queue will be found.
2014-03-14 06:36:05 +00:00
*
* @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.
2015-03-23 23:46:30 +00:00
* The index may change and should only be used immediately following this call
2014-03-14 06:36:05 +00:00
*/
getAssetIndex: function (type, key) {
2015-03-23 23:46:30 +00:00
var bestFound = -1;
for (var i = 0; i < this._fileList.length; i++)
2014-03-14 06:36:05 +00:00
{
2015-03-23 23:46:30 +00:00
var file = this._fileList[i];
if (file.type === type & & file.key === key)
2014-03-14 06:36:05 +00:00
{
2015-03-23 23:46:30 +00:00
bestFound = i;
// An already loaded/loading file may be superceded.
if (!file.loaded & & !file.loading)
2014-03-14 06:36:05 +00:00
{
2015-03-23 23:46:30 +00:00
break;
2014-03-14 06:36:05 +00:00
}
}
}
2015-03-23 23:46:30 +00:00
return bestFound;
2014-03-28 01:42:49 +00:00
2014-03-14 06:36:05 +00:00
},
2013-11-28 15:57:09 +00:00
/**
2015-03-23 23:46:30 +00:00
* Find a file/asset with a specific key.
*
* Only assets in the download file queue will be found.
2013-11-28 15:57:09 +00:00
*
* @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.
2015-03-23 23:46:30 +00:00
* @return {any} Returns an object if found that has 2 properties: `index` and `file`; otherwise a non-true value is returned.
* The index may change and should only be used immediately following this call.
2013-11-28 15:57:09 +00:00
*/
getAsset: function (type, key) {
2015-03-23 23:46:30 +00:00
var fileIndex = this.getAssetIndex(type, key);
if (fileIndex > -1)
2013-11-28 15:57:09 +00:00
{
2015-03-23 23:46:30 +00:00
return { index: fileIndex, file: this._fileList[fileIndex] };
2013-11-28 15:57:09 +00:00
}
return false;
2014-03-28 01:42:49 +00:00
2013-11-28 15:57:09 +00:00
},
/**
2015-03-23 23:46:30 +00:00
* Reset the loader and clear any queued assets. If `Loader.resetLocked` is true this operation will abort.
*
* This will abort any loading and clear any queued assets.
*
* Optionally you can clear any associated events.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#reset
2015-03-23 23:46:30 +00:00
* @protected
* @param {boolean} [hard=false] - If true then the preload sprite and other artifacts may also be cleared.
* @param {boolean} [clearEvents=false] - If true then the all Loader signals will have removeAll called on them.
2013-11-28 15:57:09 +00:00
*/
2015-03-23 23:46:30 +00:00
reset: function (hard, clearEvents) {
2013-11-28 15:57:09 +00:00
2015-07-22 14:31:30 +00:00
if (clearEvents === undefined) { clearEvents = false; }
2015-03-23 23:46:30 +00:00
if (this.resetLocked)
{
return;
}
if (hard)
{
this.preloadSprite = null;
}
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
this.isLoading = false;
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
this._processingHead = 0;
2013-11-28 15:57:09 +00:00
this._fileList.length = 0;
2015-03-23 23:46:30 +00:00
this._flightQueue.length = 0;
this._fileLoadStarted = false;
this._totalFileCount = 0;
this._totalPackCount = 0;
this._loadedPackCount = 0;
this._loadedFileCount = 0;
if (clearEvents)
{
this.onLoadStart.removeAll();
this.onLoadComplete.removeAll();
this.onPackComplete.removeAll();
this.onFileStart.removeAll();
this.onFileComplete.removeAll();
this.onFileError.removeAll();
}
2013-11-28 15:57:09 +00:00
},
/**
* 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.
2015-07-22 14:31:30 +00:00
* @param {string} [url] - The URL the asset will be loaded from.
2015-03-23 23:46:30 +00:00
* @param {object} [properties=(none)] - Any additional properties needed to load the file. These are added directly to the added file object and overwrite any defaults.
* @param {boolean} [overwrite=false] - If true then this will overwrite a file asset of the same type/key. Otherwise it will will only add a new asset. If overwrite is true, and the asset is already being loaded (or has been loaded), then it is appended instead.
2015-07-22 14:31:30 +00:00
* @param {string} [extension] - If no URL is given the Loader will sometimes auto-generate the URL based on the key, using this as the extension.
* @return {Phaser.Loader} This instance of the Phaser Loader.
2013-11-28 15:57:09 +00:00
*/
2015-07-22 14:31:30 +00:00
addToFileList: function (type, key, url, properties, overwrite, extension) {
if (overwrite === undefined) { overwrite = false; }
if (key === undefined || key === '')
{
console.warn("Phaser.Loader: Invalid or no key given of type " + type);
return this;
}
if (url === undefined || url === null)
{
if (extension)
{
url = key + extension;
}
else
{
console.warn("Phaser.Loader: No URL given for file type: " + type + " key: " + key);
return this;
}
}
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
var file = {
2013-11-28 15:57:09 +00:00
type: type,
key: key,
2015-07-22 14:31:30 +00:00
path: this.path,
2013-11-28 15:57:09 +00:00
url: url,
2015-03-23 23:46:30 +00:00
syncPoint: this._withSyncPointDepth > 0,
2013-11-28 15:57:09 +00:00
data: null,
2015-03-23 23:46:30 +00:00
loading: false,
loaded: false,
error: false
2013-11-28 15:57:09 +00:00
};
2015-03-23 23:46:30 +00:00
if (properties)
2013-11-28 15:57:09 +00:00
{
for (var prop in properties)
{
2015-03-23 23:46:30 +00:00
file[prop] = properties[prop];
2013-11-28 15:57:09 +00:00
}
}
2015-03-23 23:46:30 +00:00
var fileIndex = this.getAssetIndex(type, key);
if (overwrite & & fileIndex > -1)
{
var currentFile = this._fileList[fileIndex];
if (!currentFile.loading & & !currentFile.loaded)
{
this._fileList[fileIndex] = file;
}
else
{
this._fileList.push(file);
this._totalFileCount++;
}
}
else if (fileIndex === -1)
2013-11-28 15:57:09 +00:00
{
2015-03-23 23:46:30 +00:00
this._fileList.push(file);
this._totalFileCount++;
2013-11-28 15:57:09 +00:00
}
2015-07-22 14:31:30 +00:00
return this;
2013-11-28 15:57:09 +00:00
},
/**
* Internal function that replaces an existing entry in the file list with a new one. Do not call directly.
*
* @method Phaser.Loader#replaceInFileList
2015-03-23 23:46:30 +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.
*/
replaceInFileList: function (type, key, url, properties) {
2015-03-23 23:46:30 +00:00
return this.addToFileList(type, key, url, properties, true);
2013-11-28 15:57:09 +00:00
},
2014-07-10 19:31:11 +00:00
/**
2015-03-23 23:46:30 +00:00
* Add a JSON resource pack ('packfile') to the Loader.
*
2015-07-22 14:31:30 +00:00
* A packfile is a JSON file that contains a list of assets to the be loaded.
* Please see the example 'loader/asset pack' in the Phaser Examples repository.
*
* Packs are always put before the first non-pack file that is not loaded / loading.
*
2015-03-23 23:46:30 +00:00
* This means that all packs added before any loading has started are added to the front
2015-07-22 14:31:30 +00:00
* of the file queue, in the order added.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* The URL of the packfile can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
2014-07-10 19:31:11 +00:00
*
* @method Phaser.Loader#pack
2015-03-23 23:46:30 +00:00
* @param {string} key - Unique asset key of this resource pack.
2014-07-10 19:31:11 +00:00
* @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
2015-03-23 23:46:30 +00:00
* @param {object} [callbackContext=(loader)] - Some Loader operations, like Binary and Script require a context for their callbacks. Pass the context here.
2014-07-10 19:31:11 +00:00
* @return {Phaser.Loader} This Loader instance.
*/
pack: function (key, url, data, callbackContext) {
2015-07-22 14:31:30 +00:00
if (url === undefined) { url = null; }
if (data === undefined) { data = null; }
if (callbackContext === undefined) { callbackContext = null; }
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
if (!url & & !data)
2014-07-10 19:31:11 +00:00
{
console.warn('Phaser.Loader.pack - Both url and data are null. One must be set.');
2015-03-23 23:46:30 +00:00
2014-07-10 19:31:11 +00:00
return this;
}
2015-03-23 23:46:30 +00:00
var pack = {
type: 'packfile',
key: key,
url: url,
2015-07-22 14:31:30 +00:00
path: this.path,
2015-03-23 23:46:30 +00:00
syncPoint: true,
data: null,
loading: false,
loaded: false,
error: false,
callbackContext: callbackContext
};
2014-07-10 19:31:11 +00:00
// A data object has been given
if (data)
{
if (typeof data === 'string')
{
data = JSON.parse(data);
}
2015-03-23 23:46:30 +00:00
pack.data = data || {};
// Already consider 'loaded'
pack.loaded = true;
2014-07-10 19:31:11 +00:00
}
2015-03-23 23:46:30 +00:00
// Add before first non-pack/no-loaded ~ last pack from start prior to loading
// (Read one past for splice-to-end)
for (var i = 0; i < this._fileList.length + 1; i++)
{
var file = this._fileList[i];
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
if (!file || (!file.loaded & & !file.loading & & file.type !== 'packfile'))
{
this._fileList.splice(i, 1, pack);
this._totalPackCount++;
break;
}
}
2014-07-10 19:31:11 +00:00
return this;
},
2013-11-28 15:57:09 +00:00
/**
2015-07-22 14:31:30 +00:00
* Adds an Image to the current load queue.
*
* The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.
*
* Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* Retrieve the image via `Cache.getImage(key)`
*
* The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien"
* and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension.
* If you do not desire this action then provide a URL.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#image
* @param {string} key - Unique asset key of this image file.
2015-07-22 14:31:30 +00:00
* @param {string} [url] - URL of an image file. If undefined or `null` the url will be set to `< key>.png`, i.e. if `key` was "alien" then the URL will be "alien.png".
2013-11-28 15:57:09 +00:00
* @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) {
2015-07-22 14:31:30 +00:00
return this.addToFileList('image', key, url, undefined, overwrite, '.png');
2013-11-28 15:57:09 +00:00
},
/**
2015-07-22 14:31:30 +00:00
* Adds a Text file to the current load queue.
*
* The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* Retrieve the file via `Cache.getText(key)`
*
* The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien"
* and no URL is given then the Loader will set the URL to be "alien.txt". It will always add `.txt` as the extension.
* If you do not desire this action then provide a URL.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#text
* @param {string} key - Unique asset key of the text file.
2015-07-22 14:31:30 +00:00
* @param {string} [url] - URL of the text file. If undefined or `null` the url will be set to `< key>.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt".
2013-11-28 15:57:09 +00:00
* @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) {
2015-07-22 14:31:30 +00:00
return this.addToFileList('text', key, url, undefined, overwrite, '.txt');
2013-11-28 15:57:09 +00:00
},
2014-02-24 12:14:30 +00:00
/**
2015-07-22 14:31:30 +00:00
* Adds a JSON file to the current load queue.
*
* The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* Retrieve the file via `Cache.getJSON(key)`. JSON files are automatically parsed upon load.
* If you need to control when the JSON is parsed then use `Loader.text` instead and parse the text file as needed.
*
* The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien"
* and no URL is given then the Loader will set the URL to be "alien.json". It will always add `.json` as the extension.
* If you do not desire this action then provide a URL.
2014-02-24 12:14:30 +00:00
*
* @method Phaser.Loader#json
* @param {string} key - Unique asset key of the json file.
2015-07-22 14:31:30 +00:00
* @param {string} [url] - URL of the JSON file. If undefined or `null` the url will be set to `< key>.json`, i.e. if `key` was "alien" then the URL will be "alien.json".
2014-02-24 12:14:30 +00:00
* @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) {
2015-07-22 14:31:30 +00:00
return this.addToFileList('json', key, url, undefined, overwrite, '.json');
2014-02-24 12:14:30 +00:00
2015-07-22 14:31:30 +00:00
},
2014-02-24 12:14:30 +00:00
2015-07-22 14:31:30 +00:00
/**
* Adds a fragment shader file to the current load queue.
*
* The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* Retrieve the file via `Cache.getShader(key)`.
*
* The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "blur"
* and no URL is given then the Loader will set the URL to be "blur.frag". It will always add `.frag` as the extension.
* If you do not desire this action then provide a URL.
*
* @method Phaser.Loader#shader
* @param {string} key - Unique asset key of the fragment file.
* @param {string} [url] - URL of the fragment file. If undefined or `null` the url will be set to `< key>.frag`, i.e. if `key` was "blur" then the URL will be "blur.frag".
* @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.
*/
shader: function (key, url, overwrite) {
return this.addToFileList('shader', key, url, undefined, overwrite, '.frag');
2014-02-24 12:14:30 +00:00
},
2014-10-09 15:12:53 +00:00
/**
2015-07-22 14:31:30 +00:00
* Adds an XML file to the current load queue.
*
* The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* Retrieve the file via `Cache.getXML(key)`.
*
* The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien"
* and no URL is given then the Loader will set the URL to be "alien.xml". It will always add `.xml` as the extension.
* If you do not desire this action then provide a URL.
2014-10-09 15:12:53 +00:00
*
* @method Phaser.Loader#xml
* @param {string} key - Unique asset key of the xml file.
2015-07-22 14:31:30 +00:00
* @param {string} [url] - URL of the XML file. If undefined or `null` the url will be set to `< key>.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml".
2014-10-09 15:12:53 +00:00
* @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) {
2015-07-22 14:31:30 +00:00
return this.addToFileList('xml', key, url, undefined, overwrite, '.xml');
2014-10-09 15:12:53 +00:00
},
2013-11-28 15:57:09 +00:00
/**
2015-07-22 14:31:30 +00:00
* Adds a JavaScript file to the current load queue.
*
* The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.
*
* The key must be a unique String.
*
* The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien"
* and no URL is given then the Loader will set the URL to be "alien.js". It will always add `.js` as the extension.
* If you do not desire this action then provide a URL.
2015-03-23 23:46:30 +00:00
*
2015-07-22 14:31:30 +00:00
* Upon successful load the JavaScript is automatically turned into a script tag and executed, so be careful what you load!
2015-03-23 23:46:30 +00:00
*
* A callback, which will be invoked as the script tag has been created, can also be specified.
* The callback must return relevant `data`.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#script
* @param {string} key - Unique asset key of the script file.
2015-07-22 14:31:30 +00:00
* @param {string} [url] - URL of the JavaScript file. If undefined or `null` the url will be set to `< key>.js`, i.e. if `key` was "alien" then the URL will be "alien.js".
2015-03-23 23:46:30 +00:00
* @param {function} [callback=(none)] - Optional callback that will be called after the script tag has loaded, so you can perform additional processing.
2015-07-22 14:31:30 +00:00
* @param {object} [callbackContext=(loader)] - The context under which the callback will be applied. If not specified it will use the Phaser Loader 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
2015-07-22 14:31:30 +00:00
if (callback === undefined) { callback = false; }
2015-03-23 23:46:30 +00:00
2015-07-22 14:31:30 +00:00
if (callback !== false & & callbackContext === undefined) { callbackContext = this; }
2013-11-28 15:57:09 +00:00
2015-07-22 14:31:30 +00:00
return this.addToFileList('script', key, url, { syncPoint: true, callback: callback, callbackContext: callbackContext }, false, '.js');
2013-11-28 15:57:09 +00:00
},
/**
2015-07-22 14:31:30 +00:00
* Adds a binary file to the current load queue.
*
* The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* Retrieve the file via `Cache.getBinary(key)`.
*
* The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien"
* and no URL is given then the Loader will set the URL to be "alien.bin". It will always add `.bin` as the extension.
* If you do not desire this action then provide a URL.
2015-03-23 23:46:30 +00:00
*
* It will be loaded via xhr with a responseType of "arraybuffer". You can specify an optional callback to process the file after load.
2014-02-05 06:29:17 +00:00
* When the callback is called it will be passed 2 parameters: the key of the file and the file data.
2015-03-23 23:46:30 +00:00
*
* WARNING: If a callback is specified the data will be set to whatever it returns. 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.
2015-07-22 14:31:30 +00:00
* @param {string} [url] - URL of the binary file. If undefined or `null` the url will be set to `< key>.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin".
2015-03-23 23:46:30 +00:00
* @param {function} [callback=(none)] - Optional callback that will be passed the file after loading, so you can perform additional processing on it.
* @param {object} [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
2015-07-22 14:31:30 +00:00
if (callback === undefined) { callback = false; }
2015-03-23 23:46:30 +00:00
// Why is the default callback context the ..callback?
2015-07-22 14:31:30 +00:00
if (callback !== false & & callbackContext === undefined) { callbackContext = callback; }
2013-11-28 15:57:09 +00:00
2015-07-22 14:31:30 +00:00
return this.addToFileList('binary', key, url, { callback: callback, callbackContext: callbackContext }, false, '.bin');
2013-11-28 15:57:09 +00:00
},
/**
2015-07-22 14:31:30 +00:00
* Adds a Sprite Sheet to the current load queue.
*
* The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.
*
* To clarify the terminology that Phaser uses: A Sprite Sheet is an image containing frames, usually of an animation, that are all equal
* dimensions and often in sequence. For example if the frame size is 32x32 then every frame in the sprite sheet will be that size.
* Sometimes (outside of Phaser) the term "sprite sheet" is used to refer to a texture atlas.
* A Texture Atlas works by packing together images as best it can, using whatever frame sizes it likes, often with cropping and trimming
* the frames in the process. Software such as Texture Packer, Flash CC or Shoebox all generate texture atlases, not sprite sheets.
* If you've got an atlas then use `Loader.atlas` instead.
*
* The key must be a unique String. It is used to add the image to the Phaser.Cache upon successful load.
*
* Retrieve the file via `Cache.getImage(key)`. Sprite sheets, being image based, live in the same Cache as all other Images.
*
* The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien"
* and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension.
* If you do not desire this action then provide a URL.
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.
2015-07-22 14:31:30 +00:00
* @param {string} url - URL of the sprite sheet file. If undefined or `null` the url will be set to `< key>.png`, i.e. if `key` was "alien" then the URL will be "alien.png".
* @param {number} frameWidth - Width in pixels of a single frame in the sprite sheet.
* @param {number} frameHeight - Height in pixels of a single frame in the sprite sheet.
2014-02-05 06:29:17 +00:00
* @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
2015-07-22 14:31:30 +00:00
if (frameMax === undefined) { frameMax = -1; }
if (margin === undefined) { margin = 0; }
if (spacing === undefined) { spacing = 0; }
2013-11-28 15:57:09 +00:00
2015-07-22 14:31:30 +00:00
return this.addToFileList('spritesheet', key, url, { frameWidth: frameWidth, frameHeight: frameHeight, frameMax: frameMax, margin: margin, spacing: spacing }, false, '.png');
2013-11-28 15:57:09 +00:00
},
/**
2015-07-22 14:31:30 +00:00
* Adds an audio file to the current load queue.
*
* The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* Retrieve the file via `Cache.getSound(key)`.
*
* The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* Mobile warning: There are some mobile devices (certain iPad 2 and iPad Mini revisions) that cannot play 48000 Hz audio.
* When they try to play the audio becomes extremely distorted and buzzes, eventually crashing the sound system.
* The solution is to use a lower encoding rate such as 44100 Hz.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#audio
* @param {string} key - Unique asset key of the audio file.
2015-03-23 23:46:30 +00:00
* @param {string|string[]|object[]} urls - Either a single string or an array of URIs or pairs of `{uri: .., type: ..}`.
* If an array is specified then the first URI (or URI + mime pair) that is device-compatible will be selected.
* For example: `"jump.mp3"`, `['jump.mp3', 'jump.ogg', 'jump.m4a']`, or `[{uri: "data:< opus_resource>", type: 'opus'}, 'fallback.mp3']`.
* BLOB and DATA URIs can be used but only support automatic detection when used in the pair form; otherwise the format must be manually checked before adding the resource.
* @param {boolean} [autoDecode=true] - When using Web Audio the audio files can either be decoded at load time or run-time.
2015-07-22 14:31:30 +00:00
* Audio files can't be played until they are decoded and, if specified, this enables immediate decoding. Decoding is a non-blocking async process, however it consumes huge amounts of CPU time on mobiles especially.
2013-11-28 15:57:09 +00:00
* @return {Phaser.Loader} This Loader instance.
*/
audio: function (key, urls, autoDecode) {
2015-07-22 14:31:30 +00:00
if (this.game.sound.noAudio)
{
return this;
}
if (autoDecode === undefined) { autoDecode = true; }
2015-03-23 23:46:30 +00:00
if (typeof urls === 'string')
{
urls = [urls];
}
2013-11-28 15:57:09 +00:00
2015-07-22 14:31:30 +00:00
return this.addToFileList('audio', key, urls, { buffer: null, autoDecode: autoDecode });
2013-11-28 15:57:09 +00:00
},
2014-10-09 15:12:53 +00:00
/**
2015-07-22 14:31:30 +00:00
* Adds an audio sprite file to the current load queue.
*
* The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
2015-03-23 23:46:30 +00:00
*
* Audio Sprites are a combination of audio files and a JSON configuration.
2015-07-22 14:31:30 +00:00
*
2015-03-23 23:46:30 +00:00
* The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite
2015-07-22 14:31:30 +00:00
*
* Retrieve the file via `Cache.getSoundData(key)`.
*
* The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
2015-03-23 23:46:30 +00:00
*
* @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} [jsonURL=null] - The URL of the audiosprite configuration JSON object. If you wish to pass the data directly set this parameter to null.
* @param {string|object} [jsonData=null] - A JSON object or string containing the audiosprite configuration data. This is ignored if jsonURL is not null.
* @param {boolean} [autoDecode=true] - When using Web Audio the audio files can either be decoded at load time or run-time.
2015-07-22 14:31:30 +00:00
* Audio files can't be played until they are decoded and, if specified, this enables immediate decoding. Decoding is a non-blocking async process, however it consumes huge amounts of CPU time on mobiles especially.
2015-03-23 23:46:30 +00:00
* @return {Phaser.Loader} This Loader instance.
*/
audiosprite: function(key, urls, jsonURL, jsonData, autoDecode) {
2015-07-22 14:31:30 +00:00
if (this.game.sound.noAudio)
{
return this;
}
if (jsonURL === undefined) { jsonURL = null; }
if (jsonData === undefined) { jsonData = null; }
if (autoDecode === undefined) { autoDecode = true; }
2014-10-09 15:12:53 +00:00
2015-03-23 23:46:30 +00:00
this.audio(key, urls, autoDecode);
2014-10-09 15:12:53 +00:00
2015-03-23 23:46:30 +00:00
if (jsonURL)
{
this.json(key + '-audioatlas', jsonURL);
}
else if (jsonData)
{
if (typeof jsonData === 'string')
{
jsonData = JSON.parse(jsonData);
}
2015-07-22 14:31:30 +00:00
this.cache.addJSON(key + '-audioatlas', '', jsonData);
2015-03-23 23:46:30 +00:00
}
else
{
console.warn('Phaser.Loader.audiosprite - You must specify either a jsonURL or provide a jsonData object');
}
2014-10-09 15:12:53 +00:00
return this;
},
2015-07-22 14:31:30 +00:00
2013-11-28 15:57:09 +00:00
/**
2015-07-22 14:31:30 +00:00
* Adds a video file to the current load queue.
*
* The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* Retrieve the file via `Cache.getVideo(key)`.
*
* The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* You don't need to preload a video in order to play it in your game. See `Video.createVideoFromURL` for details.
*
* @method Phaser.Loader#video
* @param {string} key - Unique asset key of the video file.
* @param {string|string[]|object[]} urls - Either a single string or an array of URIs or pairs of `{uri: .., type: ..}`.
* If an array is specified then the first URI (or URI + mime pair) that is device-compatible will be selected.
* For example: `"boom.mp4"`, `['boom.mp4', 'boom.ogg', 'boom.webm']`, or `[{uri: "data:< opus_resource>", type: 'opus'}, 'fallback.mp4']`.
* BLOB and DATA URIs can be used but only support automatic detection when used in the pair form; otherwise the format must be manually checked before adding the resource.
* @param {string} [loadEvent='canplaythrough'] - This sets the Video source event to listen for before the load is considered complete.
* 'canplaythrough' implies the video has downloaded enough, and bandwidth is high enough that it can be played to completion.
* 'canplay' implies the video has downloaded enough to start playing, but not necessarily to finish.
* 'loadeddata' just makes sure that the video meta data and first frame have downloaded. Phaser uses this value automatically if the
* browser is detected as being Firefox and no `loadEvent` is given, otherwise it defaults to `canplaythrough`.
* @param {boolean} [asBlob=false] - Video files can either be loaded via the creation of a video element which has its src property set.
* Or they can be loaded via xhr, stored as binary data in memory and then converted to a Blob. This isn't supported in IE9 or Android 2.
* If you need to have the same video playing at different times across multiple Sprites then you need to load it as a Blob.
* @return {Phaser.Loader} This Loader instance.
*/
video: function (key, urls, loadEvent, asBlob) {
if (loadEvent === undefined)
{
if (this.game.device.firefox)
{
loadEvent = 'loadeddata';
}
else
{
loadEvent = 'canplaythrough';
}
}
if (asBlob === undefined) { asBlob = false; }
if (typeof urls === 'string')
{
urls = [urls];
}
return this.addToFileList('video', key, urls, { buffer: null, asBlob: asBlob, loadEvent: loadEvent });
},
/**
* Adds a Tile Map data file to the current load queue.
*
* You can choose to either load the data externally, by providing a URL to a json file.
* Or you can pass in a JSON object or String via the `data` parameter.
* If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache.
*
* If a URL is provided the file is **not** loaded immediately after calling this method, but is added to the load queue.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* Retrieve the file via `Cache.getTilemapData(key)`. JSON files are automatically parsed upon load.
* If you need to control when the JSON is parsed then use `Loader.text` instead and parse the text file as needed.
*
* The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the URL isn't specified and no data is given then the Loader will take the key and create a filename from that.
* For example if the key is "level1" and no URL or data is given then the Loader will set the URL to be "level1.json".
* If you set the format to be Tilemap.CSV it will set the URL to be "level1.csv" instead.
*
* If you do not desire this action then provide a URL or data object.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#tilemap
* @param {string} key - Unique asset key of the tilemap data.
2015-07-22 14:31:30 +00:00
* @param {string} [url] - URL of the tile map file. If undefined or `null` and no data is given the url will be set to `< key>.json`, i.e. if `key` was "level1" then the URL will be "level1.json".
* @param {object|string} [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
2015-07-22 14:31:30 +00:00
if (url === undefined) { url = null; }
if (data === undefined) { data = null; }
if (format === undefined) { format = Phaser.Tilemap.CSV; }
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
if (!url & & !data)
2013-11-28 15:57:09 +00:00
{
2015-07-22 14:31:30 +00:00
if (format === Phaser.Tilemap.CSV)
{
url = key + '.csv';
}
else
{
url = key + '.json';
}
2013-11-28 15:57:09 +00:00
}
// 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;
2015-07-22 14:31:30 +00:00
// A json string or object has been given
2013-11-28 15:57:09 +00:00
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;
}
2015-07-22 14:31:30 +00:00
this.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
/**
2015-07-22 14:31:30 +00:00
* Adds a physics data file to the current load queue.
*
* The data must be in `Lime + Corona` JSON format. [Physics Editor](https://www.codeandweb.com) by code'n'web exports in this format natively.
*
* You can choose to either load the data externally, by providing a URL to a json file.
* Or you can pass in a JSON object or String via the `data` parameter.
* If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache.
*
* If a URL is provided the file is **not** loaded immediately after calling this method, but is added to the load queue.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
2015-03-23 23:46:30 +00:00
*
2015-07-22 14:31:30 +00:00
* Retrieve the file via `Cache.getJSON(key)`. JSON files are automatically parsed upon load.
* If you need to control when the JSON is parsed then use `Loader.text` instead and parse the text file as needed.
*
* The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the URL isn't specified and no data is given then the Loader will take the key and create a filename from that.
* For example if the key is "alien" and no URL or data is given then the Loader will set the URL to be "alien.json".
* It will always use `.json` as the extension.
*
* If you do not desire this action then provide a URL or data object.
2014-02-18 03:01:51 +00:00
*
* @method Phaser.Loader#physics
* @param {string} key - Unique asset key of the physics json data.
2015-07-22 14:31:30 +00:00
* @param {string} [url] - URL of the physics data file. If undefined or `null` and no data is given the url will be set to `< key>.json`, i.e. if `key` was "alien" then the URL will be "alien.json".
* @param {object|string} [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
2015-07-22 14:31:30 +00:00
if (url === undefined) { url = null; }
if (data === undefined) { data = null; }
if (format === undefined) { format = Phaser.Physics.LIME_CORONA_JSON; }
2014-02-18 03:01:51 +00:00
2015-03-23 23:46:30 +00:00
if (!url & & !data)
2014-02-18 03:01:51 +00:00
{
2015-07-22 14:31:30 +00:00
url = key + '.json';
2014-02-18 03:01:51 +00:00
}
// 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
}
2015-07-22 14:31:30 +00:00
this.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
/**
2015-07-22 14:31:30 +00:00
* Adds Bitmap Font files to the current load queue.
*
* To create the Bitmap Font files you can use:
*
* BMFont (Windows, free): http://www.angelcode.com/products/bmfont/
* Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner
* Littera (Web-based, free): http://kvazars.com/littera/
*
* You can choose to either load the data externally, by providing a URL to an xml file.
* Or you can pass in an XML object or String via the `xmlData` parameter.
* If you pass a String the data is automatically run through `Loader.parseXML` and then immediately added to the Phaser.Cache.
*
* If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* Retrieve the file via `Cache.getBitmapFont(key)`. XML files are automatically parsed upon load.
* If you need to control when the XML is parsed then use `Loader.text` instead and parse the XML file as needed.
*
* The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the textureURL isn't specified then the Loader will take the key and create a filename from that.
* For example if the key is "megaFont" and textureURL is null then the Loader will set the URL to be "megaFont.png".
* The same is true for the xmlURL. If xmlURL isn't specified and no xmlData has been provided then the Loader will
* set the xmlURL to be the key. For example if the key is "megaFont" the xmlURL will be set to "megaFont.xml".
*
* If you do not desire this action then provide URLs and / or a data object.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#bitmapFont
* @param {string} key - Unique asset key of the bitmap font.
2015-07-22 14:31:30 +00:00
* @param {string} textureURL - URL of the Bitmap Font texture file. If undefined or `null` the url will be set to `< key>.png`, i.e. if `key` was "megaFont" then the URL will be "megaFont.png".
* @param {string} atlasURL - URL of the Bitmap Font atlas file (xml/json).
* @param {object} atlasData - An optional Bitmap Font atlas in string form (stringified xml/json).
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.
*/
2015-07-22 14:31:30 +00:00
bitmapFont: function (key, textureURL, atlasURL, atlasData, xSpacing, ySpacing) {
if (textureURL === undefined || textureURL === null)
{
textureURL = key + '.png';
}
2013-11-28 15:57:09 +00:00
2015-07-22 14:31:30 +00:00
if (atlasURL === undefined) { atlasURL = null; }
if (atlasData === undefined) { atlasData = null; }
if (xSpacing === undefined) { xSpacing = 0; }
if (ySpacing === undefined) { ySpacing = 0; }
2013-11-28 15:57:09 +00:00
2015-07-22 14:31:30 +00:00
// A URL to a json/xml atlas has been given
if (atlasURL)
2013-11-28 15:57:09 +00:00
{
2015-07-22 14:31:30 +00:00
this.addToFileList('bitmapfont', key, textureURL, { atlasURL: atlasURL, xSpacing: xSpacing, ySpacing: ySpacing });
2013-11-28 15:57:09 +00:00
}
else
{
2015-07-22 14:31:30 +00:00
// A stringified xml/json atlas has been given
if (typeof atlasData === 'string')
2013-11-28 15:57:09 +00:00
{
2015-07-22 14:31:30 +00:00
var json, xml;
try
{
json = JSON.parse(atlasData);
}
catch ( e )
{
xml = this.parseXml(atlasData);
}
2013-11-28 15:57:09 +00:00
2015-07-22 14:31:30 +00:00
if (!xml & & !json)
2013-11-28 15:57:09 +00:00
{
2015-07-22 14:31:30 +00:00
throw new Error("Phaser.Loader. Invalid Bitmap Font atlas given");
2013-11-28 15:57:09 +00:00
}
2015-03-23 23:46:30 +00:00
2015-07-22 14:31:30 +00:00
this.addToFileList('bitmapfont', key, textureURL, { atlasURL: null, atlasData: json || xml,
atlasType: (!!json ? 'json' : 'xml'), xSpacing: xSpacing, ySpacing: ySpacing });
2013-11-28 15:57:09 +00:00
}
}
return this;
},
/**
2015-07-22 14:31:30 +00:00
* Adds a Texture Atlas file to the current load queue.
*
* Unlike `Loader.atlasJSONHash` this call expects the atlas data to be in a JSON Array format.
*
* To create the Texture Atlas you can use tools such as:
2015-03-23 23:46:30 +00:00
*
2015-07-22 14:31:30 +00:00
* [Texture Packer](https://www.codeandweb.com/texturepacker/phaser)
2015-03-23 23:46:30 +00:00
* [Shoebox](http://renderhjs.net/shoebox/)
2015-07-22 14:31:30 +00:00
*
* If using Texture Packer we recommend you enable "Trim sprite names".
* If your atlas software has an option to "rotate" the resulting frames, you must disable it.
*
* You can choose to either load the data externally, by providing a URL to a json file.
* Or you can pass in a JSON object or String via the `atlasData` parameter.
* If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache.
*
* If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* Retrieve the file via `Cache.getImage(key)`. JSON files are automatically parsed upon load.
* If you need to control when the JSON is parsed then use `Loader.text` instead and parse the JSON file as needed.
*
* The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the textureURL isn't specified then the Loader will take the key and create a filename from that.
* For example if the key is "player" and textureURL is null then the Loader will set the URL to be "player.png".
* The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will
* set the atlasURL to be the key. For example if the key is "player" the atlasURL will be set to "player.json".
*
* If you do not desire this action then provide URLs and / or a data object.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#atlasJSONArray
* @param {string} key - Unique asset key of the texture atlas file.
2015-07-22 14:31:30 +00:00
* @param {string} [textureURL] - URL of the texture atlas image file. If undefined or `null` the url will be set to `< key>.png`, i.e. if `key` was "alien" then the URL will be "alien.png".
* @param {string} [atlasURL] - URL of the texture atlas data file. If undefined or `null` and no atlasData is given, the url will be set to `< key>.json`, i.e. if `key` was "alien" then the URL will be "alien.json".
* @param {object} [atlasData] - A JSON data object. You don't need this if the data is being loaded from a URL.
2013-11-28 15:57:09 +00:00
* @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);
},
/**
2015-07-22 14:31:30 +00:00
* Adds a Texture Atlas file to the current load queue.
*
* Unlike `Loader.atlas` this call expects the atlas data to be in a JSON Hash format.
*
* To create the Texture Atlas you can use tools such as:
2015-03-23 23:46:30 +00:00
*
2015-07-22 14:31:30 +00:00
* [Texture Packer](https://www.codeandweb.com/texturepacker/phaser)
2015-03-23 23:46:30 +00:00
* [Shoebox](http://renderhjs.net/shoebox/)
2015-07-22 14:31:30 +00:00
*
* If using Texture Packer we recommend you enable "Trim sprite names".
* If your atlas software has an option to "rotate" the resulting frames, you must disable it.
*
* You can choose to either load the data externally, by providing a URL to a json file.
* Or you can pass in a JSON object or String via the `atlasData` parameter.
* If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache.
*
* If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* Retrieve the file via `Cache.getImage(key)`. JSON files are automatically parsed upon load.
* If you need to control when the JSON is parsed then use `Loader.text` instead and parse the JSON file as needed.
*
* The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the textureURL isn't specified then the Loader will take the key and create a filename from that.
* For example if the key is "player" and textureURL is null then the Loader will set the URL to be "player.png".
* The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will
* set the atlasURL to be the key. For example if the key is "player" the atlasURL will be set to "player.json".
*
* If you do not desire this action then provide URLs and / or a data object.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#atlasJSONHash
* @param {string} key - Unique asset key of the texture atlas file.
2015-07-22 14:31:30 +00:00
* @param {string} [textureURL] - URL of the texture atlas image file. If undefined or `null` the url will be set to `< key>.png`, i.e. if `key` was "alien" then the URL will be "alien.png".
* @param {string} [atlasURL] - URL of the texture atlas data file. If undefined or `null` and no atlasData is given, the url will be set to `< key>.json`, i.e. if `key` was "alien" then the URL will be "alien.json".
* @param {object} [atlasData] - A JSON data object. You don't need this if the data is being loaded from a URL.
2013-11-28 15:57:09 +00:00
* @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);
},
/**
2015-07-22 14:31:30 +00:00
* Adds a Texture Atlas file to the current load queue.
*
* This call expects the atlas data to be in the Starling XML data format.
*
* To create the Texture Atlas you can use tools such as:
*
* [Texture Packer](https://www.codeandweb.com/texturepacker/phaser)
* [Shoebox](http://renderhjs.net/shoebox/)
*
* If using Texture Packer we recommend you enable "Trim sprite names".
* If your atlas software has an option to "rotate" the resulting frames, you must disable it.
*
* You can choose to either load the data externally, by providing a URL to an xml file.
* Or you can pass in an XML object or String via the `atlasData` parameter.
* If you pass a String the data is automatically run through `Loader.parseXML` and then immediately added to the Phaser.Cache.
*
* If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* Retrieve the file via `Cache.getImage(key)`. XML files are automatically parsed upon load.
* If you need to control when the XML is parsed then use `Loader.text` instead and parse the XML file as needed.
*
* The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the textureURL isn't specified then the Loader will take the key and create a filename from that.
* For example if the key is "player" and textureURL is null then the Loader will set the URL to be "player.png".
* The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will
* set the atlasURL to be the key. For example if the key is "player" the atlasURL will be set to "player.xml".
*
* If you do not desire this action then provide URLs and / or a data object.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#atlasXML
* @param {string} key - Unique asset key of the texture atlas file.
2015-07-22 14:31:30 +00:00
* @param {string} [textureURL] - URL of the texture atlas image file. If undefined or `null` the url will be set to `< key>.png`, i.e. if `key` was "alien" then the URL will be "alien.png".
* @param {string} [atlasURL] - URL of the texture atlas data file. If undefined or `null` and no atlasData is given, the url will be set to `< key>.json`, i.e. if `key` was "alien" then the URL will be "alien.xml".
* @param {object} [atlasData] - An XML data object. You don't need this if the data is being loaded from a URL.
2013-11-28 15:57:09 +00:00
* @return {Phaser.Loader} This Loader instance.
*/
atlasXML: function (key, textureURL, atlasURL, atlasData) {
2015-07-22 14:31:30 +00:00
if (atlasURL === undefined) { atlasURL = null; }
if (atlasData === undefined) { atlasData = null; }
if (!atlasURL & & !atlasData)
{
atlasURL = key + '.xml';
}
2013-11-28 15:57:09 +00:00
return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
},
/**
2015-07-22 14:31:30 +00:00
* Adds a Texture Atlas file to the current load queue.
2015-03-23 23:46:30 +00:00
*
2015-07-22 14:31:30 +00:00
* To create the Texture Atlas you can use tools such as:
*
* [Texture Packer](https://www.codeandweb.com/texturepacker/phaser)
2015-03-23 23:46:30 +00:00
* [Shoebox](http://renderhjs.net/shoebox/)
2013-11-28 15:57:09 +00:00
*
2015-07-22 14:31:30 +00:00
* If using Texture Packer we recommend you enable "Trim sprite names".
* If your atlas software has an option to "rotate" the resulting frames, you must disable it.
*
* You can choose to either load the data externally, by providing a URL to a json file.
* Or you can pass in a JSON object or String via the `atlasData` parameter.
* If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache.
*
* If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue.
*
* The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
*
* Retrieve the file via `Cache.getImage(key)`. JSON files are automatically parsed upon load.
* If you need to control when the JSON is parsed then use `Loader.text` instead and parse the JSON file as needed.
*
* The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
*
* If the textureURL isn't specified then the Loader will take the key and create a filename from that.
* For example if the key is "player" and textureURL is null then the Loader will set the URL to be "player.png".
* The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will
* set the atlasURL to be the key. For example if the key is "player" the atlasURL will be set to "player.json".
*
* If you do not desire this action then provide URLs and / or a data object.
*
2013-11-28 15:57:09 +00:00
* @method Phaser.Loader#atlas
* @param {string} key - Unique asset key of the texture atlas file.
2015-07-22 14:31:30 +00:00
* @param {string} [textureURL] - URL of the texture atlas image file. If undefined or `null` the url will be set to `< key>.png`, i.e. if `key` was "alien" then the URL will be "alien.png".
* @param {string} [atlasURL] - URL of the texture atlas data file. If undefined or `null` and no atlasData is given, the url will be set to `< key>.json`, i.e. if `key` was "alien" then the URL will be "alien.json".
2013-11-28 15:57:09 +00:00
* @param {object} [atlasData] - A JSON or XML data object. You don't need this if the data is being loaded from a URL.
2015-07-22 14:31:30 +00:00
* @param {number} [format] - The format of the data. Can be Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY (the default), Phaser.Loader.TEXTURE_ATLAS_JSON_HASH or Phaser.Loader.TEXTURE_ATLAS_XML_STARLING.
2013-11-28 15:57:09 +00:00
* @return {Phaser.Loader} This Loader instance.
*/
atlas: function (key, textureURL, atlasURL, atlasData, format) {
2015-07-22 14:31:30 +00:00
if (textureURL === undefined || textureURL === null)
{
textureURL = key + '.png';
}
if (atlasURL === undefined) { atlasURL = null; }
if (atlasData === undefined) { atlasData = null; }
if (format === undefined) { format = Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY; }
if (!atlasURL & & !atlasData)
{
if (format === Phaser.Loader.TEXTURE_ATLAS_XML_STARLING)
{
atlasURL = key + '.xml';
}
else
{
atlasURL = key + '.json';
}
}
2013-11-28 15:57:09 +00:00
// 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')
{
2015-03-23 23:46:30 +00:00
var xml = this.parseXml(atlasData);
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
if (!xml)
2013-11-28 15:57:09 +00:00
{
throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");
}
2015-03-23 23:46:30 +00:00
atlasData = xml;
2013-11-28 15:57:09 +00:00
}
break;
}
this.addToFileList('textureatlas', key, textureURL, { atlasURL: null, atlasData: atlasData, format: format });
}
return this;
},
/**
2015-03-23 23:46:30 +00:00
* Add a synchronization point to the assets/files added within the supplied callback.
2013-11-28 15:57:09 +00:00
*
2015-03-23 23:46:30 +00:00
* A synchronization point denotes that an asset _must_ be completely loaded before
* subsequent assets can be loaded. An asset marked as a sync-point does not need to wait
* for previous assets to load (unless they are sync-points). Resources, such as packs, may still
* be downloaded around sync-points, as long as they do not finalize loading.
*
2015-07-22 14:31:30 +00:00
* @method Phaser.Loader#withSyncPoints
2015-03-23 23:46:30 +00:00
* @param {function} callback - The callback is invoked and is supplied with a single argument: the loader.
* @param {object} [callbackContext=(loader)] - Context for the callback.
* @return {Phaser.Loader} This Loader instance.
2013-11-28 15:57:09 +00:00
*/
2015-03-23 23:46:30 +00:00
withSyncPoint: function (callback, callbackContext) {
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
this._withSyncPointDepth++;
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
try {
callback.call(callbackContext || this, this);
} finally {
this._withSyncPointDepth--;
2013-11-28 15:57:09 +00:00
}
2015-03-23 23:46:30 +00:00
return this;
2013-11-28 15:57:09 +00:00
},
/**
2015-03-23 23:46:30 +00:00
* Add a synchronization point to a specific file/asset in the load queue.
2013-11-28 15:57:09 +00:00
*
2015-03-23 23:46:30 +00:00
* This has no effect on already loaded assets.
*
2015-07-22 14:31:30 +00:00
* @method Phaser.Loader#addSyncPoint
* @param {string} type - The type of resource to turn into a sync point (image, audio, xml, etc).
* @param {string} key - Key of the file you want to turn into a sync point.
2015-03-23 23:46:30 +00:00
* @return {Phaser.Loader} This Loader instance.
* @see {@link Phaser.Loader#withSyncPoint withSyncPoint}
2013-11-28 15:57:09 +00:00
*/
2015-03-23 23:46:30 +00:00
addSyncPoint: function (type, key) {
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
var asset = this.getAsset(type, key);
if (asset)
{
asset.file.syncPoint = true;
}
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
return this;
2013-11-28 15:57:09 +00:00
},
/**
2015-03-23 23:46:30 +00:00
* Remove a file/asset from the loading queue.
2013-11-28 15:57:09 +00:00
*
2015-03-23 23:46:30 +00:00
* A file that is loaded or has started loading cannot be removed.
*
* @method Phaser.Loader#removeFile
* @protected
* @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) {
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
var asset = this.getAsset(type, key);
if (asset)
2014-07-10 19:31:11 +00:00
{
2015-03-23 23:46:30 +00:00
if (!asset.loaded & & !asset.loading)
{
this._fileList.splice(asset.index, 1);
}
2014-07-10 19:31:11 +00:00
}
},
/**
2015-03-23 23:46:30 +00:00
* Remove all file loading requests - this is _insufficient_ to stop current loading. Use `reset` instead.
2014-07-10 19:31:11 +00:00
*
2015-03-23 23:46:30 +00:00
* @method Phaser.Loader#removeAll
* @protected
2014-07-10 19:31:11 +00:00
*/
2015-03-23 23:46:30 +00:00
removeAll: function () {
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
this._fileList.length = 0;
this._flightQueue.length = 0;
2013-11-28 15:57:09 +00:00
},
2014-07-10 19:31:11 +00:00
/**
2015-03-23 23:46:30 +00:00
* Start loading the assets. Normally you don't need to call this yourself as the StateManager will do so.
2014-07-10 19:31:11 +00:00
*
2015-03-23 23:46:30 +00:00
* @method Phaser.Loader#start
2014-07-10 19:31:11 +00:00
*/
2015-03-23 23:46:30 +00:00
start: function () {
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
if (this.isLoading)
2014-07-10 19:31:11 +00:00
{
return;
}
2014-10-09 15:12:53 +00:00
2015-03-23 23:46:30 +00:00
this.hasLoaded = false;
this.isLoading = true;
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
this.updateProgress();
this.processLoadQueue();
2014-07-10 19:31:11 +00:00
},
/**
2015-03-23 23:46:30 +00:00
* Process the next item(s) in the file/asset queue.
*
* Process the queue and start loading enough items to fill up the inflight queue.
2014-07-10 19:31:11 +00:00
*
2015-03-23 23:46:30 +00:00
* If a sync-file is encountered then subsequent asset processing is delayed until it completes.
* The exception to this rule is that packfiles can be downloaded (but not processed) even if
* there appear other sync files (ie. packs) - this enables multiple packfiles to be fetched in parallel.
* such as during the start phaser.
*
* @method Phaser.Loader#processLoadQueue
2014-07-10 19:31:11 +00:00
* @private
*/
2015-03-23 23:46:30 +00:00
processLoadQueue: function () {
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
if (!this.isLoading)
2014-07-10 19:31:11 +00:00
{
2015-03-23 23:46:30 +00:00
console.warn('Phaser.Loader - active loading canceled / reset');
this.finishedLoading(true);
2014-07-10 19:31:11 +00:00
return;
}
2015-03-23 23:46:30 +00:00
// Empty the flight queue as applicable
for (var i = 0; i < this._flightQueue.length; i++)
2014-07-10 19:31:11 +00:00
{
2015-03-23 23:46:30 +00:00
var file = this._flightQueue[i];
if (file.loaded || file.error)
2014-07-10 19:31:11 +00:00
{
2015-03-23 23:46:30 +00:00
this._flightQueue.splice(i, 1);
i--;
file.loading = false;
file.requestUrl = null;
file.requestObject = null;
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
if (file.error)
2014-07-10 19:31:11 +00:00
{
2015-03-23 23:46:30 +00:00
this.onFileError.dispatch(file.key, file);
}
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
if (file.type !== 'packfile')
{
this._loadedFileCount++;
this.onFileComplete.dispatch(this.progress, file.key, !file.error, this._loadedFileCount, this._totalFileCount);
}
else if (file.type === 'packfile' & & file.error)
{
// Non-error pack files are handled when processing the file queue
this._loadedPackCount++;
this.onPackComplete.dispatch(file.key, !file.error, this._loadedPackCount, this._totalPackCount);
}
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
}
}
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
// When true further non-pack file downloads are suppressed
var syncblock = false;
2014-10-09 15:12:53 +00:00
2015-03-23 23:46:30 +00:00
var inflightLimit = this.enableParallel ? Phaser.Math.clamp(this.maxParallelDownloads, 1, 12) : 1;
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
for (var i = this._processingHead; i < this._fileList.length; i++)
{
var file = this._fileList[i];
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
// Pack is fetched (ie. has data) and is currently at the start of the process queue.
if (file.type === 'packfile' & & !file.error & & file.loaded & & i === this._processingHead)
{
// Processing the pack / adds more files
this.processPack(file);
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
this._loadedPackCount++;
this.onPackComplete.dispatch(file.key, !file.error, this._loadedPackCount, this._totalPackCount);
}
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
if (file.loaded || file.error)
{
// Item at the start of file list finished, can skip it in future
if (i === this._processingHead)
{
this._processingHead = i + 1;
}
}
else if (!file.loading & & this._flightQueue.length < inflightLimit)
{
// -> not loaded/failed, not loading
if (file.type === 'packfile' & & !file.data)
{
// Fetches the pack data: the pack is processed above as it reaches queue-start.
// (Packs do not trigger onLoadStart or onFileStart.)
this._flightQueue.push(file);
file.loading = true;
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
this.loadFile(file);
}
else if (!syncblock)
{
if (!this._fileLoadStarted)
{
this._fileLoadStarted = true;
this.onLoadStart.dispatch();
}
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
this._flightQueue.push(file);
file.loading = true;
this.onFileStart.dispatch(this.progress, file.key, file.url);
this.loadFile(file);
}
}
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
if (!file.loaded & & file.syncPoint)
{
syncblock = true;
}
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
// Stop looking if queue full - or if syncblocked and there are no more packs.
// (As only packs can be loaded around a syncblock)
if (this._flightQueue.length >= inflightLimit ||
(syncblock & & this._loadedPackCount === this._totalPackCount))
{
break;
}
}
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
this.updateProgress();
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
// True when all items in the queue have been advanced over
// (There should be no inflight items as they are complete - loaded/error.)
if (this._processingHead >= this._fileList.length)
{
this.finishedLoading();
2014-07-10 19:31:11 +00:00
}
2015-03-23 23:46:30 +00:00
else if (!this._flightQueue.length)
{
// Flight queue is empty but file list is not done being processed.
// This indicates a critical internal error with no known recovery.
console.warn("Phaser.Loader - aborting: processing queue empty, loading may have stalled");
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
var _this = this;
setTimeout(function () {
_this.finishedLoading(true);
}, 2000);
}
2014-07-10 19:31:11 +00:00
},
/**
2015-03-23 23:46:30 +00:00
* The loading is all finished.
2014-07-10 19:31:11 +00:00
*
2015-03-23 23:46:30 +00:00
* @method Phaser.Loader#finishedLoading
2014-07-10 19:31:11 +00:00
* @private
2015-03-23 23:46:30 +00:00
* @param {boolean} [abnormal=true] - True if the loading finished abnormally.
2014-07-10 19:31:11 +00:00
*/
2015-03-23 23:46:30 +00:00
finishedLoading: function (abnormal) {
if (this.hasLoaded)
{
return;
}
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
this.hasLoaded = true;
this.isLoading = false;
// If there were no files make sure to trigger the event anyway, for consistency
if (!abnormal & & !this._fileLoadStarted)
{
this._fileLoadStarted = true;
this.onLoadStart.dispatch();
}
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
this.onLoadComplete.dispatch();
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
this.reset();
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
this.game.state.loadComplete();
2014-07-10 19:31:11 +00:00
},
/**
2015-03-23 23:46:30 +00:00
* Informs the loader that the given file resource has been fetched and processed;
* or such a request has failed.
2014-07-10 19:31:11 +00:00
*
2015-03-23 23:46:30 +00:00
* @method Phaser.Loader#asyncComplete
2014-07-10 19:31:11 +00:00
* @private
2015-03-23 23:46:30 +00:00
* @param {object} file
* @param {string} [error=''] - The error message, if any. No message implies no error.
2014-07-10 19:31:11 +00:00
*/
2015-03-23 23:46:30 +00:00
asyncComplete: function (file, errorMessage) {
2014-07-10 19:31:11 +00:00
2015-07-22 14:31:30 +00:00
if (errorMessage === undefined) { errorMessage = ''; }
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
file.loaded = true;
file.error = !!errorMessage;
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
if (errorMessage)
2014-07-10 19:31:11 +00:00
{
2015-03-23 23:46:30 +00:00
file.errorMessage = errorMessage;
console.warn('Phaser.Loader - ' + file.type + '[' + file.key + ']' + ': ' + errorMessage);
// debugger;
2014-07-10 19:31:11 +00:00
}
2015-03-23 23:46:30 +00:00
this.processLoadQueue();
2014-07-10 19:31:11 +00:00
},
2013-11-28 15:57:09 +00:00
/**
2015-03-23 23:46:30 +00:00
* Process pack data. This will usually modify the file list.
2013-11-28 15:57:09 +00:00
*
2015-03-23 23:46:30 +00:00
* @method Phaser.Loader#processPack
2013-11-28 15:57:09 +00:00
* @private
2015-03-23 23:46:30 +00:00
* @param {object} pack
2013-11-28 15:57:09 +00:00
*/
2015-03-23 23:46:30 +00:00
processPack: function (pack) {
var packData = pack.data[pack.key];
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
if (!packData)
2013-11-28 15:57:09 +00:00
{
2015-03-23 23:46:30 +00:00
console.warn('Phaser.Loader - ' + pack.key + ': pack has data, but not for pack key');
2013-11-28 15:57:09 +00:00
return;
}
2014-10-09 15:12:53 +00:00
2015-03-23 23:46:30 +00:00
for (var i = 0; i < packData.length; i++)
{
var file = packData[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;
case "xml":
this.xml(file.key, file.url, file.overwrite);
break;
case "script":
this.script(file.key, file.url, file.callback, pack.callbackContext || this);
break;
case "binary":
this.binary(file.key, file.url, file.callback, pack.callbackContext || this);
break;
case "spritesheet":
this.spritesheet(file.key, file.url, file.frameWidth, file.frameHeight, file.frameMax, file.margin, file.spacing);
break;
2015-07-22 14:31:30 +00:00
case "video":
this.video(file.key, file.urls);
break;
2015-03-23 23:46:30 +00:00
case "audio":
this.audio(file.key, file.urls, file.autoDecode);
break;
case "audiosprite":
2015-07-22 14:31:30 +00:00
this.audiosprite(file.key, file.urls, file.jsonURL, file.jsonData, file.autoDecode);
2015-03-23 23:46:30 +00:00
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":
2015-07-22 14:31:30 +00:00
this.bitmapFont(file.key, file.textureURL, file.atlasURL, file.atlasData, file.xSpacing, file.ySpacing);
2015-03-23 23:46:30 +00:00
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;
2015-07-22 14:31:30 +00:00
case "shader":
this.shader(file.key, file.url, file.overwrite);
break;
2015-03-23 23:46:30 +00:00
}
}
},
/**
2015-07-22 14:31:30 +00:00
* Transforms the asset URL.
* The default implementation prepends the baseURL if the url doesn't being with http or //
2015-03-23 23:46:30 +00:00
*
* @method Phaser.Loader#transformUrl
* @protected
2015-07-22 14:31:30 +00:00
* @param {string} url - The url to transform.
* @param {object} file - The file object being transformed.
* @return {string} The transformed url. In rare cases where the url isn't specified it will return false instead.
2015-03-23 23:46:30 +00:00
*/
2015-07-22 14:31:30 +00:00
transformUrl: function (url, file) {
if (!url)
{
return false;
}
if (url.substr(0, 4) === 'http' || url.substr(0, 2) === '//')
{
return url;
}
else
{
return this.baseURL + file.path + url;
}
2015-03-23 23:46:30 +00:00
},
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
/**
* Start fetching a resource.
*
* All code paths, async or otherwise, from this function must return to `asyncComplete`.
*
* @method Phaser.Loader#loadFile
* @private
* @param {object} file
*/
loadFile: function (file) {
2014-04-15 14:39:23 +00:00
2013-11-28 15:57:09 +00:00
// Image or Data?
switch (file.type)
{
2015-03-23 23:46:30 +00:00
case 'packfile':
this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.fileComplete);
break;
2013-11-28 15:57:09 +00:00
case 'image':
case 'spritesheet':
case 'textureatlas':
case 'bitmapfont':
2015-03-23 23:46:30 +00:00
this.loadImageTag(file);
2013-11-28 15:57:09 +00:00
break;
case 'audio':
file.url = this.getAudioURL(file.url);
2015-03-23 23:46:30 +00:00
if (file.url)
2013-11-28 15:57:09 +00:00
{
// WebAudio or Audio Tag?
if (this.game.sound.usingWebAudio)
{
2015-03-23 23:46:30 +00:00
this.xhrLoad(file, this.transformUrl(file.url, file), 'arraybuffer', this.fileComplete);
2013-11-28 15:57:09 +00:00
}
else if (this.game.sound.usingAudioTag)
{
2015-03-23 23:46:30 +00:00
this.loadAudioTag(file);
2013-11-28 15:57:09 +00:00
}
}
else
{
2015-07-22 14:31:30 +00:00
this.fileError(file, null, 'No supported audio URL specified or device does not have audio playback support');
}
break;
case 'video':
file.url = this.getVideoURL(file.url);
if (file.url)
{
if (file.asBlob)
{
this.xhrLoad(file, this.transformUrl(file.url, file), 'arraybuffer', this.fileComplete);
}
else
{
this.loadVideoTag(file);
}
}
else
{
this.fileError(file, null, 'No supported video URL specified or device does not have video playback support');
2013-11-28 15:57:09 +00:00
}
break;
2014-02-24 12:14:30 +00:00
case 'json':
2014-04-29 14:39:02 +00:00
2015-03-23 23:46:30 +00:00
this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.jsonLoadComplete);
2014-02-24 12:14:30 +00:00
break;
2014-10-09 15:12:53 +00:00
case 'xml':
2015-03-23 23:46:30 +00:00
this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.xmlLoadComplete);
2014-10-09 15:12:53 +00:00
break;
2013-11-28 15:57:09 +00:00
case 'tilemap':
if (file.format === Phaser.Tilemap.TILED_JSON)
{
2015-03-23 23:46:30 +00:00
this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.jsonLoadComplete);
2013-11-28 15:57:09 +00:00
}
else if (file.format === Phaser.Tilemap.CSV)
{
2015-03-23 23:46:30 +00:00
this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.csvLoadComplete);
2013-11-28 15:57:09 +00:00
}
else
{
2015-03-23 23:46:30 +00:00
this.asyncComplete(file, "invalid Tilemap format: " + file.format);
2013-11-28 15:57:09 +00:00
}
break;
case 'text':
2014-02-05 06:29:17 +00:00
case 'script':
2015-07-22 14:31:30 +00:00
case 'shader':
2014-02-18 03:01:51 +00:00
case 'physics':
2015-03-23 23:46:30 +00:00
this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.fileComplete);
2013-11-28 15:57:09 +00:00
break;
2014-02-05 06:29:17 +00:00
case 'binary':
2015-03-23 23:46:30 +00:00
this.xhrLoad(file, this.transformUrl(file.url, file), 'arraybuffer', this.fileComplete);
2013-11-28 15:57:09 +00:00
break;
}
},
2015-03-23 23:46:30 +00:00
/**
* Continue async loading through an Image tag.
* @private
*/
loadImageTag: function (file) {
var _this = this;
file.data = new Image();
file.data.name = file.key;
if (this.crossOrigin)
{
file.data.crossOrigin = this.crossOrigin;
}
file.data.onload = function () {
if (file.data.onload)
{
file.data.onload = null;
file.data.onerror = null;
_this.fileComplete(file);
}
};
file.data.onerror = function () {
if (file.data.onload)
{
file.data.onload = null;
file.data.onerror = null;
_this.fileError(file);
}
};
file.data.src = this.transformUrl(file.url, file);
// Image is immediately-available/cached
if (file.data.complete & & file.data.width & & file.data.height)
{
file.data.onload = null;
file.data.onerror = null;
this.fileComplete(file);
}
},
2015-07-22 14:31:30 +00:00
/**
* Continue async loading through a Video tag.
* @private
*/
loadVideoTag: function (file) {
var _this = this;
file.data = document.createElement("video");
file.data.name = file.key;
file.data.controls = false;
file.data.autoplay = false;
var videoLoadEvent = function () {
file.data.removeEventListener(file.loadEvent, videoLoadEvent, false);
file.data.onerror = null;
file.data.canplay = true;
Phaser.GAMES[_this.game.id].load.fileComplete(file);
};
file.data.onerror = function () {
file.data.removeEventListener(file.loadEvent, videoLoadEvent, false);
file.data.onerror = null;
file.data.canplay = false;
_this.fileError(file);
};
file.data.addEventListener(file.loadEvent, videoLoadEvent, false);
file.data.src = this.transformUrl(file.url, file);
file.data.load();
},
2015-03-23 23:46:30 +00:00
/**
* Continue async loading through an Audio tag.
* @private
*/
loadAudioTag: function (file) {
var _this = this;
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.transformUrl(file.url, file);
this.fileComplete(file);
}
else
{
file.data = new Audio();
file.data.name = file.key;
var playThroughEvent = function () {
file.data.removeEventListener('canplaythrough', playThroughEvent, false);
file.data.onerror = null;
// Why does this cycle through games?
Phaser.GAMES[_this.game.id].load.fileComplete(file);
};
file.data.onerror = function () {
file.data.removeEventListener('canplaythrough', playThroughEvent, false);
file.data.onerror = null;
_this.fileError(file);
};
file.data.preload = 'auto';
file.data.src = this.transformUrl(file.url, file);
file.data.addEventListener('canplaythrough', playThroughEvent, false);
file.data.load();
}
},
2014-07-10 19:31:11 +00:00
/**
* Starts the xhr loader.
2014-10-09 15:12:53 +00:00
*
2015-03-23 23:46:30 +00:00
* This is designed specifically to use with asset file processing.
*
2014-07-10 19:31:11 +00:00
* @method Phaser.Loader#xhrLoad
* @private
2015-03-23 23:46:30 +00:00
* @param {object} file - The file/pack to load.
2014-07-10 19:31:11 +00:00
* @param {string} url - The URL of the file.
* @param {string} type - The xhr responseType.
2015-03-23 23:46:30 +00:00
* @param {function} onload - The function to call on success. Invoked in `this` context and supplied with `(file, xhr)` arguments.
* @param {function} [onerror=fileError] The function to call on error. Invoked in `this` context and supplied with `(file, xhr)` arguments.
2014-07-10 19:31:11 +00:00
*/
2015-03-23 23:46:30 +00:00
xhrLoad: function (file, url, type, onload, onerror) {
if (this.useXDomainRequest & & window.XDomainRequest)
{
this.xhrLoadWithXDR(file, url, type, onload, onerror);
return;
}
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.responseType = type;
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
onerror = onerror || this.fileError;
2014-07-10 19:31:11 +00:00
var _this = this;
2015-03-23 23:46:30 +00:00
xhr.onload = function () {
2015-03-26 02:38:46 +00:00
2015-03-23 23:46:30 +00:00
try {
2015-03-26 02:38:46 +00:00
2015-03-23 23:46:30 +00:00
return onload.call(_this, file, xhr);
2015-03-26 02:38:46 +00:00
2015-03-23 23:46:30 +00:00
} catch (e) {
2015-03-26 02:38:46 +00:00
// If this was the last file in the queue and an error is thrown in the create method
// then it's caught here, so be sure we don't carry on processing it
if (!_this.hasLoaded)
{
_this.asyncComplete(file, e.message || 'Exception');
}
else
{
if (window['console'])
{
console.error(e);
}
}
2015-03-23 23:46:30 +00:00
}
2014-07-10 19:31:11 +00:00
};
2015-03-23 23:46:30 +00:00
xhr.onerror = function () {
2015-03-26 02:38:46 +00:00
2015-03-23 23:46:30 +00:00
try {
2015-03-26 02:38:46 +00:00
2015-03-23 23:46:30 +00:00
return onerror.call(_this, file, xhr);
2015-03-26 02:38:46 +00:00
2015-03-23 23:46:30 +00:00
} catch (e) {
2015-03-26 02:38:46 +00:00
if (!_this.hasLoaded)
{
_this.asyncComplete(file, e.message || 'Exception');
}
else
{
if (window['console'])
{
console.error(e);
}
}
2015-03-23 23:46:30 +00:00
}
2014-07-10 19:31:11 +00:00
};
2015-03-23 23:46:30 +00:00
file.requestObject = xhr;
file.requestUrl = url;
xhr.send();
2014-07-10 19:31:11 +00:00
},
2013-11-28 15:57:09 +00:00
/**
2015-03-23 23:46:30 +00:00
* Starts the xhr loader - using XDomainRequest.
* This should _only_ be used with IE 9. Phaser does not support IE 8 and XDR is deprecated in IE 10.
*
* This is designed specifically to use with asset file processing.
2014-10-09 15:12:53 +00:00
*
2015-03-23 23:46:30 +00:00
* @method Phaser.Loader#xhrLoad
2013-11-28 15:57:09 +00:00
* @private
2015-03-23 23:46:30 +00:00
* @param {object} file - The file/pack to load.
* @param {string} url - The URL of the file.
* @param {string} type - The xhr responseType.
* @param {function} onload - The function to call on success. Invoked in `this` context and supplied with `(file, xhr)` arguments.
* @param {function} [onerror=fileError] The function to call on error. Invoked in `this` context and supplied with `(file, xhr)` arguments.
* @deprecated This is only relevant for IE 9.
2013-11-28 15:57:09 +00:00
*/
2015-03-23 23:46:30 +00:00
xhrLoadWithXDR: function (file, url, type, onload, onerror) {
// Special IE9 magic .. only
if (!this._warnedAboutXDomainRequest & &
(!this.game.device.ie || this.game.device.ieVersion >= 10))
{
this._warnedAboutXDomainRequest = true;
console.warn("Phaser.Loader - using XDomainRequest outside of IE 9");
}
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
// Ref: http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
var xhr = new window.XDomainRequest();
xhr.open('GET', url, true);
xhr.responseType = type;
// XDomainRequest has a few quirks. Occasionally it will abort requests
// 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
xhr.timeout = 3000;
onerror = onerror || this.fileError;
var _this = this;
xhr.onerror = function () {
try {
return onerror.call(_this, file, xhr);
} catch (e) {
_this.asyncComplete(file, e.message || 'Exception');
}
};
xhr.ontimeout = function () {
try {
return onerror.call(_this, file, xhr);
} catch (e) {
_this.asyncComplete(file, e.message || 'Exception');
}
};
xhr.onprogress = function() {};
xhr.onload = function () {
try {
return onload.call(_this, file, xhr);
} catch (e) {
_this.asyncComplete(file, e.message || 'Exception');
}
};
file.requestObject = xhr;
file.requestUrl = url;
// Note: The xdr.send() call is wrapped in a timeout to prevent an issue with the interface where some requests are lost
// if multiple XDomainRequests are being sent at the same time.
setTimeout(function () {
xhr.send();
}, 0);
},
2013-11-28 15:57:09 +00:00
2015-07-22 14:31:30 +00:00
/**
* Give a bunch of URLs, return the first URL that has an extension this device thinks it can play.
*
* It is assumed that the device can play "blob:" or "data:" URIs - There is no mime-type checking on data URIs.
*
* @method Phaser.Loader#getVideoURL
* @private
* @param {object[]|string[]} urls - See {@link #video} for format.
* @return {string} The URL to try and fetch; or null.
*/
getVideoURL: function (urls) {
for (var i = 0; i < urls.length; i++)
{
var url = urls[i];
var videoType;
if (url.uri) // {uri: .., type: ..} pair
{
url = url.uri;
videoType = url.type;
}
else
{
// Assume direct-data URI can be played if not in a paired form; select immediately
if (url.indexOf("blob:") === 0 || url.indexOf("data:") === 0)
{
return url;
}
if (url.indexOf("?") >= 0) // Remove query from URL
{
url = url.substr(0, url.indexOf("?"));
}
var extension = url.substr((Math.max(0, url.lastIndexOf(".")) || Infinity) + 1);
videoType = extension.toLowerCase();
}
if (this.game.device.canPlayVideo(videoType))
{
return urls[i];
}
}
return null;
},
2015-03-23 23:46:30 +00:00
/**
* Give a bunch of URLs, return the first URL that has an extension this device thinks it can play.
*
* It is assumed that the device can play "blob:" or "data:" URIs - There is no mime-type checking on data URIs.
*
* @method Phaser.Loader#getAudioURL
* @private
* @param {object[]|string[]} urls - See {@link #audio} for format.
* @return {string} The URL to try and fetch; or null.
*/
getAudioURL: function (urls) {
2013-11-28 15:57:09 +00:00
2015-07-22 14:31:30 +00:00
if (this.game.sound.noAudio)
{
return null;
}
2013-11-28 15:57:09 +00:00
for (var i = 0; i < urls.length; i++)
{
2015-03-23 23:46:30 +00:00
var url = urls[i];
var audioType;
2015-01-06 06:57:25 +00:00
2015-03-23 23:46:30 +00:00
if (url.uri) // {uri: .., type: ..} pair
2015-01-06 06:57:25 +00:00
{
2015-03-23 23:46:30 +00:00
url = url.uri;
audioType = url.type;
2015-01-06 06:57:25 +00:00
}
2015-03-23 23:46:30 +00:00
else
{
// Assume direct-data URI can be played if not in a paired form; select immediately
if (url.indexOf("blob:") === 0 || url.indexOf("data:") === 0)
{
return url;
}
2015-01-06 06:57:25 +00:00
2015-03-23 23:46:30 +00:00
if (url.indexOf("?") >= 0) // Remove query from URL
{
url = url.substr(0, url.indexOf("?"));
}
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
var extension = url.substr((Math.max(0, url.lastIndexOf(".")) || Infinity) + 1);
audioType = extension.toLowerCase();
2014-10-22 20:49:44 +00:00
}
2015-03-23 23:46:30 +00:00
if (this.game.device.canPlayAudio(audioType))
2013-11-28 15:57:09 +00:00
{
return urls[i];
}
}
return null;
},
/**
2015-03-23 23:46:30 +00:00
* Error occurred when loading a file.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#fileError
2015-03-23 23:46:30 +00:00
* @private
* @param {object} file
* @param {?XMLHttpRequest} xhr - XHR request, unspecified if loaded via other means (eg. tags)
* @param {string} reason
2013-11-28 15:57:09 +00:00
*/
2015-03-23 23:46:30 +00:00
fileError: function (file, xhr, reason) {
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
var url = file.requestUrl || this.transformUrl(file.url, file);
var message = 'error loading asset from URL ' + url;
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
if (!reason & & xhr)
{
reason = xhr.status;
}
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
if (reason)
{
message = message + ' (' + reason + ')';
}
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
this.asyncComplete(file, message);
2013-11-28 15:57:09 +00:00
},
/**
2015-03-23 23:46:30 +00:00
* Called when a file/resources had been downloaded and needs to be processed further.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#fileComplete
2015-03-23 23:46:30 +00:00
* @private
* @param {object} file - File loaded
* @param {?XMLHttpRequest} xhr - XHR request, unspecified if loaded via other means (eg. tags)
2013-11-28 15:57:09 +00:00
*/
2015-03-23 23:46:30 +00:00
fileComplete: function (file, xhr) {
2013-11-28 15:57:09 +00:00
var loadNext = true;
switch (file.type)
{
2015-03-23 23:46:30 +00:00
case 'packfile':
// Pack data must never be false-ish after it is fetched without error
var data = JSON.parse(xhr.responseText);
file.data = data || {};
break;
2013-11-28 15:57:09 +00:00
case 'image':
2015-07-22 14:31:30 +00:00
this.cache.addImage(file.key, file.url, file.data);
2013-11-28 15:57:09 +00:00
break;
case 'spritesheet':
2015-07-22 14:31:30 +00:00
this.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)
{
2015-07-22 14:31:30 +00:00
this.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format);
2013-11-28 15:57:09 +00:00
}
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)
{
2015-03-23 23:46:30 +00:00
this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', this.jsonLoadComplete);
2013-11-28 15:57:09 +00:00
}
else if (file.format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING)
{
2015-03-23 23:46:30 +00:00
this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', this.xmlLoadComplete);
2013-11-28 15:57:09 +00:00
}
else
{
throw new Error("Phaser.Loader. Invalid Texture Atlas format: " + file.format);
}
}
break;
case 'bitmapfont':
2015-07-22 14:31:30 +00:00
if (!file.atlasURL)
2013-11-28 15:57:09 +00:00
{
2015-07-22 14:31:30 +00:00
this.cache.addBitmapFont(file.key, file.url, file.data, file.atlasData, file.atlasType, 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;
2015-07-22 14:31:30 +00:00
this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', function (file, xhr) {
var json;
try
{
// Try to parse as JSON, if it fails, then it's hopefully XML
json = JSON.parse(xhr.responseText);
}
catch (e) {}
if (!!json)
{
file.atlasType = 'json';
this.jsonLoadComplete(file, xhr);
}
else
{
file.atlasType = 'xml';
this.xmlLoadComplete(file, xhr);
}
});
2013-11-28 15:57:09 +00:00
}
break;
2015-07-22 14:31:30 +00:00
case 'video':
if (file.asBlob)
{
try
{
file.data = new Blob([new Uint8Array(xhr.response)]);
}
catch (e)
{
throw new Error("Phaser.Loader. Unable to parse video file as Blob: " + file.key);
}
}
this.cache.addVideo(file.key, file.url, file.data, file.asBlob);
break;
2013-11-28 15:57:09 +00:00
case 'audio':
if (this.game.sound.usingWebAudio)
{
2015-03-23 23:46:30 +00:00
file.data = xhr.response;
2013-11-28 15:57:09 +00:00
2015-07-22 14:31:30 +00:00
this.cache.addSound(file.key, file.url, file.data, true, false);
2013-11-28 15:57:09 +00:00
if (file.autoDecode)
{
2015-03-23 23:46:30 +00:00
this.game.sound.decode(file.key);
2013-11-28 15:57:09 +00:00
}
}
else
{
2015-07-22 14:31:30 +00:00
this.cache.addSound(file.key, file.url, file.data, false, true);
2013-11-28 15:57:09 +00:00
}
break;
case 'text':
2015-03-23 23:46:30 +00:00
file.data = xhr.responseText;
2015-07-22 14:31:30 +00:00
this.cache.addText(file.key, file.url, file.data);
break;
case 'shader':
file.data = xhr.responseText;
this.cache.addShader(file.key, file.url, file.data);
2013-11-28 15:57:09 +00:00
break;
2014-02-18 03:01:51 +00:00
case 'physics':
2015-03-23 23:46:30 +00:00
var data = JSON.parse(xhr.responseText);
2015-07-22 14:31:30 +00:00
this.cache.addPhysicsData(file.key, file.url, data, file.format);
2014-02-18 03:01:51 +00:00
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;
2015-03-23 23:46:30 +00:00
file.data.text = xhr.responseText;
2013-11-28 15:57:09 +00:00
document.head.appendChild(file.data);
2014-03-14 06:36:05 +00:00
if (file.callback)
{
2015-03-23 23:46:30 +00:00
file.data = file.callback.call(file.callbackContext, file.key, xhr.responseText);
2014-03-14 06:36:05 +00:00
}
2013-11-28 15:57:09 +00:00
break;
2014-02-05 06:29:17 +00:00
case 'binary':
if (file.callback)
{
2015-03-23 23:46:30 +00:00
file.data = file.callback.call(file.callbackContext, file.key, xhr.response);
2014-02-05 06:29:17 +00:00
}
else
{
2015-03-23 23:46:30 +00:00
file.data = xhr.response;
2014-02-05 06:29:17 +00:00
}
2015-07-22 14:31:30 +00:00
this.cache.addBinary(file.key, file.data);
2014-02-05 06:29:17 +00:00
break;
2013-11-28 15:57:09 +00:00
}
if (loadNext)
{
2015-03-23 23:46:30 +00:00
this.asyncComplete(file);
2013-11-28 15:57:09 +00:00
}
},
/**
2015-03-23 23:46:30 +00:00
* Successfully loaded a JSON file - only used for certain types.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#jsonLoadComplete
2015-03-23 23:46:30 +00:00
* @private
* @param {object} file - File associated with this request
* @param {XMLHttpRequest} xhr
2013-11-28 15:57:09 +00:00
*/
2015-03-23 23:46:30 +00:00
jsonLoadComplete: function (file, xhr) {
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
var data = JSON.parse(xhr.responseText);
2013-11-28 15:57:09 +00:00
if (file.type === 'tilemap')
{
2015-07-22 14:31:30 +00:00
this.cache.addTilemap(file.key, file.url, data, file.format);
}
else if (file.type === 'bitmapfont')
{
this.cache.addBitmapFont(file.key, file.url, file.data, data, file.atlasType, file.xSpacing, file.ySpacing);
2013-11-28 15:57:09 +00:00
}
2014-02-24 12:14:30 +00:00
else if (file.type === 'json')
{
2015-07-22 14:31:30 +00:00
this.cache.addJSON(file.key, file.url, data);
2014-02-24 12:14:30 +00:00
}
2013-11-28 15:57:09 +00:00
else
{
2015-07-22 14:31:30 +00:00
this.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format);
2013-11-28 15:57:09 +00:00
}
2015-03-23 23:46:30 +00:00
this.asyncComplete(file);
2013-11-28 15:57:09 +00:00
},
/**
2015-03-23 23:46:30 +00:00
* Successfully loaded a CSV file - only used for certain types.
2013-11-28 15:57:09 +00:00
*
* @method Phaser.Loader#csvLoadComplete
2015-03-23 23:46:30 +00:00
* @private
* @param {object} file - File associated with this request
* @param {XMLHttpRequest} xhr
2013-11-28 15:57:09 +00:00
*/
2015-03-23 23:46:30 +00:00
csvLoadComplete: function (file, xhr) {
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
var data = xhr.responseText;
2013-11-28 15:57:09 +00:00
2015-07-22 14:31:30 +00:00
this.cache.addTilemap(file.key, file.url, data, file.format);
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
this.asyncComplete(file);
2013-11-28 15:57:09 +00:00
},
/**
2015-03-23 23:46:30 +00:00
* Successfully loaded an XML file - only used for certain types.
2013-11-28 15:57:09 +00:00
*
2015-03-23 23:46:30 +00:00
* @method Phaser.Loader#xmlLoadComplete
* @private
* @param {object} file - File associated with this request
* @param {XMLHttpRequest} xhr
2013-11-28 15:57:09 +00:00
*/
2015-03-23 23:46:30 +00:00
xmlLoadComplete: function (file, xhr) {
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
// Always try parsing the content as XML, regardless of actually response type
var data = xhr.responseText;
var xml = this.parseXml(data);
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
if (!xml)
{
var responseType = xhr.responseType || xhr.contentType; // contentType for MS-XDomainRequest
console.warn('Phaser.Loader - ' + file.key + ': invalid XML (' + responseType + ')');
this.asyncComplete(file, "invalid XML");
return;
}
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
if (file.type === 'bitmapfont')
{
2015-07-22 14:31:30 +00:00
this.cache.addBitmapFont(file.key, file.url, file.data, xml, file.atlasType, file.xSpacing, file.ySpacing);
2015-03-23 23:46:30 +00:00
}
else if (file.type === 'textureatlas')
{
2015-07-22 14:31:30 +00:00
this.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format);
2015-03-23 23:46:30 +00:00
}
else if (file.type === 'xml')
{
2015-07-22 14:31:30 +00:00
this.cache.addXML(file.key, file.url, xml);
2015-03-23 23:46:30 +00:00
}
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
this.asyncComplete(file);
2013-11-28 15:57:09 +00:00
},
/**
2015-03-23 23:46:30 +00:00
* Parses string data as XML.
2013-11-28 15:57:09 +00:00
*
2015-03-23 23:46:30 +00:00
* @method parseXml
* @private
* @param {string} data - The XML text to parse
* @return {?XMLDocument} Returns the xml document, or null if such could not parsed to a valid document.
2013-11-28 15:57:09 +00:00
*/
2015-03-23 23:46:30 +00:00
parseXml: function (data) {
2014-10-09 15:12:53 +00:00
2013-11-28 15:57:09 +00:00
var xml;
2015-07-22 14:31:30 +00:00
2013-11-28 15:57:09 +00:00
try
{
if (window['DOMParser'])
{
var domparser = new DOMParser();
xml = domparser.parseFromString(data, "text/xml");
}
else
{
xml = new ActiveXObject("Microsoft.XMLDOM");
2015-03-23 23:46:30 +00:00
// Why is this 'false'?
2013-11-28 15:57:09 +00:00
xml.async = 'false';
xml.loadXML(data);
}
}
catch (e)
{
2015-03-23 23:46:30 +00:00
xml = null;
2013-11-28 15:57:09 +00:00
}
if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length)
{
2015-03-23 23:46:30 +00:00
return null;
2013-11-28 15:57:09 +00:00
}
2015-03-23 23:46:30 +00:00
else
2014-10-09 15:12:53 +00:00
{
2015-03-23 23:46:30 +00:00
return xml;
2014-10-09 15:12:53 +00:00
}
2013-11-28 15:57:09 +00:00
},
/**
2015-03-23 23:46:30 +00:00
* Update the loading sprite progress.
2013-11-28 15:57:09 +00:00
*
2014-07-10 19:31:11 +00:00
* @method Phaser.Loader#nextFile
* @private
2015-03-23 23:46:30 +00:00
* @param {object} previousFile
2013-11-28 15:57:09 +00:00
* @param {boolean} success - Whether the previous asset loaded successfully or not.
*/
2015-03-23 23:46:30 +00:00
updateProgress: function () {
2013-11-28 15:57:09 +00:00
2015-03-23 23:46:30 +00:00
if (this.preloadSprite)
2013-11-28 15:57:09 +00:00
{
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
2015-03-23 23:46:30 +00:00
if (this.preloadSprite.sprite)
{
this.preloadSprite.sprite.updateCrop();
}
else
{
// We seem to have lost our sprite - maybe it was destroyed?
this.preloadSprite = null;
}
2013-11-28 15:57:09 +00:00
}
},
/**
* 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
2015-03-23 23:46:30 +00:00
* @protected
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 () {
2015-03-23 23:46:30 +00:00
return this._loadedFileCount;
2013-11-28 15:57:09 +00:00
},
/**
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
2015-03-23 23:46:30 +00:00
* @protected
2013-11-28 15:57:09 +00:00
* @return {number} The number of files that still remain in the load queue.
*/
totalQueuedFiles: function () {
2015-03-23 23:46:30 +00:00
return this._totalFileCount - this._loadedFileCount;
2013-11-28 15:57:09 +00:00
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
2015-03-23 23:46:30 +00:00
* @protected
2014-07-10 19:31:11 +00:00
* @return {number} The number of asset packs that have already been loaded (even if they errored)
*/
totalLoadedPacks: function () {
2015-03-23 23:46:30 +00:00
return this._totalPackCount;
2014-07-10 19:31:11 +00:00
},
/**
* 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
2015-03-23 23:46:30 +00:00
* @protected
2014-07-10 19:31:11 +00:00
* @return {number} The number of asset packs that still remain in the load queue.
*/
totalQueuedPacks: function () {
2015-03-23 23:46:30 +00:00
return this._totalPackCount - this._loadedPackCount;
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
}
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
};
2014-07-10 19:31:11 +00:00
2015-03-23 23:46:30 +00:00
/**
* The non-rounded load progress value (from 0.0 to 100.0).
*
* A general indicator of the progress.
* It is possible for the progress to decrease, after `onLoadStart`, if more files are dynamically added.
*
* @name Phaser.Loader#progressFloat
* @property {number}
*/
Object.defineProperty(Phaser.Loader.prototype, "progressFloat", {
get: function () {
var progress = (this._loadedFileCount / this._totalFileCount) * 100;
return Phaser.Math.clamp(progress || 0, 0, 100);
2013-11-28 15:57:09 +00:00
}
2015-03-23 23:46:30 +00:00
});
/**
* The rounded load progress percentage value (from 0 to 100). See {@link Phaser.Loader#progressFloat}.
*
* @name Phaser.Loader#progress
* @property {integer}
*/
Object.defineProperty(Phaser.Loader.prototype, "progress", {
get: function () {
return Math.round(this.progressFloat);
}
});
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" >
2015-03-23 23:46:30 +00:00
Phaser Copyright © 2012-2015 Photon Storm Ltd.
2013-10-02 14:05:55 +00:00
< / span >
< br / >
< span class = "jsdoc-message" >
2015-03-23 23:46:30 +00:00
Documentation generated by < a href = "https://github.com/jsdoc3/jsdoc" > JSDoc 3.3.0-alpha10< / a >
2015-07-29 14:01:04 +00:00
on Wed Jul 29 2015 14:57:51 GMT+0100 (GMT Daylight Time) 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 >