Commit c1f8dba3 authored by Edwise's avatar Edwise 🍷

123

parent 238b9b29
{
"success": false,
"success": true,
"message":"请稍后重试",
"data": "aaaa",
"code": "000"
......
......@@ -4,12 +4,12 @@
"data": {
"catType": 1,
"userNick": "Edwise",
"energy": "100",
"happyCoin": "1000",
"experience": "50",
"energy": 1000,
"happyCoin":1000,
"experience": 50,
"level": "1",
"avatar": "https://yun.duiba.com.cn/spark/assets/b1992c528b36c2d26942e9c83941242e59481475.png",
"sence": 1,
"avatar": "https://yun.duiba.com.cn/spark/assets/a3ae99684afa9a1f8d94f4c95ee6f1ed81de9996.png",
"sence": 3,
"catName": "喵喵喵"
}
}
\ No newline at end of file
......@@ -632,14 +632,26 @@ const resCanvasList = {
'0cc64b0c-3ccc-4d88-b697-bb402319cef7': {
name: 'ToastBg',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/ToastBg.81e208c0050ce46ac576ba881d02db07a02bffe2.png',
url: 'https://yun.duiba.com.cn/spark/assets/ToastBg.81e208c0050ce46ac576ba881d02db07a02bffe2.png',
uuid: '0cc64b0c-3ccc-4d88-b697-bb402319cef7'
},
'69009eb9-4593-4a43-a9d7-a6356ebd6d04': {
name: '精力条对话框',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/精力条对话框.da8e059d18cf967026989e3c376b7364210c3d4e.png',
url: 'https://yun.duiba.com.cn/spark/assets/精力条对话框.da8e059d18cf967026989e3c376b7364210c3d4e.png',
uuid: '69009eb9-4593-4a43-a9d7-a6356ebd6d04'
},
'72345190-f95b-4152-bccf-393b8a5aa8d0': {
name: '召回猫咪icon',
ext: '.png',
url: 'https://yun.duiba.com.cn/spark/assets/召回猫咪icon.41d0b6bb23a7eccf0facb8918cfb679239b7f82f.png',
uuid: '72345190-f95b-4152-bccf-393b8a5aa8d0'
},
'3b12798d-d932-4f5b-a442-6e4877ba5c16': {
name: 'LetterTexture',
ext: '.png',
url: 'https://yun.duiba.com.cn/spark/assets/LetterTexture.78192e79fa3b21a85b245038f23561eeb5141d4d.png',
uuid: '3b12798d-d932-4f5b-a442-6e4877ba5c16'
}
};
export default resCanvasList;
......@@ -3,6 +3,7 @@ const BlueCatTexture = require("./src/lottieSrc/lottieTextureJson/BlueCatTexture
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,
......@@ -19,6 +20,10 @@ const resLottieList = {
"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
......@@ -7,13 +7,16 @@ export class Ins {
public static stageW: number;
public static stageH: number;
/**猫咪是否出寝了 */
public static catIsOut:boolean;
public static userInfo: {
"catName": string, //猫咪姓名
"catType": string, //猫咪类型
"userNick": string, //用户昵称
"energy": string, //精力值
"happyCoin": string, //欢乐币
"experience": string, //经验值
"energy": number, //精力值
"happyCoin": number, //欢乐币
"experience": number, //经验值
"level": string, //等级
"avatar": string, //头像
"sence": number, //场景
......
......@@ -114,12 +114,12 @@ export class Main {
sendTbNet(TbNetName.getActivityBaseInfoById, {}, (s, res) => {
console.log('getActivityBaseInfoById success,res',s,res)
})
console.log('准备打开弹窗')
setTimeout(() => {
sendTbNet(TbNetName.showModal, {name:'ruleModal'}, (s, res) => {
console.log('showModal ruleModal, success,res',s,res)
})
}, 3000);
// console.log('准备打开弹窗')
// setTimeout(() => {
// sendTbNet(TbNetName.showModal, {name:'ruleModal'}, (s, res) => {
// console.log('showModal ruleModal, success,res',s,res)
// })
// }, 3000);
// console.log('准备切换到兑换页面')
// setTimeout(() => {
// sendTbNet(TbNetName.navigateToPage, {name:'pageshop'}, (s, res) => {
......
......@@ -150,6 +150,7 @@ export class Cat extends Module {
console.log(actType);
sendTbNet(TbNetName.interaction, {}, (s, r) => {
if (s) {
FYGE.GDispatcher.dispatchEvent(MSG.UPDATE_USERINFO);
that.actRunning = true;
switch (actType) {
case CAT_ACTTYPEP.SLEEP:
......@@ -160,7 +161,8 @@ export class Cat extends Module {
}
}else
{
FYGE.GDispatcher.dispatchEvent("23",r.message)
// FYGE.GDispatcher.dispatchEvent("23",r.message)
showToast(r.message)
}
})
......
{
"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
......@@ -19,7 +19,7 @@ export class SelectCatPanel extends Panel {
var bg = Ins.initSprite("db53267d-4141-4d3e-afda-9b523c89be3e");
that.addChild(bg);
that.x = (Ins.stageW - bg.width) >> 1;
that.y = Ins.stageH < 1624 ? (Ins.stageH - bg.height + 300) >> 1 : (Ins.stageH - bg.height) >> 1;
that.y = (Ins.stageH - bg.height) >> 1;
that.selectSureBtn = Ins.initSprite("628fc38b-7dc0-4c69-aac1-279d60c8f1ed", 185, 804);
that.addChild(that.selectSureBtn);
......
......@@ -7,65 +7,68 @@ import { MSG, SCENETYPE } from "../Enum";
import { showToast } from "../../module/ctrls";
import { GDispatcher } from "../Main";
import { Cat } from "../cat/Cat";
import { sendTbNet, TbNetName } from "../TaoBaoNet";
import { letter } from "../lottieSrc/lottieTs/letter";
export class MainScene extends Scene{
export class MainScene extends Scene {
/**场景背景 */
private sceneBg:FYGE.Sprite;
private sceneBg: FYGE.Sprite;
/**场景背景纹理 */
private bgTexture:FYGE.Texture;
private bgTexture: FYGE.Texture;
/**场景背景uuid组 */
private bgUUID:string[]=[];
private bgUUID: string[] = [];
/**主页面UI */
private mainUi:MainSceneBtnUi;
private mainUi: MainSceneBtnUi;
/**台历按钮,进入教室 */
private tlBtn:FYGE.Sprite;
private tlBtn: FYGE.Sprite;
/**毛线球按钮,进入操场 */
private mxqBtn:FYGE.Sprite;
private mxqBtn: FYGE.Sprite;
/**猫猫 */
private cat:Cat;
private cat: Cat;
/**信封 */
private letter:FYGE.Lottie;
private letter: FYGE.Lottie;
/**精力条组 */
private energyGroup:FYGE.Sprite; //精力条组/背景
private energyImg:FYGE.Sprite; //精力条图片
private energyDeco:FYGE.Sprite; //精力条装饰品,就是那个可爱的猫爪子
private energyLabel:FYGE.TextField; //精力条文本,精力条下方的文本x/xxx
private energyDialog:FYGE.Sprite; //精力条上方的气泡
private energyDialogLabel:FYGE.TextField; //精力条上方气泡中的文字
private energy:number; //当前精力值
private energyImgW:number; //精力条宽度
initUi(){
private energyGroup: FYGE.Sprite; //精力条组/背景
private energyImg: FYGE.Sprite; //精力条图片
private energyDeco: FYGE.Sprite; //精力条装饰品,就是那个可爱的猫爪子
private energyLabel: FYGE.TextField; //精力条文本,精力条下方的文本x/xxx
private energyDialog: FYGE.Sprite; //精力条上方的气泡
private energyDialogLabel: FYGE.TextField; //精力条上方气泡中的文字
private energy: number; //当前精力值
private energyImgW: number; //精力条宽度
private maxEnergy: number = 1500; //最大精力值
initUi() {
var that = this;
that.initSceneEle();
}
/**初始化场景元素 */
initSceneEle(){
initSceneEle() {
var that = this;
that.x = (Ins.stageW - 750)>>1;
that.y = (Ins.stageH - 1624)>>1;
that.x = (Ins.stageW - 750) >> 1;
that.y = (Ins.stageH - 1624) >> 1;
console.log(that.y);
that.mouseChildren = true;
//0:教室,1:操场,2:寝室
that.bgUUID = ["c6d699b0-b276-4985-b3ea-47bcef13f2ea","efaf990e-5392-49ad-94d8-25c04f651ede","b3c8c187-e5c9-4968-9a00-a118d18ab2fc"];
that.bgUUID = ["c6d699b0-b276-4985-b3ea-47bcef13f2ea", "efaf990e-5392-49ad-94d8-25c04f651ede", "b3c8c187-e5c9-4968-9a00-a118d18ab2fc"];
//生成默认场景,后面要改成根据接口值判断
that.sceneBg = Ins.initSprite("b3c8c187-e5c9-4968-9a00-a118d18ab2fc");
that.addChild(that.sceneBg);
that.tlBtn = Ins.initSprite("1f8b040d-2fbc-4ff8-92f9-159773364fae",0,640);
that.tlBtn = Ins.initSprite("1f8b040d-2fbc-4ff8-92f9-159773364fae", 0, 640);
that.tlBtn.alpha = 0.1;
that.tlBtn.mouseEnable = true;
that.addChild(that.tlBtn);
that.mxqBtn = Ins.initSprite("1f8b040d-2fbc-4ff8-92f9-159773364fae",50,940);
that.mxqBtn = Ins.initSprite("1f8b040d-2fbc-4ff8-92f9-159773364fae", 50, 940);
that.mxqBtn.width = 80;
that.mxqBtn.height = 80;
that.mxqBtn.alpha = 0.1;
that.mxqBtn.mouseEnable = true;
that.addChild(that.mxqBtn);
that.mainUi = new MainSceneBtnUi({uiType:SCENETYPE.BEADROOM});
that.mainUi = new MainSceneBtnUi({ uiType: SCENETYPE.BEADROOM });
that.addChild(that.mainUi);
that.initCat();
......@@ -73,31 +76,58 @@ export class MainScene extends Scene{
}
/**初始化猫咪 */
initCat(){
initCat() {
var that = this;
that.cat = new Cat({type:"xianluo"});
that.cat = new Cat({ type: "xianluo" });
that.addChild(that.cat);
if (Ins.catIsOut) {
that.cat.visible = false;
//当猫出走的时候,隐藏猫咪,创建信封
that.letter = new FYGE.Lottie(letter);
that.addChild(that.letter);
that.letter.play();
}
}
/**打开信封 */
openLetter() {
console.log("打开信封弹窗")
if(this.letter&&this.letter.visible){
sendTbNet(TbNetName.showModal, { name: 'ruleModal' }, (s, res) => {
console.log('showModal ruleModal, success,res', s, res)
})
}
}
/**删除信封 */
removeLetter() {
var that = this;
Ins.stopLottieAnim(that.letter);
}
/**初始化精力组 */
initEnergy(){
initEnergy() {
var that = this;
that.energyGroup = Ins.initSprite("fa59e617-f1d9-4065-85e1-6f6ebefb230f",60,1119);
that.energyGroup = Ins.initSprite("fa59e617-f1d9-4065-85e1-6f6ebefb230f", 60, 1119);
that.energyGroup.mouseEnable = false;
that.energyGroup.mouseChildren = false;
that.addChild(that.energyGroup);
that.energyImg = Ins.initSprite("e00aee6d-2a90-4e92-b365-f031320d582c",9,9);
that.energyImg = Ins.initSprite("e00aee6d-2a90-4e92-b365-f031320d582c", 9, 9);
that.energyImgW = that.energyImg.width;
that.energyGroup.addChild(that.energyImg);
that.energyDeco = Ins.initSprite("0eb9c19f-248e-4bf1-bffb-ea694a94b16f",541,-9);
that.energyDeco = Ins.initSprite("0eb9c19f-248e-4bf1-bffb-ea694a94b16f", 541, -9);
that.energyGroup.addChild(that.energyDeco);
that.energyDialog = Ins.initSprite("69009eb9-4593-4a43-a9d7-a6356ebd6d04",174,-60);
that.energyDialog = Ins.initSprite("69009eb9-4593-4a43-a9d7-a6356ebd6d04", 174, -60);
that.energyGroup.addChild(that.energyDialog);
that.energyDialogLabel = Ins.initLabel({size:26,text:"每5分钟恢复10点精力"});
that.energyDialogLabel = Ins.initLabel({ size: 26, text: "每5分钟恢复10点精力" });
that.energyDialog.addChild(that.energyDialogLabel);
that.energyDialogLabel.x = (that.energyDialog.width - that.energyDialogLabel.textWidth)*0.5;
that.energyDialogLabel.y = (that.energyDialog.height - that.energyDialogLabel.textHeight)*0.5-2;
that.energyDialogLabel.x = (that.energyDialog.width - that.energyDialogLabel.textWidth) * 0.5;
that.energyDialogLabel.y = (that.energyDialog.height - that.energyDialogLabel.textHeight) * 0.5 - 2;
that.energyLabel = Ins.initLabel({ size: 26, y: 85 });
that.energyGroup.addChild(that.energyLabel);
var mask = new FYGE.Shape();
mask.beginFill(6,1);
mask.drawRoundedRect(0,0,that.energyImg.width,that.energyImg.height,38,38,38,38);
mask.beginFill(6, 1);
mask.drawRoundedRect(0, 0, that.energyImg.width, that.energyImg.height, 38, 38, 38, 38);
mask.endFill();
mask.x = 9;
mask.y = 9;
......@@ -106,53 +136,92 @@ export class MainScene extends Scene{
that.setEnergy();
}
/**设置精力 */
setEnergy(){
/**设置精力组数据 */
setEnergy() {
var that = this;
that.energyImg.scaleX = 0.5;
that.energyDeco.x = that.energyImgW*that.energyImg.scaleX-that.energyDeco.width*0.5;
that.energy = Ins.userInfo.energy;
that.energyImg.scaleX = (that.energy / that.maxEnergy);
that.energyDeco.x = that.energyImgW * that.energyImg.scaleX - that.energyDeco.width * 0.5;
that.energyLabel.text = "精力" + that.energy + "/" + that.maxEnergy;
that.energyLabel.x = (that.energyGroup.width - that.energyLabel.textWidth) / 2
}
/**按照时间恢复精力 */
energyUp() {
}
/**切换场景 */
changeMainScene(type:SCENETYPE){
console.log("切换到"+type)
changeMainScene(type: SCENETYPE) {
console.log("切换到" + type)
var that = this;
that.sceneBg.texture = RES.getRes(resCanvasList[that.bgUUID[type]].url)
//切换场景时判断猫在不在,后面要改成与接口值判断
if(type==2){
that.cat.visible = true;
}else{
if (Ins.catIsOut) {
that.cat.visible = false;
that.cat.setCatAnimShow(0);
} else {
if ((type + 1) == Ins.userInfo.sence) {
that.cat.visible = true;
} else {
that.cat.visible = false;
that.cat.setCatAnimShow(0);
}
}
switch(type){
case SCENETYPE.BEADROOM:
switch (type) {
case SCENETYPE.BEADROOM: //切换到寝室
that.mxqBtn.visible = that.tlBtn.visible = true;
if (that.letter && Ins.catIsOut) {
that.letter.visible = true;
}
break;
case SCENETYPE.CLASSROOM:
case SCENETYPE.CLASSROOM: //切换到教室
that.mxqBtn.visible = that.tlBtn.visible = false;
if (that.letter) {
that.letter.visible = false;
}
break;
case SCENETYPE.PLAYGROUND:
case SCENETYPE.PLAYGROUND: //切换到操场
that.mxqBtn.visible = that.tlBtn.visible = false;
if (that.letter) {
that.letter.visible = false;
}
break;
}
that.mainUi.changeBtnByUiType(type);
}
/**更新用户相关信息 */
updateUserInfo() {
var that = this;
sendTbNet(TbNetName.getUserInfo, {}, (s, r) => {
if (s) {
Ins.userInfo = r.data;
that.setEnergy();
that.mainUi.updateUserInfo();
} else {
showToast(r.message)
}
})
}
initEvents(){
initEvents() {
var that = this;
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);
that.tlBtn.addEventListener(FYGE.MouseEvent.CLICK, () => { that.changeMainScene(SCENETYPE.CLASSROOM) }, that);
that.mxqBtn.addEventListener(FYGE.MouseEvent.CLICK, () => { that.changeMainScene(SCENETYPE.PLAYGROUND) }, that);
that.letter&&that.letter.addEventListener(FYGE.MouseEvent.CLICK,that.openLetter,that);
FYGE.GDispatcher.addEventListener(MSG.CHANGE_SCENE, () => { that.changeMainScene(SCENETYPE.BEADROOM) }, that);
FYGE.GDispatcher.addEventListener(MSG.UPDATE_USERINFO, that.updateUserInfo, that);
}
removeEvents(){
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);
that.tlBtn.removeEventListener(FYGE.MouseEvent.CLICK, () => { that.changeMainScene(SCENETYPE.CLASSROOM) }, that);
that.mxqBtn.removeEventListener(FYGE.MouseEvent.CLICK, () => { that.changeMainScene(SCENETYPE.PLAYGROUND) }, that);
that.letter&&that.letter.removeEventListener(FYGE.MouseEvent.CLICK,that.openLetter,that);
FYGE.GDispatcher.removeEventListener(MSG.CHANGE_SCENE, () => { that.changeMainScene(SCENETYPE.BEADROOM) }, that);
FYGE.GDispatcher.removeEventListener(MSG.UPDATE_USERINFO, that.updateUserInfo, that);
}
}
\ No newline at end of file
......@@ -5,7 +5,7 @@ import Root from "./Root";
import resCanvasList from "../../../game/resCanvasList"
import { MainScene } from "./MainScene";
import { Ins } from "../Ins";
import { showPanel, showToast } from "../../module/ctrls";
import { changeScene, showPanel, showToast } from "../../module/ctrls";
import { SelectCatPanel } from "../panels/selectcatpanel/SelectCatPanel";
import { sendTbNet, TbNetName } from "../TaoBaoNet";
export class StartScene extends Scene {
......@@ -20,7 +20,13 @@ export class StartScene extends Scene {
if(s){
if(r.data){
Ins.userInfo = r.data;
this.addChild(new MainScene());
/**判断猫咪是否出寝,只在用户进入游戏时判断,后面要根据接口改写,现在先做测试 */
if(r.data.happyCoin>2000){
Ins.catIsOut = true;
}else{
Ins.catIsOut = false;
}
changeScene(MainScene)
}else
{
showPanel(SelectCatPanel);
......
......@@ -36,6 +36,8 @@ export class MainSceneBtnUi extends Module {
private playBtn: FYGE.Sprite;
/**补充精力按钮 */
private energyBtn: FYGE.Sprite;
/**召回猫咪按钮 */
private catRecall: FYGE.Sprite;
/**猫猫信息组 */
private catInfoGroup: FYGE.Sprite;
private catAvatar: FYGE.Sprite; //猫猫头像
......@@ -45,6 +47,10 @@ export class MainSceneBtnUi extends Module {
private fishPointGroup: FYGE.Sprite;
private fishPointLabel: FYGE.TextField; //鱼鱼积分文本
/**按钮组,一个上方按钮组,一个下方按钮组,如果用于适配就改变这两个按钮组 */
private topBtnGroup:FYGE.Sprite;
private bottomBtnGroup:FYGE.Sprite;
/**互动进行中,当互动进行中时,无法点击互动按钮进行互动 */
private actRunning: boolean = false;
initUi() {
......@@ -58,30 +64,49 @@ export class MainSceneBtnUi extends Module {
that.mouseEnable = false;
that.mouseChildren = true;
that.strategyBtn = Ins.initSprite("e636bd22-361f-442a-8684-ccfe1141485a", 579, 332);
that.addChild(that.strategyBtn);
that.topBtnGroup = new FYGE.Sprite();
that.topBtnGroup.y = 220;
that.topBtnGroup.mouseEnable = that.topBtnGroup.mouseChildren = true;
that.addChild(that.topBtnGroup);
that.bottomBtnGroup = new FYGE.Sprite();
that.bottomBtnGroup.y = 1240;
that.bottomBtnGroup.mouseEnable = that.bottomBtnGroup.mouseChildren = true;
that.addChild(that.bottomBtnGroup);
that.strategyBtn = Ins.initSprite("e636bd22-361f-442a-8684-ccfe1141485a", 579, 112);
that.topBtnGroup.addChild(that.strategyBtn);
that.prizeBtn = Ins.initSprite("e8b083c7-307a-4446-9bc9-99f75c3573e5", 579, 457);
that.addChild(that.prizeBtn);
that.prizeBtn = Ins.initSprite("e8b083c7-307a-4446-9bc9-99f75c3573e5", 579, 237);
that.topBtnGroup.addChild(that.prizeBtn);
that.energyBtn = Ins.initSprite("cdb8e186-9872-442e-b71e-bba0a9ce5846", 539, 1233);
that.addChild(that.energyBtn);
that.energyBtn = Ins.initSprite("cdb8e186-9872-442e-b71e-bba0a9ce5846", 539, -7);
that.bottomBtnGroup.addChild(that.energyBtn);
that.initCatInfoGroup();
that.initFishPointGroup();
that.initActBtn();
that.updateUserInfo();
that.start();
}
/**初始化猫猫信息 */
initCatInfoGroup() {
var that = this;
that.catInfoGroup = Ins.initSprite("af4b699e-5152-4571-8c54-1c06eabf19e9", 69, 220),
that.addChild(that.catInfoGroup);
that.catInfoGroup = Ins.initSprite("af4b699e-5152-4571-8c54-1c06eabf19e9", 69),
that.topBtnGroup.addChild(that.catInfoGroup);
that.catAvatar = new FYGE.Sprite();
that.catInfoGroup.addChild(that.catAvatar);
var mask = new FYGE.Shape();
mask.beginFill(6, 1);
mask.drawCircle(0, 0, 24)
// mask.drawRoundedRect(0, 0, 52, 52, 38, 38, 38, 38);
mask.endFill();
mask.x = 33;
mask.y = 33;
that.catInfoGroup.addChild(mask);
that.catAvatar.mask = mask;
that.catNameLabel = Ins.initLabel({ color: "black", size: 24, text: "喵喵喵", x: (95 - 19), y: (167 - 145) })
that.catInfoGroup.addChild(that.catNameLabel);
......@@ -93,8 +118,8 @@ export class MainSceneBtnUi extends Module {
/**初始化鱼鱼积分组 */
initFishPointGroup() {
var that = this;
that.fishPointGroup = Ins.initSprite("f0810375-c8f1-4939-9b11-1cbde6840e2a", 465, 220);
that.addChild(that.fishPointGroup);
that.fishPointGroup = Ins.initSprite("f0810375-c8f1-4939-9b11-1cbde6840e2a", 465);
that.topBtnGroup.addChild(that.fishPointGroup);
that.fishPointLabel = Ins.initLabel({ color: "black", size: 24, text: "111111", x: 99, y: 24 })
that.fishPointGroup.addChild(that.fishPointLabel);
......@@ -103,46 +128,71 @@ export class MainSceneBtnUi extends Module {
/**初始化互动按钮 */
initActBtn() {
var that = this;
that.combingBtn = Ins.initSprite("aa17cfa9-f1db-47eb-9eeb-f5947b7f47a8", 62, 1240);
that.addChild(that.combingBtn);
that.catBtn = Ins.initSprite("0b44efa9-1e8a-4c43-a2a5-93852d88918c", 210, 1240);
that.addChild(that.catBtn);
that.returnBtn = Ins.initSprite("55f703cd-f0d2-4ec1-9430-6193c1cbc1cb", 62, 1240);
that.addChild(that.returnBtn);
that.touchHeadBtn = Ins.initSprite("b7ec0f16-ea48-4e41-8def-7cc660fa93d7", 210, 1240);
that.addChild(that.touchHeadBtn);
that.playBtn = Ins.initSprite("922deced-62d2-4995-9dd6-82bc7913f362", 210, 1240);
that.addChild(that.playBtn);
that.combingBtn = Ins.initSprite("aa17cfa9-f1db-47eb-9eeb-f5947b7f47a8", 62);
that.bottomBtnGroup.addChild(that.combingBtn);
that.catBtn = Ins.initSprite("0b44efa9-1e8a-4c43-a2a5-93852d88918c", 210);
that.bottomBtnGroup.addChild(that.catBtn);
that.returnBtn = Ins.initSprite("55f703cd-f0d2-4ec1-9430-6193c1cbc1cb", 62);
that.bottomBtnGroup.addChild(that.returnBtn);
that.touchHeadBtn = Ins.initSprite("b7ec0f16-ea48-4e41-8def-7cc660fa93d7", 210);
that.bottomBtnGroup.addChild(that.touchHeadBtn);
that.playBtn = Ins.initSprite("922deced-62d2-4995-9dd6-82bc7913f362", 210);
that.bottomBtnGroup.addChild(that.playBtn);
that.catRecall = Ins.initSprite("72345190-f95b-4152-bccf-393b8a5aa8d0", 62)
that.bottomBtnGroup.addChild(that.catRecall);
that.hideAllActBtn();
that.changeBtnByUiType(that.uiType)
}
/**更新用户数据,在初始化时调用一次,后续通过消息调用,调用用户信息接口的时候调用 */
updateUserInfo() {
var that = this;
const { catName, happyCoin, level, avatar } = Ins.userInfo;
that.catAvatar.texture = RES.getRes(avatar);
that.catAvatar.width = 52;
that.catAvatar.height = 52;
that.catAvatar.x = that.catAvatar.y = 5
that.catNameLabel.text = catName;
that.catLevelLabel.text = "Lv." + level;
that.fishPointLabel.text = "" + happyCoin;
}
/**隐藏所有互动按钮 */
hideAllActBtn() {
var that = this;
that.combingBtn.visible = false;
that.catBtn.visible = false;
that.returnBtn.visible = false;
that.touchHeadBtn.visible = false;
that.playBtn.visible = false;
that.changeBtnByUiType(that.uiType)
that.catRecall.visible = false;
}
/**改变按钮显示,根据uiType */
changeBtnByUiType(type: any) {
var that = this;
that.combingBtn.visible = false;
that.catBtn.visible = false;
that.returnBtn.visible = false;
that.touchHeadBtn.visible = false;
that.playBtn.visible = false;
that.hideAllActBtn();
switch (type) {
case SCENETYPE.BEADROOM:
that.combingBtn.visible = true;
that.catBtn.visible = true;
if (Ins.catIsOut) {
that.catRecall.visible = true;
} else {
that.combingBtn.visible = true;
that.catBtn.visible = true;
}
break;
case SCENETYPE.CLASSROOM:
that.returnBtn.visible = true;
if (!Ins.catIsOut) {
that.touchHeadBtn.visible = true;
}
that.touchHeadBtn.visible = true;
break;
case SCENETYPE.PLAYGROUND:
that.returnBtn.visible = true;
that.playBtn.visible = true;
if (!Ins.catIsOut) {
that.playBtn.visible = true;
}
break;
default: console.log("改变场景ui时设置uiType错误");
break;
......@@ -153,10 +203,10 @@ export class MainSceneBtnUi extends Module {
touchHandler(e: FYGE.MouseEvent) {
console.log(e.target);
var that = this;
that.btnDelay(e.target);
if (e.target == that.returnBtn) {
that.returnBedRoom();
} else {
that.btnDelay(e.target);
switch (e.target) {
case that.energyBtn:
that.getEnergy();
......@@ -179,11 +229,22 @@ export class MainSceneBtnUi extends Module {
case that.prizeBtn:
that.openPrizePage();
break;
case that.catRecall:
that.catRecallHandler();
break;
default:console.log("主页面按钮点击事件错误,请检查")
break;
}
}
}
/**召回猫咪事件 */
catRecallHandler(){
console.log("召回猫咪");
}
/**补充精力 */
getEnergy() {
console.log("补充精力");
......@@ -243,6 +304,7 @@ export class MainSceneBtnUi extends Module {
that.addEvent(that.catBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.addEvent(that.combingBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.addEvent(that.touchHeadBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.addEvent(that.catRecall, FYGE.MouseEvent.CLICK, that.touchHandler);
}
/**添加事件,为了防止obj没有被创建封装 */
......@@ -265,7 +327,13 @@ export class MainSceneBtnUi extends Module {
that.removeEvent(that.energyBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.removeEvent(that.returnBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.removeEvent(that.strategyBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.removeEvent(that.prizeBtn, FYGE.MouseEvent.CLICK, that.touchHandler)
that.removeEvent(that.prizeBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.removeEvent(that.playBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.removeEvent(that.catBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.removeEvent(that.combingBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.removeEvent(that.touchHeadBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.removeEvent(that.catRecall, FYGE.MouseEvent.CLICK, that.touchHandler);
}
start() {
......
......@@ -4,4 +4,4 @@
</canvas>
</view>
<rule-modal a:if="{{ruleModalVisible}}" onModalClose="closeRuleModal"><text>{{rule}}</text></rule-modal>
\ No newline at end of file
<rule-modal a:if="{{ruleModalVisible}}" onModalClose="closeRuleModal"><text>{{rule}}</text></rule-modal>
\ 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