添加ScrollView组件demo

This commit is contained in:
我是leo
2018-03-19 20:29:25 +08:00
parent 17e683605a
commit 43ec23f976
24 changed files with 23810 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
cc.Class({
extends: cc.Component,
properties: {
horizontal: cc.ScrollView,
vertical: cc.ScrollView,
grid: cc.ScrollView,
item: cc.Node,
},
// use this for initialization
onLoad: function () {
// this.label.string = this.text;
this.horizontal.node.active = true;
this.vertical.node.active = false;
this.grid.node.active = false;
},
onBtnClicked(event, customData) {
console.log('customData=', customData);
this.horizontal.node.active = false;
this.vertical.node.active = false;
this.grid.node.active = false;
var node = this.node.getChildByName(customData);
switch (node.name) {
case 'horizontal': {
this.horizontal.node.active = true;
this.onAddItem(this.horizontal, this.item);
break;
}
case 'vertical': {
this.vertical.node.active = true;
this.onAddItem(this.vertical, this.item);
break;
}
case 'grid': {
this.grid.node.active = true;
this.onAddItem(this.grid, this.item);
break;
}
}
},
onAddItem(scrollView, item) {
console.log(scrollView.node);
var contentNode = scrollView.node.getChildByName('view').getChildByName('content');
var child = cc.instantiate(item);
contentNode.addChild(child);
},
// called every frame
update: function (dt) {
},
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "280c3aec-6492-4a9d-9f51-a9b00b570b4a",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}