Loader (Extends from Scene)

Module: engine.loader

Dynamic loader for assets.

new game.Loader( )

Properties

_backgroundColorRgb Object

(No description yet)

_error String

(No description yet)

_loadCount Number

(No description yet)

_loadedFiles Array

(No description yet)

_mouseDownTime Number

(No description yet)

_mouseDownX Number

(No description yet)

_mouseDownY Number

(No description yet)

_pausedAnims Array

(No description yet)

_pausedObjects Array

(No description yet)

_pausedTimers Array

(No description yet)

_pausedTweens Array

(No description yet)

_queue Array

List of media files to load.

_updateOrder Array

(No description yet)

backgroundColor String (Default: null)
Background color of scene.
isMouseDown Boolean (Default: false)

(No description yet)

loaded Number

Number of files loaded.

objects Array
List of objects in scene.
paused Boolean (Default: false)
Is scene paused.
percent Number

Percent of files loaded.

physics Array
List of physics worlds in scene.
scene String

Name of scene to set, when loader complete.

stage Container
Main container for scene.
started Boolean (Default: false)

Is loader started.

timers Array
List of timers in scene.
totalFiles Number

Total files to load.

tweens Array
List of tweens in scene.

Methods

_complete()

(No description yet)

_exit(sceneName)

(No description yet)

Parameters:

  • sceneName String
_getFilePath() String

(No description yet)

_getFolder() String

(No description yet)

_mousedown(x, y, id, event)

(No description yet)

Parameters:

  • x Number
  • y Number
  • id Number
  • event MouseEvent|TouchEvent
_mousemove(x, y, id, event)

(No description yet)

Parameters:

  • x Number
  • y Number
  • id Number
  • event MouseEvent|TouchEvent
_mouseup(x, y, id, event)

(No description yet)

Parameters:

  • x Number
  • y Number
  • id Number
  • event MouseEvent|TouchEvent
_pause()

(No description yet)

_progress(error)

(No description yet)

Parameters:

  • error String
_resume()

(No description yet)

_startLoading()

(No description yet)

_swipe(dir)

(No description yet)

Parameters:

  • dir String
_update()

(No description yet)

_updateCollision()

(No description yet)

_updateObjects()

(No description yet)

_updatePhysics()

(No description yet)

_updateRenderer()

(No description yet)

_updateScene()

(No description yet)

_updateTimers()

(No description yet)

_updateTweens()

(No description yet)

addObject(object)
Add object to scene, so it's update function get's called every frame.

Parameters:

  • object Object
click(x, y, id, event)
Called, when mouse or touch is released and no swipe is triggered.

Parameters:

  • x Number
  • y Number
  • id Number
  • event MouseEvent|TouchEvent
exit(sceneName) Boolean
Called, before scene is changed.

Parameters:

  • sceneName String
Return true to abort exit.
generateFont(data, callback)

(No description yet)

Parameters:

  • data XML|JSON
  • callback Function
keydown(key, shift, ctrl, alt) Boolean
Called, when key is pressed.

Parameters:

  • key String
  • shift Boolean
  • ctrl Boolean
  • alt Boolean
return true to prevent default keydown action.
keyup(key)
Called, when key is released.

Parameters:

  • key String
loadAtlas(filePath, callback)

(No description yet)

Parameters:

  • filePath String
  • callback Function
loadAudio(filePath, callback)

(No description yet)

Parameters:

  • filePath String
  • callback Function
loadCSS(filePath, callback)

(No description yet)

Parameters:

  • filePath String
  • callback Function
loadFile(filePath, callback)

Load file with XMLHttpRequest.

Parameters:

  • filePath String
  • callback Function
loadFont(filePath, callback)

(No description yet)

Parameters:

  • filePath String
  • callback Function
loadImage(filePath, callback)

(No description yet)

Parameters:

  • filePath String
  • callback Function
loadJSON(filePath, callback)

(No description yet)

Parameters:

  • filePath String
  • callback Function
loadScript(filePath, callback)

(No description yet)

Parameters:

  • filePath String
  • callback Function
mousedown(x, y, id, event)
Called, when mouse or touch is down.

Parameters:

  • x Number
  • y Number
  • id Number
  • event MouseEvent|TouchEvent
mousemove(x, y, id, event)
Called, when mouse or touch is moved.

Parameters:

  • x Number
  • y Number
  • id Number
  • event MouseEvent|TouchEvent
mouseout(event)
Called, when mouse goes out of canvas.

Parameters:

  • event MouseEvent
mouseup(x, y, id, event)
Called, when mouse or touch is released.

Parameters:

  • x Number
  • y Number
  • id Number
  • event MouseEvent|TouchEvent
onComplete()

Called, when all files loaded.

onError(error)

Called, when loader got error.

Parameters:

  • error String
onPause()
Called, when scene is paused.
onProgress(percent)

Called, when file is loaded.

Parameters:

  • percent Number
onResize()
Called, when system is resized.
onResume()
Called, when paused scene is resumed.
onStart()

Called, when loader is started.

parseAtlas(json, callback)

(No description yet)

Parameters:

  • json Object
  • callback Function
parseCSS(filePath, callback, request)

(No description yet)

Parameters:

  • filePath String
  • callback Function
  • request XMLHttpRequest
parseFont(filePath, callback, request)

(No description yet)

Parameters:

  • filePath String
  • callback Function
  • request XMLHttpRequest
parseJSON(filePath, callback, request)

(No description yet)

Parameters:

  • filePath String
  • callback Function
  • request XMLHttpRequest
pause()
Pause scene. All current objects, timers and tweens are saved and restored when pause is resumed. Also physics are not updated when scene is paused.
removeObject(object)
Remove object from scene, so it's update function doesn't get called anymore.

Parameters:

  • object Object
removeTimer(timer, [doCallback])
Remove timer from scene.

Parameters:

  • timer Timer
  • doCallback Boolean (optional)
removeTimers([doCallback])
Remove all timers from scene.

Parameters:

  • doCallback Boolean (optional)
removeTweens()
Remove all tweens from scene.
resume()
Resume paused scene.
start()

Start loader.

swipe(direction)
Callback for swipe.

Parameters:

  • direction String
update()
This is called every frame.

Attributes

backgroundColor String (Default: #000)

Background color of loader.

errorColor String (Default: #ff0000)

Color of error text.

formats Object

List of supported file formats and their loading functions.

maxFiles Number (Default: 4)

How many files to load at same time.

minTime Number (Default: 500)

Minimum time, that the loader is visible.

preRender Boolean (Default: false)

Pre-render images, when they are loaded. Use this to avoid small pause, when rendering large images first time.

showLogo Boolean (Default: true)

Show Panda 2 logo in loader.

showPercent Boolean (Default: true)

Show percents of how much is loaded.

swipeDist Number (Default: 100)
Minimum distance to trigger swipe.
swipeTime Number (Default: 500)
Maximum time to trigger swipe (ms).
text String (Default: 'Made with Panda 2 - www.panda2.io')

Text to show on bottom of the loader

textColor String (Default: #fff)

Color of loader texts.

updateOrder Array (Default: physics,tweens,collision,timers,scene,objects,renderer)
Update order for each frame.