Last active
July 18, 2016 21:10
-
-
Save vegarringdal/b8e2befa38b29afe1fa1187c506141a9 to your computer and use it in GitHub Desktop.
cocos 2d JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| http://discuss.cocos2d-x.org/t/how-to-pass-parameters-between-scenes-transition-scenes-in-cocos-creator/30364/3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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