Commit 74debd0a authored by wjf's avatar wjf

l

parent 334469c5
...@@ -56,11 +56,11 @@ ...@@ -56,11 +56,11 @@
canvas.width = document.body.clientWidth * (window.devicePixelRatio || 1) canvas.width = document.body.clientWidth * (window.devicePixelRatio || 1)
canvas.height = document.body.clientHeight * (window.devicePixelRatio || 1) canvas.height = document.body.clientHeight * (window.devicePixelRatio || 1)
var main = new Main(canvas); var main = new Main(canvas);
console.log(main.stage)
var mouseEvent = main.stage.onMouseEvent.bind(main.stage); var mouseEvent = main.stage.onMouseEvent.bind(main.stage);
canvas.addEventListener("touchstart", mouseEvent, false); canvas.addEventListener("touchstart", mouseEvent, false);
canvas.addEventListener('touchmove', mouseEvent, false); canvas.addEventListener('touchmove', mouseEvent, false);
canvas.addEventListener('touchend', mouseEvent, false); canvas.addEventListener('touchend', mouseEvent, false);
window.stage = main.stage
}) })
......
...@@ -1746,7 +1746,6 @@ var Main = (function () { ...@@ -1746,7 +1746,6 @@ var Main = (function () {
exports.GDispatcher.dispatchEvent({ type: G_EVENT_1.G_EVENT.ON_SHOW }); exports.GDispatcher.dispatchEvent({ type: G_EVENT_1.G_EVENT.ON_SHOW });
}; };
Main.prototype.pause = function () { Main.prototype.pause = function () {
this._pause = true;
exports.GDispatcher.dispatchEvent({ type: G_EVENT_1.G_EVENT.ON_HIDE }); exports.GDispatcher.dispatchEvent({ type: G_EVENT_1.G_EVENT.ON_HIDE });
}; };
Main.prototype.addGlobalEvent = function (name, fun, thisObj, once) { Main.prototype.addGlobalEvent = function (name, fun, thisObj, once) {
...@@ -1777,6 +1776,34 @@ var Main = (function () { ...@@ -1777,6 +1776,34 @@ var Main = (function () {
return Main; return Main;
}()); }());
exports.Main = Main; exports.Main = Main;
function createNineTextures(imageUrl) {
return new Promise(function (resolve, reject) {
var image = new Image();
image.setAttribute("crossOrigin", "anonymous");
image.onload = function () {
var obj = {};
var name = "lalala";
var row = 4, col = 3;
var w = image.width / col;
var h = image.height / row;
for (var i = 0; i < col * row; i++)
obj[name + i] = {
"x": i % col * w,
"y": ~~(i / col) * h,
w: w, h: h, sw: w, sh: h, ox: 0, oy: 0, ro: false
};
FYGE.createTextureSheet(new FYGE.BaseTexture(image), obj);
var arr = [];
for (var i = 0; i < col * row; i++)
arr.push(FYGE.TextureCache[name + i]);
resolve(arr);
};
image.onerror = function (err) {
reject(err);
};
image.src = imageUrl;
});
}
/***/ }), /***/ }),
...@@ -10191,7 +10218,7 @@ exports.ResJson = { ...@@ -10191,7 +10218,7 @@ exports.ResJson = {
} }
} }
], ],
"path": "https://yun.duiba.com.cn/db_games/activity/babycare_xiaoxiao/1595853182/resource/" "path": "https://yun.duiba.com.cn/db_games/activity/babycare_xiaoxiao/1595928326/resource/"
}; };
...@@ -17626,7 +17653,7 @@ var SuccessNoPrizePanel = (function (_super) { ...@@ -17626,7 +17653,7 @@ var SuccessNoPrizePanel = (function (_super) {
} }
} }
}); });
this.tipsTex.text = " \u592A\u5389\u5BB3\u4E86\uFF01\n\u518D\u89E3\u9501" + dLevel_1 + "\u5173\u53EF\u4EE5\u5F00\u7EA2\u5305\u4E86"; this.tipsTex.text = "\t\t\t\u592A\u5389\u5BB3\u4E86\uFF01\n\u518D\u89E3\u9501" + dLevel_1 + "\u5173\u53EF\u4EE5\u5F00\u7EA2\u5305\u4E86";
this.tipsTex.textAlign = TEXT_ALIGN.CENTER; this.tipsTex.textAlign = TEXT_ALIGN.CENTER;
this.tipsTex.textWidth = 750; this.tipsTex.textWidth = 750;
this.tipsTex.x = 0; this.tipsTex.x = 0;
...@@ -17861,6 +17888,8 @@ var SuccessPrizePanel = (function (_super) { ...@@ -17861,6 +17888,8 @@ var SuccessPrizePanel = (function (_super) {
this.checkTex.textWidth = 750; this.checkTex.textWidth = 750;
this.checkTex.x = 0; this.checkTex.x = 0;
this.checkTex.textAlign = TEXT_ALIGN.CENTER; this.checkTex.textAlign = TEXT_ALIGN.CENTER;
this.tipsTex.textWidth = 750;
this.tipsTex.x = 0;
this.tipsTex.textAlign = TEXT_ALIGN.CENTER; this.tipsTex.textAlign = TEXT_ALIGN.CENTER;
this.starGroup = this.addChild(new SuccessNoPrizePanel_1.SuccessStarGroup()); this.starGroup = this.addChild(new SuccessNoPrizePanel_1.SuccessStarGroup());
this.starGroup.position.set(373, 678); this.starGroup.position.set(373, 678);
...@@ -17874,6 +17903,7 @@ var SuccessPrizePanel = (function (_super) { ...@@ -17874,6 +17903,7 @@ var SuccessPrizePanel = (function (_super) {
this.againBtn.visible = false; this.againBtn.visible = false;
this.goPrizeBtn.visible = false; this.goPrizeBtn.visible = false;
this.prizeImg.visible = false; this.prizeImg.visible = false;
this.tipsTex.text = '\t\t满星过关!';
switch (this.data.tool.type) { switch (this.data.tool.type) {
case PropType_1.PropType.BOOMS: case PropType_1.PropType.BOOMS:
propImg.texture = RES_1.RES.getRes('boomBtn.png'); propImg.texture = RES_1.RES.getRes('boomBtn.png');
...@@ -17893,9 +17923,16 @@ var SuccessPrizePanel = (function (_super) { ...@@ -17893,9 +17923,16 @@ var SuccessPrizePanel = (function (_super) {
} }
} }
else if (this.data.prize && this.data.prize.image) { else if (this.data.prize && this.data.prize.image) {
if (this.data.level == 120) {
this.againBtn.visible = false;
this.goPrizeBtn.visible = false;
}
else {
this.noPrizeAgainBtn.visible = false; this.noPrizeAgainBtn.visible = false;
}
this.prop.visible = false; this.prop.visible = false;
this.prizeImg.texture = Texture.fromUrl(this.data.prize.image); this.prizeImg.texture = Texture.fromUrl(this.data.prize.image);
this.tipsTex.text = '\t\t闯关成功!获得抽大奖机会!';
} }
}; };
SuccessPrizePanel.prototype.lightEffect = function () { SuccessPrizePanel.prototype.lightEffect = function () {
...@@ -18634,20 +18671,15 @@ var LotteryScene = (function (_super) { ...@@ -18634,20 +18671,15 @@ var LotteryScene = (function (_super) {
configurable: true configurable: true
}); });
LotteryScene.prototype.initUi = function () { LotteryScene.prototype.initUi = function () {
var _this = this;
this.y = -layers_1.layers.stageOffsetY; this.y = -layers_1.layers.stageOffsetY;
this.addChild(new FYGE.Sprite(RES_1.RES.getRes("lotteryMachineBg.jpg"))); this.addChild(new FYGE.Sprite(RES_1.RES.getRes("lotteryMachineBg.jpg")));
var upLevel = 120; Tools_1.Tools.baseInfo.prizeLevels.sort(function (a, b) {
var dLevel = 120; return a - b;
Tools_1.Tools.baseInfo.prizeLevels.forEach(function (value, index) {
var d = value - _this.data.level;
if (_this.data.level <= value && d >= 0 && d <= dLevel) {
upLevel = value;
dLevel = d + 1;
}
}); });
var index = Tools_1.Tools.baseInfo.prizeLevels.indexOf(this.data.level);
var upLevel = Tools_1.Tools.baseInfo.prizeLevels[index + 1];
this.addChild(Tools_1.Tools.getText(this.data.level + "关抽奖奖励", 53.19, "#ffffff", FYGE.TEXT_ALIGN.CENTER, 488, (750 - 488) / 2, 360)).bold = true; this.addChild(Tools_1.Tools.getText(this.data.level + "关抽奖奖励", 53.19, "#ffffff", FYGE.TEXT_ALIGN.CENTER, 488, (750 - 488) / 2, 360)).bold = true;
this.addChild(Tools_1.Tools.getText("下一奖励关卡:" + upLevel + "关", 32.54, "#ffffff", FYGE.TEXT_ALIGN.CENTER, 488, (750 - 488) / 2, 420)); this.addChild(Tools_1.Tools.getText(upLevel ? "下一奖励关卡:" + upLevel + "关" : "", 32.54, "#ffffff", FYGE.TEXT_ALIGN.CENTER, 488, (750 - 488) / 2, 420));
this.addChild(new FYGE.Button(RES_1.RES.getRes("lotteryBtn.png"))) this.addChild(new FYGE.Button(RES_1.RES.getRes("lotteryBtn.png")))
.addEventListener(FYGE.MouseEvent.CLICK, this.lottery, this) .addEventListener(FYGE.MouseEvent.CLICK, this.lottery, this)
.position.set((750 - RES_1.RES.getRes("lotteryBtn.png").width) / 2, 797); .position.set((750 - RES_1.RES.getRes("lotteryBtn.png").width) / 2, 797);
...@@ -18984,6 +19016,8 @@ var MapScene_1 = __webpack_require__(/*! ./map/MapScene */ "./src/scene/map/MapS ...@@ -18984,6 +19016,8 @@ var MapScene_1 = __webpack_require__(/*! ./map/MapScene */ "./src/scene/map/MapS
var NoStepPanel_1 = __webpack_require__(/*! ../panels/NoStepPanel */ "./src/panels/NoStepPanel.ts"); var NoStepPanel_1 = __webpack_require__(/*! ../panels/NoStepPanel */ "./src/panels/NoStepPanel.ts");
var FirstPropGift_1 = __webpack_require__(/*! ../something/uis/FirstPropGift */ "./src/something/uis/FirstPropGift.ts"); var FirstPropGift_1 = __webpack_require__(/*! ../something/uis/FirstPropGift */ "./src/something/uis/FirstPropGift.ts");
var bonus_lottie_1 = __webpack_require__(/*! ../lotties/bonus_lottie */ "./src/lotties/bonus_lottie.ts"); var bonus_lottie_1 = __webpack_require__(/*! ../lotties/bonus_lottie */ "./src/lotties/bonus_lottie.ts");
var Main_1 = __webpack_require__(/*! ../Main */ "./src/Main.ts");
var G_EVENT_1 = __webpack_require__(/*! ../common/G_EVENT */ "./src/common/G_EVENT.ts");
var aniClass = { var aniClass = {
"BoomAni": BoomAni_1.BoomAni, "BoomAni": BoomAni_1.BoomAni,
"IceAni": IceAni_1.IceAni, "IceAni": IceAni_1.IceAni,
...@@ -21132,8 +21166,19 @@ var SettingBtn = (function (_super) { ...@@ -21132,8 +21166,19 @@ var SettingBtn = (function (_super) {
_this.texture = RES_1.RES.getRes(_this.isOn ? "musicOn.png" : "musicOff.png"); _this.texture = RES_1.RES.getRes(_this.isOn ? "musicOn.png" : "musicOff.png");
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.openMusic, { isOn: _this.isOn }); TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.openMusic, { isOn: _this.isOn });
}, _this); }, _this);
_this.isOn = true;
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.openMusic, { isOn: _this.isOn });
Main_1.GDispatcher.addEventListener(G_EVENT_1.G_EVENT.ON_SHOW, _this.onShow, _this);
return _this; return _this;
} }
class_1.prototype.onShow = function () {
if (this.isOn)
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.openMusic, { isOn: true });
};
class_1.prototype.destroy = function () {
Main_1.GDispatcher.removeEventListener(G_EVENT_1.G_EVENT.ON_SHOW, this.onShow, this);
_super.prototype.destroy.call(this);
};
return class_1; return class_1;
}(FYGE.Sprite))); }(FYGE.Sprite)));
musicBtn.position.set(11, 97); musicBtn.position.set(11, 97);
...@@ -21144,9 +21189,12 @@ var SettingBtn = (function (_super) { ...@@ -21144,9 +21189,12 @@ var SettingBtn = (function (_super) {
musicBtn.visible = !musicBtn.visible; musicBtn.visible = !musicBtn.visible;
bg.visible = !bg.visible; bg.visible = !bg.visible;
}, _this); }, _this);
console.log(btn);
return _this; return _this;
} }
SettingBtn.prototype.destroy = function () {
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.openMusic, { isOn: false });
_super.prototype.destroy.call(this);
};
return SettingBtn; return SettingBtn;
}(FYGE.Container)); }(FYGE.Container));
...@@ -21222,6 +21270,7 @@ var CheckBtn = (function (_super) { ...@@ -21222,6 +21270,7 @@ var CheckBtn = (function (_super) {
Object.defineProperty(CheckBtn.prototype, "data", { Object.defineProperty(CheckBtn.prototype, "data", {
set: function (data) { set: function (data) {
this._data = data; this._data = data;
this.checkData.isPlayed = true;
if (!data) if (!data)
return; return;
if (!data.isVisitSuccess) if (!data.isVisitSuccess)
...@@ -22089,6 +22138,8 @@ var TaskPanel_1 = __webpack_require__(/*! ../../panels/TaskPanel */ "./src/panel ...@@ -22089,6 +22138,8 @@ var TaskPanel_1 = __webpack_require__(/*! ../../panels/TaskPanel */ "./src/panel
var TaoBaoNet_1 = __webpack_require__(/*! ../../TaoBaoNet */ "./src/TaoBaoNet.ts"); var TaoBaoNet_1 = __webpack_require__(/*! ../../TaoBaoNet */ "./src/TaoBaoNet.ts");
var Texture = FYGE.Texture; var Texture = FYGE.Texture;
var LotteryScene_1 = __webpack_require__(/*! ../LotteryScene */ "./src/scene/LotteryScene.ts"); var LotteryScene_1 = __webpack_require__(/*! ../LotteryScene */ "./src/scene/LotteryScene.ts");
var Main_1 = __webpack_require__(/*! ../../Main */ "./src/Main.ts");
var G_EVENT_1 = __webpack_require__(/*! ../../common/G_EVENT */ "./src/common/G_EVENT.ts");
var MapUI = (function (_super) { var MapUI = (function (_super) {
__extends(MapUI, _super); __extends(MapUI, _super);
function MapUI() { function MapUI() {
...@@ -22123,7 +22174,8 @@ var MapUI = (function (_super) { ...@@ -22123,7 +22174,8 @@ var MapUI = (function (_super) {
break; break;
case this.myPrizeBtn: case this.myPrizeBtn:
console.log('我的奖品'); console.log('我的奖品');
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.navigateTo, { url: '/pages/myPrize/myPrize' }, function () { }, true); TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.navigateTo, { url: '/pages/myPrize/myPrize' }, function () {
}, true);
break; break;
case this.prizeBox: case this.prizeBox:
console.log('奖励盒子'); console.log('奖励盒子');
...@@ -22222,6 +22274,7 @@ var CreditsBox = (function (_super) { ...@@ -22222,6 +22274,7 @@ var CreditsBox = (function (_super) {
return [4, this.updateCredits()]; return [4, this.updateCredits()];
case 1: case 1:
_a.sent(); _a.sent();
Main_1.GDispatcher.addEventListener(G_EVENT_1.G_EVENT.ON_SHOW, this.updateCredits, this);
return [2]; return [2];
} }
}); });
...@@ -22246,6 +22299,10 @@ var CreditsBox = (function (_super) { ...@@ -22246,6 +22299,10 @@ var CreditsBox = (function (_super) {
}); });
}); });
}; };
CreditsBox.prototype.destroy = function () {
_super.prototype.destroy.call(this);
Main_1.GDispatcher.removeEventListener(G_EVENT_1.G_EVENT.ON_SHOW, this.updateCredits, this);
};
return CreditsBox; return CreditsBox;
}(Container)); }(Container));
var PrizeBox = (function (_super) { var PrizeBox = (function (_super) {
This diff is collapsed.
This diff is collapsed.
var fs = require("fs");
var path = require('path');
const { createCanvas, loadImage } = require('canvas')
let MaxRectsPacker = require("maxrects-packer").MaxRectsPacker; let MaxRectsPacker = require("maxrects-packer").MaxRectsPacker;
const options = {
var aaa =require()
var pathName = "./psd/common"
//读文件夹
var files = fs.readdirSync(pathName);
//找出所有png图片
var images = [];
let count = 0, countAll = files.length;
files.forEach(async function (fileName) {
if (path.extname(fileName).indexOf(".png") < 0) {
if (++count == countAll) tm()
return;
}
// console.log(img)
images.push(
await handleImage(fileName)
)
if (++count == countAll) tm()
})
//开始处理
function tm() {
// console.log(images)
// return
const options = {
smart: true, smart: true,
pot: true, pot: false,//是否powerOf2
square: false, square: false,
allowRotation: true, allowRotation: true,
tag: false, tag: false,
border: 2 border: 2
}; // Set packing options }; // Set packing options
let packer = new MaxRectsPacker(1024, 1024, 2, options); // width, height, padding, options let packer = new MaxRectsPacker(2048, 2048, 2, options); // width, height, padding, options
// console.log(packer.options) // console.log(packer.options)
let input = [ // any object with width & height is OK since v2.1.0 packer.addArray(images);
{width: 600, height: 20, name: "tree"},
{width: 20, height: 600, name: "flower"}, packer.bins.forEach((bin, i) => {
// {width: 600, height: 20, name: "tree"}, console.log(bin);
// {width: 20, height: 600, name: "flower"}, var canvas = createCanvas(bin.width, bin.height)
// {width: 2000, height: 2000, name: "oversized background"}, var ctx = canvas.getContext("2d");
// {width: 1000, height: 1000, name: "background"}, var obj = {}
// {width: 1000, height: 1000, name: "overlay"} bin.rects.forEach((rect) => {
]; ctx.save()
if (rect.rot) {
packer.addArray(input); // Start packing with input array ctx.translate(rect.x, rect.y);
// packer.next(); // Start a new packer bin ctx.rotate(Math.PI / 2)
packer.addArray([ {width: 600, height: 20, name: "tree"}, ctx.translate(-rect.x, -rect.y);
{width: 20, height: 600, name: "flower"},]); // Adding to the new bin ctx.drawImage(rect.imgData, rect.x, rect.y - rect.height)
// packer.addArray(input.slice()); } else {
// packer.addArray(input.slice()); ctx.drawImage(rect.imgData, rect.x, rect.y)
packer.bins.forEach(bin => { }
console.log(bin.rects); ctx.restore();
}); //数据
obj[rect.name] = {
// Reuse packer "x": rect.x,
// let bins = packer.save(); "y": rect.y,
// packer.load(bins); "w": rect.width,
// console.log(packer.bins) "h": rect.height,
// packer.addArray(input); "ox": rect.offsetX ? rect.offsetX : 0,
\ No newline at end of file "oy": rect.offsetY ? rect.offsetY : 0,
"sw": rect.originW,
"sh": rect.originH,
"ro": rect.rot,
}
})
canvas.createPNGStream().pipe(fs.createWriteStream("./psd/out.png"));
fs.writeFileSync("./psd/out.json", JSON.stringify(obj, "", "\t"));
});
}
// console.log(images.length)
/**
* 处理图片
* @param {*} imgName
*/
async function handleImage(imgName) {
// console.log(image(fs.readFileSync(pathName + "/" + (imgName))))
const myimg = await loadImage(fs.readFileSync(pathName + "/" + (imgName))/*'./image/b.png'*/).catch((err) => { });
if (!myimg) {
return null
}
const canvas = createCanvas(myimg.width, myimg.height)
const ctx = canvas.getContext('2d');
ctx.drawImage(myimg, 0, 0)
var imageData = ctx.getImageData(0, 0, myimg.width, myimg.height);
if (!needTrim(imageData)) {
return {
name: imgName,
width: myimg.width,
height: myimg.height,
originW: myimg.width,
originH: myimg.height,
imgData: myimg,
}
} else {
const pixels = imageData.data;
const len = pixels.length;
const bound = {
top: null,
left: null,
right: null,
bottom: null,
};
let i;
let x;
let y;
let width = myimg.width, height = myimg.height
for (i = 0; i < len; i += 4) {
if (pixels[i + 3] !== 0) {
x = (i / 4) % width;
y = ~~((i / 4) / width);
if (bound.top === null) {
bound.top = y;
}
if (bound.left === null) {
bound.left = x;
}
else if (x < bound.left) {
bound.left = x;
}
if (bound.right === null) {
bound.right = x + 1;
}
else if (bound.right < x) {
bound.right = x + 1;
}
if (bound.bottom === null) {
bound.bottom = y;
}
else if (bound.bottom < y) {
bound.bottom = y;
}
}
}
width = bound.right - bound.left;
height = bound.bottom - bound.top //+ 1;
const data = ctx.getImageData(bound.left, bound.top, width, height);
var cc = createCanvas(width, height)
cc.getContext("2d").putImageData(data, 0, 0)
return {
offsetX: bound.left,
offsetY: bound.top,
name: imgName,
width: width,
height: height,
originW: myimg.width,
originH: myimg.height,
imgData: cc,
};
}
}
/**
* 判断是否要进行透明度裁切
* @param {*} imageData
*/
function needTrim(imageData) {
const width = imageData.width;
const height = imageData.height;
const pixels = imageData.data;
const len = pixels.length;
//4条边缘,有任何一条出现全透明像素就要进行裁切
let hasPix = false;
//上边缘
for (var i = 0; i < width; i++) {
if (pixels[i * 4 + 3] !== 0) {
hasPix = true;
break
}
}
if (!hasPix) return true;
//下边缘
hasPix = false;
for (var i = 0; i < width; i++) {
if (pixels[width * (height - 1) * 4 + i * 4 + 3] !== 0) {
hasPix = true;
break
}
}
if (!hasPix) return true;
//左边缘
hasPix = false;
for (var i = 0; i < height; i++) {
if (pixels[width * i * 4 + 3] !== 0) {
hasPix = true;
break
}
}
//右边缘
hasPix = false;
for (var i = 0; i < height; i++) {
if (pixels[width * i * 4 + 3 + (width - 1) * 4] !== 0) {
hasPix = true;
break
}
}
if (!hasPix) return true;
return false
}
\ No newline at end of file
...@@ -121,7 +121,7 @@ export class Main { ...@@ -121,7 +121,7 @@ export class Main {
} }
//在小程序隐藏时调用onHide //在小程序隐藏时调用onHide
pause() { pause() {
this._pause = true; // this._pause = true;//先不暂停了
GDispatcher.dispatchEvent({ type: G_EVENT.ON_HIDE }); GDispatcher.dispatchEvent({ type: G_EVENT.ON_HIDE });
} }
...@@ -183,4 +183,34 @@ export class Main { ...@@ -183,4 +183,34 @@ export class Main {
function createNineTextures(imageUrl): Promise<FYGE.Texture[]> {
return new Promise((resolve, reject) => {
let image = new Image();
image.setAttribute("crossOrigin", "anonymous");
image.onload = function () {
var obj = {}
//名字。
var name = "lalala";
var row = 4, col = 3;
var w = image.width / col;
var h = image.height / row;
//生成9张图的数据
for (var i = 0; i < col * row; i++)
obj[name + i] = {
"x": i % col * w,
"y": ~~(i / col) * h,
w, h, sw: w, sh: h, ox: 0, oy: 0, ro: false
};
FYGE.createTextureSheet(new FYGE.BaseTexture(image), obj);
//取TextureCache里的
var arr = [];
for (var i = 0; i < col * row; i++)arr.push(FYGE.TextureCache[name + i])
resolve(arr)
}
image.onerror = function (err) {
reject(err)
}
image.src = imageUrl
})
}
\ No newline at end of file
This diff is collapsed.
...@@ -28,8 +28,8 @@ export class SuccessPrizePanel extends Panel { ...@@ -28,8 +28,8 @@ export class SuccessPrizePanel extends Panel {
this.isShowing = true; this.isShowing = true;
this.anchor.set(375, 812); this.anchor.set(375, 812);
Tween.get(this) Tween.get(this)
.set({scaleX: 0, scaleY: 0}) .set({ scaleX: 0, scaleY: 0 })
.to({scaleX: 1, scaleY: 1}, 400, Ease.backOut) .to({ scaleX: 1, scaleY: 1 }, 400, Ease.backOut)
.call(() => { .call(() => {
this.isShowing = false; this.isShowing = false;
}); });
...@@ -96,7 +96,13 @@ export class SuccessPrizePanel extends Panel { ...@@ -96,7 +96,13 @@ export class SuccessPrizePanel extends Panel {
break; break;
} }
} else if (this.data.prize && this.data.prize.image) { } else if (this.data.prize && this.data.prize.image) {
if (this.data.level == 120) {//120关不显示闯关按钮,换图
this.againBtn.visible = false;
this.goPrizeBtn.visible = false;
} else {
this.noPrizeAgainBtn.visible = false; this.noPrizeAgainBtn.visible = false;
}
this.prop.visible = false; this.prop.visible = false;
this.prizeImg.texture = Texture.fromUrl(this.data.prize.image); this.prizeImg.texture = Texture.fromUrl(this.data.prize.image);
this.tipsTex.text = '\t\t闯关成功!获得抽大奖机会!'; this.tipsTex.text = '\t\t闯关成功!获得抽大奖机会!';
...@@ -104,13 +110,13 @@ export class SuccessPrizePanel extends Panel { ...@@ -104,13 +110,13 @@ export class SuccessPrizePanel extends Panel {
} }
private lightEffect() { private lightEffect() {
Tween.get(this.light1, {loop: true}) Tween.get(this.light1, { loop: true })
.set({anchorX: 219.5, anchorY: 219.5}) .set({ anchorX: 219.5, anchorY: 219.5 })
.to({rotation: 360}, 12000); .to({ rotation: 360 }, 12000);
Tween.get(this.light2, {loop: true}) Tween.get(this.light2, { loop: true })
.set({anchorX: 219.5, anchorY: 219.5}) .set({ anchorX: 219.5, anchorY: 219.5 })
.to({rotation: -360}, 12000); .to({ rotation: -360 }, 12000);
} }
start(data) { start(data) {
...@@ -121,7 +127,7 @@ export class SuccessPrizePanel extends Panel { ...@@ -121,7 +127,7 @@ export class SuccessPrizePanel extends Panel {
* 挑战满星 * 挑战满星
*/ */
private again() { private again() {
changeScene(MapScene, {level: this.data.level}); changeScene(MapScene, { level: this.data.level });
super.hidePanel(); super.hidePanel();
} }
...@@ -132,7 +138,7 @@ export class SuccessPrizePanel extends Panel { ...@@ -132,7 +138,7 @@ export class SuccessPrizePanel extends Panel {
if (this.data.level == 120) { if (this.data.level == 120) {
changeScene(MapScene); changeScene(MapScene);
} else { } else {
changeScene(MapScene, {level: this.data.level + 1}); changeScene(MapScene, { level: this.data.level + 1 });
} }
super.hidePanel(); super.hidePanel();
} }
...@@ -140,7 +146,7 @@ export class SuccessPrizePanel extends Panel { ...@@ -140,7 +146,7 @@ export class SuccessPrizePanel extends Panel {
public goPrize() { public goPrize() {
// 去抽奖 // 去抽奖
changeScene(LotteryScene, {level: this.data.level}) changeScene(LotteryScene, { level: this.data.level })
super.hidePanel(); super.hidePanel();
} }
......
...@@ -25,15 +25,20 @@ export class LotteryScene extends Scene { ...@@ -25,15 +25,20 @@ export class LotteryScene extends Scene {
//背景 //背景
this.addChild(new FYGE.Sprite(RES.getRes("lotteryMachineBg.jpg"))) this.addChild(new FYGE.Sprite(RES.getRes("lotteryMachineBg.jpg")))
//计算下一关的关数 //计算下一关的关数
let upLevel: number = 120; // let upLevel: number = 120;
let dLevel: number = 120; // let dLevel: number = 120;
Tools.baseInfo.prizeLevels.forEach((value, index) => { // Tools.baseInfo.prizeLevels.forEach((value, index) => {
const d: number = value - this.data.level; // const d: number = value - this.data.level;
if (this.data.level <= value && d >= 0 && d <= dLevel) { // if (this.data.level <= value && d >= 0 && d <= dLevel) {
upLevel = value; // upLevel = value;
dLevel = d + 1; // dLevel = d + 1;
} // }
}); // });
Tools.baseInfo.prizeLevels.sort((a, b) => {
return a - b
})
var index = Tools.baseInfo.prizeLevels.indexOf(this.data.level);
let upLevel = Tools.baseInfo.prizeLevels[index + 1]
//标题文案 //标题文案
this.addChild(Tools.getText( this.addChild(Tools.getText(
this.data.level + "关抽奖奖励", this.data.level + "关抽奖奖励",
...@@ -46,7 +51,7 @@ export class LotteryScene extends Scene { ...@@ -46,7 +51,7 @@ export class LotteryScene extends Scene {
)).bold = true; )).bold = true;
//下一次抽奖文案 //下一次抽奖文案
this.addChild(Tools.getText( this.addChild(Tools.getText(
"下一奖励关卡:" + upLevel + "关", upLevel ? "下一奖励关卡:" + upLevel + "关" : "",
32.54, 32.54,
"#ffffff", "#ffffff",
FYGE.TEXT_ALIGN.CENTER, FYGE.TEXT_ALIGN.CENTER,
......
...@@ -63,6 +63,8 @@ import { MapScene } from './map/MapScene'; ...@@ -63,6 +63,8 @@ import { MapScene } from './map/MapScene';
import { NoStepPanel } from '../panels/NoStepPanel'; import { NoStepPanel } from '../panels/NoStepPanel';
import { FirstPropGift } from '../something/uis/FirstPropGift'; import { FirstPropGift } from '../something/uis/FirstPropGift';
import { bonus_lottie } from '../lotties/bonus_lottie'; import { bonus_lottie } from '../lotties/bonus_lottie';
import { GDispatcher } from '../Main';
import { G_EVENT } from '../common/G_EVENT';
const aniClass = { const aniClass = {
"BoomAni": BoomAni, "BoomAni": BoomAni,
...@@ -2906,6 +2908,18 @@ class SettingBtn extends FYGE.Container { ...@@ -2906,6 +2908,18 @@ class SettingBtn extends FYGE.Container {
//播放或暂停音乐接口 //播放或暂停音乐接口
sendTbNet(TbNetName.openMusic, { isOn: this.isOn }) sendTbNet(TbNetName.openMusic, { isOn: this.isOn })
}, this); }, this);
//默认开启
this.isOn = true;
sendTbNet(TbNetName.openMusic, { isOn: this.isOn })
//添加onSHow事件
GDispatcher.addEventListener(G_EVENT.ON_SHOW, this.onShow, this)
}
onShow() {
if (this.isOn) sendTbNet(TbNetName.openMusic, { isOn: true })
}
destroy() {
GDispatcher.removeEventListener(G_EVENT.ON_SHOW, this.onShow, this)
super.destroy()
} }
}); });
musicBtn.position.set(11, 97); musicBtn.position.set(11, 97);
...@@ -2917,8 +2931,11 @@ class SettingBtn extends FYGE.Container { ...@@ -2917,8 +2931,11 @@ class SettingBtn extends FYGE.Container {
musicBtn.visible = !musicBtn.visible musicBtn.visible = !musicBtn.visible
bg.visible = !bg.visible bg.visible = !bg.visible
}, this) }, this)
}
destroy() {
console.log(btn) //关闭音乐
sendTbNet(TbNetName.openMusic, { isOn: false })
super.destroy()
} }
} }
\ 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