完成首页
@ -1,14 +1,19 @@
|
|||||||
import BackHomeBtn from "./BackHomeBtn";
|
import BackHomeBtn from './BackHomeBtn';
|
||||||
const {ccclass, property} = cc._decorator;
|
const { ccclass, property } = cc._decorator;
|
||||||
|
const LOAD_SCENE_MIN_SEC: number = 1.2;
|
||||||
enum sceneList {
|
enum sceneList {
|
||||||
"Infinite_bg_scroll" = "背景无限滚动",
|
'Infinite_bg_scroll' = '背景无限滚动',
|
||||||
"Joystick" = "遥控杆",
|
'Joystick' = '遥控杆',
|
||||||
"Coin_fly_to_wallet" = "金币落袋",
|
'Coin_fly_to_wallet' = '金币落袋',
|
||||||
"Magnifying_mirror" = "放大镜"
|
'Magnifying_mirror' = '放大镜'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ccclass
|
@ccclass
|
||||||
export default class Home extends cc.Component {
|
export default class Home extends cc.Component {
|
||||||
|
@property(cc.Node)
|
||||||
|
loadingNode: cc.Node = null;
|
||||||
|
@property(cc.ProgressBar)
|
||||||
|
loadingProgress: cc.ProgressBar = null;
|
||||||
@property(cc.Node)
|
@property(cc.Node)
|
||||||
scrollContent: cc.Node = null;
|
scrollContent: cc.Node = null;
|
||||||
@property(cc.Prefab)
|
@property(cc.Prefab)
|
||||||
@ -23,42 +28,83 @@ export default class Home extends cc.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
judgeJump() {
|
judgeJump() {
|
||||||
const sceneName = this.getQueryStringByName("sceneName");
|
const sceneName = this.getQueryStringByName('sceneName');
|
||||||
const isSameVisit = window["isSameVisit"];
|
const isSameVisit = window['isSameVisit'];
|
||||||
|
|
||||||
if (!sceneName) return;
|
if (!sceneName) return;
|
||||||
if (isSameVisit) return;
|
if (isSameVisit) return;
|
||||||
|
|
||||||
if (sceneList[sceneName]) {
|
if (sceneList[sceneName]) {
|
||||||
window["isSameVisit"] = true;
|
window['isSameVisit'] = true;
|
||||||
this.loadScene(sceneName);
|
this.loadScene(sceneName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getQueryStringByName(name) {
|
getQueryStringByName(name) {
|
||||||
let result = window.location.search.match(new RegExp("[\?\&]" + name+ "=([^\&]+)","i"));
|
let result = window.location.search.match(new RegExp('[?&]' + name + '=([^&]+)', 'i'));
|
||||||
return result == null || result.length < 1 ? "" : result[1];
|
return result == null || result.length < 1 ? '' : result[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
initScrollItem() {
|
initScrollItem() {
|
||||||
for (let key in sceneList) {
|
for (let key in sceneList) {
|
||||||
let scrollItem = cc.instantiate(this.scrollItemPrefab);
|
let scrollItem = cc.instantiate(this.scrollItemPrefab);
|
||||||
|
|
||||||
scrollItem.getChildByName("label").getComponent(cc.Label).string = sceneList[key];
|
scrollItem.getChildByName('label').getComponent(cc.Label).string = sceneList[key];
|
||||||
scrollItem.on(cc.Node.EventType.TOUCH_END, () => {
|
scrollItem.on(
|
||||||
cc.tween(scrollItem)
|
cc.Node.EventType.TOUCH_END,
|
||||||
.to(0.1, { scale: 1.05 })
|
() => {
|
||||||
.to(0.1, { scale: 1 })
|
cc.tween(scrollItem)
|
||||||
.start();
|
.to(0.1, { scale: 1.05 })
|
||||||
this.loadScene(key);
|
.to(0.1, { scale: 1 })
|
||||||
}, this);
|
.start();
|
||||||
|
this.loadScene(key);
|
||||||
|
},
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
this.scrollContent.addChild(scrollItem);
|
this.scrollContent.addChild(scrollItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beginLoad: boolean = false;
|
||||||
|
finishLoadFlag: boolean = false;
|
||||||
|
loadTime: number = 0;
|
||||||
|
loadSceneName: string = '';
|
||||||
loadScene(key) {
|
loadScene(key) {
|
||||||
cc.director.loadScene(key);
|
if (this.beginLoad) return;
|
||||||
BackHomeBtn.instance.toggleActive(true);
|
this.loadingProgress.progress = 0;
|
||||||
|
this.loadingNode.active = true;
|
||||||
|
this.beginLoad = true;
|
||||||
|
this.loadSceneName = key;
|
||||||
|
|
||||||
|
cc.director.preloadScene(
|
||||||
|
key,
|
||||||
|
(completedCount, totalCount) => {
|
||||||
|
// 还是做假进度条吧,缓存之后太快了,一闪而过的体验不好
|
||||||
|
// this.loadingProgress.progress = completedCount / totalCount;
|
||||||
|
},
|
||||||
|
(error, asset) => {
|
||||||
|
if (!error) {
|
||||||
|
this.finishLoadFlag = true;
|
||||||
|
} else {
|
||||||
|
this.loadingNode.active = false;
|
||||||
|
this.beginLoad = false;
|
||||||
|
this.loadTime = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(dt) {
|
||||||
|
if (!this.beginLoad) return;
|
||||||
|
|
||||||
|
if (this.loadTime >= LOAD_SCENE_MIN_SEC && this.finishLoadFlag) {
|
||||||
|
this.loadingProgress.progress = 1;
|
||||||
|
BackHomeBtn.instance.toggleActive(true);
|
||||||
|
cc.director.loadScene(this.loadSceneName);
|
||||||
|
} else {
|
||||||
|
this.loadTime += dt;
|
||||||
|
this.loadingProgress.progress = Math.min(this.loadTime / LOAD_SCENE_MIN_SEC, this.finishLoadFlag ? 1 : 0.9);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
assets/Scene/Home/Texture/avatar.png
Normal file
After Width: | Height: | Size: 363 KiB |
@ -1,20 +1,20 @@
|
|||||||
{
|
{
|
||||||
"ver": "2.3.4",
|
"ver": "2.3.4",
|
||||||
"uuid": "1c14c2d0-c971-4bca-a2be-8458a3083f70",
|
"uuid": "faefe167-15a3-45f1-8281-920ba11dd0f6",
|
||||||
"type": "sprite",
|
"type": "sprite",
|
||||||
"wrapMode": "clamp",
|
"wrapMode": "clamp",
|
||||||
"filterMode": "bilinear",
|
"filterMode": "bilinear",
|
||||||
"premultiplyAlpha": false,
|
"premultiplyAlpha": false,
|
||||||
"genMipmaps": false,
|
"genMipmaps": false,
|
||||||
"packable": true,
|
"packable": true,
|
||||||
"width": 474,
|
"width": 1350,
|
||||||
"height": 316,
|
"height": 1350,
|
||||||
"platformSettings": {},
|
"platformSettings": {},
|
||||||
"subMetas": {
|
"subMetas": {
|
||||||
"th": {
|
"avatar": {
|
||||||
"ver": "1.0.4",
|
"ver": "1.0.4",
|
||||||
"uuid": "c569c4d9-3ae8-496d-ac64-40c32782c594",
|
"uuid": "ee4860e7-78d7-4f1a-a1e2-e2c9201ef1b0",
|
||||||
"rawTextureUuid": "1c14c2d0-c971-4bca-a2be-8458a3083f70",
|
"rawTextureUuid": "faefe167-15a3-45f1-8281-920ba11dd0f6",
|
||||||
"trimType": "auto",
|
"trimType": "auto",
|
||||||
"trimThreshold": 1,
|
"trimThreshold": 1,
|
||||||
"rotated": false,
|
"rotated": false,
|
||||||
@ -22,10 +22,10 @@
|
|||||||
"offsetY": 0,
|
"offsetY": 0,
|
||||||
"trimX": 0,
|
"trimX": 0,
|
||||||
"trimY": 0,
|
"trimY": 0,
|
||||||
"width": 474,
|
"width": 1350,
|
||||||
"height": 316,
|
"height": 1350,
|
||||||
"rawWidth": 474,
|
"rawWidth": 1350,
|
||||||
"rawHeight": 316,
|
"rawHeight": 1350,
|
||||||
"borderTop": 0,
|
"borderTop": 0,
|
||||||
"borderBottom": 0,
|
"borderBottom": 0,
|
||||||
"borderLeft": 0,
|
"borderLeft": 0,
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
BIN
assets/Scene/Home/Texture/ewm.jpg
Normal file
After Width: | Height: | Size: 26 KiB |
@ -1,20 +1,20 @@
|
|||||||
{
|
{
|
||||||
"ver": "2.3.4",
|
"ver": "2.3.4",
|
||||||
"uuid": "3f716868-44f8-4ff2-9f85-72917cc049da",
|
"uuid": "b7a2debd-36ee-4af0-abf4-1fbde3a8cb9a",
|
||||||
"type": "sprite",
|
"type": "sprite",
|
||||||
"wrapMode": "clamp",
|
"wrapMode": "clamp",
|
||||||
"filterMode": "bilinear",
|
"filterMode": "bilinear",
|
||||||
"premultiplyAlpha": false,
|
"premultiplyAlpha": false,
|
||||||
"genMipmaps": false,
|
"genMipmaps": false,
|
||||||
"packable": true,
|
"packable": true,
|
||||||
"width": 78,
|
"width": 258,
|
||||||
"height": 67,
|
"height": 258,
|
||||||
"platformSettings": {},
|
"platformSettings": {},
|
||||||
"subMetas": {
|
"subMetas": {
|
||||||
"npm_1": {
|
"ewm": {
|
||||||
"ver": "1.0.4",
|
"ver": "1.0.4",
|
||||||
"uuid": "d4d6a44a-040e-442d-ab8f-1fa461cafd87",
|
"uuid": "802b4004-09af-4e51-9f68-21dbc96a0e02",
|
||||||
"rawTextureUuid": "3f716868-44f8-4ff2-9f85-72917cc049da",
|
"rawTextureUuid": "b7a2debd-36ee-4af0-abf4-1fbde3a8cb9a",
|
||||||
"trimType": "auto",
|
"trimType": "auto",
|
||||||
"trimThreshold": 1,
|
"trimThreshold": 1,
|
||||||
"rotated": false,
|
"rotated": false,
|
||||||
@ -22,10 +22,10 @@
|
|||||||
"offsetY": 0,
|
"offsetY": 0,
|
||||||
"trimX": 0,
|
"trimX": 0,
|
||||||
"trimY": 0,
|
"trimY": 0,
|
||||||
"width": 78,
|
"width": 258,
|
||||||
"height": 67,
|
"height": 258,
|
||||||
"rawWidth": 78,
|
"rawWidth": 258,
|
||||||
"rawHeight": 67,
|
"rawHeight": 258,
|
||||||
"borderTop": 0,
|
"borderTop": 0,
|
||||||
"borderBottom": 0,
|
"borderBottom": 0,
|
||||||
"borderLeft": 0,
|
"borderLeft": 0,
|
Before Width: | Height: | Size: 82 B After Width: | Height: | Size: 82 B |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 32 KiB |
@ -13,7 +13,7 @@
|
|||||||
"includeSDKBox": false,
|
"includeSDKBox": false,
|
||||||
"inlineSpriteFrames": true,
|
"inlineSpriteFrames": true,
|
||||||
"inlineSpriteFrames_native": true,
|
"inlineSpriteFrames_native": true,
|
||||||
"mergeStartScene": false,
|
"mergeStartScene": true,
|
||||||
"optimizeHotUpdate": false,
|
"optimizeHotUpdate": false,
|
||||||
"md5Cache": true,
|
"md5Cache": true,
|
||||||
"encryptJs": true,
|
"encryptJs": true,
|
||||||
|