Commit 0bbc3e09 authored by wildfirecode13's avatar wildfirecode13

Merge branch 'master' of gitlab2.dui88.com:wanghongyuan/new_taobao

parents 9bd4e7a1 6a87293d
......@@ -7941,7 +7941,7 @@ export class Lottie extends Container {
* 暂时不考虑重复init
* @param data
*/
init(data: LottieData): void;
init(data: any): void;
private initChildren;
private initState;
/**
......
......@@ -604,6 +604,30 @@ const resCanvasList = {
ext: '.png',
url: 'https://yun.duiba.com.cn/spark/assets/选择猫咪背景.380e7b102d2288cfd03900177d662d8f5f38f400.png',
uuid: 'db53267d-4141-4d3e-afda-9b523c89be3e'
},
'1e663b9f-cca2-4e5e-a7d5-d2eb6bd6b3aa': {
name: 'BlueCatTexture',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/BlueCatTexture.5cafc98c235a09ef5207b52aadbfb7278d0b5a05.png',
uuid: '1e663b9f-cca2-4e5e-a7d5-d2eb6bd6b3aa'
},
'8d158036-37a0-4c5c-b4bf-e792e48700e0': {
name: 'OrengeCatTexture',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/OrengeCatTexture.3c7d51810caa1db0ff2d371c86ff5e5b877fe506.png',
uuid: '8d158036-37a0-4c5c-b4bf-e792e48700e0'
},
'd10c8371-7326-45cf-b3f4-bd81569a4e87': {
name: 'SanhuaCatTexture',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/SanhuaCatTexture.ccc3ead1ca6f7ee0478660219c168b48fc8e7d02.png',
uuid: 'd10c8371-7326-45cf-b3f4-bd81569a4e87'
},
'e90852de-0b38-44f8-ac8c-6eacdcc08001': {
name: 'XianluoCatTexture',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/XianluoCatTexture.7a41e13c71fdec1757c57440faecf6c9d3ae0e9c.png',
uuid: 'e90852de-0b38-44f8-ac8c-6eacdcc08001'
}
};
export default resCanvasList;
import resCanvasList from "./resCanvasList";
const BlueCatTexture = require("./src/lottieSrc/lottieTextureJson/BlueCatTexture.json")
const OrengeCatTexture = require("./src/lottieSrc/lottieTextureJson/OrengeCatTexture.json")
const SanhuaCatTexture = require("./src/lottieSrc/lottieTextureJson/SanhuaCatTexture.json")
const XianluoCatTexture = require("./src/lottieSrc/lottieTextureJson/XianluoCatTexture.json")
const resLottieList = {
"blueCat":{
imgUrl:resCanvasList["1e663b9f-cca2-4e5e-a7d5-d2eb6bd6b3aa"].url,
json:BlueCatTexture
},
"orengeCat":{
imgUrl:resCanvasList["8d158036-37a0-4c5c-b4bf-e792e48700e0"].url,
json:OrengeCatTexture
},
"sanhuaCat":{
imgUrl:resCanvasList["d10c8371-7326-45cf-b3f4-bd81569a4e87"].url,
json:SanhuaCatTexture
},
"xianluoCat":{
imgUrl:resCanvasList["e90852de-0b38-44f8-ac8c-6eacdcc08001"].url,
json:XianluoCatTexture
}
}
export default resLottieList;
\ No newline at end of file
......@@ -13,5 +13,19 @@ export enum MSG{
/**改变场景,参数为uiType */
CHANGE_SCENE="CHANGE_SCENE",
/**选择猫咪 */
SELECT_CAT="SELECT_CAT"
SELECT_CAT="SELECT_CAT",
/**猫咪互动 */
CAT_ACT="CAT_ACT"
}
/**猫咪类型 */
export enum CATTYPE{
/**蓝猫 */
BLUE,
/**橙猫 */
ORENGE,
/**三花 */
SANHUA,
/**暹罗 */
XIANLUO
}
\ No newline at end of file
import resCanvasList from '../resCanvasList';
const buleCatHand = require("./lottieSrc/lottieTextureJson/blueCatHand.json")
export namespace InitLottie {
export function initLottie() {
console.log(buleCatHand);
return new Promise((r,j)=>{
FYGE.GlobalLoader.loadImage((s, image) => {
export function initLottieList(resList:any[]){
console.log("开始加载lottie资源")
let list = [];
for (let key in resList) {
list.push(resList[key]);
}
console.log(list)
let p: Promise<any> = new Promise((resolve, reject) => {
initLottie((s) => {
if (s) {
FYGE.createTextureSheet(new FYGE.BaseTexture(image), buleCatHand);
r();
resolve()
} else {
j();
reject();
}
}, resCanvasList["3a105062-4474-4f37-abd2-fa9471e2536f"].url)
}, list/*, resPath + name*/)
})
return p;
}
export function initLottie(callback: (allLoaded: boolean) => void, arr: any[]) {
let count = 0;
let countAll = arr.length;
console.log(countAll)
if (!countAll) callback(true);
let mark = true;
for (let i = 0; i < countAll; i++) {
let textureJson = arr[i].json;
FYGE.GlobalLoader.loadImage((s, image) => {
if (s) {
FYGE.createTextureSheet(new FYGE.BaseTexture(image),textureJson );
} else {
mark = false
}
if (++count == countAll) callback(mark);
}, arr[i]["imgUrl"])
}
// return new Promise((r,j)=>{
// FYGE.GlobalLoader.loadImage((s, image) => {
// if (s) {
// FYGE.createTextureSheet(new FYGE.BaseTexture(image), buleCatHand);
// r();
// } else {
// j();
// }
// }, resCanvasList["3a105062-4474-4f37-abd2-fa9471e2536f"].url)
// })
}
......
......@@ -8,7 +8,8 @@ import { destroyNetData } from "./TaoBaoNet";
import resCanvasList from '../resCanvasList';
import resloadingList from '../resloadingList'
import resloadingList from '../resloadingList';
import resLottieList from '../resLottieList';
import { setStage } from "./scenes/stage";
import { LoadingScene } from "./scenes/LoadingScene";
import { Ins } from "./Ins";
......@@ -85,7 +86,7 @@ export class Main {
await RES.loadSparkAssets(resloadingList);
changeScene(LoadingScene);
await RES.loadSparkAssets(resCanvasList);
await InitLottie.initLottie();
await InitLottie.initLottieList(resLottieList);
console.log("通用资源加载完成")
FYGE.GDispatcher.dispatchEvent("loadEnd");
//打开开始场景
......
import { Module } from "../../module/views/Module";
import { lanmao01shuijiao } from "../lottieSrc/lottieTs/blueCat/lanmao01shuijiao";
import { lanmao02shuohua } from "../lottieSrc/lottieTs/blueCat/lanmao02shuohua";
import { lanmao03shumao } from "../lottieSrc/lottieTs/blueCat/lanmao03shumao";
import { lanmaolumao } from "../lottieSrc/lottieTs/blueCat/lanmaolumao";
import { lanmao06motou } from "../lottieSrc/lottieTs/blueCat/lanmao06motou";
import { lanmao05wanqiu } from "../lottieSrc/lottieTs/blueCat/lanmao05wanqiu";
import { jumaolumao04 } from "../lottieSrc/lottieTs/orengeCat/jumaolumao04";
import { jumao01 } from "../lottieSrc/lottieTs/orengeCat/jumao01";
import { jumaomotoumao } from "../lottieSrc/lottieTs/orengeCat/jumaomotoumao";
import { jumaoshumao } from "../lottieSrc/lottieTs/orengeCat/jumaoshumao";
import { jumaoshuohua } from "../lottieSrc/lottieTs/orengeCat/jumaoshuohua";
import { jumaowanshua } from "../lottieSrc/lottieTs/orengeCat/jumaowanshua";
import { sanhua01shuijiao } from "../lottieSrc/lottieTs/sanhuaCat/sanhua01shuijiao";
import { sanhua02shuohua2 } from "../lottieSrc/lottieTs/sanhuaCat/sanhua02shuohua 2";
import { sanhua03shumao } from "../lottieSrc/lottieTs/sanhuaCat/sanhua03shumao";
import { sanhua05wanqiu } from "../lottieSrc/lottieTs/sanhuaCat/sanhua05wanqiu";
import { sanhua06motou } from "../lottieSrc/lottieTs/sanhuaCat/sanhua06motou";
import { sanhualumao } from "../lottieSrc/lottieTs/sanhuaCat/sanhualumao";
import { xianluo03shumao } from "../lottieSrc/lottieTs/xianluoCat/xianluo03shumao";
import { xianluo04wanqiu } from "../lottieSrc/lottieTs/xianluoCat/xianluo04wanqiu";
import { xianluo05motou } from "../lottieSrc/lottieTs/xianluoCat/xianluo05motou";
import { xianluolumao } from "../lottieSrc/lottieTs/xianluoCat/xianluolumao";
import { xianluomao01 } from "../lottieSrc/lottieTs/xianluoCat/xianluomao01";
import { xianluoshuohua } from "../lottieSrc/lottieTs/xianluoCat/xianluoshuohua";
import { CATTYPE, MSG } from "../Enum";
import { Ins } from "../Ins";
export class Cat extends Module{
constructor(data?:any){
export class Cat extends Module {
constructor(data?: any) {
super(data);
this.catType = data.type;
}
cat:FYGE.Lottie;
catType: any;
cat_sleep: FYGE.Lottie; //睡觉
cat_talk: FYGE.Lottie; //说话
cat_clear: FYGE.Lottie; //梳毛
cat_rua: FYGE.Lottie; //撸猫
cat_play: FYGE.Lottie; //玩球
cat_touch: FYGE.Lottie; //摸头
catAnimArr: FYGE.Lottie[] = []; //猫咪lottie实例组
catLottieArr: any
initUi(){
initUi() {
this.initCatLottieArr();
console.log(this.catLottieArr);
this.initCat();
this.setCatAnimShow(1,()=>{
this.setCatAnimShow(0);
});
}
/**初始化猫咪Lottie数据组 */
initCatLottieArr() {
this.catLottieArr = {
"blue": {
sleep: lanmao01shuijiao,
talk: lanmao02shuohua,
clear: lanmao03shumao,
rua: lanmaolumao,
play: lanmao05wanqiu,
touch: lanmao06motou
},
"orenge": {
sleep: jumao01,
talk: jumaoshumao,
clear: jumaoshumao,
rua: jumaolumao04,
play: jumaowanshua,
touch: jumaomotoumao
},
"sanhua": {
sleep: sanhua01shuijiao,
talk: sanhua02shuohua2,
clear: sanhua03shumao,
rua: sanhualumao,
play: sanhua05wanqiu,
touch: sanhua06motou
},
"xianluo": {
sleep: xianluomao01,
talk: xianluoshuohua,
clear: xianluo03shumao,
rua: xianluolumao,
play: xianluo04wanqiu,
touch: xianluo05motou
}
}
}
/**初始化猫咪动作 */
initCat() {
var that = this;
that.cat_sleep = new FYGE.Lottie(that.catLottieArr[that.catType].sleep);
that.addChild(that.cat_sleep);
that.catAnimArr.push(that.cat_sleep);
that.cat_talk = new FYGE.Lottie(that.catLottieArr[that.catType].talk);
that.addChild(that.cat_talk);
that.catAnimArr.push(that.cat_talk);
that.cat_clear = new FYGE.Lottie(that.catLottieArr[that.catType].clear);
that.addChild(that.cat_clear);
that.catAnimArr.push(that.cat_clear);
that.cat_rua = new FYGE.Lottie(that.catLottieArr[that.catType].rua);
that.addChild(that.cat_rua);
that.catAnimArr.push(that.cat_rua);
that.cat_play = new FYGE.Lottie(that.catLottieArr[that.catType].play);
that.addChild(that.cat_play);
that.catAnimArr.push(that.cat_play);
that.cat_touch = new FYGE.Lottie(that.catLottieArr[that.catType].touch);
that.addChild(that.cat_touch);
that.catAnimArr.push(that.cat_touch);
}
/**根据index显示猫咪动画
* 0:睡觉,1:说话,2:梳毛,3:撸猫,4:玩球,5:摸头
*/
setCatAnimShow(index: number, callback?: () => void) {
for (let i = 0; i < this.catAnimArr.length; i++) {
if (i == index) {
this.catAnimArr[i].visible = true;
let loop = callback ? 1 : 0;
this.catAnimArr[i].play(loop, callback)
} else {
this.catAnimArr[i].visible = false;
this.catAnimArr[i].stop();
}
}
}
/**猫咪互动 */
catAct(e){
}
initEvents(){
FYGE.GDispatcher.addEventListener(MSG.CAT_ACT,this.catAct,this);
}
removeEvents(){
FYGE.GDispatcher.removeEventListener(MSG.CAT_ACT,this.catAct,this);
}
}
\ No newline at end of file
......@@ -4,9 +4,10 @@ import { RES } from "../../module/RES";
import { Ins } from "../Ins";
import { MainSceneBtnUi } from "../ui/mainSceneBtnUi";
import { MSG, SCENETYPE } from "../Enum";
import {lanmao06motou} from "../lottieSrc/lottieTs/buleCatHand"
import { showToast } from "../../module/ctrls";
import { GDispatcher } from "../Main";
import { Cat } from "../cat/Cat";
export class MainScene extends Scene{
/**场景背景 */
private sceneBg:FYGE.Sprite;
......@@ -21,7 +22,7 @@ export class MainScene extends Scene{
/**毛线球按钮,进入操场 */
private mxqBtn:FYGE.Sprite;
/**猫猫 */
private cat;
private cat:Cat;
/**信封 */
initUi(){
......@@ -55,18 +56,32 @@ export class MainScene extends Scene{
that.mainUi = new MainSceneBtnUi({uiType:SCENETYPE.BEADROOM});
that.addChild(that.mainUi);
that.initCat();
}
that.cat = new FYGE.Lottie(lanmao06motou);
this.addChild(that.cat)
that.cat.play();
that.initEvents();
initCat(){
var that = this;
that.cat = new Cat({type:"xianluo"});
that.addChild(that.cat);
}
/**切换场景 */
changeMainScene(type:SCENETYPE){
console.log("切换到教室场景")
console.log("切换到"+type)
var that = this;
that.sceneBg.texture = RES.getRes(resCanvasList[that.bgUUID[type]].url)
switch(type){
case SCENETYPE.BEADROOM:
that.mxqBtn.visible = that.tlBtn.visible = true;
break;
case SCENETYPE.CLASSROOM:
that.mxqBtn.visible = that.tlBtn.visible = false;
break;
case SCENETYPE.PLAYGROUND:
that.mxqBtn.visible = that.tlBtn.visible = false;
break;
}
that.mainUi.changeBtnByUiType(type);
}
......@@ -77,5 +92,14 @@ export class MainScene extends Scene{
console.log("主场景添加事件")
that.tlBtn.addEventListener(FYGE.MouseEvent.CLICK,()=>{that.changeMainScene(SCENETYPE.CLASSROOM)},that);
that.mxqBtn.addEventListener(FYGE.MouseEvent.CLICK,()=>{that.changeMainScene(SCENETYPE.PLAYGROUND)},that);
FYGE.GDispatcher.addEventListener(MSG.CHANGE_SCENE,()=>{that.changeMainScene(SCENETYPE.BEADROOM)},that);
}
removeEvents(){
var that = this;
console.log("主场景移除事件")
that.tlBtn.removeEventListener(FYGE.MouseEvent.CLICK,()=>{that.changeMainScene(SCENETYPE.CLASSROOM)},that);
that.mxqBtn.removeEventListener(FYGE.MouseEvent.CLICK,()=>{that.changeMainScene(SCENETYPE.PLAYGROUND)},that);
FYGE.GDispatcher.removeEventListener(MSG.CHANGE_SCENE,()=>{that.changeMainScene(SCENETYPE.BEADROOM)},that);
}
}
\ No newline at end of file
......@@ -3,12 +3,10 @@ import { RES } from "../../module/RES";
import Root from "./Root";
// import res from "../../test/output.json"
import resCanvasList from "../../../game/resCanvasList"
// import {lanmao06motou} from "../lottieSrc/lottieTs/buleCatHand"
import { MainScene } from "./MainScene";
import { Ins } from "../Ins";
import { showPanel } from "../../module/ctrls";
import { SelectCatPanel } from "../panels/selectcatpanel/SelectCatPanel";
const buleCatHand = require("../lottieSrc/lottieTextureJson/blueCatHand.json")
export class StartScene extends Scene {
initUi() {
super.initUi();
......
......@@ -179,6 +179,7 @@ export class MainSceneBtnUi extends Module{
/**返回到寝室 */
returnBedRoom(){
console.log("返回到寝室");
FYGE.GDispatcher.dispatchEvent(MSG.CHANGE_SCENE);
}
/**玩耍 */
......
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