Description

Called a scene. Call the method "exit" of the current scene (if any) and changes of scene

Usage

Parameters

  • scene {String}

    name

  • (optional) {Object} optional

    params Display settings of the scene

    • overlay {Boolean} : Displays the scene over the previous scenes without leave
    • exitScenes {Object} : Parameter to indicate which scene to leave and when
      • allExcept (optional) {Array} : Names of other scenes not to leave
      • when (optional) {String} : When should I leave the scenes calling the scene
        • "afterPreload" : When the scene is called preloaded
      • params (optional) {Object} Other params
    • transition {Object|Boolean} : Makes a transition to the scene called. If true, makes a simple fade to 30 frames. To specify the parameters of the melt :

      transition: {
          type: "fade",
          frames : 30,
          finish: function() {
      
          }
      }
      

      For a complex animation :

      1. Put the workers directory to the root of your project.
      2. Place the image of transition in your project
      3. Set the image as an image transition in loading scene :

        materials: {
            images: {
                "img": {path: "path/to/img.png", transition: true}
            }
        }
        
      4. Set the parameters of the transition :

        transition: {
            type: "image",
            id: "img",
            finish: function() {
        
            }
        }
        

        Example

Returns

CanvasEngine.Scene

Example

"canvas" is the variable initialized for CanvasEngine

canvas.Scene.call("SceneName");

Superimposed scenes

canvas.Scene.call("SceneName", {
    overlay: true
});

Leaving the other scenes after preloading of the scene called

canvas.Scene.call("SceneName", {
    exitScenes: {
        when: "afterPreload"
    }
});

With other parameters :

canvas.Scene.call("SceneName", {
    params: {"foo": "bar"}
});

and, in ready method :

ready: function(stage, el, params) {
    console.log(params.foo) // bar
}

Discussion