mirror of
https://github.com/Leo501/CocosCreatorTutorial.git
synced 2026-05-20 01:19:14 +08:00
添加ScrollView组件demo
This commit is contained in:
67
ScrollViewDemo/.gitignore
vendored
Normal file
67
ScrollViewDemo/.gitignore
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# Fireball Projects
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
library/
|
||||
temp/
|
||||
local/
|
||||
build/
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# Logs and databases
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# files for debugger
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*.sln
|
||||
*.csproj
|
||||
*.pidb
|
||||
*.unityproj
|
||||
*.suo
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# OS generated files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
.DS_Store
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# exvim files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*UnityVS.meta
|
||||
*.err
|
||||
*.err.meta
|
||||
*.exvim
|
||||
*.exvim.meta
|
||||
*.vimentry
|
||||
*.vimentry.meta
|
||||
*.vimproject
|
||||
*.vimproject.meta
|
||||
.vimfiles.*/
|
||||
.exvim.*/
|
||||
quick_gen_project_*_autogen.bat
|
||||
quick_gen_project_*_autogen.bat.meta
|
||||
quick_gen_project_*_autogen.sh
|
||||
quick_gen_project_*_autogen.sh.meta
|
||||
.exvim.app
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# webstorm files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
.idea/
|
||||
|
||||
#//////////////////////////
|
||||
# VS Code
|
||||
#//////////////////////////
|
||||
|
||||
.vscode/
|
||||
2
ScrollViewDemo/README.md
Normal file
2
ScrollViewDemo/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# hello-world
|
||||
Hello world new project template.
|
||||
6
ScrollViewDemo/assets/Scene.meta
Normal file
6
ScrollViewDemo/assets/Scene.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
3015
ScrollViewDemo/assets/Scene/helloworld.fire
Normal file
3015
ScrollViewDemo/assets/Scene/helloworld.fire
Normal file
File diff suppressed because it is too large
Load Diff
7
ScrollViewDemo/assets/Scene/helloworld.fire.meta
Normal file
7
ScrollViewDemo/assets/Scene/helloworld.fire.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"asyncLoadAssets": false,
|
||||
"autoReleaseAssets": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
6
ScrollViewDemo/assets/Script.meta
Normal file
6
ScrollViewDemo/assets/Script.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
55
ScrollViewDemo/assets/Script/HelloWorld.js
Normal file
55
ScrollViewDemo/assets/Script/HelloWorld.js
Normal 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) {
|
||||
|
||||
},
|
||||
});
|
||||
9
ScrollViewDemo/assets/Script/HelloWorld.js.meta
Normal file
9
ScrollViewDemo/assets/Script/HelloWorld.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "280c3aec-6492-4a9d-9f51-a9b00b570b4a",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
6
ScrollViewDemo/assets/Texture.meta
Normal file
6
ScrollViewDemo/assets/Texture.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
BIN
ScrollViewDemo/assets/Texture/Head0.png
Normal file
BIN
ScrollViewDemo/assets/Texture/Head0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
30
ScrollViewDemo/assets/Texture/Head0.png.meta
Normal file
30
ScrollViewDemo/assets/Texture/Head0.png.meta
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"uuid": "c993d9ec-ad11-473d-a3fe-d59941177c3f",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"subMetas": {
|
||||
"Head0": {
|
||||
"ver": "1.0.3",
|
||||
"uuid": "10836e17-9703-42aa-8c02-77e91154dff8",
|
||||
"rawTextureUuid": "c993d9ec-ad11-473d-a3fe-d59941177c3f",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 100,
|
||||
"height": 100,
|
||||
"rawWidth": 100,
|
||||
"rawHeight": 100,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
ScrollViewDemo/assets/Texture/HelloWorld.png
Normal file
BIN
ScrollViewDemo/assets/Texture/HelloWorld.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
30
ScrollViewDemo/assets/Texture/HelloWorld.png.meta
Normal file
30
ScrollViewDemo/assets/Texture/HelloWorld.png.meta
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"subMetas": {
|
||||
"HelloWorld": {
|
||||
"ver": "1.0.3",
|
||||
"uuid": "31bc895a-c003-4566-a9f3-2e54ae1c17dc",
|
||||
"rawTextureUuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 195,
|
||||
"height": 270,
|
||||
"rawWidth": 195,
|
||||
"rawHeight": 270,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
ScrollViewDemo/assets/Texture/singleColor.png
Normal file
BIN
ScrollViewDemo/assets/Texture/singleColor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
30
ScrollViewDemo/assets/Texture/singleColor.png.meta
Normal file
30
ScrollViewDemo/assets/Texture/singleColor.png.meta
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"subMetas": {
|
||||
"singleColor": {
|
||||
"ver": "1.0.3",
|
||||
"uuid": "410fb916-8721-4663-bab8-34397391ace7",
|
||||
"rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 2,
|
||||
"height": 2,
|
||||
"rawWidth": 2,
|
||||
"rawHeight": 2,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
20475
ScrollViewDemo/creator.d.ts
vendored
Normal file
20475
ScrollViewDemo/creator.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
15
ScrollViewDemo/jsconfig.json
Normal file
15
ScrollViewDemo/jsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"experimentalDecorators": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".vscode",
|
||||
"library",
|
||||
"local",
|
||||
"settings",
|
||||
"temp"
|
||||
]
|
||||
}
|
||||
4
ScrollViewDemo/project.json
Normal file
4
ScrollViewDemo/project.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"engine": "cocos2d-html5",
|
||||
"packages": "packages"
|
||||
}
|
||||
13
ScrollViewDemo/settings/builder.json
Normal file
13
ScrollViewDemo/settings/builder.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"excludeScenes": [],
|
||||
"orientation": {
|
||||
"landscapeLeft": true,
|
||||
"landscapeRight": true,
|
||||
"portrait": false,
|
||||
"upsideDown": false
|
||||
},
|
||||
"packageName": "org.cocos2d.helloworld",
|
||||
"startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"title": "hello_world",
|
||||
"webOrientation": "auto"
|
||||
}
|
||||
7
ScrollViewDemo/settings/builder.panel.json
Normal file
7
ScrollViewDemo/settings/builder.panel.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"excludeScenes": [],
|
||||
"packageName": "org.cocos2d.helloworld",
|
||||
"platform": "web-mobile",
|
||||
"startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"title": "HelloWorld"
|
||||
}
|
||||
28
ScrollViewDemo/settings/project.json
Normal file
28
ScrollViewDemo/settings/project.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"collision-matrix": [
|
||||
[
|
||||
true
|
||||
]
|
||||
],
|
||||
"excluded-modules": [],
|
||||
"group-list": [
|
||||
"default"
|
||||
],
|
||||
"start-scene": "current",
|
||||
"design-resolution-width": 960,
|
||||
"design-resolution-height": 640,
|
||||
"fit-width": false,
|
||||
"fit-height": true,
|
||||
"use-project-simulator-setting": false,
|
||||
"simulator-orientation": false,
|
||||
"use-customize-simulator": false,
|
||||
"simulator-resolution": {
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"cocos-analytics": {
|
||||
"enable": false,
|
||||
"appID": "13798",
|
||||
"appSecret": "959b3ac0037d0f3c2fdce94f8421a9b2"
|
||||
}
|
||||
}
|
||||
BIN
ScrollViewDemo/template-banner.png
Normal file
BIN
ScrollViewDemo/template-banner.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
5
ScrollViewDemo/template.json
Normal file
5
ScrollViewDemo/template.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "TEMPLATES.helloworld.name",
|
||||
"desc": "TEMPLATES.helloworld.desc",
|
||||
"banner": "template-banner.png"
|
||||
}
|
||||
Reference in New Issue
Block a user