Commit 94cb9bb6 authored by 范雪寒's avatar 范雪寒

feat: loading

parent a4d22fe8
......@@ -70,18 +70,21 @@
"_children": [
{
"__id__": 3
},
{
"__id__": 5
}
],
"_active": true,
"_components": [
{
"__id__": 5
"__id__": 7
},
{
"__id__": 6
"__id__": 8
},
{
"__id__": 7
"__id__": 9
}
],
"_prefab": null,
......@@ -230,6 +233,100 @@
"_alignWithScreen": true,
"_id": "81GN3uXINKVLeW4+iKSlim"
},
{
"__type__": "cc.Node",
"_name": "layout",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 6
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 300,
"height": 200
},
"_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": "c2sOE7+gtD8K6NRKHK87V9"
},
{
"__type__": "cc.Layout",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_layoutSize": {
"__type__": "cc.Size",
"width": 300,
"height": 200
},
"_resize": 1,
"_N$layoutType": 1,
"_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": "6dN4iu1W1PSbBpz3uIfg1F"
},
{
"__type__": "cc.Canvas",
"_name": "",
......
......@@ -7,6 +7,11 @@ const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
onLoad() {
this.initSceneData();
this.initSize();
this.showWaitingLetters();
}
addPreloadImage() {
// TODO 根据自己的配置预加载图片资源
......@@ -46,6 +51,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
const step = this.data.step;
cc.director.loadScene(`PS_001_scene1`, () => {
this.hideWaitingLetters();
if (step != 0) {
PS_001_Ctrl.getIns().time = 1;
PS_001_Ctrl.getIns().goscene(conf[step].id);
......@@ -64,4 +70,57 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
})
}
showWaitingLetters() {
const colorList = this.getRainbowColorList();
const layout = cc.find('Canvas/layout');
layout.active = true;
layout.removeAllChildren();
const str = 'Now Loading...';
str.split('').forEach((word, idx) => {
const node = new cc.Node();
const label = node.addComponent(cc.Label);
label.string = word;
node.parent = layout;
node.color = colorList[idx];
cc.tween(node)
.delay(idx / 4)
.by(0.3, { y: 50 }, { easing: 'sineOut' })
.by(0.3, { y: -50 }, { easing: 'sineIn' })
.delay((str.length - idx) / 4)
.union()
.repeatForever()
.start();
});
const totalWidth = layout.children.reduce((width, node, idx) => {
return width + node.width;
}, 0);
layout.width = totalWidth;
}
hideWaitingLetters() {
const layout = cc.find('Canvas/layout');
if (layout) {
layout.active = false;
}
}
getRainbowColorList() {
return [
cc.color(0, 255, 0),
cc.color(0, 255, 128),
cc.color(0, 255, 255),
cc.color(0, 128, 255),
cc.color(0, 0, 255),
cc.color(128, 0, 255),
cc.color(255, 0, 255),
cc.color(255, 0, 128),
cc.color(255, 0, 0),
cc.color(255, 128, 0),
cc.color(255, 255, 0),
cc.color(128, 255, 0),
cc.color(0, 255, 0),
cc.color(0, 255, 0),
];
}
}
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