Commit 40e3d7f0 authored by Tt's avatar Tt

代码整理

parent b7893774
...@@ -79,18 +79,24 @@ ...@@ -79,18 +79,24 @@
}, },
{ {
"__id__": 14 "__id__": 14
},
{
"__id__": 24
},
{
"__id__": 26
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 24 "__id__": 33
}, },
{ {
"__id__": 25 "__id__": 34
}, },
{ {
"__id__": 26 "__id__": 35
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1254,6 +1260,395 @@ ...@@ -1254,6 +1260,395 @@
"preload": false, "preload": false,
"_id": "dey05oKrBIspvsDa6pOIQz" "_id": "dey05oKrBIspvsDa6pOIQz"
}, },
{
"__type__": "cc.Node",
"_name": "item",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 25
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 131.33,
"height": 65.2
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 1
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-102.2,
105.16,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "9bVeK7KRtLiYjbABJie3Gd"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 24
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "ScrollView content\n\n",
"_N$string": "ScrollView content\n\n",
"_fontSize": 16,
"_lineHeight": 20,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 0,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "bd/vtfl55Jfp7eWEIALhvU"
},
{
"__type__": "cc.Node",
"_name": "scroll",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [
{
"__id__": 27
}
],
"_active": true,
"_components": [
{
"__id__": 31
},
{
"__id__": 32
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 240,
"height": 250
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-390.749,
37.766,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "60RCz+Mn1Pl53s0U1oPyQM"
},
{
"__type__": "cc.Node",
"_name": "view",
"_objFlags": 0,
"_parent": {
"__id__": 26
},
"_children": [
{
"__id__": 28
}
],
"_active": true,
"_components": [
{
"__id__": 30
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 240,
"height": 250
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "derP1zk0lAd4P8mbkHMXvI"
},
{
"__type__": "cc.Node",
"_name": "content",
"_objFlags": 0,
"_parent": {
"__id__": 27
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 29
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 220,
"height": 400
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 1
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
115.30999755859375,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "33FgO69m5Dz6H919wtIPIQ"
},
{
"__type__": "cc.Layout",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 28
},
"_enabled": true,
"_layoutSize": {
"__type__": "cc.Size",
"width": 300,
"height": 200
},
"_resize": 1,
"_N$layoutType": 2,
"_N$cellSize": {
"__type__": "cc.Size",
"width": 40,
"height": 40
},
"_N$startAxis": 0,
"_N$paddingLeft": 0,
"_N$paddingRight": 0,
"_N$paddingTop": 0,
"_N$paddingBottom": 0,
"_N$spacingX": 0,
"_N$spacingY": 0,
"_N$verticalDirection": 1,
"_N$horizontalDirection": 0,
"_N$affectedByScale": false,
"_id": "3chvDjaZdOwY3IDRGTebIh"
},
{
"__type__": "cc.Mask",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 27
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_spriteFrame": null,
"_type": 0,
"_segments": 64,
"_N$alphaThreshold": 0,
"_N$inverted": false,
"_id": "694YKsN2BJQqVjV4pBrSdO"
},
{
"__type__": "cc.ScrollView",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 26
},
"_enabled": true,
"horizontal": false,
"vertical": true,
"inertia": true,
"brake": 0.75,
"elastic": true,
"bounceDuration": 0.23,
"scrollEvents": [],
"cancelInnerEvents": true,
"_N$content": {
"__id__": 28
},
"content": {
"__id__": 28
},
"_N$horizontalScrollBar": null,
"_N$verticalScrollBar": null,
"_id": "92xjV09xlI9aWoOLobZjP8"
},
{
"__type__": "8db05zjxQdJ84wfJbBeDash",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 26
},
"_enabled": true,
"item": {
"__id__": 24
},
"items": [],
"list": [],
"updateItem": null,
"target": {},
"addNum": 1,
"selector": {},
"_id": "7f/tl7SzpGPLUMPbL0tAVw"
},
{ {
"__type__": "cc.Canvas", "__type__": "cc.Canvas",
"_name": "", "_name": "",
......
class Item {
public type: number;//商品类型
public name: string;//商品名称
public icon: string;//商品图片--可用type生成
public growthValue: number;//生长值
public cost: number;//费用
public discount: number;//折扣
constructor(obj: any) {
this.type = obj.type;
this.name = obj.name;
this.icon = obj.icon;
this.growthValue = obj.growthValue;
this.cost = obj.cost;
this.discount = obj.discount;
}
}
class Shop {
public _list: Array<Item>
constructor() {
this._list = [];
}
parse(list: any) {
if (!list) return;
this._list = list.map(li => {
return new Item(li);
})
}
get list() {
return this._list;
}
}
export { Shop, Item };
{
"ver": "1.0.8",
"uuid": "7696c029-a1e7-49e2-887c-fd3791e8ded1",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Node)
item: cc.Node = null;
@property
items: any = null;
@property
list: Array<any> = [];
@property
updateItem: any = null;
@property
target: any = null;
@property
addNum: number = 1;
@property
selector: any = null;
flush() {
//执行一次更新
this._updateScrollView();
}
onLoad() {
}
_updateScrollView() {
//如果有性能压力改成 顺序加载,并且在关闭的时候能自动检测停止加载
//在界面下方的所有节点自动的显示效果是隐藏效果。
let view = this.node.getChildByName("view");
let content = view.getChildByName("content");
//后面改成动态判断内部节点的方式而不是暴力移除
content.removeAllChildren();
let addNum = this.addNum || 1;
let list = this.list;
let items = this.items;
if (!items || items.length == 0) items = [this.item];
for (let i = 0; i < list.length; i += addNum) {
let datas = [list[i]];
for (let m = 1; m < addNum; m++) {
datas.push(list[i + m]);
}
let item = this._selectorCall(items, datas);
let itemClone = cc.instantiate(item);
itemClone.x = 0;
itemClone.y = 0;
content.addChild(itemClone);
itemClone.active = true;
this._updateItemCall(itemClone, datas);
}
}
_updateItemCall(itemClone, datas) {
this.updateItem && this.updateItem.call(this.target, itemClone, datas);
}
_selectorCall(items, datas) {
return items[0];
if (!this.selector) return items[0];
return this.selector(items, datas);
}
}
{
"ver": "1.0.8",
"uuid": "8db05ce3-c507-49f3-8c1f-25b05e0dab21",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"skipLibCheck": true, "skipLibCheck": true,
"outDir": "temp/vscode-dist", "outDir": "temp/vscode-dist",
"allowJs": true,
"forceConsistentCasingInFileNames": true "forceConsistentCasingInFileNames": true
}, },
"exclude": [ "exclude": [
......
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