Commit eaa67fb7 authored by 范雪寒's avatar 范雪寒

feat: 将预制节点放到resources文件夹里

parent 3ae5f23b
{
"ver": "1.1.2",
"uuid": "75835c75-5df7-4594-bb63-56f33654da79",
"isBundle": true,
"bundleName": "resources",
"priority": 8,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
// 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: {
},
ctor() {
this._dataList = null;
this._currentIdx = 0;
},
start() {
this.initListeners();
},
initListeners() {
const BtnNext = this.node.getChildByName('BtnNext');
const BtnPrevious = this.node.getChildByName('BtnPrevious');
const BtnBack = this.node.getChildByName('BtnBack');
const buttonsNode = cc.find('ButtonsNode');
if (!this._dataList[this._currentIdx + 1]) {
BtnNext.active = false;
}
BtnNext.on('click', () => {
demoItem = this._dataList[this._currentIdx + 1];
cc.director.loadScene(demoItem.sceneName, () => {
const scene = cc.director.getScene();
const newButtonNode = cc.instantiate(buttonsNode);
newButtonNode.parent = scene;
newButtonNode.x = 0;
newButtonNode.y = 0;
newButtonNode.getComponent('ButtonsNode').setDataList(demoList, idx);
});
});
if (!this._dataList[this._currentIdx - 1]) {
BtnPrevious.active = false;
}
BtnPrevious.on('click', () => {
demoItem = this._dataList[this._currentIdx - 1];
cc.director.loadScene(demoItem.sceneName, () => {
const scene = cc.director.getScene();
const newButtonNode = cc.instantiate(buttonsNode);
newButtonNode.parent = scene;
newButtonNode.x = 0;
newButtonNode.y = 0;
newButtonNode.getComponent('ButtonsNode').setDataList(demoList, idx);
});
});
BtnBack.on('click', () => {
cc.director.loadScene('mainPage');
});
},
setDataList(dataList, currentIdx) {
this._dataList = dataList;
this._currentIdx = currentIdx;
},
// update (dt) {},
});
...@@ -28,9 +28,13 @@ ...@@ -28,9 +28,13 @@
} }
], ],
"_active": true, "_active": true,
"_components": [], "_components": [
{
"__id__": 35
}
],
"_prefab": { "_prefab": {
"__id__": 35 "__id__": 36
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -325,7 +329,7 @@ ...@@ -325,7 +329,7 @@
"__id__": 1 "__id__": 1
}, },
"asset": { "asset": {
"__id__": 0 "__uuid__": "ffa620db-880d-4ed4-8dd1-00133559ac52"
}, },
"fileId": "f7UGNL7UVGk4CTBReMALGN", "fileId": "f7UGNL7UVGk4CTBReMALGN",
"sync": false "sync": false
...@@ -395,7 +399,7 @@ ...@@ -395,7 +399,7 @@
"__id__": 1 "__id__": 1
}, },
"asset": { "asset": {
"__id__": 0 "__uuid__": "ffa620db-880d-4ed4-8dd1-00133559ac52"
}, },
"fileId": "7bl06GQFdGLa/C8+8YqOF7", "fileId": "7bl06GQFdGLa/C8+8YqOF7",
"sync": false "sync": false
...@@ -515,7 +519,7 @@ ...@@ -515,7 +519,7 @@
"__id__": 1 "__id__": 1
}, },
"asset": { "asset": {
"__id__": 0 "__uuid__": "ffa620db-880d-4ed4-8dd1-00133559ac52"
}, },
"fileId": "5fVxX0MPlFjKczib59bpkl", "fileId": "5fVxX0MPlFjKczib59bpkl",
"sync": false "sync": false
...@@ -766,7 +770,7 @@ ...@@ -766,7 +770,7 @@
"__id__": 1 "__id__": 1
}, },
"asset": { "asset": {
"__id__": 0 "__uuid__": "ffa620db-880d-4ed4-8dd1-00133559ac52"
}, },
"fileId": "69vL47dSFMiYTImeroVZPx", "fileId": "69vL47dSFMiYTImeroVZPx",
"sync": false "sync": false
...@@ -836,7 +840,7 @@ ...@@ -836,7 +840,7 @@
"__id__": 1 "__id__": 1
}, },
"asset": { "asset": {
"__id__": 0 "__uuid__": "ffa620db-880d-4ed4-8dd1-00133559ac52"
}, },
"fileId": "02nTlGH8pMYKr9XuX25KFp", "fileId": "02nTlGH8pMYKr9XuX25KFp",
"sync": false "sync": false
...@@ -956,7 +960,7 @@ ...@@ -956,7 +960,7 @@
"__id__": 1 "__id__": 1
}, },
"asset": { "asset": {
"__id__": 0 "__uuid__": "ffa620db-880d-4ed4-8dd1-00133559ac52"
}, },
"fileId": "416mO1C4lJEb9hSe7wx3Jg", "fileId": "416mO1C4lJEb9hSe7wx3Jg",
"sync": false "sync": false
...@@ -1207,7 +1211,7 @@ ...@@ -1207,7 +1211,7 @@
"__id__": 1 "__id__": 1
}, },
"asset": { "asset": {
"__id__": 0 "__uuid__": "ffa620db-880d-4ed4-8dd1-00133559ac52"
}, },
"fileId": "771uGcSddClYMu7NGmbLaH", "fileId": "771uGcSddClYMu7NGmbLaH",
"sync": false "sync": false
...@@ -1277,7 +1281,7 @@ ...@@ -1277,7 +1281,7 @@
"__id__": 1 "__id__": 1
}, },
"asset": { "asset": {
"__id__": 0 "__uuid__": "ffa620db-880d-4ed4-8dd1-00133559ac52"
}, },
"fileId": "4b75kT7rVHTruaArhQn4G5", "fileId": "4b75kT7rVHTruaArhQn4G5",
"sync": false "sync": false
...@@ -1397,18 +1401,28 @@ ...@@ -1397,18 +1401,28 @@
"__id__": 1 "__id__": 1
}, },
"asset": { "asset": {
"__id__": 0 "__uuid__": "ffa620db-880d-4ed4-8dd1-00133559ac52"
}, },
"fileId": "aa1/O6kH1CT62jMktS6TUP", "fileId": "aa1/O6kH1CT62jMktS6TUP",
"sync": false "sync": false
}, },
{
"__type__": "abb52OcegZE5rPyTByt2ykw",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
"__id__": 1 "__id__": 1
}, },
"asset": { "asset": {
"__id__": 0 "__uuid__": "ffa620db-880d-4ed4-8dd1-00133559ac52"
}, },
"fileId": "d7OJrcCmJLEIoN3nqNXoZJ", "fileId": "d7OJrcCmJLEIoN3nqNXoZJ",
"sync": false "sync": false
......
// 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) {},
});
This diff is collapsed.
...@@ -34,9 +34,16 @@ cc.Class({ ...@@ -34,9 +34,16 @@ cc.Class({
button.x = (width / widthLength) * ((idx % widthLength) - (widthLength - 1) / 2); button.x = (width / widthLength) * ((idx % widthLength) - (widthLength - 1) / 2);
button.y = 300 - Math.floor(idx / widthLength) * 50; button.y = 300 - Math.floor(idx / widthLength) * 50;
const buttonsNode = cc.find('ButtonsNode');
button.on('click', () => { button.on('click', () => {
cc.director.loadScene(demoItem.sceneName, () => { cc.director.loadScene(demoItem.sceneName, () => {
const scene = cc.director.getScene();
const newButtonNode = cc.instantiate(buttonsNode);
newButtonNode.parent = scene;
newButtonNode.x = 0;
newButtonNode.y = 0;
newButtonNode.getComponent('ButtonsNode').setDataList(demoList, idx);
}); });
}); });
}); });
......
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