Commit 0f6d5422 authored by haiyoucuv's avatar haiyoucuv

init

parent 3ba2e095
...@@ -22,20 +22,23 @@ ...@@ -22,20 +22,23 @@
"__id__": 2 "__id__": 2
}, },
{ {
"__id__": 14 "__id__": 8
},
{
"__id__": 20
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 20 "__id__": 26
}, },
{ {
"__id__": 22 "__id__": 28
} }
], ],
"_prefab": { "_prefab": {
"__id__": 24 "__id__": 30
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
...@@ -66,6 +69,139 @@ ...@@ -66,6 +69,139 @@
}, },
"_id": "" "_id": ""
}, },
{
"__type__": "cc.Node",
"_name": "prizeImg",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
},
{
"__id__": 5
}
],
"_prefab": {
"__id__": 7
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 45.228999999999985,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 4
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "a3VdeU06ZMj6Vvi41WzZ5G"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 6
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": null,
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "25HV7XkRFNHrJpilkGdZKl"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "eaoS3868xD9bBeSp1sxlPH",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "numBg", "_name": "numBg",
...@@ -76,25 +212,25 @@ ...@@ -76,25 +212,25 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 3 "__id__": 9
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 9 "__id__": 15
}, },
{ {
"__id__": 11 "__id__": 17
} }
], ],
"_prefab": { "_prefab": {
"__id__": 13 "__id__": 19
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 29.98199999999997, "x": 29.98199999999997,
"y": -85.65599999999995, "y": 9.228999999999985,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
...@@ -126,20 +262,20 @@ ...@@ -126,20 +262,20 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 2 "__id__": 8
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 4 "__id__": 10
}, },
{ {
"__id__": 6 "__id__": 12
} }
], ],
"_prefab": { "_prefab": {
"__id__": 8 "__id__": 14
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
...@@ -176,11 +312,11 @@ ...@@ -176,11 +312,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 3 "__id__": 9
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 5 "__id__": 11
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
...@@ -204,11 +340,11 @@ ...@@ -204,11 +340,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 3 "__id__": 9
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 7 "__id__": 13
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
...@@ -285,11 +421,11 @@ ...@@ -285,11 +421,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 2 "__id__": 8
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 10 "__id__": 16
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
...@@ -313,11 +449,11 @@ ...@@ -313,11 +449,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 2 "__id__": 8
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 12 "__id__": 18
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
...@@ -377,19 +513,19 @@ ...@@ -377,19 +513,19 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 15 "__id__": 21
}, },
{ {
"__id__": 17 "__id__": 23
} }
], ],
"_prefab": { "_prefab": {
"__id__": 19 "__id__": 25
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": -110.28999999999994, "y": -26.38499999999999,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
...@@ -421,11 +557,11 @@ ...@@ -421,11 +557,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 14 "__id__": 20
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 16 "__id__": 22
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
...@@ -449,11 +585,11 @@ ...@@ -449,11 +585,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 14 "__id__": 20
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 18 "__id__": 24
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
...@@ -534,17 +670,17 @@ ...@@ -534,17 +670,17 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 21 "__id__": 27
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 100, "width": 100,
"height": 100 "height": 190
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0.5, "x": 0.5,
"y": 1 "y": 0.5
}, },
"_id": "" "_id": ""
}, },
...@@ -562,7 +698,7 @@ ...@@ -562,7 +698,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 23 "__id__": 29
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
...@@ -575,7 +711,7 @@ ...@@ -575,7 +711,7 @@
"a": 255 "a": 255
}, },
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "10867b5d-624d-4816-b428-8418d8d50261@f9941", "__uuid__": "7d8f9b89-4fd1-4c9f-a3ab-38ec7cded7ca@f9941",
"__expectedType__": "cc.SpriteFrame" "__expectedType__": "cc.SpriteFrame"
}, },
"_type": 0, "_type": 0,
...@@ -595,7 +731,7 @@ ...@@ -595,7 +731,7 @@
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "2aPmet/ANH9owbi8fIqpbq" "fileId": "5aJRpZaPNJM7YRw7bAvkVB"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
......
...@@ -199,7 +199,7 @@ ...@@ -199,7 +199,7 @@
"_priority": 40000, "_priority": 40000,
"_fov": 45, "_fov": 45,
"_fovAxis": 0, "_fovAxis": 0,
"_orthoHeight": 727.2602377807134, "_orthoHeight": 752.2582582582583,
"_near": 0, "_near": 0,
"_far": 2000, "_far": 2000,
"_color": { "_color": {
...@@ -2957,7 +2957,7 @@ ...@@ -2957,7 +2957,7 @@
"_priority": 50000, "_priority": 50000,
"_fov": 45, "_fov": 45,
"_fovAxis": 0, "_fovAxis": 0,
"_orthoHeight": 727.2602377807134, "_orthoHeight": 752.2582582582583,
"_near": 1, "_near": 1,
"_far": 2000, "_far": 2000,
"_color": { "_color": {
...@@ -10000,7 +10000,7 @@ ...@@ -10000,7 +10000,7 @@
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "cdNum", "_name": "cdNum",
"_objFlags": 0, "_objFlags": 512,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 262 "__id__": 262
...@@ -11998,7 +11998,7 @@ ...@@ -11998,7 +11998,7 @@
"y": 180, "y": 180,
"z": 0 "z": 0
}, },
"_id": "c7pMbs2VZM8KwIJtJyYTfE" "_id": "14pA+dmYNCRoSAY8mYJjjX"
}, },
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
...@@ -12020,7 +12020,7 @@ ...@@ -12020,7 +12020,7 @@
"x": 0, "x": 0,
"y": 1 "y": 1
}, },
"_id": "78BzAu8+VC6KMO66WHAuoG" "_id": "eaMiD7fIJAPZo57gfOPtgx"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -12056,7 +12056,7 @@ ...@@ -12056,7 +12056,7 @@
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_useGrayscale": false, "_useGrayscale": false,
"_atlas": null, "_atlas": null,
"_id": "b13h4yg39NkqJOEvjJt6pQ" "_id": "7alP2f+PZFEY5Ro0EAJ7B9"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
...@@ -12104,7 +12104,7 @@ ...@@ -12104,7 +12104,7 @@
"y": 0, "y": 0,
"z": 0 "z": 0
}, },
"_id": "8axQDpB9ZPpYnQ6u6Sb3nl" "_id": "4dijCnIqRNfZlEDqjQjliv"
}, },
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
...@@ -12126,7 +12126,7 @@ ...@@ -12126,7 +12126,7 @@
"x": 0, "x": 0,
"y": 1 "y": 1
}, },
"_id": "27kVmT1BxH67AyHZ2kQQTF" "_id": "8adzGN/qFD2L70dAXLXYmy"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -12162,7 +12162,7 @@ ...@@ -12162,7 +12162,7 @@
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_useGrayscale": false, "_useGrayscale": false,
"_atlas": null, "_atlas": null,
"_id": "80m8/7/FdBjKRe80JMbUsv" "_id": "feHobxKShB0oCaJaM48cPw"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
...@@ -12210,7 +12210,7 @@ ...@@ -12210,7 +12210,7 @@
"y": 0, "y": 0,
"z": 0 "z": 0
}, },
"_id": "45ydlCpuNBF7rOAKtlUxAM" "_id": "66U/DEMh5JBLHFz/1CGEgT"
}, },
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
...@@ -12232,7 +12232,7 @@ ...@@ -12232,7 +12232,7 @@
"x": 0, "x": 0,
"y": 1 "y": 1
}, },
"_id": "e1CXYsFD9ONpaRmof9+F0l" "_id": "d7DmKtXghPmLAk7AHbmAAU"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -12268,7 +12268,7 @@ ...@@ -12268,7 +12268,7 @@
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_useGrayscale": false, "_useGrayscale": false,
"_atlas": null, "_atlas": null,
"_id": "a7B/HMeWhEc5AO3g5KVU5q" "_id": "33rM5GqrRJgYgFLTZuJ8vm"
}, },
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
...@@ -12460,7 +12460,7 @@ ...@@ -12460,7 +12460,7 @@
"y": 180, "y": 180,
"z": 0 "z": 0
}, },
"_id": "2aNQ0/h5dK/4sJrh4YCiUb" "_id": "64GTjd4ItN/ImetWle0xwM"
}, },
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
...@@ -12482,7 +12482,7 @@ ...@@ -12482,7 +12482,7 @@
"x": 0, "x": 0,
"y": 1 "y": 1
}, },
"_id": "19ooYL8I5Iy5/+L5kEUQto" "_id": "814wn6YJtPjqM+J2mZnz8z"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -12518,7 +12518,7 @@ ...@@ -12518,7 +12518,7 @@
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_useGrayscale": false, "_useGrayscale": false,
"_atlas": null, "_atlas": null,
"_id": "5cp3Lm/nVJ+L4l3TbrTPK1" "_id": "94/htU18dCYLjMTpSfI7/j"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
...@@ -12566,7 +12566,7 @@ ...@@ -12566,7 +12566,7 @@
"y": 0, "y": 0,
"z": 0 "z": 0
}, },
"_id": "94uiSKMHdC4LNxDTWdM2w4" "_id": "ffLQ+MMKJBbodU8s7fM5Xi"
}, },
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
...@@ -12588,7 +12588,7 @@ ...@@ -12588,7 +12588,7 @@
"x": 0, "x": 0,
"y": 1 "y": 1
}, },
"_id": "bdSoBchxJCjKyUWds8wlo6" "_id": "9afYoihrlAW6OnooFM/uQt"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -12624,7 +12624,7 @@ ...@@ -12624,7 +12624,7 @@
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_useGrayscale": false, "_useGrayscale": false,
"_atlas": null, "_atlas": null,
"_id": "eavRms1MlKw4+lHieeJWB0" "_id": "9b/QX6uzdGa7mKs9hk28SG"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
...@@ -12672,7 +12672,7 @@ ...@@ -12672,7 +12672,7 @@
"y": 0, "y": 0,
"z": 0 "z": 0
}, },
"_id": "55PXby4lZDhJc0lv1VJSWs" "_id": "9fV4t5DLBNTpVsss7JXw2t"
}, },
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
...@@ -12694,7 +12694,7 @@ ...@@ -12694,7 +12694,7 @@
"x": 0, "x": 0,
"y": 1 "y": 1
}, },
"_id": "65T4kcm1JOIYoZmOp4PFzA" "_id": "be0k8wl5NMFbK1VMzStFjQ"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -12730,7 +12730,7 @@ ...@@ -12730,7 +12730,7 @@
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_useGrayscale": false, "_useGrayscale": false,
"_atlas": null, "_atlas": null,
"_id": "20VG09QBNCPZ1P5p6ON9d0" "_id": "37JQBOwxlOKIaCvMbiXg50"
}, },
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
......
...@@ -9,6 +9,7 @@ import OpenLuckyPanel from "../Panels/OpenLuckyPanel"; ...@@ -9,6 +9,7 @@ import OpenLuckyPanel from "../Panels/OpenLuckyPanel";
import shareStore from "../store/shareStore"; import shareStore from "../store/shareStore";
import GetPrize from "db://assets/Scripts/Panels/GetPrize"; import GetPrize from "db://assets/Scripts/Panels/GetPrize";
import store from "../store/store"; import store from "../store/store";
import { VList } from "../../Test/VList";
const {ccclass, property} = _decorator; const {ccclass, property} = _decorator;
...@@ -51,9 +52,10 @@ export class BlessingBagPage extends Scene { ...@@ -51,9 +52,10 @@ export class BlessingBagPage extends Scene {
//福袋轮播图 //福袋轮播图
@property(Prefab) prize_list: Prefab = null; @property(Prefab) prize_list: Prefab = null;
@property(Node) prizeListDiamond: Node = null;
@property(Node) prizeListGold: Node = null; @property(VList) sliverList: VList = null;
@property(Node) prizeListSliver: Node = null; @property(VList) goldList: VList = null;
@property(VList) diamondList: VList = null;
//赚福袋任务界面 //赚福袋任务界面
...@@ -115,59 +117,32 @@ export class BlessingBagPage extends Scene { ...@@ -115,59 +117,32 @@ export class BlessingBagPage extends Scene {
const { bagPrizeVO } = store.bagInfo; const { bagPrizeVO } = store.bagInfo;
bagPrizeVO.map((item, index) => { const updateItem = (node, data) => {
//银福袋轮播 node.getChildByName("prizeImg")
if (item.type === 1) { .getComponent(Sprite).spriteFrame = data.prizeImg;
item.prizeVOList.map((item, index) => {
const prizeSliver = instantiate(this.prize_list)
this.prizeListSliver.addChild(prizeSliver)
prizeSliver.getComponent(Sprite).spriteFrame = item.prizeImg node.getChildByName("numBg")
.getChildByName("num")
.getComponent(Label).string = `X${data.sendCount}`;
const numBg = prizeSliver.getChildByName("numBg") node.getChildByName("prizeName")
const num = numBg.getChildByName("num") .getComponent(Label).string = data.prizeName;
num.getComponent(Label).string = `X${item.sendCount}` };
const prizeName = prizeSliver.getChildByName("prizeName") bagPrizeVO.map((item) => {
prizeName.getComponent(Label).string = item.prizeName //银福袋轮播
if (item.type === 1) {
}) this.sliverList.init(item.prizeVOList, updateItem);
} }
//金福袋轮播 //金福袋轮播
if (item.type === 2) { if (item.type === 2) {
item.prizeVOList.map((item, index) => { this.goldList.init(item.prizeVOList, updateItem);
const prizeGold = instantiate(this.prize_list)
this.prizeListGold.addChild(prizeGold)
prizeGold.getComponent(Sprite).spriteFrame = item.prizeImg
const numBg = prizeGold.getChildByName("numBg")
const num = numBg.getChildByName("num")
num.getComponent(Label).string = `X${item.sendCount}`
const prizeName = prizeGold.getChildByName("prizeName")
prizeName.getComponent(Label).string = item.prizeName
})
} }
//钻石福袋轮播 //钻石福袋轮播
if (item.type === 3) { if (item.type === 3) {
item.prizeVOList.map((item, index) => { this.diamondList.init(item.prizeVOList, updateItem);
const prizeDiamond = instantiate(this.prize_list)
this.prizeListDiamond.addChild(prizeDiamond)
prizeDiamond.getComponent(Sprite).spriteFrame = item.prizeImg
const numBg = prizeDiamond.getChildByName("numBg")
const num = numBg.getChildByName("num")
num.getComponent(Label).string = `X${item.sendCount}`
const prizeName = prizeDiamond.getChildByName("prizeName")
prizeName.getComponent(Label).string = item.prizeName
})
} }
}) })
......
...@@ -251,7 +251,7 @@ export class MainGame extends Scene { ...@@ -251,7 +251,7 @@ export class MainGame extends Scene {
this.initAnimal(+getUrlParam("aiNum")); this.initAnimal(+getUrlParam("aiNum"));
} else { } else {
// 初始化NPC // 初始化NPC
this.initAnimal(15); this.initAnimal(12);
// this.initAnimal(1); // this.initAnimal(1);
} }
......
This diff is collapsed.
{
"ver": "1.1.50",
"importer": "scene",
"imported": true,
"uuid": "f12326db-0532-4293-8fba-d4dad8809cf9",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}
import { _decorator, Component, EventTouch, instantiate, Mask, math, Node, Prefab, Size, UITransform } from "cc";
const { ccclass, property, requireComponent } = _decorator;
@ccclass("VList")
@requireComponent([UITransform, Mask])
export class VList extends Component {
@property(Prefab)
itemPrefab: Prefab = null;
@property
gapX: number = 0;
@property
autoScroll: boolean = true;
@property
speed: number = 100;
_init: boolean = false;
_auto: boolean = true;
_data: any = [];
callback: (node: Node, index: number) => void = () => {};
uiTransform: UITransform = null;
itemSize: Size;
itemArr: { node: Node, i: number }[] = [];
onLoad() {
this.uiTransform = this.getComponent(UITransform);
this.node.on(Node.EventType.TOUCH_START, this.onTouchStart, this);
this.node.on(Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
this.node.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
this.node.on(Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
}
init(data: any[], callback: (node: Node, index: number) => void) {
this._data = data;
this.callback = callback;
const node = instantiate(this.itemPrefab);
this.node.addChild(node);
this.itemSize = node.getComponent(UITransform).contentSize.clone();
this.itemArr.push({ node, i: 0 });
this.updateItem(node, 0);
const num = ~~(this.uiTransform.width / (this.itemSize.width + this.gapX)) + 2;
for (let i = 1; i <= num; i++) {
const node = instantiate(this.itemPrefab);
this.node.addChild(node);
this.itemArr.push({ node, i });
this.updateItem(node, i);
}
this.itemArr.forEach(({ node }, i) => {
node.setPosition(i * (this.itemSize.width + this.gapX) - this.uiTransform.width * this.uiTransform.anchorX, 0);
});
this._init = true;
}
onTouchStart() {
this._auto = false;
}
onTouchMove(e: EventTouch) {
this.updateX(e.getDeltaX());
}
onTouchEnd() {
this._auto = true;
}
update(deltaTime: number) {
const { _auto, autoScroll, speed } = this;
if (autoScroll && _auto) {
this.updateX(-speed * deltaTime);
}
}
updateX(deltaX: number) {
if (!this._init) return;
deltaX = math.clamp(deltaX, -50, 50);
const { gapX, itemArr, itemSize, uiTransform } = this;
const index = ~~(itemArr.length / 2);
const newX = itemArr[index].node.position.x + deltaX;
itemArr[index].node.setPosition(newX, 0);
const iSize = gapX + itemSize.width;
for (let i = index - 1; i >= 0; i--) {
itemArr[i].node.setPosition(itemArr[i + 1].node.position.x - iSize, 0);
}
for (let i = index + 1; i < itemArr.length; i++) {
itemArr[i].node.setPosition(itemArr[i - 1].node.position.x + iSize, 0);
}
if (deltaX < 0) {
if (itemArr[0].node.position.x <= -(uiTransform.width * uiTransform.anchorX) - itemSize.width) {
const newI = itemArr[itemArr.length - 1].i + 1;
itemArr[0].i = newI;
this.updateItem(itemArr[0].node, newI);
itemArr.push(itemArr.shift());
}
} else {
if (itemArr[itemArr.length - 1].node.position.x >= (uiTransform.width * (1 - uiTransform.anchorX)) + itemSize.width) {
const newI = itemArr[0].i - 1;
itemArr[itemArr.length - 1].i = newI;
this.updateItem(itemArr[itemArr.length - 1].node, newI);
itemArr.unshift(itemArr.pop());
}
}
}
updateItem(node: Node, index: number) {
const dLen = this._data.length;
const dataIndex = (dLen + index % dLen) % dLen;
this.callback(node, this._data[dataIndex]);
}
}
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "f3443f6b-f95d-4005-9e15-cfce1cf81b62",
"files": [],
"subMetas": {},
"userData": {}
}
...@@ -98,14 +98,14 @@ ...@@ -98,14 +98,14 @@
</style> </style>
<script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734925399949/src/assets/plugin/zepto.min.js"></script> <script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734940806006/src/assets/plugin/zepto.min.js"></script>
<script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734925399949/src/assets/plugin/declare-process.js"></script> <script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734940806006/src/assets/plugin/declare-process.js"></script>
<script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734925399949/src/assets/plugin/SVGA.Lite.v2.1.1.js"></script> <script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734940806006/src/assets/plugin/SVGA.Lite.v2.1.1.js"></script>
<script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734925399949/src/assets/plugin/jszip.min.v3.10.1.js"></script> <script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734940806006/src/assets/plugin/jszip.min.v3.10.1.js"></script>
<script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734925399949/src/assets/plugin/rem.min.js"></script> <script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734940806006/src/assets/plugin/rem.min.js"></script>
<script src="//res.wx.qq.com/open/js/jweixin-1.6.0.js"></script> <script src="//res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<!-- <link rel="stylesheet" type="text/css" href="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734925399949/style.css" />--> <!-- <link rel="stylesheet" type="text/css" href="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734940806006/style.css" />-->
<!-- <link rel="stylesheet" type="text/css" href="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734925399949/custom.css" />--> <!-- <link rel="stylesheet" type="text/css" href="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734940806006/custom.css" />-->
<!-- <script src="//yun-duiba-credits-test.duibatest.com.cn/TNGD_GAMES/libs/eruda.min.js"></script>--> <!-- <script src="//yun-duiba-credits-test.duibatest.com.cn/TNGD_GAMES/libs/eruda.min.js"></script>-->
<!-- <script>eruda.init()</script>--> <!-- <script>eruda.init()</script>-->
...@@ -118,20 +118,20 @@ ...@@ -118,20 +118,20 @@
</div> </div>
<!-- Polyfills bundle. --> <!-- Polyfills bundle. -->
<script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734925399949/src/polyfills.bundle.js" charset="utf-8"></script> <script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734940806006/src/polyfills.bundle.js" charset="utf-8"></script>
<!-- SystemJS support. --> <!-- SystemJS support. -->
<script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734925399949/src/system.bundle.js" charset="utf-8"></script> <script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1734940806006/src/system.bundle.js" charset="utf-8"></script>
<!-- Import map --> <!-- Import map -->
<!--<script src="https://yun.duiba.com.cn/db_games/ccc_game/template3d/1734925399949/src/import-map.json" type="systemjs-importmap" charset="utf-8"></script>--> <!--<script src="https://yun.duiba.com.cn/db_games/ccc_game/template3d/1734940806006/src/import-map.json" type="systemjs-importmap" charset="utf-8"></script>-->
<script type="systemjs-importmap" charset="utf-8"> <script type="systemjs-importmap" charset="utf-8">
{"imports":{"cc":"//yun.duiba.com.cn/db_games/ccc_game/template3d/1734925399949/cocos-js/cc.js"}} {"imports":{"cc":"//yun.duiba.com.cn/db_games/ccc_game/template3d/1734940806006/cocos-js/cc.js"}}
</script> </script>
<script> <script>
System.import('//yun.duiba.com.cn/db_games/ccc_game/template3d/1734925399949/index.js').catch(function (err) { System.import('//yun.duiba.com.cn/db_games/ccc_game/template3d/1734940806006/index.js').catch(function (err) {
console.error(err); console.error(err);
}) })
</script> </script>
......
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
"progress": 1, "progress": 1,
"state": "success", "state": "success",
"stage": "build", "stage": "build",
"message": "2024-12-23 11:44:51 build success in 1 min 32 s!", "message": "2024-12-23 16:00:52 build success in 47 s!",
"detailMessage": "builder:build-project-total (91849ms)\r", "detailMessage": "builder:build-project-total (46942ms)\r",
"options": { "options": {
"name": "cocos-template-3d", "name": "cocos-template-3d",
"server": "", "server": "",
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
"__version__": "1.3.8", "__version__": "1.3.8",
"logDest": "project://temp/builder/log/web-mobile2024-11-6 15-39.log" "logDest": "project://temp/builder/log/web-mobile2024-11-6 15-39.log"
}, },
"time": "2024-12-23 11:43:19", "time": "2024-12-23 16:00:05",
"dirty": false "dirty": false
} }
} }
......
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