Commit 74debd0a authored by wjf's avatar wjf

l

parent 334469c5
......@@ -56,11 +56,11 @@
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)
var mouseEvent = main.stage.onMouseEvent.bind(main.stage);
canvas.addEventListener("touchstart", mouseEvent, false);
canvas.addEventListener('touchmove', mouseEvent, false);
canvas.addEventListener('touchend', mouseEvent, false);
window.stage = main.stage
})
......
......@@ -1746,7 +1746,6 @@ var Main = (function () {
exports.GDispatcher.dispatchEvent({ type: G_EVENT_1.G_EVENT.ON_SHOW });
};
Main.prototype.pause = function () {
this._pause = true;
exports.GDispatcher.dispatchEvent({ type: G_EVENT_1.G_EVENT.ON_HIDE });
};
Main.prototype.addGlobalEvent = function (name, fun, thisObj, once) {
......@@ -1777,6 +1776,34 @@ var Main = (function () {
return 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 = {
}
}
],
"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) {
}
}
});
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.textWidth = 750;
this.tipsTex.x = 0;
......@@ -17861,6 +17888,8 @@ var SuccessPrizePanel = (function (_super) {
this.checkTex.textWidth = 750;
this.checkTex.x = 0;
this.checkTex.textAlign = TEXT_ALIGN.CENTER;
this.tipsTex.textWidth = 750;
this.tipsTex.x = 0;
this.tipsTex.textAlign = TEXT_ALIGN.CENTER;
this.starGroup = this.addChild(new SuccessNoPrizePanel_1.SuccessStarGroup());
this.starGroup.position.set(373, 678);
......@@ -17874,6 +17903,7 @@ var SuccessPrizePanel = (function (_super) {
this.againBtn.visible = false;
this.goPrizeBtn.visible = false;
this.prizeImg.visible = false;
this.tipsTex.text = '\t\t满星过关!';
switch (this.data.tool.type) {
case PropType_1.PropType.BOOMS:
propImg.texture = RES_1.RES.getRes('boomBtn.png');
......@@ -17893,9 +17923,16 @@ var SuccessPrizePanel = (function (_super) {
}
}
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.prop.visible = false;
this.prizeImg.texture = Texture.fromUrl(this.data.prize.image);
this.tipsTex.text = '\t\t闯关成功!获得抽大奖机会!';
}
};
SuccessPrizePanel.prototype.lightEffect = function () {
......@@ -18634,20 +18671,15 @@ var LotteryScene = (function (_super) {
configurable: true
});
LotteryScene.prototype.initUi = function () {
var _this = this;
this.y = -layers_1.layers.stageOffsetY;
this.addChild(new FYGE.Sprite(RES_1.RES.getRes("lotteryMachineBg.jpg")));
var upLevel = 120;
var dLevel = 120;
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;
}
Tools_1.Tools.baseInfo.prizeLevels.sort(function (a, b) {
return a - b;
});
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("下一奖励关卡:" + 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")))
.addEventListener(FYGE.MouseEvent.CLICK, this.lottery, this)
.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
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 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 = {
"BoomAni": BoomAni_1.BoomAni,
"IceAni": IceAni_1.IceAni,
......@@ -21132,8 +21166,19 @@ var SettingBtn = (function (_super) {
_this.texture = RES_1.RES.getRes(_this.isOn ? "musicOn.png" : "musicOff.png");
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.openMusic, { isOn: _this.isOn });
}, _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;
}
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;
}(FYGE.Sprite)));
musicBtn.position.set(11, 97);
......@@ -21144,9 +21189,12 @@ var SettingBtn = (function (_super) {
musicBtn.visible = !musicBtn.visible;
bg.visible = !bg.visible;
}, _this);
console.log(btn);
return _this;
}
SettingBtn.prototype.destroy = function () {
TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.openMusic, { isOn: false });
_super.prototype.destroy.call(this);
};
return SettingBtn;
}(FYGE.Container));
......@@ -21222,6 +21270,7 @@ var CheckBtn = (function (_super) {
Object.defineProperty(CheckBtn.prototype, "data", {
set: function (data) {
this._data = data;
this.checkData.isPlayed = true;
if (!data)
return;
if (!data.isVisitSuccess)
......@@ -22089,6 +22138,8 @@ var TaskPanel_1 = __webpack_require__(/*! ../../panels/TaskPanel */ "./src/panel
var TaoBaoNet_1 = __webpack_require__(/*! ../../TaoBaoNet */ "./src/TaoBaoNet.ts");
var Texture = FYGE.Texture;
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) {
__extends(MapUI, _super);
function MapUI() {
......@@ -22123,7 +22174,8 @@ var MapUI = (function (_super) {
break;
case this.myPrizeBtn:
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;
case this.prizeBox:
console.log('奖励盒子');
......@@ -22222,6 +22274,7 @@ var CreditsBox = (function (_super) {
return [4, this.updateCredits()];
case 1:
_a.sent();
Main_1.GDispatcher.addEventListener(G_EVENT_1.G_EVENT.ON_SHOW, this.updateCredits, this);
return [2];
}
});
......@@ -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;
}(Container));
var PrizeBox = (function (_super) {
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"groups": [
{
"keys": "amazing.png,great.png,img_0.png,img_1.png,img_10.png,img_11.png,img_12.png,img_13.png,img_14.png,img_15.png,img_16.png,img_17.png,img_18.png,img_19.png,img_2.png,img_3.png,img_4.png,img_5.png,img_6.png,img_7.png,img_8.png,img_9.png,wonderful.png",
"name": "bonusTime"
},
{
"keys": "增加体力背景.png,无字按钮底.png",
"name": "BuyPowerPanel"
},
{
"keys": "boomBtn.png,comCloseBtn.png,comm_light.png,ele0.png,ele1.png,ele10.png,ele11.png,ele12.png,ele13.png,ele14.png,ele2.png,ele3.png,ele4.png,ele5.png,ele6.png,ele7.png,ele8.png,ele9.png,hammerBtn.png,star.png,stepBtn.png,toastBg.png,waitingBg.png,waitingRot.png,关闭按钮.png,再想想.png,开始闯关不要能量.png,开始闯关要能量.png,确定.png,继续闯关大.png,继续闯关小.png",
"name": "common"
},
{
"keys": "积分不足背景.png,赚取积分.png",
"name": "CreditsOutPanel"
......@@ -16,6 +24,14 @@
"keys": "失败Bg.png,失败重新闯关.png",
"name": "FailedPanel"
},
{
"keys": "fesEleSmallDis1.png,fesEleSmallDis10.png,fesEleSmallDis2.png,fesEleSmallDis3.png,fesEleSmallDis4.png,fesEleSmallDis5.png,fesEleSmallDis6.png,fesEleSmallDis7.png,fesEleSmallDis8.png,fesEleSmallDis9.png,fesRedBigLight.png,fesRedBombSta1.png,fesRedCap.png,fesRedDown.png,fesRedSmallLight.png,fesRedUp.png,festivalTargetBg.png,lineLight1.png,lineLight10.png,lineLight11.png,lineLight12.png,lineLight13.png,lineLight2.png,lineLight3.png,lineLight4.png,lineLight5.png,lineLight6.png,lineLight7.png,lineLight8.png,lineLight9.png,xingxingbi.png",
"name": "festival"
},
{
"keys": "dis_ele0_0.png,dis_ele0_1.png,dis_ele0_10.png,dis_ele0_11.png,dis_ele0_12.png,dis_ele0_13.png,dis_ele0_14.png,dis_ele0_2.png,dis_ele0_3.png,dis_ele0_4.png,dis_ele0_5.png,dis_ele0_6.png,dis_ele0_7.png,dis_ele0_8.png,dis_ele0_9.png,dis_ele1_0.png,dis_ele1_1.png,dis_ele1_10.png,dis_ele1_11.png,dis_ele1_12.png,dis_ele1_13.png,dis_ele1_14.png,dis_ele1_2.png,dis_ele1_3.png,dis_ele1_4.png,dis_ele1_5.png,dis_ele1_6.png,dis_ele1_7.png,dis_ele1_8.png,dis_ele1_9.png,dis_ele2_0.png,dis_ele2_1.png,dis_ele2_10.png,dis_ele2_11.png,dis_ele2_12.png,dis_ele2_13.png,dis_ele2_14.png,dis_ele2_2.png,dis_ele2_3.png,dis_ele2_4.png,dis_ele2_5.png,dis_ele2_6.png,dis_ele2_7.png,dis_ele2_8.png,dis_ele2_9.png,dis_ele3_.png,dis_ele3_0.png,dis_ele3_1.png,dis_ele3_10.png,dis_ele3_11.png,dis_ele3_12.png,dis_ele3_13.png,dis_ele3_14.png,dis_ele3_2.png,dis_ele3_3.png,dis_ele3_4.png,dis_ele3_6.png,dis_ele3_7.png,dis_ele3_8.png,dis_ele3_9.png,dis_ele4_0.png,dis_ele4_1.png,dis_ele4_10.png,dis_ele4_11.png,dis_ele4_12.png,dis_ele4_13.png,dis_ele4_14.png,dis_ele4_2.png,dis_ele4_3.png,dis_ele4_4.png,dis_ele4_5.png,dis_ele4_6.png,dis_ele4_7.png,dis_ele4_8.png,dis_ele4_9.png,hor_ele0_0.png,hor_ele0_1.png,hor_ele0_10.png,hor_ele0_11.png,hor_ele0_12.png,hor_ele0_13.png,hor_ele0_14.png,hor_ele0_15.png,hor_ele0_2.png,hor_ele0_3.png,hor_ele0_4.png,hor_ele0_5.png,hor_ele0_6.png,hor_ele0_7.png,hor_ele0_8.png,hor_ele0_9.png,hor_ele1_0.png,hor_ele1_1.png,hor_ele1_10.png,hor_ele1_11.png,hor_ele1_12.png,hor_ele1_13.png,hor_ele1_14.png,hor_ele1_15.png,hor_ele1_2.png,hor_ele1_3.png,hor_ele1_4.png,hor_ele1_5.png,hor_ele1_6.png,hor_ele1_7.png,hor_ele1_8.png,hor_ele1_9.png,hor_ele2_0.png,hor_ele2_1.png,hor_ele2_10.png,hor_ele2_11.png,hor_ele2_12.png,hor_ele2_13.png,hor_ele2_14.png,hor_ele2_15.png,hor_ele2_2.png,hor_ele2_3.png,hor_ele2_4.png,hor_ele2_5.png,hor_ele2_6.png,hor_ele2_7.png,hor_ele2_8.png,hor_ele2_9.png,hor_ele3_0.png,hor_ele3_1.png,hor_ele3_10.png,hor_ele3_11.png,hor_ele3_12.png,hor_ele3_13.png,hor_ele3_14.png,hor_ele3_15.png,hor_ele3_2.png,hor_ele3_3.png,hor_ele3_4.png,hor_ele3_5.png,hor_ele3_6.png,hor_ele3_7.png,hor_ele3_8.png,hor_ele3_9.png,hor_ele4_0.png,hor_ele4_1.png,hor_ele4_10.png,hor_ele4_11.png,hor_ele4_12.png,hor_ele4_13.png,hor_ele4_14.png,hor_ele4_15.png,hor_ele4_2.png,hor_ele4_3.png,hor_ele4_4.png,hor_ele4_5.png,hor_ele4_6.png,hor_ele4_7.png,hor_ele4_8.png,hor_ele4_9.png,ver_ele0_0.png,ver_ele0_1.png,ver_ele0_10.png,ver_ele0_11.png,ver_ele0_12.png,ver_ele0_13.png,ver_ele0_14.png,ver_ele0_15.png,ver_ele0_2.png,ver_ele0_3.png,ver_ele0_4.png,ver_ele0_5.png,ver_ele0_6.png,ver_ele0_7.png,ver_ele0_8.png,ver_ele0_9.png,ver_ele1_0.png,ver_ele1_1.png,ver_ele1_10.png,ver_ele1_11.png,ver_ele1_12.png,ver_ele1_13.png,ver_ele1_14.png,ver_ele1_15.png,ver_ele1_2.png,ver_ele1_3.png,ver_ele1_4.png,ver_ele1_5.png,ver_ele1_6.png,ver_ele1_7.png,ver_ele1_8.png,ver_ele1_9.png,ver_ele2_0.png,ver_ele2_1.png,ver_ele2_10.png,ver_ele2_11.png,ver_ele2_12.png,ver_ele2_13.png,ver_ele2_14.png,ver_ele2_15.png,ver_ele2_2.png,ver_ele2_3.png,ver_ele2_4.png,ver_ele2_5.png,ver_ele2_6.png,ver_ele2_7.png,ver_ele2_8.png,ver_ele2_9.png,ver_ele3_0.png,ver_ele3_1.png,ver_ele3_10.png,ver_ele3_11.png,ver_ele3_12.png,ver_ele3_13.png,ver_ele3_14.png,ver_ele3_15.png,ver_ele3_2.png,ver_ele3_3.png,ver_ele3_4.png,ver_ele3_5.png,ver_ele3_6.png,ver_ele3_7.png,ver_ele3_8.png,ver_ele3_9.png,ver_ele4_0.png,ver_ele4_1.png,ver_ele4_10.png,ver_ele4_11.png,ver_ele4_12.png,ver_ele4_13.png,ver_ele4_14.png,ver_ele4_15.png,ver_ele4_2.png,ver_ele4_3.png,ver_ele4_4.png,ver_ele4_5.png,ver_ele4_6.png,ver_ele4_7.png,ver_ele4_8.png,ver_ele4_9.png",
"name": "fiveVerHorDis"
},
{
"keys": "圆圈.png,开心收下.png",
"name": "FreePowerPanel"
......@@ -24,6 +40,34 @@
"keys": "joinBg.png,joinBtn.png",
"name": "JoinPanel"
},
{
"keys": "carb_arm.png,carb_body.png,carb_hand_l.png,carb_hand_r.png,fox_arm_l.png,fox_body.png,fox_head.png,fox_tail0.png,fox_tail1.png,fox_tail10.png,fox_tail11.png,fox_tail12.png,fox_tail13.png,fox_tail14.png,fox_tail2.png,fox_tail3.png,fox_tail4.png,fox_tail5.png,fox_tail6.png,fox_tail7.png,fox_tail8.png,fox_tail9.png,hommer.png,img_line1.png,img_line2.png,img_line3.png,img_line4.png,img_line5.png,img_owl.png,img_tree.png,lighting_1.png,lighting_2.png,loadingBg.jpg,loadingBg2.png,loadingPro0.png,loadingPro1.png,loadingPro10.png,loadingPro11.png,loadingPro2.png,loadingPro3.png,loadingPro4.png,loadingPro5.png,loadingPro6.png,loadingPro7.png,loadingPro8.png,loadingPro9.png,loadingTitle.png,owl_sleep.png,proDown.png,wheel.png",
"name": "loadingScene"
},
{
"keys": "lotteryBtn.png,lotteryItemBg.png,lotteryMachineBg.jpg,lotteryReturnBtn.png,prizeItemBg.png,shadowMask.png",
"name": "lotteryScene"
},
{
"keys": "cur_light_1.png,cur_light_2.png,guide_fox.png,guide_hand.png,guide_light.png,guide_tip.png,map_avatar_bg.png,map_bg1.jpg,map_bg2.jpg,map_bg3.jpg,map_check_disable.png,map_check_disable_prize.png,map_check_enable.png,map_check_enable_cur.png,map_creditsBg.png,map_energyAdd.png,map_energyBg.png,map_prizeBox.png,map_prizeBtn.png,map_ruleBtn.png,map_star_disable.png,map_star_enable.png,map_taskBtn.png,map_推车.png,map_狐狸气球.png,water1.png,water2.png",
"name": "map"
},
{
"keys": "prize_check_0.png,prize_check_1.png,prize_check_10.png,prize_check_11.png,prize_check_12.png,prize_check_13.png,prize_check_14.png,prize_check_15.png,prize_check_16.png,prize_check_2.png,prize_check_3.png,prize_check_4.png,prize_check_5.png,prize_check_6.png,prize_check_7.png,prize_check_8.png,prize_check_9.png",
"name": "mapCheckPrizeEffect"
},
{
"keys": "map_crab_0.png,map_crab_1.png,map_crab_10.png,map_crab_11.png,map_crab_12.png,map_crab_13.png,map_crab_14.png,map_crab_15.png,map_crab_16.png,map_crab_17.png,map_crab_18.png,map_crab_19.png,map_crab_2.png,map_crab_20.png,map_crab_21.png,map_crab_22.png,map_crab_23.png,map_crab_24.png,map_crab_25.png,map_crab_26.png,map_crab_27.png,map_crab_28.png,map_crab_29.png,map_crab_3.png,map_crab_30.png,map_crab_4.png,map_crab_5.png,map_crab_6.png,map_crab_7.png,map_crab_8.png,map_crab_9.png",
"name": "mapCrabEffect"
},
{
"keys": "map_owl_0.png,map_owl_1.png,map_owl_10.png,map_owl_11.png,map_owl_12.png,map_owl_13.png,map_owl_14.png,map_owl_15.png,map_owl_2.png,map_owl_3.png,map_owl_4.png,map_owl_5.png,map_owl_6.png,map_owl_7.png,map_owl_8.png,map_owl_9.png",
"name": "mapOwlEffect"
},
{
"keys": "map_whale_0.png,map_whale_1.png,map_whale_10.png,map_whale_11.png,map_whale_12.png,map_whale_2.png,map_whale_3.png,map_whale_4.png,map_whale_5.png,map_whale_6.png,map_whale_7.png,map_whale_8.png,map_whale_9.png",
"name": "mapWhaleEffect"
},
{
"keys": "体力不足Bg.png,体力不足按钮.png",
"name": "NoEnergyPanel"
......@@ -36,6 +80,10 @@
"keys": "步数耗尽Bg.png,步数耗尽复活.png,步数耗尽结束按钮.png",
"name": "NoStepPanel"
},
{
"keys": "blueDoorBg.png,bonusFra0.png,bonusFra1.png,bonusFra10.png,bonusFra11.png,bonusFra2.png,bonusFra3.png,bonusFra4.png,bonusFra5.png,bonusFra6.png,bonusFra7.png,bonusFra8.png,bonusFra9.png,bonusShoot.png,boom0.png,boom1.png,boom10.png,boom11.png,boom12.png,boom13.png,boom14.png,boom15.png,boom16.png,boom17.png,boom18.png,boom19.png,boom2.png,boom20.png,boom3.png,boom4.png,boom5.png,boom6.png,boom7.png,boom8.png,boom9.png,brownBallFace.png,bubbleStar1.png,bubbleStar10.png,bubbleStar11.png,bubbleStar12.png,bubbleStar13.png,bubbleStar14.png,bubbleStar15.png,bubbleStar16.png,bubbleStar17.png,bubbleStar18.png,bubbleStar19.png,bubbleStar2.png,bubbleStar3.png,bubbleStar4.png,bubbleStar5.png,bubbleStar6.png,bubbleStar7.png,bubbleStar8.png,bubbleStar9.png,bubleEle0.png,bubleEle1.png,bubleEle2.png,bubleEle3.png,bubleEle4.png,chapterNum0.png,chapterNum1.png,chapterNum2.png,chapterNum3.png,chapterNum4.png,chapterNum5.png,chapterNum6.png,chapterNum7.png,chapterNum8.png,chapterNum9.png,chapterNum关.png,chapterNum第.png,chooseRect.png,doorClosed.png,doorOpen.png,eggPiece1.png,eggPiece2.png,eggPiece3.png,eggPiece4.png,eggPiece5.png,eggStatus0.png,eggStatus1.png,eggStatus2.png,ele0Exp.png,ele1Exp.png,ele2Exp.png,ele3Exp.png,ele4Exp.png,exLighting0.png,exLighting10.png,exLighting13.png,exLighting15.png,exLighting17.png,exLighting18.png,exLighting2.png,exLighting20.png,exLighting22.png,exLighting24.png,exLighting26.png,exLighting28.png,exLighting31.png,exLighting33.png,exLighting4.png,exLighting6.png,exLighting8.png,eyeDownLeft.png,eyeDownRight.png,eyeSingle.png,gameGuideBoard.png,greenCircleDown.png,greenCircleUp.png,greyBallFace.png,guidePropBoom.png,guidePropCow.png,guidePropHammer.png,guidePropHand.png,guidePropMsgPanel.png,guidePropShoe.png,hairballDisBg.png,hairballPiece1.png,hairballPiece2.png,hairballPiece3.png,hairballPiece4.png,hairballPiece5.png,hairballPiece6.png,hairballPiece7.png,hairballPiece8.png,hairballPiece9.png,ice2.png,ice3.png,ice4.png,ice5.png,ice6.png,jellyArrow.png,leftArrow.png,lightedStar.png,lineLight.png,lockVine.png,magicLion.png,magicLionBg.png,main_mapbottom.png,musicOff.png,musicOn.png,playBg.jpg,propNum0.png,propNum1.png,propNum2.png,propNum3.png,propNum4.png,propNum5.png,propNum6.png,propNum7.png,propNum8.png,propNum9.png,rectLat.png,rectLatWhite.png,redDoorBg.png,rightArrow.png,rightMark.png,rock2.png,rock3.png,rock4.png,rock5.png,rock6.png,scoreNum0.png,scoreNum1.png,scoreNum2.png,scoreNum3.png,scoreNum4.png,scoreNum5.png,scoreNum6.png,scoreNum7.png,scoreNum8.png,scoreNum9.png,scoreNum关.png,scoreNum冒号.png,scoreNum分.png,scoreNum数.png,scoreNum通.png,settingBg.png,settingBtn.png,starProgress.png,stepAni1.png,stepAni10.png,stepAni11.png,stepAni2.png,stepAni3.png,stepAni4.png,stepAni5.png,stepAni6.png,stepAni7.png,stepAni8.png,stepAni9.png,stepNum0.png,stepNum1.png,stepNum2.png,stepNum3.png,stepNum4.png,stepNum5.png,stepNum6.png,stepNum7.png,stepNum8.png,stepNum9.png,table.png,tarNum0.png,tarNum1.png,tarNum2.png,tarNum3.png,tarNum4.png,tarNum5.png,tarNum6.png,tarNum7.png,tarNum8.png,tarNum9.png,topBg.png,unlightedStar.png,yellowCircleDown.png,yellowCircleUp.png,yellowDoorBg.png",
"name": "playScene"
},
{
"keys": "prizePanel.png,prizePanelBtn.png",
"name": "PrizePanel"
......@@ -44,6 +92,10 @@
"keys": "活动规则背景.png",
"name": "RulePanel"
},
{
"keys": "star_light_0.png,star_light_1.png,star_light_10.png,star_light_11.png,star_light_12.png,star_light_13.png,star_light_14.png,star_light_15.png,star_light_2.png,star_light_3.png,star_light_4.png,star_light_5.png,star_light_6.png,star_light_7.png,star_light_8.png,star_light_9.png",
"name": "starLight"
},
{
"keys": "开始闯关Bg.png",
"name": "StartPanel"
......@@ -67,58 +119,6 @@
{
"keys": "使用道具背景.png",
"name": "UseToolPanel"
},
{
"keys": "amazing.png,great.png,img_0.png,img_1.png,img_10.png,img_11.png,img_12.png,img_13.png,img_14.png,img_15.png,img_16.png,img_17.png,img_18.png,img_19.png,img_2.png,img_3.png,img_4.png,img_5.png,img_6.png,img_7.png,img_8.png,img_9.png,wonderful.png",
"name": "bonusTime"
},
{
"keys": "boomBtn.png,comCloseBtn.png,comm_light.png,ele0.png,ele1.png,ele10.png,ele11.png,ele12.png,ele13.png,ele14.png,ele2.png,ele3.png,ele4.png,ele5.png,ele6.png,ele7.png,ele8.png,ele9.png,hammerBtn.png,star.png,stepBtn.png,toastBg.png,waitingBg.png,waitingRot.png,关闭按钮.png,再想想.png,开始闯关不要能量.png,开始闯关要能量.png,确定.png,继续闯关大.png,继续闯关小.png",
"name": "common"
},
{
"keys": "fesEleSmallDis1.png,fesEleSmallDis10.png,fesEleSmallDis2.png,fesEleSmallDis3.png,fesEleSmallDis4.png,fesEleSmallDis5.png,fesEleSmallDis6.png,fesEleSmallDis7.png,fesEleSmallDis8.png,fesEleSmallDis9.png,fesRedBigLight.png,fesRedBombSta1.png,fesRedCap.png,fesRedDown.png,fesRedSmallLight.png,fesRedUp.png,festivalTargetBg.png,lineLight1.png,lineLight10.png,lineLight11.png,lineLight12.png,lineLight13.png,lineLight2.png,lineLight3.png,lineLight4.png,lineLight5.png,lineLight6.png,lineLight7.png,lineLight8.png,lineLight9.png,xingxingbi.png",
"name": "festival"
},
{
"keys": "dis_ele0_0.png,dis_ele0_1.png,dis_ele0_10.png,dis_ele0_11.png,dis_ele0_12.png,dis_ele0_13.png,dis_ele0_14.png,dis_ele0_2.png,dis_ele0_3.png,dis_ele0_4.png,dis_ele0_5.png,dis_ele0_6.png,dis_ele0_7.png,dis_ele0_8.png,dis_ele0_9.png,dis_ele1_0.png,dis_ele1_1.png,dis_ele1_10.png,dis_ele1_11.png,dis_ele1_12.png,dis_ele1_13.png,dis_ele1_14.png,dis_ele1_2.png,dis_ele1_3.png,dis_ele1_4.png,dis_ele1_5.png,dis_ele1_6.png,dis_ele1_7.png,dis_ele1_8.png,dis_ele1_9.png,dis_ele2_0.png,dis_ele2_1.png,dis_ele2_10.png,dis_ele2_11.png,dis_ele2_12.png,dis_ele2_13.png,dis_ele2_14.png,dis_ele2_2.png,dis_ele2_3.png,dis_ele2_4.png,dis_ele2_5.png,dis_ele2_6.png,dis_ele2_7.png,dis_ele2_8.png,dis_ele2_9.png,dis_ele3_.png,dis_ele3_0.png,dis_ele3_1.png,dis_ele3_10.png,dis_ele3_11.png,dis_ele3_12.png,dis_ele3_13.png,dis_ele3_14.png,dis_ele3_2.png,dis_ele3_3.png,dis_ele3_4.png,dis_ele3_6.png,dis_ele3_7.png,dis_ele3_8.png,dis_ele3_9.png,dis_ele4_0.png,dis_ele4_1.png,dis_ele4_10.png,dis_ele4_11.png,dis_ele4_12.png,dis_ele4_13.png,dis_ele4_14.png,dis_ele4_2.png,dis_ele4_3.png,dis_ele4_4.png,dis_ele4_5.png,dis_ele4_6.png,dis_ele4_7.png,dis_ele4_8.png,dis_ele4_9.png,hor_ele0_0.png,hor_ele0_1.png,hor_ele0_10.png,hor_ele0_11.png,hor_ele0_12.png,hor_ele0_13.png,hor_ele0_14.png,hor_ele0_15.png,hor_ele0_2.png,hor_ele0_3.png,hor_ele0_4.png,hor_ele0_5.png,hor_ele0_6.png,hor_ele0_7.png,hor_ele0_8.png,hor_ele0_9.png,hor_ele1_0.png,hor_ele1_1.png,hor_ele1_10.png,hor_ele1_11.png,hor_ele1_12.png,hor_ele1_13.png,hor_ele1_14.png,hor_ele1_15.png,hor_ele1_2.png,hor_ele1_3.png,hor_ele1_4.png,hor_ele1_5.png,hor_ele1_6.png,hor_ele1_7.png,hor_ele1_8.png,hor_ele1_9.png,hor_ele2_0.png,hor_ele2_1.png,hor_ele2_10.png,hor_ele2_11.png,hor_ele2_12.png,hor_ele2_13.png,hor_ele2_14.png,hor_ele2_15.png,hor_ele2_2.png,hor_ele2_3.png,hor_ele2_4.png,hor_ele2_5.png,hor_ele2_6.png,hor_ele2_7.png,hor_ele2_8.png,hor_ele2_9.png,hor_ele3_0.png,hor_ele3_1.png,hor_ele3_10.png,hor_ele3_11.png,hor_ele3_12.png,hor_ele3_13.png,hor_ele3_14.png,hor_ele3_15.png,hor_ele3_2.png,hor_ele3_3.png,hor_ele3_4.png,hor_ele3_5.png,hor_ele3_6.png,hor_ele3_7.png,hor_ele3_8.png,hor_ele3_9.png,hor_ele4_0.png,hor_ele4_1.png,hor_ele4_10.png,hor_ele4_11.png,hor_ele4_12.png,hor_ele4_13.png,hor_ele4_14.png,hor_ele4_15.png,hor_ele4_2.png,hor_ele4_3.png,hor_ele4_4.png,hor_ele4_5.png,hor_ele4_6.png,hor_ele4_7.png,hor_ele4_8.png,hor_ele4_9.png,ver_ele0_0.png,ver_ele0_1.png,ver_ele0_10.png,ver_ele0_11.png,ver_ele0_12.png,ver_ele0_13.png,ver_ele0_14.png,ver_ele0_15.png,ver_ele0_2.png,ver_ele0_3.png,ver_ele0_4.png,ver_ele0_5.png,ver_ele0_6.png,ver_ele0_7.png,ver_ele0_8.png,ver_ele0_9.png,ver_ele1_0.png,ver_ele1_1.png,ver_ele1_10.png,ver_ele1_11.png,ver_ele1_12.png,ver_ele1_13.png,ver_ele1_14.png,ver_ele1_15.png,ver_ele1_2.png,ver_ele1_3.png,ver_ele1_4.png,ver_ele1_5.png,ver_ele1_6.png,ver_ele1_7.png,ver_ele1_8.png,ver_ele1_9.png,ver_ele2_0.png,ver_ele2_1.png,ver_ele2_10.png,ver_ele2_11.png,ver_ele2_12.png,ver_ele2_13.png,ver_ele2_14.png,ver_ele2_15.png,ver_ele2_2.png,ver_ele2_3.png,ver_ele2_4.png,ver_ele2_5.png,ver_ele2_6.png,ver_ele2_7.png,ver_ele2_8.png,ver_ele2_9.png,ver_ele3_0.png,ver_ele3_1.png,ver_ele3_10.png,ver_ele3_11.png,ver_ele3_12.png,ver_ele3_13.png,ver_ele3_14.png,ver_ele3_15.png,ver_ele3_2.png,ver_ele3_3.png,ver_ele3_4.png,ver_ele3_5.png,ver_ele3_6.png,ver_ele3_7.png,ver_ele3_8.png,ver_ele3_9.png,ver_ele4_0.png,ver_ele4_1.png,ver_ele4_10.png,ver_ele4_11.png,ver_ele4_12.png,ver_ele4_13.png,ver_ele4_14.png,ver_ele4_15.png,ver_ele4_2.png,ver_ele4_3.png,ver_ele4_4.png,ver_ele4_5.png,ver_ele4_6.png,ver_ele4_7.png,ver_ele4_8.png,ver_ele4_9.png",
"name": "fiveVerHorDis"
},
{
"keys": "carb_arm.png,carb_body.png,carb_hand_l.png,carb_hand_r.png,fox_arm_l.png,fox_body.png,fox_head.png,fox_tail0.png,fox_tail1.png,fox_tail10.png,fox_tail11.png,fox_tail12.png,fox_tail13.png,fox_tail14.png,fox_tail2.png,fox_tail3.png,fox_tail4.png,fox_tail5.png,fox_tail6.png,fox_tail7.png,fox_tail8.png,fox_tail9.png,hommer.png,img_line1.png,img_line2.png,img_line3.png,img_line4.png,img_line5.png,img_owl.png,img_tree.png,lighting_1.png,lighting_2.png,loadingBg.jpg,loadingBg2.png,loadingPro0.png,loadingPro1.png,loadingPro10.png,loadingPro11.png,loadingPro2.png,loadingPro3.png,loadingPro4.png,loadingPro5.png,loadingPro6.png,loadingPro7.png,loadingPro8.png,loadingPro9.png,loadingTitle.png,owl_sleep.png,proDown.png,wheel.png",
"name": "loadingScene"
},
{
"keys": "lotteryBtn.png,lotteryItemBg.png,lotteryMachineBg.jpg,lotteryReturnBtn.png,prizeItemBg.png,shadowMask.png",
"name": "lotteryScene"
},
{
"keys": "cur_light_1.png,cur_light_2.png,guide_fox.png,guide_hand.png,guide_light.png,guide_tip.png,map_avatar_bg.png,map_bg1.jpg,map_bg2.jpg,map_bg3.jpg,map_check_disable.png,map_check_disable_prize.png,map_check_enable.png,map_check_enable_cur.png,map_creditsBg.png,map_energyAdd.png,map_energyBg.png,map_prizeBox.png,map_prizeBtn.png,map_ruleBtn.png,map_star_disable.png,map_star_enable.png,map_taskBtn.png,map_推车.png,map_狐狸气球.png,water1.png,water2.png",
"name": "map"
},
{
"keys": "prize_check_0.png,prize_check_1.png,prize_check_10.png,prize_check_11.png,prize_check_12.png,prize_check_13.png,prize_check_14.png,prize_check_15.png,prize_check_16.png,prize_check_2.png,prize_check_3.png,prize_check_4.png,prize_check_5.png,prize_check_6.png,prize_check_7.png,prize_check_8.png,prize_check_9.png",
"name": "mapCheckPrizeEffect"
},
{
"keys": "map_crab_0.png,map_crab_1.png,map_crab_10.png,map_crab_11.png,map_crab_12.png,map_crab_13.png,map_crab_14.png,map_crab_15.png,map_crab_16.png,map_crab_17.png,map_crab_18.png,map_crab_19.png,map_crab_2.png,map_crab_20.png,map_crab_21.png,map_crab_22.png,map_crab_23.png,map_crab_24.png,map_crab_25.png,map_crab_26.png,map_crab_27.png,map_crab_28.png,map_crab_29.png,map_crab_3.png,map_crab_30.png,map_crab_4.png,map_crab_5.png,map_crab_6.png,map_crab_7.png,map_crab_8.png,map_crab_9.png",
"name": "mapCrabEffect"
},
{
"keys": "map_owl_0.png,map_owl_1.png,map_owl_10.png,map_owl_11.png,map_owl_12.png,map_owl_13.png,map_owl_14.png,map_owl_15.png,map_owl_2.png,map_owl_3.png,map_owl_4.png,map_owl_5.png,map_owl_6.png,map_owl_7.png,map_owl_8.png,map_owl_9.png",
"name": "mapOwlEffect"
},
{
"keys": "map_whale_0.png,map_whale_1.png,map_whale_10.png,map_whale_11.png,map_whale_12.png,map_whale_2.png,map_whale_3.png,map_whale_4.png,map_whale_5.png,map_whale_6.png,map_whale_7.png,map_whale_8.png,map_whale_9.png",
"name": "mapWhaleEffect"
},
{
"keys": "blueDoorBg.png,bonusFra0.png,bonusFra1.png,bonusFra10.png,bonusFra11.png,bonusFra2.png,bonusFra3.png,bonusFra4.png,bonusFra5.png,bonusFra6.png,bonusFra7.png,bonusFra8.png,bonusFra9.png,bonusShoot.png,boom0.png,boom1.png,boom10.png,boom11.png,boom12.png,boom13.png,boom14.png,boom15.png,boom16.png,boom17.png,boom18.png,boom19.png,boom2.png,boom20.png,boom3.png,boom4.png,boom5.png,boom6.png,boom7.png,boom8.png,boom9.png,brownBallFace.png,bubbleStar1.png,bubbleStar10.png,bubbleStar11.png,bubbleStar12.png,bubbleStar13.png,bubbleStar14.png,bubbleStar15.png,bubbleStar16.png,bubbleStar17.png,bubbleStar18.png,bubbleStar19.png,bubbleStar2.png,bubbleStar3.png,bubbleStar4.png,bubbleStar5.png,bubbleStar6.png,bubbleStar7.png,bubbleStar8.png,bubbleStar9.png,bubleEle0.png,bubleEle1.png,bubleEle2.png,bubleEle3.png,bubleEle4.png,chapterNum0.png,chapterNum1.png,chapterNum2.png,chapterNum3.png,chapterNum4.png,chapterNum5.png,chapterNum6.png,chapterNum7.png,chapterNum8.png,chapterNum9.png,chapterNum关.png,chapterNum第.png,chooseRect.png,doorClosed.png,doorOpen.png,eggPiece1.png,eggPiece2.png,eggPiece3.png,eggPiece4.png,eggPiece5.png,eggStatus0.png,eggStatus1.png,eggStatus2.png,ele0Exp.png,ele1Exp.png,ele2Exp.png,ele3Exp.png,ele4Exp.png,exLighting0.png,exLighting10.png,exLighting13.png,exLighting15.png,exLighting17.png,exLighting18.png,exLighting2.png,exLighting20.png,exLighting22.png,exLighting24.png,exLighting26.png,exLighting28.png,exLighting31.png,exLighting33.png,exLighting4.png,exLighting6.png,exLighting8.png,eyeDownLeft.png,eyeDownRight.png,eyeSingle.png,gameGuideBoard.png,greenCircleDown.png,greenCircleUp.png,greyBallFace.png,guidePropBoom.png,guidePropCow.png,guidePropHammer.png,guidePropHand.png,guidePropMsgPanel.png,guidePropShoe.png,hairballDisBg.png,hairballPiece1.png,hairballPiece2.png,hairballPiece3.png,hairballPiece4.png,hairballPiece5.png,hairballPiece6.png,hairballPiece7.png,hairballPiece8.png,hairballPiece9.png,ice2.png,ice3.png,ice4.png,ice5.png,ice6.png,jellyArrow.png,leftArrow.png,lightedStar.png,lineLight.png,lockVine.png,magicLion.png,magicLionBg.png,main_mapbottom.png,musicOff.png,musicOn.png,playBg.jpg,propNum0.png,propNum1.png,propNum2.png,propNum3.png,propNum4.png,propNum5.png,propNum6.png,propNum7.png,propNum8.png,propNum9.png,rectLat.png,rectLatWhite.png,redDoorBg.png,rightArrow.png,rightMark.png,rock2.png,rock3.png,rock4.png,rock5.png,rock6.png,scoreNum0.png,scoreNum1.png,scoreNum2.png,scoreNum3.png,scoreNum4.png,scoreNum5.png,scoreNum6.png,scoreNum7.png,scoreNum8.png,scoreNum9.png,scoreNum关.png,scoreNum冒号.png,scoreNum分.png,scoreNum数.png,scoreNum通.png,settingBg.png,settingBtn.png,starProgress.png,stepAni1.png,stepAni10.png,stepAni11.png,stepAni2.png,stepAni3.png,stepAni4.png,stepAni5.png,stepAni6.png,stepAni7.png,stepAni8.png,stepAni9.png,stepNum0.png,stepNum1.png,stepNum2.png,stepNum3.png,stepNum4.png,stepNum5.png,stepNum6.png,stepNum7.png,stepNum8.png,stepNum9.png,table.png,tarNum0.png,tarNum1.png,tarNum2.png,tarNum3.png,tarNum4.png,tarNum5.png,tarNum6.png,tarNum7.png,tarNum8.png,tarNum9.png,topBg.png,unlightedStar.png,yellowCircleDown.png,yellowCircleUp.png,yellowDoorBg.png",
"name": "playScene"
},
{
"keys": "star_light_0.png,star_light_1.png,star_light_10.png,star_light_11.png,star_light_12.png,star_light_13.png,star_light_14.png,star_light_15.png,star_light_2.png,star_light_3.png,star_light_4.png,star_light_5.png,star_light_6.png,star_light_7.png,star_light_8.png,star_light_9.png",
"name": "starLight"
}
],
"path": "./resource/"
......
var fs = require("fs");
var path = require('path');
const { createCanvas, loadImage } = require('canvas')
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,
pot: true,
pot: false,//是否powerOf2
square: false,
allowRotation: true,
tag: false,
border: 2
}; // Set packing options
let packer = new MaxRectsPacker(1024, 1024, 2, options); // width, height, padding, options
// console.log(packer.options)
let input = [ // any object with width & height is OK since v2.1.0
{width: 600, height: 20, name: "tree"},
{width: 20, height: 600, name: "flower"},
// {width: 600, height: 20, name: "tree"},
// {width: 20, height: 600, name: "flower"},
// {width: 2000, height: 2000, name: "oversized background"},
// {width: 1000, height: 1000, name: "background"},
// {width: 1000, height: 1000, name: "overlay"}
];
packer.addArray(input); // Start packing with input array
// packer.next(); // Start a new packer bin
packer.addArray([ {width: 600, height: 20, name: "tree"},
{width: 20, height: 600, name: "flower"},]); // Adding to the new bin
// packer.addArray(input.slice());
// packer.addArray(input.slice());
packer.bins.forEach(bin => {
console.log(bin.rects);
});
// Reuse packer
// let bins = packer.save();
// packer.load(bins);
// console.log(packer.bins)
// packer.addArray(input);
\ No newline at end of file
}; // Set packing options
let packer = new MaxRectsPacker(2048, 2048, 2, options); // width, height, padding, options
// console.log(packer.options)
packer.addArray(images);
packer.bins.forEach((bin, i) => {
console.log(bin);
var canvas = createCanvas(bin.width, bin.height)
var ctx = canvas.getContext("2d");
var obj = {}
bin.rects.forEach((rect) => {
ctx.save()
if (rect.rot) {
ctx.translate(rect.x, rect.y);
ctx.rotate(Math.PI / 2)
ctx.translate(-rect.x, -rect.y);
ctx.drawImage(rect.imgData, rect.x, rect.y - rect.height)
} else {
ctx.drawImage(rect.imgData, rect.x, rect.y)
}
ctx.restore();
//数据
obj[rect.name] = {
"x": rect.x,
"y": rect.y,
"w": rect.width,
"h": rect.height,
"ox": rect.offsetX ? rect.offsetX : 0,
"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 {
}
//在小程序隐藏时调用onHide
pause() {
this._pause = true;
// this._pause = true;//先不暂停了
GDispatcher.dispatchEvent({ type: G_EVENT.ON_HIDE });
}
......@@ -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 source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -28,8 +28,8 @@ export class SuccessPrizePanel extends Panel {
this.isShowing = true;
this.anchor.set(375, 812);
Tween.get(this)
.set({scaleX: 0, scaleY: 0})
.to({scaleX: 1, scaleY: 1}, 400, Ease.backOut)
.set({ scaleX: 0, scaleY: 0 })
.to({ scaleX: 1, scaleY: 1 }, 400, Ease.backOut)
.call(() => {
this.isShowing = false;
});
......@@ -96,7 +96,13 @@ export class SuccessPrizePanel extends Panel {
break;
}
} 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.prop.visible = false;
this.prizeImg.texture = Texture.fromUrl(this.data.prize.image);
this.tipsTex.text = '\t\t闯关成功!获得抽大奖机会!';
......@@ -104,13 +110,13 @@ export class SuccessPrizePanel extends Panel {
}
private lightEffect() {
Tween.get(this.light1, {loop: true})
.set({anchorX: 219.5, anchorY: 219.5})
.to({rotation: 360}, 12000);
Tween.get(this.light1, { loop: true })
.set({ anchorX: 219.5, anchorY: 219.5 })
.to({ rotation: 360 }, 12000);
Tween.get(this.light2, {loop: true})
.set({anchorX: 219.5, anchorY: 219.5})
.to({rotation: -360}, 12000);
Tween.get(this.light2, { loop: true })
.set({ anchorX: 219.5, anchorY: 219.5 })
.to({ rotation: -360 }, 12000);
}
start(data) {
......@@ -121,7 +127,7 @@ export class SuccessPrizePanel extends Panel {
* 挑战满星
*/
private again() {
changeScene(MapScene, {level: this.data.level});
changeScene(MapScene, { level: this.data.level });
super.hidePanel();
}
......@@ -132,7 +138,7 @@ export class SuccessPrizePanel extends Panel {
if (this.data.level == 120) {
changeScene(MapScene);
} else {
changeScene(MapScene, {level: this.data.level + 1});
changeScene(MapScene, { level: this.data.level + 1 });
}
super.hidePanel();
}
......@@ -140,7 +146,7 @@ export class SuccessPrizePanel extends Panel {
public goPrize() {
// 去抽奖
changeScene(LotteryScene, {level: this.data.level})
changeScene(LotteryScene, { level: this.data.level })
super.hidePanel();
}
......
......@@ -25,15 +25,20 @@ export class LotteryScene extends Scene {
//背景
this.addChild(new FYGE.Sprite(RES.getRes("lotteryMachineBg.jpg")))
//计算下一关的关数
let upLevel: number = 120;
let dLevel: number = 120;
Tools.baseInfo.prizeLevels.forEach((value, index) => {
const d: number = value - this.data.level;
if (this.data.level <= value && d >= 0 && d <= dLevel) {
upLevel = value;
dLevel = d + 1;
}
});
// let upLevel: number = 120;
// let dLevel: number = 120;
// Tools.baseInfo.prizeLevels.forEach((value, index) => {
// const d: number = value - this.data.level;
// if (this.data.level <= value && d >= 0 && d <= dLevel) {
// upLevel = value;
// 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.data.level + "关抽奖奖励",
......@@ -46,7 +51,7 @@ export class LotteryScene extends Scene {
)).bold = true;
//下一次抽奖文案
this.addChild(Tools.getText(
"下一奖励关卡:" + upLevel + "关",
upLevel ? "下一奖励关卡:" + upLevel + "关" : "",
32.54,
"#ffffff",
FYGE.TEXT_ALIGN.CENTER,
......
......@@ -63,6 +63,8 @@ import { MapScene } from './map/MapScene';
import { NoStepPanel } from '../panels/NoStepPanel';
import { FirstPropGift } from '../something/uis/FirstPropGift';
import { bonus_lottie } from '../lotties/bonus_lottie';
import { GDispatcher } from '../Main';
import { G_EVENT } from '../common/G_EVENT';
const aniClass = {
"BoomAni": BoomAni,
......@@ -2906,6 +2908,18 @@ class SettingBtn extends FYGE.Container {
//播放或暂停音乐接口
sendTbNet(TbNetName.openMusic, { isOn: this.isOn })
}, 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);
......@@ -2917,8 +2931,11 @@ class SettingBtn extends FYGE.Container {
musicBtn.visible = !musicBtn.visible
bg.visible = !bg.visible
}, this)
}
console.log(btn)
destroy() {
//关闭音乐
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