Commit c3487b29 authored by zhangjinzhou's avatar zhangjinzhou

代码暂存

parent 9067d195
.DS_Store
node_modules/
coverage/
dist/
npm-debug.log
selenium-debug.log
.idea
.builds
.project
.vscode
yarn-error.log
.yarn
.package-lock
yarn.lock
.cache
packages/**/package-lock.json
......@@ -32,7 +32,7 @@
height: 100%;
overflow: hidden;
position: absolute;
background-color: #fff;
background-color: #f5cccd;
/* background: linear-gradient(#93dbb7,#ff0,#b5d89a); */
/* background: linear-gradient(#93dbb7,#b5d89a); */
}
......@@ -40,6 +40,46 @@
</head>
<body>
<audio style="display:none;
height: 0" id="tqyx" preload="auto"
src="https://yun.duiba.com.cn/aurora/assets/8e3c6af83c20daff6ad34ff198413f0be4903039.mp3">
</audio>
<audio style="display:none;
height: 0" id="ptldyx" preload="auto"
src="https://yun.duiba.com.cn/aurora/assets/b83729366abd4c6aed590bf40bb3ad15e806c8d5.mp3">
</audio>
<audio style="display:none;
height: 0" id="byldyx" preload="auto"
src="https://yun.duiba.com.cn/aurora/assets/069079dea1901151594684de3ef294925556c1c3.mp3">
</audio>
<audio style="display:none;
height: 0" id="bzkyx" preload="auto"
src="https://yun.duiba.com.cn/aurora/assets/6f19e09e8a5300d59b069ed55b82ab8f8b876dc6.mp3">
</audio>
<audio style="display:none;
height: 0" id="wmldyx1" preload="auto"
src="https://yun.duiba.com.cn/aurora/assets/c492aa71c3f385ae179977b328ec3d93c4c085e2.mp3">
</audio>
<audio style="display:none;
height: 0" id="wmldyx2" preload="auto"
src="https://yun.duiba.com.cn/aurora/assets/317e268d07cefddc69309941e38dbcf7d48f8ebc.mp3">
</audio>
<audio style="display:none;
height: 0" id="wmldyx3" preload="auto"
src="https://yun.duiba.com.cn/aurora/assets/5e7795c318bdf5357441085d0c681221274a72a9.mp3">
</audio>
<audio style="display:none;
height: 0" id="wmldyx4" preload="auto"
src="https://yun.duiba.com.cn/aurora/assets/7a62f51f550ea3968fe080ee56abf28be8a92f8c.mp3">
</audio>
<audio style="display:none;
height: 0" id="jlsxlyx" preload="auto"
src="https://yun.duiba.com.cn/aurora/assets/eb4246b47a8fc2c5707d764bee2cd6a710bdc13e.mp3">
</audio>
<audio style="display:none;
height: 0" id="zjqdyx" preload="auto"
src="https://yun.duiba.com.cn/aurora/assets/a6e1c99e49f258a42d65ac00b81c5a2b103aa172.mp3">
</audio>
<script src="output.js"></script>
<!-- <div id="__loading__" style="position:absolute;left:50%;top:50%;margin-left:-45px;color:#ffffff">拼命加载中...</div> -->
<!-- <img src="" id="img" /> -->
......@@ -49,6 +89,27 @@
</body>
<!-- 帧率检测 -->
<!-- <script src="libs/stats.js"></script> -->
<!-- <script src="https://cdn.bootcss.com/vConsole/3.3.0/vconsole.min.js"></script> -->
<script>
// var vConsole = new VConsole();
try {
window["mute"] = localStorage.getItem("mute") == "1" ? true : false;
} catch (e) {
window["mute"] = false;
}
window["mute"] = false;
window["playsound"] = function (id) {
if (window["mute"]) {
return;
}
let audio = document.getElementById(id);
if (audio) {
// console.log("音效播放:=======",audio);
audio.play();
}
}
</script>
<script>
window.addEventListener("load", function () {
//获取canvas
......@@ -56,7 +117,7 @@
canvas.width = document.body.clientWidth * (window.devicePixelRatio || 1)
canvas.height = document.body.clientHeight * (window.devicePixelRatio || 1)
var main = new Main(canvas);
console.log(main.stage)
// console.log(main.stage);
var mouseEvent = main.stage.onMouseEvent.bind(main.stage);
canvas.addEventListener("touchstart", mouseEvent, false);
canvas.addEventListener('touchmove', mouseEvent, false);
......
{
"success": true
}
\ No newline at end of file
{
"success": true
}
\ No newline at end of file
{
"success": true,
"data": {
"tips": "梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛",
"isUpgrade": true,
"channel": "aliqua",
"strategyCode": "dolore",
"code": "et nostrud adipisicing",
"image": "occaecat aliquip",
"name": "officia et deserunt ut",
"type": 65894870.29773912
},
"code": "culpa eu Ut"
}
\ No newline at end of file
{
"success": true,
"message":"",
"data": {
"catType": 2,
"userNick": "Edwise",
"energy": 100,
"happyCoin":1000,
"experience": 50,
"level": "1",
"avatar": "https://yun.duiba.com.cn/spark/assets/a3ae99684afa9a1f8d94f4c95ee6f1ed81de9996.png",
"sence": 3,
"catName": "喵喵喵",
"senceTips":["1说话说话说话说话说话说话说话说话说话说话说话","2说话说话说话说话说话说话说话说话说话说话说话说话","3说话说话说话说话说话说话说话说话说话说话说话说话"]
}
}
\ No newline at end of file
import { promises } from "fs";
interface ResData {
......@@ -123,7 +122,6 @@ export namespace RES {
export function loadSparkAssets(resList: any[]): Promise<any> {
console.log("开始加载spark资源")
let list = [];
for (let key in resList) {
list.push(resList[key]);
......@@ -140,6 +138,7 @@ export namespace RES {
return p;
}
/**
* 根据组名加载一组资源,通常用于加载一个视图的的所有资源
* 里的promise的resolve并没有返回值
......@@ -312,8 +311,7 @@ export namespace RES {
let mark = true;
for (var i = 0; i < countAll; i++) {
let resName = arr[i]['url'];
getResAsync(""+resName, (res, str) => {
// console.log("加载了"+res)
getResAsync(resName, (res, str) => {
//标记失败,如果有一项资源加载失败,标记下
if (!res) mark = false
if (++count == countAll) callback(mark);
......
......@@ -4,7 +4,6 @@ import { Panel } from "../views/Panel";
import { layers } from "../views/layers";
import { showWaiting, hideWaiting } from "./waitingCtrl";
import { showToast } from "./toastCtrl";
import { Ins } from "../../src/Ins";
export default class PanelCtrl {
/**
......
......@@ -2,8 +2,6 @@
import { layers } from "../views/layers";
import { RES } from "../RES";
import resCanvasList from "../../resCanvasList.js"
import { Ins } from "../../src/Ins";
let inited = false;
let _toast: Toast;
......@@ -16,14 +14,14 @@ const initToast = () => {
_toast = new Toast();
_parent = layers.toastLayer;
_toast.alpha = 0;
_toast.x = (layers.stageWidth - _toast.width) / 2;
_toast.x = layers.stageOffsetX - _parent.x + (layers.stageWidth - _toast.width) / 2;
var h = _toast.height;
var y = layers.stageOffsetY - _parent.y;
startY = y - h;
endY = y + (layers.stageHeight - h) / 2;
}
}
export const showToast = (msg="网络异常,请稍后重试~") => {
export const showToast = (msg: string) => {
initToast();
_toast.show(msg)
_parent.addChild(_toast);
......@@ -58,18 +56,14 @@ class Toast extends FYGE.Container {
msg: FYGE.TextField;
bg: FYGE.Sprite;
PADDING = 40;
bgw:number;
constructor() {
super();
this.mouseChildren = false;
this.mouseEnable = false;
// var toastBgTexture: FYGE.Texture = RES.getRes("toastBg.png");
var toastBgTexture: FYGE.Texture = RES.getRes(resCanvasList["0cc64b0c-3ccc-4d88-b697-bb402319cef7"].url);
var toastBgTexture: FYGE.Texture = RES.getRes("toastBg.png");
if (toastBgTexture) {
this.bg = new FYGE.Sprite(toastBgTexture);
// this.bg.x = (750 - 460) / 2// (layers.stageWidth - this.bg.width) / 2
// this.bgw = this.bg.width
this.bg.x = (layers.stageWidth - this.bg.width) / 2
this.addChild(this.bg);
}
......@@ -89,12 +83,11 @@ class Toast extends FYGE.Container {
show(msg: string) {
this.msg.text = msg;
//文本居中适配
this.msg.x = (layers.stageWidth - this.msg.textWidth) / 2;//( (this.bg?this.bg.width:0) - this.msg.textWidth) / 2
// // 是否需要根据文本宽度缩放背景
this.bg.width = Math.min(this.msg.textWidth + this.PADDING * 2, 523);
// 背景居中适配,由于上面一行注释,那这行就构造函数里只执行一次吧
this.bg.x = (Ins.stageW - this.bg.width) / 2
// console.log(Ins.stageW,this.bg.width)
this.msg.x = ( (this.bg?this.bg.width:0) - this.msg.textWidth) / 2//(layers.stageWidth - this.msg.textWidth) / 2;
//是否需要根据文本宽度缩放背景
// this.bg.width = Math.min(this.msg.textWidth + this.PADDING * 2, 523);
//背景居中适配,由于上面一行注释,那这行就构造函数里只执行一次吧
// this.bg.x = (layers.stageWidth - this.bg.width) / 2
}
destroy() {
......
......@@ -91,7 +91,7 @@ class Waiting extends FYGE.Container {
}
show(msg: string = "加载中") {
// this.msg.text = msg;
this.msg.text = msg;
}
destroy() {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -17,7 +17,7 @@
"progress": "^2.0.0",
"ts-loader": "^4.0.0",
"tslint": "^5.9.1",
"typescript": "^4.0.2",
"typescript": "^2.7.2",
"webpack": "^4.1.0",
"webpack-cli": "^3.1.1",
"webpack-dev-server": "^3.1.0",
......@@ -25,9 +25,7 @@
"uglifyjs-webpack-plugin": "^2.1.2",
"psd": "^3.2.0"
},
"dependencies": {
"tans_lottie": "^1.0.4"
},
"dependencies": {},
"scripts": {
"psd": "node scripts/psdH.js && node scripts/flushRes",
"createModule": "node scripts/createModule",
......
const propsdata = {
}
export default propsdata;
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
{
"groups": [
{
"keys": "comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common",
"atlas": "common.json"
},
{
"keys": "map_bg1.jpg",
"name": "startScene"
}
],
"path": "./resource/"
}
\ No newline at end of file
const resCanvasList = {};
const resCanvasList = {
};
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 LetterTexture = require("./src/lottieSrc/lottieTextureJson/LetterTexture.json")
const resLottieList = {
"blueCat":{
imgUrl:resCanvasList["a7dc39fa-5f6d-4e94-8979-81c4a4aa183f"].url,
json:BlueCatTexture
},
"orengeCat":{
imgUrl:resCanvasList["72987d74-2fa7-49b9-865d-a0d80c6ed220"].url,
json:OrengeCatTexture
},
"sanhuaCat":{
imgUrl:resCanvasList["75320997-b466-4161-abab-b03a51ec522b"].url,
json:SanhuaCatTexture
},
"xianluoCat":{
imgUrl:resCanvasList["de2d1dca-ed1c-4fe0-93ef-684f4b96c87e"].url,
json:XianluoCatTexture
},
"letter":{
imgUrl:resCanvasList["3b12798d-d932-4f5b-a442-6e4877ba5c16"].url,
json:LetterTexture
}
}
export default resLottieList;
\ No newline at end of file
const resloadingList = {
'42084cc4-390d-4eee-8392-fbbe2e59455e': {
name: 'loading底',
ext: '.png',
uuid: '42084cc4-390d-4eee-8392-fbbe2e59455e',
url: 'https://yun.duiba.com.cn/spark/assets/a1e89704a94ef7b5f3d6e612bc21d234525c7e86.png'
},
'1857a043-27d7-4925-9535-acb70ae3e90e': {
name: 'loading对话框',
ext: '.png',
uuid: '1857a043-27d7-4925-9535-acb70ae3e90e',
url: 'https://yun.duiba.com.cn/spark/assets/d3c5ce01e28ed1de56b019e55119bf7a93217e7b.png'
},
'bd699d4f-af43-463f-b2ba-43e2803228a1': {
name: 'loding条底',
ext: '.png',
uuid: 'bd699d4f-af43-463f-b2ba-43e2803228a1',
url: 'https://yun.duiba.com.cn/spark/assets/8e0533f29853ccb5179cbc8f3b9bde4b89ea186a.png'
},
'efc21755-0441-41d5-b56f-d177026342d4': {
name: '进度条4',
ext: '.png',
uuid: 'efc21755-0441-41d5-b56f-d177026342d4',
url: 'https://yun.duiba.com.cn/spark/assets/cb28f449fab3a7a88b4058d6d19119a9b3b7f7ed.png'
},
'd01a19e5-fa4f-40b9-a6dc-9d21e0cc756e': {
name: '爪子',
ext: '.png',
uuid: 'd01a19e5-fa4f-40b9-a6dc-9d21e0cc756e',
url: 'https://yun.duiba.com.cn/spark/assets/57784d76f734ce9accf6006dcd40972292e3d22f.png'
},
'4e3c6e09-0593-4818-976a-d73fe588580b': {
name: '摸头猫2',
ext: '.png',
uuid: '4e3c6e09-0593-4818-976a-d73fe588580b',
url: 'https://yun.duiba.com.cn/spark/assets/25b18893820ee0b6998c527c41a8b58ee516ac31.png'
}
}
export default resloadingList;
\ No newline at end of file
......@@ -6,9 +6,7 @@ var fs = require("fs");
// fs.readFileSync("./output.js")
// )
// var endPath = 'D:/duibaGame/测试项目0527/taobaominiTest/client/pages/index1/';
var endPath = '/Users/wanghongyuan/new_taobao/taobao_mini/client/pages/pagecanvas/';
var endPath = 'D:/taobao/example/new_taobao/project/src/pages/pagecanvas/';
var version = Math.round(new Date().getTime() / 1000);
// fs.writeFileSync(endPath + "output." + version + ".js", fs.readFileSync("./released/output.js"));
fs.writeFileSync(endPath + "output.js", fs.readFileSync("./released/output.js"));
......
/**当前场景对应的类型 */
export enum SCENETYPE{
/**教室 */
CLASSROOM=1,
/**操场 */
PLAYGROUND,
/**寝室 */
BEADROOM
}
/**自定义事件 */
export enum MSG{
/**改变场景,参数为uiType */
CHANGE_SCENE="CHANGE_SCENE",
/**选择猫咪 */
SELECT_CAT="SELECT_CAT",
/**猫咪互动 */
CAT_ACT="CAT_ACT",
/**刷新用户领养信息 */
UPDATE_USERINFO = "UPDATE_USERINFO"
}
/**猫咪类型 */
export enum CATTYPE{
/**蓝猫 */
BLUE,
/**橙猫 */
ORENGE,
/**三花 */
SANHUA,
/**暹罗 */
XIANLUO
}
/**猫咪互动动作 */
export enum CAT_ACTTYPEP{
/**睡觉 */
SLEEP,
/**说话 */
TALK,
/**梳毛 */
CLEAR,
/**撸猫 */
RUA,
/**玩耍 */
PLAY,
/**摸头杀 */
TOUCH
}
\ No newline at end of file
import resCanvasList from '../resCanvasList';
export namespace InitLottie {
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) {
resolve()
} else {
reject();
}
}, 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)
// })
}
}
\ No newline at end of file
import { RES } from "../module/RES";
import resCanvasList from "../resCanvasList"
import { SCENETYPE } from "./Enum";
/**记录全局信息与全局方法 */
export class Ins {
/**舞台宽高 */
public static stageW: number;
public static stageH: number;
/**猫咪是否出寝了 */
public static catIsOut:boolean;
/**当前用户所在场景 */
public static curScene:SCENETYPE;
public static userInfo: {
"catName": string, //猫咪姓名
"catType": string, //猫咪类型
"userNick": string, //用户昵称
"energy": number, //精力值
"happyCoin": number, //欢乐币
"experience": number, //经验值
"level": string, //等级
"avatar": string, //头像
"sence": number, //场景
"senceTips":string[] //场景互动文案(猫咪说话)
}
public static showToast(msg?:any){
FYGE.GDispatcher.dispatchEvent("toast",msg);
}
public static showLoading(){
FYGE.GDispatcher.dispatchEvent("loading");
}
public static hideLoading(){
FYGE.GDispatcher.dispatchEvent("hideloading");
}
/**删除一个lottie的所有tween,停止动效 */
public static stopLottieAnim(lottie: FYGE.Lottie) {
FYGE.Tween.removeTweens(lottie);
lottie.children.forEach((s) => {
FYGE.Tween.removeTweens(s);
})
}
/**根据uuid获取资源 */
public static getRes(uuid: string) {
return RES.getRes(resCanvasList[uuid].url)
}
/**生成一个Sprite */
public static initSprite(uuid?: string, x = 0, y = 0) {
let btn = new FYGE.Sprite();
if (uuid) {
btn.texture = this.getRes(uuid);
}
btn.x = x;
btn.y = y;
return btn;
}
/**生成一个文本
* data:{color?:string,size?:number,x?:number,y?:number,text?:string}
*/
public static initLabel(data: any) {
let label = new FYGE.TextField();
label.fillColor = data.color ? data.color : "black";
label.size = data.size ? data.size : 24;
label.x = data.x ? data.x : 0,
label.y = data.y ? data.y : 0,
label.text = data.text ? data.text : "";
return label;
}
}
\ No newline at end of file
......@@ -2,18 +2,12 @@ import { RES } from "../module/RES";
import { layers, destroyLayers } from "../module/views/layers";
import { ResJson } from "./ResJson";
import { G_EVENT } from "./common/G_EVENT";
import { destroyAllCtrls, changeScene, hideWaiting } from "../module/ctrls";
import { destroyAllCtrls, changeScene } from "../module/ctrls";
import { StartScene } from "./scenes/StartScene";
import { destroyNetData, sendTbNet, TbNetName } from "./TaoBaoNet";
import { destroyNetData } from "./TaoBaoNet";
import resCanvasList from '../resCanvasList';
import resloadingList from '../resloadingList';
import resLottieList from '../resLottieList';
import { setStage } from "./scenes/stage";
import { LoadingScene } from "./scenes/LoadingScene";
import { Ins } from "./Ins";
import { InitLottie } from "./initLottie";
/**
......@@ -28,7 +22,6 @@ export class Main {
private requestID;
private _pause: boolean;
constructor(canvas: HTMLCanvasElement) {
console.warn=function(){}
var sysInfo;
//@ts-ignore 存在my就初始化
if (my) {
......@@ -44,10 +37,9 @@ export class Main {
1624,//设计高度
sysInfo && sysInfo.windowWidth || document.body.clientWidth,
sysInfo && sysInfo.windowHeight || document.body.clientHeight,
FYGE.RENDERER_TYPE.CANVAS
FYGE.RENDERER_TYPE.WEBGL
);
this.stage = stage;
setStage(stage);
//开始循环
// FYGE.Stage.flushAll();
//stage初始化
......@@ -81,21 +73,14 @@ export class Main {
// RES.loadSkinConfig(SkinJson);
//加载通用资源
// await RES.loadGroup("common");
Ins.stageW = this.stage.viewRect.width;
Ins.stageH = this.stage.viewRect.height;
console.log("舞台宽高:",Ins.stageW,Ins.stageH)
await RES.loadSparkAssets(resloadingList);
console.log('resloadingList 加载完毕')
changeScene(LoadingScene);
await RES.loadSparkAssets(resCanvasList).catch(()=>{
console.log('loadSparkAssets resCanvasList 失败')
});
console.log('resCanvasList 加载完毕')
await InitLottie.initLottieList(resLottieList);
console.log("initLottieList完成")
FYGE.GDispatcher.dispatchEvent("loadEnd");
await RES.loadSparkAssets(resCanvasList);
console.log("通用资源加载完成");
// await loadAllSvga();
// console.log("svg全加载完毕,打开场景");
//打开开始场景
// changeScene(StartScene);
changeScene(StartScene);
GDispatcher.dispatchEvent("game-load-complete");
// changeScene(LoadingScene);
// changeScene(SStartScene);
// changeScene(StoryScene);
......@@ -109,24 +94,14 @@ export class Main {
//获取数据,,必成功
// showWaiting();
// sendTbNet(TbNetName.getAppData, {}, (s, res) => {
// console.log('getAppData success,res',s,res)
// })
// sendTbNet(TbNetName.getActivityBaseInfoById, {}, (s, res) => {
// console.log('getActivityBaseInfoById success,res',s,res)
// hideWaiting();
// Tool.globalData = res.data;
// changeScene(PlayScene);
// //先去获取下任务列表的商品信息吧
// sendTbNet(TbNetName.getTaskList, { activityId: Tool.globalData.activityId }, (s, res) => {
// if (s) Tool.browseItems = res.data.browseItemIds.content;
// })
// console.log('准备打开弹窗')
// setTimeout(() => {
// sendTbNet(TbNetName.showModal, {name:'messageModal',data:{catName:'喵喵'}}, (s, res) => {
// console.log('showModal messageModal, success,res',s,res)
// })
// }, 3000);
// console.log('准备切换到兑换页面')
// setTimeout(() => {
// sendTbNet(TbNetName.navigateToPage, {name:'pageshop'}, (s, res) => {
// console.log('navigateToPage pageshop, success,res',s,res)
// })
// }, 5000);
}
//在小程序显示时调用onShow
......
export const ResJson = {
"groups": [
{
"keys": "comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common",
"atlas": "common.json"
},
{
"keys": "map_bg1.jpg",
"name": "startScene"
}
],
"path": "https://yun.duiba.com.cn/db_games/activity/babycare_xiaoxiao/1600763276/resource/"
"path": "./resource/"
}
\ No newline at end of file
import { showToast, wait, clearWait } from "../module/ctrls";
import { Ins } from "./Ins";
import { GDispatcher } from "./Main";
//接口枚举,包括需要调用淘宝的api,用是否含有兑吧区分,或者单独区分
export enum TbNetName {
navigateToPage = "mine.navigateToPage",
showModal = "mine.showModal",
/**
* 获取用户领养信息
*/
getUserInfo = "tmallCat.getUserInfo",
/**
* 猫咪互动
*/
interaction = "tamllCat.interaction",
/**
* 埋点统计 到时改名字
* activityId params elemType
*/
trackingReport = "squirrelsAdoptRest2c.trackingReport",
/**
* 进入活动调用, 刷新数据不调用该接口
* activityId userNick avatar follow inviteId
*/
getIndex = "babycare.getIndex",
getActivityBaseInfoById= "bubbleSurviva.getActivityBaseInfoById",
/**
* 活动基本信息
* @param activityId
* @type {string}
*/
getActivityBaseInfoById = "babycare.getActivityBaseInfoById",
/**
* 获取游戏信息
......@@ -169,7 +166,7 @@ export function sendTbNet(
netName: TbNetName,
parameter?: any,
callback?: (success: boolean, res?: dataOut) => void,
hideMsg: boolean = true
hideMsg: boolean = false
): Promise<dataOut> {
return new Promise((resolve, reject) => {
//网络超时
......@@ -216,7 +213,7 @@ export function sendTbNet(
//记录数据
dataRecord[netName] = d;
//统一错误信息提示,d.data为了区分网络超时
if (!hideMsg && !d.success) Ins.showToast(d.message || "网络超时")
if (!hideMsg && !d.success) showToast(d.message || "网络超时")
//执行回调
callback && callback(d.success, d);
resolve(d)
......
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, CAT_ACTTYPEP } from "../Enum";
import { Ins } from "../Ins";
import { sendTbNet, TbNetName } from "../TaoBaoNet";
import { showToast } from "../../module/ctrls";
export class Cat extends Module {
constructor(data?: any) {
super(data);
this.catType = data.type;
}
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 //猫咪lottie数据组
actRunning: boolean = false; //动效是否进行中,如果动效进行中,无法进行其他动效
dialog:FYGE.Sprite; //猫咪对话框气泡
dialogText:FYGE.TextField; //猫咪对话框气泡文字内容
dialogPos:any[]=[{x:1,y:1}]; //猫咪对话框气泡位置
initUi() {
this.initCatLottieArr();
console.log(this.catLottieArr);
this.initCat();
this.initDialog();
var tipsArr = Ins.userInfo.senceTips;
var index = Math.floor(Math.random()*tipsArr.length)
this.showDialog(1,tipsArr[index]);
this.setCatAnimShow(1,()=>{this.stopCatAct()});
this.initEvents();
}
/**初始化猫咪Lottie数据组 */
initCatLottieArr() {
this.catLottieArr = {
"blue": {
sleep: lanmao01shuijiao,
talk: lanmao02shuohua,
clear: lanmao03shumao,
rua: lanmaolumao,
play: lanmao05wanqiu,
touch: lanmao06motou
},
"orenge": {
sleep: jumao01,
talk: jumaoshuohua,
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);
}
/**初始化对话框 */
initDialog(){
var that = this;
that.dialogPos = [{},{x:280,y:516},{x:320,y:400},{x:280,y:556},{x:280,y:536},{x:370,y:536}]
that.dialog = Ins.initSprite("624e8c63-963f-4b20-9802-b0fb006fbf93");
that.dialog.position.set(280,526)
that.addChild(that.dialog);
that.dialogText = Ins.initLabel({size:24,x:30,y:20});
that.dialogText.textWidth = 280;
that.dialog.addChild(that.dialogText);
that.dialogText.textHeight = 138;
that.dialogText.verticalAlign = FYGE.VERTICAL_ALIGN.MIDDLE
// that.dialogText.text = "哈哈哈哈哈哈哈,哈哈哈\n哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈";
console.log("最大长度为"+that.dialogText.text.length)
console.log("当前文本高度为"+that.dialogText.textHeight);
// that.dialog.visible = false;
that.dialog.alpha = 0;
}
/**显示对话框 */
showDialog(type,msg:string){
var that = this;
msg = msg.length>=11?msg.substring(0,11)+'\n'+msg.substring(11):msg
that.dialog.position.set(that.dialogPos[type].x,that.dialogPos[type].y)
that.dialogText.text = msg;
FYGE.Tween.removeTweens(that.dialog);
that.dialog.alpha = 0;
FYGE.Tween.get(that.dialog).to({alpha:1},400);
// this.dialog.visible = true;
}
/**隐藏对话框 */
hideDialog(){
this.dialog.alpha = 0;
FYGE.Tween.removeTweens(this.dialog);
}
/**根据index显示猫咪动画
* 0:睡觉,1:说话,2:梳毛,3:撸猫,4:玩球,5:摸头
*/
setCatAnimShow(index: number, callback?: () => void) {
if (index == 0 || index == 1) {
this.actRunning = false;
}
for (let i = 0; i < this.catAnimArr.length; i++) {
if (i == index) {
this.catAnimArr[i].visible = true;
let loop = callback ? 1 : 0;
console.log("hahaha", loop);
Ins.stopLottieAnim(this.catAnimArr[i]);
this.catAnimArr[i].play(loop, callback);
console.log("播放", index);
} else {
this.catAnimArr[i].visible = false;
Ins.stopLottieAnim(this.catAnimArr[i]);
}
}
}
/**猫咪停止互动 */
stopCatAct(){
var that = this;
that.hideDialog();
that.setCatAnimShow(0,null);
}
/**猫咪互动 */
catAct(e) {
if (this.actRunning) return;
var that = this;
let actType = e.data;
var type;
switch(actType){
case 2: type=2;
break;
case 3: type=1;
break;
case 4: type=4;
break;
case 5: type=3;
break;
}
console.log(actType);
sendTbNet(TbNetName.interaction, {type:type,scene:Ins.curScene}, (s, r) => {
if (s) {
FYGE.GDispatcher.dispatchEvent(MSG.UPDATE_USERINFO);
that.actRunning = true;
switch (actType) {
case CAT_ACTTYPEP.SLEEP:
break;
default:
that.showDialog(actType,r.data.tips);
that.setCatAnimShow(actType, () => {
that.stopCatAct();
});
break;
}
}else
{
Ins.showToast(r.message)
}
})
}
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
......@@ -2,4 +2,10 @@ export enum G_EVENT {
ON_SHOW = 'onShow', // 页面显示
ON_HIDE = 'onHide', // 页面隐藏
UPDATE_TASK = 'UpdateTask', // 更新任务
//游戏事件
JUMP_HIGH_RESET = "jump-high-reset",
JUMP_HIGH_START="jump-high-start",
JUMP_HIGH_REVIVE="jump-high-revive",
JUMP_HIGH_PAUSE="jump-high-pause",
JUMP_HIGI_RESUME="jump-high-resume"
}
{
"1085e1ca-a5a5-4e1c-9917-fb27efa359f7.png": {
"x": 2,
"y": 2,
"w": 299,
"h": 175,
"ox": 0,
"oy": 0,
"sw": 299,
"sh": 175,
"ro": false
},
"eafa36c0-16e3-4112-b56e-a492a4899a5f.png": {
"x": 2,
"y": 179,
"w": 298,
"h": 243,
"ox": 0,
"oy": 0,
"sw": 298,
"sh": 243,
"ro": true
},
"6612ca2f-948b-49a3-982f-250e4cd9c635.png": {
"x": 247,
"y": 179,
"w": 249,
"h": 215,
"ox": 0,
"oy": 0,
"sw": 249,
"sh": 215,
"ro": false
},
"798dbdf0-d769-4d22-baaf-b811eb29db30.png": {
"x": 2,
"y": 479,
"w": 187,
"h": 24,
"ox": 0,
"oy": 0,
"sw": 187,
"sh": 24,
"ro": false
}
}
\ No newline at end of file
export const letter = {
"v": "5.6.10",
"fr": 30,
"ip": 0,
"op": 17,
"w": 750,
"h": 1624,
"nm": "底",
"layers": [
{
"ind": 1,
"ty": 2,
"nm": "点击信封打开看看",
"refId": "798dbdf0-d769-4d22-baaf-b811eb29db30",
"ks": {
"o": {
"a": 1,
"k": [
{
"t": 0,
"s": [
100
]
},
{
"t": 7,
"s": [
100
]
},
{
"t": 8,
"s": [
0
]
},
{
"t": 15,
"s": [
0
]
},
{
"t": 16,
"s": [
100
]
}
]
},
"r": {
"a": 0,
"k": 0
},
"p": {
"a": 0,
"k": [
383.5,
1003,
0
]
},
"a": {
"a": 0,
"k": [
93.5,
12,
0
]
},
"s": {
"a": 0,
"k": [
100,
100,
100
]
}
},
"ip": 0,
"op": 600
},
{
"ind": 3,
"ty": 2,
"nm": "上",
"refId": "1085e1ca-a5a5-4e1c-9917-fb27efa359f7",
"ks": {
"o": {
"a": 0,
"k": 100
},
"r": {
"a": 0,
"k": 0
},
"p": {
"a": 0,
"k": [
388.5,
887.5,
0
]
},
"a": {
"a": 0,
"k": [
149.5,
87.5,
0
]
},
"s": {
"a": 0,
"k": [
100,
100,
100
]
}
},
"ip": 0,
"op": 600
},
{
"ind": 4,
"ty": 2,
"nm": "字条",
"refId": "6612ca2f-948b-49a3-982f-250e4cd9c635",
"ks": {
"o": {
"a": 0,
"k": 100
},
"r": {
"a": 0,
"k": 0
},
"p": {
"a": 1,
"k": [
{
"t": 0,
"s": [
388.5,
866.5,
0
]
},
{
"t": 8,
"s": [
388.5,
859.5,
0
]
},
{
"t": 16,
"s": [
388.5,
866.5,
0
]
}
]
},
"a": {
"a": 0,
"k": [
124.5,
107.5,
0
]
},
"s": {
"a": 0,
"k": [
100,
100,
100
]
}
},
"ip": 0,
"op": 600
},
{
"ind": 5,
"ty": 2,
"nm": "下",
"refId": "eafa36c0-16e3-4112-b56e-a492a4899a5f",
"ks": {
"o": {
"a": 0,
"k": 100
},
"r": {
"a": 0,
"k": 0
},
"p": {
"a": 0,
"k": [
390,
835.5,
0
]
},
"a": {
"a": 0,
"k": [
149,
121.5,
0
]
},
"s": {
"a": 0,
"k": [
100,
100,
100
]
}
},
"ip": 0,
"op": 600
}
],
"markers": []
}
\ No newline at end of file
This diff is collapsed.
import { Panel } from "../../module/views/Panel";
import { Ins } from "../Ins";
export class RulePanel extends Panel{
constructor(data?:any){
super(data)
}
initUi(){
var bg = Ins.initSprite("41365963-7e27-42a2-963d-157d40b0fb6d");
this.addChild(bg);
this.x = (Ins.stageW - bg.width)>>1;
this.y = (Ins.stageH - bg.height)>>1;
var ruleLabel = Ins.initLabel({size:24,text:"规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则规则"})
var ruleView = new FYGE.ScrollPage(574,279,ruleLabel.textHeight)
ruleLabel.textWidth = 570;
// ruleLabel.
ruleView.isSpringBack = false;
ruleView.x = 76;
ruleView.y = 167;
this.addChild(ruleView);
ruleView.view.addChild(ruleLabel);
// ruleLabel.text.replace("规则","aa")
}
}
\ No newline at end of file
import { Panel } from "../../module/views/Panel";
export class SetCatNamePanel extends Panel{
constructor(data?:any){
super(data);
}
/**名字输入框 */
nameInput:FYGE.TextField;
initUi(){
// FYGE.inputFeildIosEnable
this.nameInput = new FYGE.TextField();
// this.nameInput.lineType
}
}
\ No newline at end of file
import { Module } from "../../../module/views/Module";
import { MSG } from "../../Enum";
import { Ins } from "../../Ins";
export class SelectCatGroup extends Module {
constructor(data?: any) {
super(data);
this.type = data.type;
this.imgUUid = data.uuid;
this.nameText = data.name;
// this.addEventListener(FYGE.Event.REMOVED_FROM_STAGE, this.destroy, this)
}
/**猫咪图片uuid */
private imgUUid: string;
/**被选中图片 */
private isSelectImg: FYGE.Sprite;
/**类型 */
private type: number;
/**猫咪名称 */
private nameText: string;
initUi() {
var that = this;
that.mouseEnable = true;
that.mouseChildren = true;
var bg = Ins.initSprite("8850353b-0a98-4335-9d46-a36678f44be0");
that.addChild(bg);
var catImg = Ins.initSprite(that.imgUUid, 67, 36);
that.addChild(catImg);
var nameLabel = Ins.initLabel({ size: 24, x: 32, y: 207, text: that.nameText ? that.nameText : "田园橘猫" });
nameLabel.textWidth = 232;
nameLabel.textAlign = FYGE.TEXT_ALIGN.CENTER;
that.addChild(nameLabel);
that.isSelectImg = Ins.initSprite("f956cda2-5eef-4942-8737-742d171527bd", 224, 172);
that.addChild(that.isSelectImg);
if (that.type == 0) {
that.isSelectImg.visible = true;
} else {
that.isSelectImg.visible = false;
}
that.initEvents();
}
initEvents() {
this.addEventListener(FYGE.MouseEvent.CLICK, this.selected, this);
FYGE.GDispatcher.addEventListener(MSG.SELECT_CAT, this.changeState, this);
}
removeEvents() {
this.removeEventListener(FYGE.MouseEvent.CLICK, this.selected, this);
FYGE.GDispatcher.removeEventListener(MSG.SELECT_CAT, this.changeState, this);
}
/**更新状态 */
changeState(e){
if(e.data == this.type){
this.isSelectImg.visible = true;
}else{
this.isSelectImg.visible = false;
}
}
/**选择 */
selected() {
var that = this;
that.isSelectImg.visible = !that.isSelectImg.visible;
FYGE.GDispatcher.dispatchEvent(MSG.SELECT_CAT, that.type);
}
}
\ No newline at end of file
import { changeScene, closeCurrentPanel } from "../../../module/ctrls";
import { Panel } from "../../../module/views/Panel";
import { MSG } from "../../Enum";
import { Ins } from "../../Ins";
import { MainScene } from "../../scenes/MainScene";
import { SelectCatGroup } from "./SelectCatGroup";
export class SelectCatPanel extends Panel {
/**当前选择的类型 */
curSelectType: number = 0;
/**确认选择按钮 */
selectSureBtn: FYGE.Sprite;
initUi() {
var that = this;
var bg = Ins.initSprite("db53267d-4141-4d3e-afda-9b523c89be3e");
that.addChild(bg);
that.x = (Ins.stageW - bg.width) >> 1;
that.y = (Ins.stageH - bg.height) >> 1;
that.selectSureBtn = Ins.initSprite("628fc38b-7dc0-4c69-aac1-279d60c8f1ed", 185, 804);
that.addChild(that.selectSureBtn);
that.initSelectCatGroup();
}
initSelectCatGroup() {
var catData = [
{ img: "e28e5250-c740-4e4f-a855-c415c557e77e", name: "11111" },
{ img: "193f6955-d754-4b9f-80ca-b9b9a72e8a8b", name: "22222" },
{ img: "fe52ffae-fadd-40f3-97b5-d3d56fd04781", name: "33333" },
{ img: "95a6b0a9-3e7a-4a0b-82b6-6742e2a8bddf", name: "44444" }];
for (let i = 0; i < 4; i++) {
var selectCatGroup = new SelectCatGroup({ type: i, uuid: catData[i].img, name: catData[i].name });
selectCatGroup.x = 43 + i % 2 * 334;
selectCatGroup.y = 197 + Math.floor(i / 2) * 304;
this.addChild(selectCatGroup);
}
}
/**获取选择信息 */
catSelect(e) {
this.curSelectType = e.data;
console.log("选择了", e.data)
}
/**确认选择 */
selectSure() {
//弹出取名弹窗
closeCurrentPanel();
changeScene(MainScene);
}
initEvents() {
FYGE.GDispatcher.addEventListener(MSG.SELECT_CAT, this.catSelect, this);
this.selectSureBtn.addEventListener(FYGE.MouseEvent.CLICK, this.selectSure, this);
}
removeEvents() {
FYGE.GDispatcher.removeEventListener(MSG.SELECT_CAT, this.catSelect, this);
this.selectSureBtn.removeEventListener(FYGE.MouseEvent.CLICK, this.selectSure, this);
}
}
\ No newline at end of file
import { RES } from "../../module/RES";
import resCanvasList from "../../resCanvasList";
export default class DropItem extends FYGE.Sprite {
constructor() {
super();
this.texture = RES.getRes(
resCanvasList["593e9d74-4944-496a-b6c1-8316756f8bf7"].url
);
this.y = 0;
}
updatePosition() {
this.y += 10;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
let _stage;
export const getStage = ():FYGE.Stage => _stage;
export const setStage = (stage) => {
_stage = stage;
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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