预加载问题

This commit is contained in:
DESKTOP-J7I1C4E\a9350 2024-03-09 13:17:48 +08:00
parent edba3e9514
commit c0da02c955
15 changed files with 1771 additions and 935 deletions

View File

@ -4,20 +4,35 @@ const { ccclass, property } = _decorator;
@ccclass('StartGameRoot')
export class StartGameRoot extends Component {
/// 玩法介绍按钮
@property(Node) PressenButton: Node;
/// 玩法介绍UI预制件
@property(Prefab) pressenPrefab: Prefab;
//// 开始游戏按钮
@property(Node) StartButton: Node;
/// UI层预制件
@property(Prefab) UIPrefab: Prefab;
start() {
this.PressenButton.on(Node.EventType.TOUCH_END,this.onTouchEnd,this);
this.PressenButton.on(Node.EventType.TOUCH_END,this.pressenOnTouchEnd,this);
this.StartButton.on(Node.EventType.TOUCH_END,this.startOnTouchEnd,this);
}
onTouchEnd(event:Event){
pressenOnTouchEnd(event:Event){
const pressent = instantiate(this.pressenPrefab);
this.node.addChild(pressent);
pressent.setPosition(0,0);
}
startOnTouchEnd(event:Event){
this.node.destroy();
const ui = instantiate(this.UIPrefab);
this.node.parent.addChild(ui);
}
update(deltaTime: number) {
}

21
assets/Script/UIRoot.ts Normal file
View File

@ -0,0 +1,21 @@
import { _decorator, assetManager, Component, instantiate, Node, Prefab } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('UIRoot')
export class UIRoot extends Component {
@property({ type: Prefab, displayName: 'Ani帧数', tooltip: "Ani总共有多少帧" })
startGameRootPrefab:Prefab;
start() {
this.node.addChild(instantiate(this.startGameRootPrefab));
}
update(deltaTime: number) {
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "a578cd6a-ad34-4875-a305-844b629bc2cc",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,259 @@
[
{
"__type__": "cc.Prefab",
"_name": "Gamer",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false
},
{
"__type__": "cc.Node",
"_name": "Gamer",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [
{
"__id__": 2
}
],
"_active": true,
"_components": [
{
"__id__": 6
},
{
"__id__": 8
},
{
"__id__": 10
}
],
"_prefab": {
"__id__": 12
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"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": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "Role",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
}
],
"_prefab": {
"__id__": 5
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"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": 1073741824,
"_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": "6206qxk1NFE5QmAvH3zvq1"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "65epnVCaxNSIGMknmNdcpA",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 7
},
"_contentSize": {
"__type__": "cc.Size",
"width": 40,
"height": 36
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "c6XJpShO1IiISvt/47nt+K"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 9
},
"_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": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "f1HLPxYllBtLhId3RcwwDZ"
},
{
"__type__": "a80463xbJJM5qU8FUhHK84e",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 11
},
"ImgPath": "interface2/event/chn_event_2020/200922_dnf_marble/01_ingame.img",
"ImgIndex": 32,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "5fuqRs6VlLV6IWVYCnfh42"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "4dIR0b3MJAHIpU7ERJwTWq",
"instance": null,
"targetOverrides": null
}
]

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "7fb32db3-b3d6-44f1-abaa-f6063c24e07f",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "Gamer"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "500c80cc-b47e-4a2d-98c7-4f6ce6113811",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "StartGameRoot"
}
}

View File

@ -0,0 +1,220 @@
[
{
"__type__": "cc.Prefab",
"_name": "UI",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false
},
{
"__type__": "cc.Node",
"_name": "UI",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [
{
"__id__": 2
}
],
"_active": true,
"_components": [
{
"__id__": 10
}
],
"_prefab": {
"__id__": 12
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"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": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_prefab": {
"__id__": 3
},
"__editorExtras__": {}
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 2
},
"asset": {
"__uuid__": "7fb32db3-b3d6-44f1-abaa-f6063c24e07f",
"__expectedType__": "cc.Prefab"
},
"fileId": "4dIR0b3MJAHIpU7ERJwTWq",
"instance": {
"__id__": 4
},
"targetOverrides": null
},
{
"__type__": "cc.PrefabInstance",
"fileId": "d7vgkaVD5OmapjIefZvdyK",
"prefabRootNode": {
"__id__": 1
},
"mountedChildren": [],
"mountedComponents": [],
"propertyOverrides": [
{
"__id__": 5
},
{
"__id__": 7
},
{
"__id__": 8
},
{
"__id__": 9
}
],
"removedComponents": []
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 6
},
"propertyPath": [
"_name"
],
"value": "Gamer"
},
{
"__type__": "cc.TargetInfo",
"localID": [
"4dIR0b3MJAHIpU7ERJwTWq"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 6
},
"propertyPath": [
"_lpos"
],
"value": {
"__type__": "cc.Vec3",
"x": 266.766,
"y": 240.999,
"z": 0
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 6
},
"propertyPath": [
"_lrot"
],
"value": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 6
},
"propertyPath": [
"_euler"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
}
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 11
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "ebXzZerpNCrpui6J6cpIgs"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "54XqsHof9Fxrxjq1dsKg2i",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": [
{
"__id__": 2
}
]
}
]

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "b5b15b0a-c30d-4b95-aee9-b2798a9ad12d",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "UI"
}
}

View File

@ -1,7 +1,10 @@
import { _decorator, Component, director, Node } from 'cc';
import { _decorator, Component, director, instantiate, Node, Prefab, resources, Scene } from 'cc';
import { GlobalAudio } from '../../GlobalScript/GlobalAudio/GlobalAudio';
import { ImagePack } from '../../GlobalScript/ImagePack/ImagePack';
import { GameScript } from '../../GlobalScript/GameScript/GameScript';
import { UIRoot } from '../../Script/UIRoot';
const { ccclass, property } = _decorator;
@ -18,6 +21,8 @@ export class LodingLogic extends Component {
NpkManage: boolean = false;
//Pvf管理器初始化状态
PvfManage: boolean = false;
start() {
//初始化音频Map
GlobalAudio.getInstance().Init(() => {
@ -31,6 +36,7 @@ export class LodingLogic extends Component {
GameScript.getInstance().Init(() => {
this.PvfManage = true;
});
}
CheckInitState() {
@ -40,18 +46,24 @@ export class LodingLogic extends Component {
else return true;
}
update(deltaTime: number) {
if (this.CheckInitState() && !this.InitFlag && this.LogoFlag) {
this.scheduleOnce(function () {
// director.loadScene("LoginGame");
director.loadScene("main");
director.preloadScene("main",()=>{
director.loadScene("main");
});
}, 0);
this.InitFlag = true;
} else {
//每帧调用
GameScript.getInstance().Update();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
"enable": true,
"customSplash": {
"complete": true,
"form": "https://creator-api.cocos.com/api/form/show?sid=9ca4a815f78c9bcd01d30320bbf2f99b"
"form": "https://creator-api.cocos.com/api/form/show?sid=713f3d658f5b15c1ab406d720b890938"
}
},
"removeSplash": {
@ -15,8 +15,8 @@
"label": "removeSplash",
"enable": true,
"removeSplash": {
"complete": false,
"form": "https://creator-api.cocos.com/api/form/show?sid=9ca4a815f78c9bcd01d30320bbf2f99b"
"complete": true,
"form": "https://creator-api.cocos.com/api/form/show?sid=713f3d658f5b15c1ab406d720b890938"
}
}
}