Skip to content

Instantly share code, notes, and snippets.

@vegarringdal
Last active July 18, 2016 21:10
Show Gist options
  • Select an option

  • Save vegarringdal/b8e2befa38b29afe1fa1187c506141a9 to your computer and use it in GitHub Desktop.

Select an option

Save vegarringdal/b8e2befa38b29afe1fa1187c506141a9 to your computer and use it in GitHub Desktop.
cocos 2d JS
http://discuss.cocos2d-x.org/t/how-to-pass-parameters-between-scenes-transition-scenes-in-cocos-creator/30364/3
cc.Class({
extends: cc.Component,
properties: {
label: {
default: null,
type: cc.Label
},
text: 'Hello, World!'
},
// use this for initialization
onLoad: function () {
this.label.string = this.text;
},
// called every frame
update: function (dt) {
console.log("running");
},
onDestroy :function (dt) {
console.log("destroy");
},
onDisable :function (dt) {
console.log("onDisable");
},
start :function (dt) {
console.log("start");
},
onEnable :function (dt) {
//get the scene
var scene = cc.director.getScene();
//get the canvas
var canvas = scene.getChildByName('Canvas')
//run action -> fade out 3 sec and load another scene
canvas.runAction(
cc.sequence(
cc.fadeOut(5),
cc.callFunc(function () {
cc.director.loadScene('cool');
})
)
);
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment