mirror of
https://github.com/Leo501/CocosCreatorTutorial.git
synced 2026-05-09 07:07:31 +08:00
更新ScrolView的例子,添加滑动事件
This commit is contained in:
@@ -23,21 +23,24 @@ cc.Class({
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -48,8 +51,17 @@ cc.Class({
|
||||
contentNode.addChild(child);
|
||||
},
|
||||
|
||||
onEventScrollView(event, eventType) {
|
||||
console.log('eventType=', eventType, cc.ScrollView.EventType);
|
||||
//当滑动到最后,添加一个
|
||||
if (cc.ScrollView.EventType.AUTOSCROLL_ENDED_WITH_THRESHOLD == eventType) {
|
||||
console.log('aa');
|
||||
this.onAddItem(this.vertical, this.item);
|
||||
}
|
||||
},
|
||||
|
||||
// called every frame
|
||||
update: function (dt) {
|
||||
|
||||
},
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user