Commit 09f8472b authored by Master Q's avatar Master Q

音频文件和 游戏 spi 文件要放到 淘宝cdn 上

parent b4122601
This diff is collapsed.
...@@ -173,9 +173,9 @@ export namespace RES { ...@@ -173,9 +173,9 @@ export namespace RES {
* @param comFun 加载回调 * @param comFun 加载回调
* @param thisObj this指向 * @param thisObj this指向
*/ */
export function getResAsync(str: string, comFun?: (res: any, str: string) => void, thisObj?: any): Promise<any> { export function getResAsync(str: string, comFun?: (res: any, str: string) => void, thisObj?: any, loadType?: string): Promise<any> {
// var arr = str.split("."); // var arr = str.split(".");
var type = str.substring(str.lastIndexOf(".") + 1, str.length); var type = loadType || str.substring(str.lastIndexOf(".") + 1, str.length);
//如果是图片 //如果是图片
if (type == "png" || type == "jpg") { if (type == "png" || type == "jpg") {
//原先就有了,加载过的,且已加载完成的 //原先就有了,加载过的,且已加载完成的
...@@ -252,7 +252,6 @@ export namespace RES { ...@@ -252,7 +252,6 @@ export namespace RES {
} }
} }
else if (type == 'spi') { else if (type == 'spi') {
console.log(str)
if (spineDataHash[str]) { if (spineDataHash[str]) {
comFun && comFun.call(thisObj, spineDataHash[str], str) comFun && comFun.call(thisObj, spineDataHash[str], str)
return new Promise((r) => { return new Promise((r) => {
...@@ -356,9 +355,9 @@ export namespace RES { ...@@ -356,9 +355,9 @@ export namespace RES {
* @param str * @param str
* @return 已加载好得素材或null * @return 已加载好得素材或null
*/ */
export function getRes<T extends string>(str: T): GetResType<T> { export function getRes<T extends string>(str: T, type?: string): GetResType<T> {
if (!str) return null; if (!str) return null;
var type = str.substring(str.lastIndexOf(".") + 1, str.length); var type = type || str.substring(str.lastIndexOf(".") + 1, str.length);
if (type == "png" || type == "jpg") { if (type == "png" || type == "jpg") {
return textureHash[str] || FYGE.TextureCache[str] || null; return textureHash[str] || FYGE.TextureCache[str] || null;
} }
......
...@@ -496,7 +496,7 @@ export class GameScene extends Dream.RenderContainer { ...@@ -496,7 +496,7 @@ export class GameScene extends Dream.RenderContainer {
const stackHeadBox = this.GameEleStack.stackHead const stackHeadBox = this.GameEleStack.stackHead
const {x: preX, y: preY} = stackHeadBox const {x: preX, y: preY} = stackHeadBox
const dir = this.dir = -1 //Math.random() > 0.5 ? 1 : -1 const dir = this.dir = Math.random() > 0.5 ? 1 : -1
// 刷新 // 刷新
const isWithGift = this.isWithGift = this.isCouldHaveGift && Math.random() < GameConfig.finalGiftPart const isWithGift = this.isWithGift = this.isCouldHaveGift && Math.random() < GameConfig.finalGiftPart
this.isCouldHaveGift = false this.isCouldHaveGift = false
......
...@@ -8,6 +8,7 @@ import { PerfectJumpEnd } from "../../lotties/PerfectJumpEnd"; ...@@ -8,6 +8,7 @@ import { PerfectJumpEnd } from "../../lotties/PerfectJumpEnd";
import { fadeOutUpFactory } from "../../modules/animations"; import { fadeOutUpFactory } from "../../modules/animations";
import { RES } from "../../modules/RES"; import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload"; import { UsePreload } from "../../modules/UseDecorator/usePreload";
import { getTbSpi } from "../../tools/simpleTools";
export enum PlayAniEnum { export enum PlayAniEnum {
Stand = 'daiji', Stand = 'daiji',
...@@ -30,7 +31,11 @@ export type PlayerIns = { ...@@ -30,7 +31,11 @@ export type PlayerIns = {
@UsePreload({ @UsePreload({
preAction: async function() { preAction: async function() {
if (!window) {
await RES.getResAsync(getTbSpi(), () => {}, null, 'spi')
} else {
await RES.loadGroup('spine') await RES.loadGroup('spine')
}
}, },
loadingComponent: null loadingComponent: null
}) })
...@@ -78,7 +83,7 @@ export class Player extends Dream.RenderContainer<{ ...@@ -78,7 +83,7 @@ export class Player extends Dream.RenderContainer<{
} }
render() { render() {
const PlayerSpineData = RES.getRes('rabbit.spi') const PlayerSpineData = RES.getRes(!window ? getTbSpi() : 'rabbit.spi', 'spi')
return ( return (
<DreamContainer inlineProps={{ <DreamContainer inlineProps={{
......
// @ts-ignore // @ts-ignore
const app = getApp() const app = typeof getApp == 'function' && getApp()
const audioIns = app?.audioContext const audioIns = app?.audioContext
if (audioIns) { if (audioIns) {
audioIns.onPlay(() => { audioIns.onPlay(() => {
...@@ -12,5 +12,20 @@ if (audioIns) { ...@@ -12,5 +12,20 @@ if (audioIns) {
} }
export function PlayAudio() { export function PlayAudio() {
console.log('app =====', app)
audioIns && audioIns.play() audioIns && audioIns.play()
} }
export const getTbSpi = (function() {
let spiSrc = ''
return function() {
if (spiSrc) return spiSrc
// @ts-ignore
const app = typeof getApp == 'function' && getApp()
if (app) {
return spiSrc = app.rabbitSpiUrl
} else {
throw new Error('no app !!!!!')
}
}
})()
\ No newline at end of file
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