Class Index | File Index

Classes


Class LoadingScene

LoadingScene Loads a given set of assets. Assets include Graphics and Sounds.
Defined in: LoadingScene.js.

// Displays a single message as assets are loading.
LoadingScene({
   steps: {
      "Assets": [
         Graphic({ url: "./images/ball.png" }),
         Sound({ url: "./sounds/bang.ogg" }),
         ...
      ]
   }
})
// This example will show the following message:
// "Loading - Assets [percent]% complete, overall [percent]% complete"
// Having two steps for images and sounds.
LoadingScene({
   steps: {
      "Graphics": [
         Graphic({ url: "./images/ball.png" }),
         ...
      ],
      "Sounds": [
         Sound({ url: "./sounds/bang.ogg" }),
         ...
      ]
   }
})
// You can also supply your own content.
// Say you want to display your own background image as the assets are loading
LoadingScene({
   steps: {
      "Assets": [
         Graphic({ url: "./images/ball.png" }),
         Sound({ url: "./sounds/bang.ogg" }),
         ...
      ]
   },
   content: [
      Graphic({ url: "./images/loading_bg.png" })
   ]
})
Class Summary
Constructor Attributes Constructor Name and Description
 
LoadingScene(_details)
Method Summary
Method Attributes Method Name and Description
 
Creates the default content for this LoadingScene.
 
 
load(_scene, _parent)
Loads any content provided then starts the loader thread to preload any assets provided in the steps.
 
Loads the next asset in the current step.
 
update(_run_time)
Updates all content within this LoadingScene.
Class Detail
LoadingScene(_details)
Parameters:
{Object} _details
A JSON object with the following properties.
Property Required Default
content no
steps no
Method Detail
createDefaultContent()
Creates the default content for this LoadingScene. The default content is a Text object which displays the following message in the middle of the scene: "Loading - [step] [percent]% complete, overall [percent]% complete"

finish()
var stage = Stage({
   scene: Scene({
      content: [
         LoadingScene({
            steps: { ... },
            finished: function() {
               stage.unload(); stage.setScene(nextScene); stage.load();
            }
         })
      ]
   })
});

load(_scene, _parent)
Loads any content provided then starts the loader thread to preload any assets provided in the steps.
Parameters:
_scene
_parent

loadNextAsset()
Loads the next asset in the current step.

update(_run_time)
Updates all content within this LoadingScene. This update function differs from the Scene object because it passes extra information to each content. It calls each component's update function with the following:
Property Type Description
runtime Integer Current time in milliseconds since the scene was loaded.
step String Current step name as defined in the _details object.
step_percent Decimal Percent complete within the current step.
total_percent Decimal Percent complete overall.
finished Boolean Have all the assets been loaded.
Parameters:
_run_time

Documentation generated by JsDoc Toolkit 2.3.0 on Fri Oct 30 2009 09:09:10 GMT-0700 (PDT)