18 changed files with 610 additions and 300 deletions
Binary file not shown.
After Width: | Height: | Size: 317 KiB |
@ -0,0 +1,29 @@ |
|||||
|
{ |
||||
|
"bundles":[ |
||||
|
{ |
||||
|
"name":"load-screen", |
||||
|
"assets":[ |
||||
|
{ |
||||
|
"alias":"cbg", |
||||
|
"src":"/controller_prompt_bg.png" |
||||
|
}, |
||||
|
{ |
||||
|
"alias":"bg", |
||||
|
"src":"/bg.png" |
||||
|
}, |
||||
|
{ |
||||
|
"alias":"dnf", |
||||
|
"src":"https://www.kkkk1000.com/images/learnPixiJS-AnimatedSprite/dnf.png" |
||||
|
}, |
||||
|
{ |
||||
|
"alias":"btn-bg", |
||||
|
"src":"/assets/images/button_square_depth_gloss.png" |
||||
|
}, |
||||
|
{ |
||||
|
"alias":"btn-bg-press", |
||||
|
"src":"/assets/images/button_square_depth_gradient.png" |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
] |
||||
|
} |
@ -0,0 +1,45 @@ |
|||||
|
import { Assets } from "pixi.js"; |
||||
|
|
||||
|
|
||||
|
export async function initAssets() { |
||||
|
await Assets.init({ manifest: "/manifest.json" }) |
||||
|
} |
||||
|
|
||||
|
const catchMap = new Map() |
||||
|
|
||||
|
export async function loadAsset(name: string, cb?: (progress: number) => void) { |
||||
|
const check = () => { |
||||
|
if (catchMap.has(name)) { |
||||
|
const rr = catchMap.get(name) |
||||
|
rr.count++ |
||||
|
console.log(2211); |
||||
|
catchMap.set(name, rr) |
||||
|
cb?.(1) |
||||
|
return rr.data |
||||
|
} |
||||
|
} |
||||
|
check() |
||||
|
const res = await Assets.loadBundle(name, (progress: number) => { |
||||
|
cb?.(progress) |
||||
|
}) |
||||
|
let r = check() |
||||
|
if (r) return r |
||||
|
catchMap.set(name, { |
||||
|
data: res, |
||||
|
count: 1 |
||||
|
}) |
||||
|
return res |
||||
|
} |
||||
|
/** |
||||
|
* 没有场景加载时方会卸载 |
||||
|
*/ |
||||
|
export async function unLoadAsset(name: string) { |
||||
|
if (catchMap.has(name)) { |
||||
|
const rr = catchMap.get(name) |
||||
|
rr.count-- |
||||
|
if (rr.count == 0) { |
||||
|
await Assets.unloadBundle(name) |
||||
|
catchMap.delete(name) |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
import { EP } from "@/enmu"; |
||||
|
import { IWindow } from "."; |
||||
|
import { Container, Ticker } from "pixi.js"; |
||||
|
|
||||
|
export abstract class PWindow implements IWindow { |
||||
|
components: Record<string, any>; |
||||
|
_type?: EP; |
||||
|
_initLayout?: Boolean; |
||||
|
_initAssets?: Boolean; |
||||
|
_layoutChild?: void | any[]; |
||||
|
stage: Container; |
||||
|
loader?: Loader; |
||||
|
changeStage?(name: string, opts?: {isHolderLast?: boolean}): void; |
||||
|
loadBundle?(): void; |
||||
|
unLoadBundle?(): void; |
||||
|
layout?(): void; |
||||
|
onLoad?(): void; |
||||
|
onUnLoad?(): void; |
||||
|
lateUpdate?(dt: number, name: string, ticker: Ticker): void; |
||||
|
update?(dt: number, name: string, ticker: Ticker): void; |
||||
|
} |
@ -1,21 +1,32 @@ |
|||||
|
import { Assets } from "pixi.js"; |
||||
import { EDirection } from "./enmu"; |
import { EDirection } from "./enmu"; |
||||
import { gameManager, initGame, stageManager, windows } from "./Game"; |
import { gameManager, initGame, stageManager } from "./Game"; |
||||
import { addSound } from "./Game/Sound"; |
import Game from "./Game/Game"; |
||||
|
import { initAssets } from "./Game/Assets"; |
||||
|
|
||||
gameManager.loader |
// gameManager.loader
|
||||
// .add("my-sound", "/bg.mp3", (e) => addSound(e)) // 背景音乐
|
// // .add("my-sound", "/bg.mp3", (e) => addSound(e)) // 背景音乐
|
||||
.add("bg", "/bg.png") // 背景图片
|
// .add("bg", "/bg.png") // 背景图片
|
||||
.add("dnf", "https://www.kkkk1000.com/images/learnPixiJS-AnimatedSprite/dnf.png") // 背景图片
|
// .add("dnf", "https://www.kkkk1000.com/images/learnPixiJS-AnimatedSprite/dnf.png") // 背景图片
|
||||
.add("btn-bg", "/assets/images/button_square_depth_gloss.png") // 背景图片
|
// .add("btn-bg", "/assets/images/button_square_depth_gloss.png") // 背景图片
|
||||
.add("btn-bg-press", "/assets/images/button_square_depth_gradient.png") // 背景图片
|
// .add("btn-bg-press", "/assets/images/button_square_depth_gradient.png") // 背景图片
|
||||
.load(); |
// .load();
|
||||
|
|
||||
gameManager.loader.onProgress.add((loader) => { |
// gameManager.loader.onProgress.add((loader) => {
|
||||
console.log(loader.progress); |
// console.log(loader.progress);
|
||||
}); |
// });
|
||||
gameManager.loader.onComplete.once((loader) => { |
// gameManager.loader.onComplete.once((loader) => {
|
||||
console.log(loader.resources); |
// console.log(loader.resources);
|
||||
|
// initGame();
|
||||
|
// gameManager.setDirection(EDirection.Landscape);
|
||||
|
// stageManager.initStage("init");
|
||||
|
// });
|
||||
|
|
||||
|
setTimeout(() => { |
||||
|
;(async ()=>{ |
||||
|
await initAssets(); |
||||
|
await Game.getInstance().init() |
||||
initGame(); |
initGame(); |
||||
gameManager.setDirection(EDirection.Landscape); |
gameManager.setDirection(EDirection.Landscape); |
||||
stageManager.initStage("init"); |
})() |
||||
}); |
}, 200); |
Loading…
Reference in new issue