Commit d71dc056 authored by 张超's avatar 张超 🎱

转盘

parent 28e608e7
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
"globalBackgroundWidth": -1, "globalBackgroundWidth": -1,
"globalBackgroundHeight": -1, "globalBackgroundHeight": -1,
"globalBackgroundColor": "#ffffff", "globalBackgroundColor": "#ffffff",
"globalBackgroundImage": "" "globalBackgroundImage": "",
"globalAutoLayerMarkEnable": false
}, },
"1667fb18fa6": { "1667fb18fa6": {
"bindingDataTestObj": [ "bindingDataTestObj": [
...@@ -49,13 +50,8 @@ ...@@ -49,13 +50,8 @@
"useBgImage": false, "useBgImage": false,
"useBgColor": true "useBgColor": true
}, },
"1679825b217": { "167963bd0a4": {
"backgroundX": 0, "backgroundType": "user",
"backgroundY": 0, "backgroundColor": "#877c7c"
"backgroundWidth": -1,
"backgroundHeight": -1,
"useBgImage": true,
"useBgColor": true,
"backgroundAlpha": 100
} }
} }
\ No newline at end of file
...@@ -20,6 +20,7 @@ import showAlertPanel from "./ctrls/showAlertPanel"; ...@@ -20,6 +20,7 @@ import showAlertPanel from "./ctrls/showAlertPanel";
import { ModuleTypes } from "./types/sceneTypes"; import { ModuleTypes } from "./types/sceneTypes";
import layers from "./views/layers"; import layers from "./views/layers";
import SlotPanel from "./components/SlotPanel"; import SlotPanel from "./components/SlotPanel";
import RotatePanel from "./components/RotatePanel";
export default class MainBase extends eui.UILayer { export default class MainBase extends eui.UILayer {
constructor() { constructor() {
...@@ -41,6 +42,7 @@ export default class MainBase extends eui.UILayer { ...@@ -41,6 +42,7 @@ export default class MainBase extends eui.UILayer {
[ModuleTypes.RANK_PANEL, { cls: RankPanel }], [ModuleTypes.RANK_PANEL, { cls: RankPanel }],
[ModuleTypes.TREASURE_PANEL, { cls: TreasurePanel }], [ModuleTypes.TREASURE_PANEL, { cls: TreasurePanel }],
[ModuleTypes.SLOT_PANEL, { cls: SlotPanel }], [ModuleTypes.SLOT_PANEL, { cls: SlotPanel }],
[ModuleTypes.ROTATE_PANEL, { cls: RotatePanel }],
]; ];
......
import { DataManager } from "../../tw/manager/DataManager";
import { NetManager } from "../../tw/manager/NetManager";
import { ModuleTypes } from "../types/sceneTypes";
import wait from "../../new_tc/wait";
import submitAfterDostart from "../../new_tw/ctrls/submitAfterDostart";
import PanelCtrl from "../ctrls/panelCtrl";
import Panel from "./Panel";
import centerAnchorOffset from "../views/centerAnchorOffset"
import showAlertPanel from "../ctrls/showAlertPanel";
import getCountTxt from "../../new_tw/datas/getCountTxt";
export default class RotatePannel extends Panel {
countTxt: eui.Label;
optionList: any;
wheelPos: any;
start() {
if (!DataManager.ins.getOptionsData)
NetManager.ins.getOptions(() => {
this.initRotate()
})
else
this.initRotate()
}
private async initRotate() {
this.optionList = DataManager.ins.getOptionsData.optionList.filter(item => (item as any).scoreArea === '21,30')
this['rotateStart'] && this['rotateStart'].once(egret.TouchEvent.TOUCH_TAP, this.onTap_rotateStart, this);
this.updateCountTxt()
this.renderOptions(this['wheel'].width / 2, this['wheel'])
}
onTap_rotateStart() {
if (!this.check()) return;
this.closeBtns.forEach(btn => btn.touchEnabled = false);
this['rotateStart'].touchEnabled = false;
}
renderOptions(r, container) {
let itemDeg = 360 / 8;
this.optionList.reduce((sum, item, index) => {
let gift = new eui.Group;
return sum.then(() => {
return loadImageByUrl(item.logo).then((image: any) => {
image.y = 220
centerAnchorOffset(image)
gift.addChild(image)
gift.addChild(this.renderText(item.name))
container.addChild(gift);
let giftDeg = index * itemDeg
gift.rotation = 180 + giftDeg
gift.x = r - Math.sin((Math.PI * giftDeg) / 180) * (r - 70);
gift.y = r + Math.cos((Math.PI * giftDeg) / 180) * (r - 70);
gift.scaleX = gift.scaleY = 0.35;
});
});
}, Promise.resolve());
this.showAnimation(50000, 360, true, null, null);
}
renderText(text) {
const textField = new egret.TextField();
textField.text = text;
textField.strokeColor = 0xffffff;
textField.size = 60;
textField.lineSpacing = 20;
textField.y = 0
textField.textAlign = egret.HorizontalAlign.CENTER;
centerAnchorOffset(textField)
return textField;
};
updateCountTxt() {
if (this.countTxt) {
this.countTxt.text = getCountTxt();
}
}
check() {
if (DataManager.ins.getInfoData.status.code == 2) {
showAlertPanel('对不起,您的积分不足。', null, 'lackOfMoney')
return false;
}
if (DataManager.ins.getInfoData.status.code == 3) {
showAlertPanel('对不起,参与次数已用完。', null, 'lackOfChance')
return false;
}
return true;
}
showAnimation(time, resultAngle, loop, type, cb) {
let target = this['wheel'];
//这个是转盘转
let tw = egret.Tween.get(target, {
loop: loop
});
tw = tw.to({ rotation: resultAngle }, time, type);
cb && tw.call(cb, self);
}
get skinKey() { return 'Rotate' }
protected get closeBtns(): eui.Button[] {
return [this['rotateClose']]
}
}
const loadImageByUrl = (url: string) => {
return new Promise((resolve, reject) => {
RES.getResByUrl(
url,
texture => {
let image = new egret.Bitmap(texture)
resolve(image)
},
this,
'image'
)
})
}
...@@ -34,7 +34,7 @@ export default class SlotPanel extends Panel { ...@@ -34,7 +34,7 @@ export default class SlotPanel extends Panel {
} }
private async initSlot() { private async initSlot() {
this['slotStartBtn'] && this['slotStartBtn'].once(egret.TouchEvent.TOUCH_TAP, this.onTap_slotStart, this); this['slotStartBtn'] && this['slotStartBtn'].once(egret.TouchEvent.TOUCH_TAP, this.onTap_slotStart, this);
this.optionList = DataManager.ins.getOptionsData.optionList.filter(item => (item as any).scoreArea === '1,10') this.optionList = DataManager.ins.getOptionsData.optionList.filter(item => (item as any).scoreArea === '11,20')
this.drawMask() this.drawMask()
this.renderSlotWrap() this.renderSlotWrap()
this.updateCountTxt() this.updateCountTxt()
...@@ -68,8 +68,6 @@ export default class SlotPanel extends Panel { ...@@ -68,8 +68,6 @@ export default class SlotPanel extends Panel {
} }
onTap_slotStart() { onTap_slotStart() {
if (!this.check()) return; if (!this.check()) return;
// this.gameReset()
this.closeBtns.forEach(btn => btn.touchEnabled = false); this.closeBtns.forEach(btn => btn.touchEnabled = false);
this['slotStartBtn'].touchEnabled = false; this['slotStartBtn'].touchEnabled = false;
this.calcSpeed(1, 20) this.calcSpeed(1, 20)
......
...@@ -14,6 +14,7 @@ export default class StartSceneBase extends Scene { ...@@ -14,6 +14,7 @@ export default class StartSceneBase extends Scene {
rankBtn: eui.Button; rankBtn: eui.Button;
elements: eui.Group; elements: eui.Group;
slotsBtn: eui.Button; slotsBtn: eui.Button;
rotateBtn: eui.Button;
exemptionTxt: eui.Label; exemptionTxt: eui.Label;
async start(data?) { async start(data?) {
...@@ -66,6 +67,12 @@ export default class StartSceneBase extends Scene { ...@@ -66,6 +67,12 @@ export default class StartSceneBase extends Scene {
this.rankBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_rankBtn, this); this.rankBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_rankBtn, this);
if (this.slotsBtn) if (this.slotsBtn)
this.slotsBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_slotsBtn, this); this.slotsBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_slotsBtn, this);
if (this.rotateBtn)
this.rotateBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_rotateBtn, this);
}
onTap_rotateBtn(e: egret.Event) {
PanelCtrl.instance.show(ModuleTypes.ROTATE_PANEL);
} }
onTap_slotsBtn(e: egret.Event) { onTap_slotsBtn(e: egret.Event) {
PanelCtrl.instance.show(ModuleTypes.SLOT_PANEL); PanelCtrl.instance.show(ModuleTypes.SLOT_PANEL);
......
...@@ -10,4 +10,5 @@ export enum ModuleTypes { ...@@ -10,4 +10,5 @@ export enum ModuleTypes {
RANK_PANEL, RANK_PANEL,
TREASURE_PANEL, TREASURE_PANEL,
SLOT_PANEL, SLOT_PANEL,
ROTATE_PANEL,
} }
\ No newline at end of file
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
}, },
{ {
"name": "preload", "name": "preload",
"keys": "conveyor_png,slot_close_png,slot_start_btn_png,slot_wrap-bottom_png,slot_wrap-top_png,closeBtn2_png,hand2_png,treasurebg3_png,treasurebg22_png,conveyor2_png,slot_close2_png,slot_start_btn2_png,slot_wrap-bottom2_png,slot_wrap-top2_png" "keys": "conveyor_png,slot_close_png,slot_start_btn_png,slot_wrap-bottom_png,slot_wrap-top_png,closeBtn2_png,hand2_png,treasurebg3_png,treasurebg22_png,conveyor2_png,slot_close2_png,slot_start_btn2_png,slot_wrap-bottom2_png,slot_wrap-top2_png,light_png,wheel_png,rotate_start_btn_png,rotate_close_png"
} }
], ],
"resources": [ "resources": [
...@@ -358,6 +358,26 @@ ...@@ -358,6 +358,26 @@
"name": "slot_wrap-top2_png", "name": "slot_wrap-top2_png",
"type": "image", "type": "image",
"url": "assets/slot/slot_wrap-top.png" "url": "assets/slot/slot_wrap-top.png"
},
{
"name": "light_png",
"type": "image",
"url": "assets/rotate/light.png"
},
{
"name": "wheel_png",
"type": "image",
"url": "assets/rotate/wheel.png"
},
{
"name": "rotate_start_btn_png",
"type": "image",
"url": "assets/rotate/rotate_start_btn.png"
},
{
"name": "rotate_close_png",
"type": "image",
"url": "assets/rotate/rotate_close.png"
} }
] ]
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
"resource/skins/StartSkin.exml", "resource/skins/StartSkin.exml",
"resource/skins/TreasureSkin.exml", "resource/skins/TreasureSkin.exml",
"resource/skins/SlotSkin.exml", "resource/skins/SlotSkin.exml",
"resource/skins/RotateSkin.exml",
"resource/skins/VScrollBarSkin.exml" "resource/skins/VScrollBarSkin.exml"
], ],
"path": "resource/default.thm.json" "path": "resource/default.thm.json"
......
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="RotateSkin" width="750" height="1334" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<w:Config id="167963bd0a4"/>
<e:Image source="light_png" x="-19" y="133"/>
<e:Group id="wheel" width="661" height="660" x="374.5" y="614" anchorOffsetX="330" anchorOffsetY="330">
<e:Image id="wheelPng" x="330" y="330" source="wheel_png" scaleX="1" scaleY="1" anchorOffsetX="330" anchorOffsetY="330"/>
</e:Group>
<e:Button id="rotateStart" label="" x="277" y="496.5">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="rotate_start_btn_png" source.down="rotate_start_btn_png" source.disabled="禁用状态资源名rotate_start_btn_png"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="rotateClose" label="Button" x="588.5" y="217.06">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="rotate_close_png" source.down="rotate_close_png" source.disabled="禁用状态资源名rotate_close_png"/>
</e:Skin>
</e:skinName>
</e:Button>
<e:Label id="countTxt" text="1/1" width="100%" verticalAlign="middle" textAlign="center" left="0" y="1011"/>
</e:Skin>
\ No newline at end of file
...@@ -118,6 +118,14 @@ ...@@ -118,6 +118,14 @@
</e:Skin> </e:Skin>
</e:skinName> </e:skinName>
</e:Button> </e:Button>
<e:Button id="rotateBtn" label="大转盘" y="128.74" scaleX="1" scaleY="1" left="612">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="rankBtn_png" source.down="rankBtn_png" source.disabled="rankBtn_png"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0" size="26"/>
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="treasureBtn" label="宝箱" y="74" scaleX="1" scaleY="1" left="598"> <e:Button id="treasureBtn" label="宝箱" y="74" scaleX="1" scaleY="1" left="598">
<e:skinName> <e:skinName>
<e:Skin states="up,down,disabled"> <e:Skin states="up,down,disabled">
......
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