Commit 3ae5f23b authored by 范雪寒's avatar 范雪寒

feat: 创建预制

parent 83ecdba1
// Learn cc.Class:
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start () {
},
// update (dt) {},
});
{
"ver": "1.0.8",
"uuid": "abb5239c-7a06-44e6-b3f2-4c1caddb2930",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.7",
"uuid": "ffa620db-880d-4ed4-8dd1-00133559ac52",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
......@@ -9,29 +9,37 @@ cc.Class({
extends: cc.Component,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start () {
start() {
const demoList = [{
sceneName: 'demo_01_showFireworks',
label: '烟花效果'
}];
demoList.forEach((demoItem, idx) => {
const button = cc.instantiate(cc.find('Canvas/New Button'));
const label = cc.find('Background/Label', button);
label.getComponent(cc.Label).string = demoItem.label;
const width = 1200;
const widthLength = 4;
button.parent = this.node;
button.x = (width / widthLength) * ((idx % widthLength) - (widthLength - 1) / 2);
button.y = 300 - Math.floor(idx / widthLength) * 50;
button.on('click', () => {
cc.director.loadScene(demoItem.sceneName, () => {
});
});
});
},
// update (dt) {},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment