Commit 18379d96 authored by huangwenjie's avatar huangwenjie

1

parent dc05c071
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>圣诞礼献全城</title>
<title>9宠养成</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
......@@ -44,10 +44,7 @@
</head>
<body>
<audio style="display:none;
height: 0" id="bg0-music" preload="auto"
src="https://yun.duiba.com.cn/db_games/activity/dwslz_wn/bg0Music.mp3" loop="loop">
</audio>
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main"
data-orientation="auto" data-scale-mode="fixedWidth" data-frame-rate="60" data-content-width="750"
data-content-height="1624" data-multi-fingered="2" data-show-fps="false" data-show-log="false"
......@@ -89,7 +86,7 @@
// var dev = true;
var resPath = '';
// svga路径
var svgaPath = "//duiba.oss-cn-hangzhou.aliyuncs.com/db_games/activity/ChristmasGifts/svgas/"
var svgaPath = "//yun.duiba.com.cn/db_games/activity/Thanksgivingballons/svgas/"
// http://duiba.oss-cn-hangzhou.aliyuncs.com/db_games/activity/Thanksgivingballons/svgas/playTurkey.svga
function resolve(a) {
var b = eval(a);
......@@ -143,54 +140,7 @@
shareIosLinkActivity: ''
};
</script>
<script>
//音乐自动播放
$(document).ready(function () {
autoPlayMusic();
audioAutoPlay();
});
function audioAutoPlay() {
var audio = null;
console.log('bg0mus')
audio = document.getElementById('bg0-music');
audio.play();
document.addEventListener("WeixinJSBridgeReady", function () {
audio.play();
}, false);
}
// 音乐播放
function autoPlayMusic() {
// 自动播放音乐效果,解决浏览器或者APP自动播放问题
function musicInBrowserHandler() {
musicPlay(true);
document.body.removeEventListener('touchstart', musicInBrowserHandler);
}
document.body.addEventListener('touchstart', musicInBrowserHandler);
// 自动播放音乐效果,解决微信自动播放问题
function musicInWeixinHandler() {
musicPlay(true);
document.addEventListener("WeixinJSBridgeReady", function () {
musicPlay(true);
}, false);
document.removeEventListener('DOMContentLoaded', musicInWeixinHandler);
}
document.addEventListener('DOMContentLoaded', musicInWeixinHandler);
}
function playBg0Music(isPlay) {
var media = document.querySelector('#bg0-music');
if (isPlay && media.paused) {
media.play();
}
if (!isPlay && !media.paused) {
media.pause();
}
}
</script>
<script src="output.js"></script>
</body>
......
......@@ -6,8 +6,8 @@
<e:Group width="750" height="800" horizontalCenter="0" verticalCenter="0">
<e:Image id="bg" source="msgBg_png" horizontalCenter="0" y="93" x="0" scaleX="1" scaleY="1"/>
<e:Button id="closeBtn" label="" x="584" y="108.89">
<e:Image id="bg" source="msgBg_png" horizontalCenter="0" y="2.9999999999999716" x="0" scaleX="1" scaleY="1"/>
<e:Button id="closeBtn" label="" x="604" y="108.89">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="closeBtn_png" source.down="closeBtn_png" source.disabled="closeBtn_png"/>
......@@ -15,7 +15,7 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="earnBtn" label="" anchorOffsetX="171.5" anchorOffsetY="43.5" horizontalCenter="0.5" y="536.7" x="135" scaleX="1" scaleY="1" width="343" height="87">
<e:Button id="earnBtn" label="" anchorOffsetX="171.5" anchorOffsetY="43.5" horizontalCenter="0.5" y="577.7" x="135" scaleX="1" scaleY="1" width="343" height="87">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="msgSureBtn_png" source.down="msgSureBtn_png" source.disabled="msgSureBtn_png"/>
......@@ -23,8 +23,7 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Label id="msgTitle" touchEnabled="false" size="50" width="403.85" anchorOffsetY="0" height="100" textAlign="center" bold="true" anchorOffsetX="0" verticalAlign="middle" fontFamily="Microsoft YaHei" text="积分不足" horizontalCenter="0" y="228.2" x="173" scaleX="1" scaleY="1" textColor="0x000000" visible="false"/>
<e:Label id="tips" touchEnabled="false" size="36" width="556.85" anchorOffsetY="0" height="190.91" textAlign="center" anchorOffsetX="0" verticalAlign="middle" y="309.05" fontFamily="Microsoft YaHei" scaleX="1" scaleY="1" horizontalCenter="0.5" text="抱歉,您当前的积分不足" textColor="0x000000"/>
<e:Image source="noPrizeTitle_png" y="256" horizontalCenter="0"/>
<e:Label id="msgTitle" touchEnabled="false" size="50" width="403.85" anchorOffsetY="0" height="100" textAlign="center" bold="true" anchorOffsetX="0" verticalAlign="middle" fontFamily="Microsoft YaHei" text="积分不足" horizontalCenter="0" y="218.20000000000002" x="173" scaleX="1" scaleY="1" textColor="0xFFFFFF"/>
<e:Label id="tips" touchEnabled="false" size="36" width="556.85" anchorOffsetY="0" height="190.91" textAlign="center" anchorOffsetX="0" verticalAlign="middle" y="319.05" fontFamily="Microsoft YaHei" scaleX="1" scaleY="1" horizontalCenter="0.5" textColor="0xFFFFFF" text="抱歉,您当前的积分不足"/>
</e:Group>
</e:Skin>
\ No newline at end of file
......@@ -7,8 +7,8 @@
<e:Group width="750" height="800" horizontalCenter="0" verticalCenter="0">
<e:Image id="bg" source="msgBg_png" horizontalCenter="-2" y="135" x="0" scaleX="1" scaleY="1"/>
<e:Button id="closeBtn" label="" x="576.85" y="141">
<e:Image id="bg" source="msgBg_png" horizontalCenter="0" y="2.9999999999999716" x="0" scaleX="1" scaleY="1"/>
<e:Button id="closeBtn" label="" x="604" y="108.89">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="closeBtn_png" source.down="closeBtn_png" source.disabled="closeBtn_png"/>
......@@ -16,7 +16,7 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="loginBtn" label="" anchorOffsetX="171.5" anchorOffsetY="43.5" horizontalCenter="0.5" y="587.7" x="135" scaleX="1" scaleY="1" width="343" height="87">
<e:Button id="loginBtn" label="" anchorOffsetX="171.5" anchorOffsetY="43.5" horizontalCenter="0.5" y="577.7" x="135" scaleX="1" scaleY="1" width="343" height="87">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="loginBtn_png" source.down="loginBtn_png" source.disabled="loginBtn_png"/>
......@@ -25,8 +25,8 @@
</e:skinName>
</e:Button>
<e:Label id="msgTitle" touchEnabled="false" size="50" width="403.85" anchorOffsetY="0" height="100" textAlign="center" bold="true" anchorOffsetX="0" verticalAlign="middle" fontFamily="Microsoft YaHei" text="未登录" horizontalCenter="0" y="268.2" x="173" scaleX="1" scaleY="1" textColor="0x000000"/>
<e:Label id="msgTxt" touchEnabled="false" size="36" width="556.85" anchorOffsetY="0" height="190.91" textAlign="center" anchorOffsetX="0" verticalAlign="middle" y="349.05" fontFamily="Microsoft YaHei" scaleX="1" scaleY="1" horizontalCenter="0.5" text="抱歉,请先登录" textColor="0x000000"/>
<e:Label id="msgTitle" touchEnabled="false" size="50" width="403.85" anchorOffsetY="0" height="100" textAlign="center" bold="true" anchorOffsetX="0" verticalAlign="middle" fontFamily="Microsoft YaHei" text="未登录" horizontalCenter="0" y="218.20000000000002" x="173" scaleX="1" scaleY="1" textColor="0xffffff"/>
<e:Label id="msgTxt" touchEnabled="false" size="36" width="556.85" anchorOffsetY="0" height="190.91" textAlign="center" anchorOffsetX="0" verticalAlign="middle" y="319.05" fontFamily="Microsoft YaHei" scaleX="1" scaleY="1" horizontalCenter="0.5" textColor="0xffffff" text="抱歉,请先登录"/>
</e:Group>
......
......@@ -7,8 +7,8 @@
<e:Group width="750" height="800" horizontalCenter="0" verticalCenter="0">
<e:Image id="bg" source="msgBg_png" horizontalCenter="0" y="129" x="0" scaleX="1" scaleY="1"/>
<e:Button id="closeBtn0" label="" x="584" y="144.89">
<e:Image id="bg" source="msgBg_png" horizontalCenter="0" y="2.9999999999999716" x="0" scaleX="1" scaleY="1"/>
<e:Button id="closeBtn0" label="" x="604" y="108.89">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="closeBtn_png" source.down="closeBtn_png" source.disabled="closeBtn_png"/>
......@@ -16,7 +16,7 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="sureBtn" label="" anchorOffsetX="171.5" anchorOffsetY="43.5" horizontalCenter="0.5" y="572.7" x="135" scaleX="1" scaleY="1" width="343" height="87">
<e:Button id="closeBtn" label="" anchorOffsetX="171.5" anchorOffsetY="43.5" horizontalCenter="0.5" y="577.7" x="135" scaleX="1" scaleY="1" width="343" height="87">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="msgSureBtn_png" source.down="msgSureBtn_png" source.disabled="msgSureBtn_png"/>
......@@ -24,9 +24,8 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Label id="msgTitle" touchEnabled="false" size="45" width="403.85" anchorOffsetY="0" height="100" textAlign="center" bold="true" anchorOffsetX="0" verticalAlign="middle" fontFamily="Microsoft YaHei" text="网络异常" horizontalCenter="0" y="262.2" x="173" scaleX="1" scaleY="1" textColor="0x000000" visible="false"/>
<e:Label id="msgTxt" touchEnabled="false" text="{data.message}" size="30" width="556.85" anchorOffsetY="0" height="190.91" textAlign="center" bold="true" anchorOffsetX="0" verticalAlign="middle" y="345.05" fontFamily="Microsoft YaHei" scaleX="1" scaleY="1" horizontalCenter="0.5" textColor="0x000000"/>
<e:Image source="warningtitle_png" y="300" horizontalCenter="0"/>
<e:Label id="msgTitle" touchEnabled="false" size="45" width="403.85" anchorOffsetY="0" height="100" textAlign="center" bold="true" anchorOffsetX="0" verticalAlign="middle" fontFamily="Microsoft YaHei" text="网络异常" horizontalCenter="0" y="218.20000000000002" x="173" scaleX="1" scaleY="1" textColor="0xffffff"/>
<e:Label id="msgTxt" touchEnabled="false" text="{data.message}" size="30" width="556.85" anchorOffsetY="0" height="190.91" textAlign="center" bold="true" anchorOffsetX="0" verticalAlign="middle" y="319.05" fontFamily="Microsoft YaHei" scaleX="1" scaleY="1" horizontalCenter="0.5" textColor="0xffffff" lineSpacing="15"/>
</e:Group>
......
......@@ -11,18 +11,26 @@
<e:Group width="750" height="1000" horizontalCenter="0" verticalCenter="-50">
<e:Image horizontalCenter="0" source="msgBg_png" anchorOffsetY="0" height="859" verticalCenter="-70.5" x="0" y="0" scaleX="1" scaleY="1" scale9Grid="60,380,284,95"/>
<e:Scroller id="scroller" width="469" height="482" y="234" anchorOffsetY="0" anchorOffsetX="0" horizontalCenter="0" x="122.00000000000001" scaleX="1" scaleY="1">
<e:Image horizontalCenter="0" source="msgBg_png" scale9Grid="115,216,517,402" anchorOffsetY="0" height="1000" verticalCenter="0" x="0" y="0" scaleX="1" scaleY="1"/>
<e:Button id="closeBtn0" label="" x="604" y="108.89">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="closeBtn_png" source.down="closeBtn_png" source.disabled="closeBtn_png"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
</e:skinName>
</e:Button>
<e:Scroller id="scroller" width="506" height="482" y="320" anchorOffsetY="0" anchorOffsetX="0" horizontalCenter="0" x="122.00000000000001" scaleX="1" scaleY="1">
<e:Group id="group" width="100%" anchorOffsetY="0" x="0" y="-252" height="479">
<e:Rect width="100%" height="10" x="206" y="59" fillAlpha="0"/>
<e:Label id="labContent" width="100%" text="" lineSpacing="10" size="30" multiline="true" anchorOffsetY="-8" fontFamily="Microsoft YaHei" textColor="0x000000"/>
<e:Label id="labContent" width="100%" text="" lineSpacing="10" size="30" multiline="true" anchorOffsetY="-8" fontFamily="Microsoft YaHei" textColor="0xffffff"/>
<e:layout>
<e:VerticalLayout/>
</e:layout>
</e:Group>
</e:Scroller>
<e:Button id="closeBtn" label="" icon="knowBtn_png" y="779.58" skinName="ui.IconButtonSkin" width="343" anchorOffsetX="171.5" height="87" anchorOffsetY="43.5" horizontalCenter="0" x="203.99999999999997" scaleX="1" scaleY="1"/>
<e:Image source="ruleTitle_png" y="164" horizontalCenter="0" x="270" scaleX="1" scaleY="1"/>
<e:Button id="closeBtn" label="" icon="knowBtn_png" y="871.58" skinName="ui.IconButtonSkin" width="343" anchorOffsetX="171.5" height="87" anchorOffsetY="43.5" horizontalCenter="0" x="203.99999999999997" scaleX="1" scaleY="1"/>
<e:Image source="ruleTitle_png" y="232.00000000000006" horizontalCenter="0" x="270" scaleX="1" scaleY="1"/>
</e:Group>
......
<?xml version="1.0" encoding="utf-8"?>
<e:Skin width="750" height="1206" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image id="bg" source="startBg_jpg" x="0" y="0"/>
<e:Group id="ballon" width="369" height="504" y="860.72" anchorOffsetY="487" anchorOffsetX="179" x="376">
<e:Image source="start_ballon_png" y="0" horizontalCenter="0"/>
<e:Image source="start_ballon_face1_png" x="241" y="126"/>
<e:Image source="start_ballon_face0_png" x="38" y="114"/>
</e:Group>
<e:Image source="infoBg_png" x="212.5" y="1054.24"/>
<e:Image source="countBg_png" y="731.72" horizontalCenter="0.5"/>
<e:Button id="recordBtn" label="" skinName="ui.IconButtonSkin" icon="recordBtn_png" width="137" height="43" anchorOffsetY="21.5" anchorOffsetX="68.5" left="30" top="30"/>
<e:Button id="ruleBtn" label="" skinName="ui.IconButtonSkin" icon="ruleBtn_png" width="137" height="43" anchorOffsetY="21.5" anchorOffsetX="68.5" right="30" top="30"/>
<e:Label id="costTxt" text="10积分/次" x="269.5" y="740.72" anchorOffsetX="0" width="216" anchorOffsetY="0" height="44.5" textAlign="center" verticalAlign="middle" textColor="0xf25757" fontFamily="Microsoft YaHei" size="20"/>
<e:Group id="main" width="750" height="1206" horizontalCenter="0" verticalCenter="0">
<e:Image id="bg" source="startBg_jpg" scaleX="1" scaleY="1" horizontalCenter="0" verticalCenter="0"/>
<e:Group id="sled" width="800" height="933" x="65" y="60" anchorOffsetX="0" anchorOffsetY="0" visible="false">
<e:Group id="hand" width="205.36" height="89" x="350.67" y="458.24" anchorOffsetX="166.67" anchorOffsetY="24.24" rotation="-45">
<e:Image source="hand_png" x="31" anchorOffsetX="0" anchorOffsetY="0" y="0" scaleX="1" scaleY="1"/>
<e:Image source="giveStar_png" x="-14.63" y="-8.55"/>
</e:Group>
<e:Image source="sled_png" x="0" y="0"/>
</e:Group>
<e:Button id="recordBtn" label="" skinName="ui.IconButtonSkin" icon="recordBtn_png" anchorOffsetY="26.5" anchorOffsetX="62" left="0" top="90" width="124" height="53" x="0" y="90" scaleX="1" scaleY="1"/>
<e:Button id="ruleBtn" label="" skinName="ui.IconButtonSkin" icon="ruleBtn_png" height="53" anchorOffsetY="26.5" anchorOffsetX="62" top="30" left="0" width="124" x="0" y="29.999999999999996" scaleX="1" scaleY="1"/>
<e:Label id="costTxt" text="10积分/次" y="1117.39" anchorOffsetX="0" width="313" anchorOffsetY="0" height="44.5" textAlign="center" verticalAlign="middle" fontFamily="Microsoft YaHei" textColor="0x393f71" scaleX="1" scaleY="1" size="26" horizontalCenter="0"/>
<e:Label id="creditsTxt" text="剩余积分:10" y="1085.6" anchorOffsetX="0" width="301" size="26" fontFamily="Microsoft YaHei" horizontalCenter="1.5" anchorOffsetY="0" height="36" textAlign="center" verticalAlign="middle" x="226" scaleX="1" scaleY="1" textColor="0x393f71"/>
<e:Group id="title" width="556" height="300" top="56" horizontalCenter="0" anchorOffsetX="278" anchorOffsetY="150" scaleX="0">
<e:Image source="title_png" y="0" x="0" scaleX="1" scaleY="1"/>
<e:Image id="star0" source="star_png" x="47.96" y="218.24" anchorOffsetX="30.8" anchorOffsetY="0" scaleX="0.8" scaleY="0.8"/>
<e:Image id="star1" source="star_png" x="145.16" y="219.04" anchorOffsetX="30.8" anchorOffsetY="0"/>
<e:Image id="star2" source="star_png" x="407.15" y="221.05" anchorOffsetX="30.8" anchorOffsetY="0" scaleX="0.6" scaleY="0.6"/>
<e:Image id="star3" source="star_png" x="509.8" y="219.99" anchorOffsetX="30.8" anchorOffsetY="0" scaleX="0.5" scaleY="0.5"/>
</e:Group>
<e:Group id="startBtn" width="352" height="98" y="1015" anchorOffsetX="176" anchorOffsetY="49" horizontalCenter="0">
</e:Group>
<e:Image id="musicOn" source="musicOn_png" anchorOffsetX="34.5" anchorOffsetY="34.5" height="69" width="69" x="685.5" y="64.5"/>
<e:Image id="musicOff" source="musicOff_png" width="69" height="69" anchorOffsetY="34.5" anchorOffsetX="34.5" x="685.5" y="64.5" visible="false"/>
</e:Group>
<e:Label id="creditsTxt" text="剩余积分:10" y="1058.24" anchorOffsetX="0" width="301" size="22" fontFamily="Microsoft YaHei" horizontalCenter="1.5" anchorOffsetY="0" height="36" textAlign="center" verticalAlign="middle"/>
<e:Group id="startBtn" width="200" height="200" y="822.72" horizontalCenter="0"/>
</e:Skin>
\ No newline at end of file
......@@ -20,8 +20,6 @@ import NoPrizePanel from './pops/prizePanel/NoPrizePanel';
import RulePanel from './pops/rule/RulePanel';
import StartScene from './scenes/StartScene';
import PlayScene from './scenes/playScene/PlayScene';
import GameFailPanel from './pops/prizePanel/gameFailPanel';
import warningPanel from './pops/warning/Warning';
class Main extends MainBase {
......@@ -32,8 +30,6 @@ class Main extends MainBase {
PanelCtrl.instance.registerClass(ModuleTypes.MSG_PANEL, Msg);
PanelCtrl.instance.registerClass(ModuleTypes.LOGIN_PANEL, LoginPanel);
PanelCtrl.instance.registerClass(ModuleTypes.GETCREDITS_PANEL, GetCreditsPanel);
PanelCtrl.instance.registerClass(ModuleTypes.WARNING_PANEL, warningPanel);
PanelCtrl.instance.registerClass(ModuleTypes.GAMEFAIL_PANEL, GameFailPanel);
PanelCtrl.instance.registerClass(ModuleTypes.NOPRIZE_PANEL, NoPrizePanel);
PanelCtrl.instance.registerClass(ModuleTypes.PRIZE_PANEL, PrizePanel);
PanelCtrl.instance.registerClass(ModuleTypes.RULE_PANEL, RulePanel);
......@@ -67,7 +63,6 @@ class Main extends MainBase {
GDispatcher.addEvent('PreloadLoaded', () => {
Waiting.instance.show()
// this.createGameScene()
}, this);
GDispatcher.addEvent('PlayLoaded', () => {
// Waiting.instance.hide()
......@@ -79,17 +74,18 @@ class Main extends MainBase {
return new Promise(async (r) => {
await Promise.all([
SVGACtrl.instance.load("collect", "collect.svga"),
SVGACtrl.instance.load("fall", "fall.svga"),
SVGACtrl.instance.load("impact_stone", "impact_stone.svga"),
SVGACtrl.instance.load("impact_user", "impact_user.svga"),
SVGACtrl.instance.load("user", "user.svga"),
SVGACtrl.instance.load("startBtn", "startBtn.svga")
SVGACtrl.instance.load("startTurkey", "startTurkey.svga"),
SVGACtrl.instance.load("playTurkey", "playTurkey.svga"),
SVGACtrl.instance.load("eyes", "eyes.svga"),
SVGACtrl.instance.load("startBtn", "startBtn.svga"),
SVGACtrl.instance.load("explode", "explode.svga")
])
.then(() => {
r();
})
.catch(() => {
.catch((e) => {
console.error(e);
PanelCtrl.instance.show(ModuleTypes.MSG_PANEL, { msg: "网络异常,请稍后再试~", title: "很遗憾", type: "reload" })
})
......@@ -113,25 +109,26 @@ class Main extends MainBase {
} else if (i == ResGroupNameArr.length - 1) {
this.trace(`${ResGroupNameArr[i]}组加载完成`);
GameConst.stage = this.stage;
window['allLoaded'] = true
setTimeout(() => {
console.log(GameConst.stage.width, GameConst.stage.height)
}, 100);
console.log("开始加载svga");
this.loadSvga()
.then(() => {
console.log("svga加载完成");
window['allLoaded'] = true
RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this);
RES.removeEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onResourceLoadError, this);
RES.removeEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this);
this.createGameScene()
})
.catch(e => {
console.error(e);
})
setTimeout(() => {
console.log(GameConst.stage.width, GameConst.stage.height)
}, 100);
RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this);
RES.removeEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onResourceLoadError, this);
RES.removeEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this);
}
}
}
......
......@@ -21,6 +21,7 @@ export default class GetCreditsPanel extends Panel {
initEvents() {
super.initEvents();
this.onTap(this.earnBtn, this.onTap_earnBtn);
this.onTap(this.closeBtn, this.onTouchTap);
}
onTap_earnBtn() {
......@@ -35,6 +36,7 @@ export default class GetCreditsPanel extends Panel {
removeEvents() {
super.removeEvents();
this.clearTap(this.earnBtn, this.onTap_earnBtn);
this.clearTap(this.closeBtn, this.onTouchTap);
}
}
\ No newline at end of file
......@@ -4,6 +4,13 @@ import Panel from "../../views/Panel";
import SceneCtrl from '../../ctrls/sceneCtrl';
export default class Msg extends Panel {
public bg: eui.Image;
public closeBtn0: eui.Button;
public closeBtn: eui.Button;
public msgTitle: eui.Label;
public msgTxt: eui.Label;
set message(val) {
......@@ -33,9 +40,9 @@ export default class Msg extends Panel {
return [this['closeBtn']]
}
public closeBtn: eui.Button;
initEvents() {
this.closeBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_closeBtn, this);
this.onTap(this.closeBtn0, this.onTap_closeBtn)
this.onTap(this.closeBtn, this.onTap_closeBtn)
}
private onTap_closeBtn(e: egret.TouchEvent) {
......@@ -70,5 +77,11 @@ export default class Msg extends Panel {
}
}
removeEvents() {
super.removeEvents()
this.clearTap(this.closeBtn0, this.onTap_closeBtn)
this.clearTap(this.closeBtn, this.onTap_closeBtn)
}
protected get skinKey() { return 'Msg' }
}
\ No newline at end of file
......@@ -12,27 +12,35 @@ export default class NoPrizePanel extends Panel {
protected get skinKey() { return 'NoPrize' }
public bg: eui.Image;
public img: eui.Image;
public failTxt: eui.Label;
public sureBtn: eui.Button;
public againBtn: eui.Button;
public closeBtn: eui.Button;
public noPrizeTitle: eui.Image;
public scoreTxt: eui.Label;
public maxScoreTxt: eui.Label;
get score() { return DataManager.ins.getData("ngameSubmit").data.score }
get maxScore() { return DataManager.ins.getData("ngameSubmit").data.maxScore }
public failTitle: eui.Image;
public emoji: eui.Image;
start(data) {
if (this.score) {
this.scoreTxt.text = `${this.score}`
} else {
this.scoreTxt.text = `0`
}
if (this.score) {
this.maxScoreTxt.text = `${this.maxScore}`
} else {
this.maxScoreTxt.text = `0`
switch (data.type) {
case noPrizeTypes.FAIL:
this.noPrizeTitle.visible = false
this.failTitle.visible = true
this.failTxt.text = `哎呀,就差那么一丢丢了`
break;
case noPrizeTypes.NOPRIZE:
this.noPrizeTitle.visible = true
this.failTitle.visible = false
this.failTxt.text = `感恩大礼与你失之交臂`
break;
case noPrizeTypes.THANKS:
this.noPrizeTitle.visible = true
this.failTitle.visible = false
this.failTxt.text = `感恩大礼与你失之交臂`
break;
default:
break;
}
}
......@@ -42,6 +50,7 @@ export default class NoPrizePanel extends Panel {
this.onTap(this.againBtn, this.onTap_CloseBtn)
this.onTap(this.closeBtn, this.onTap_CloseBtn)
this.onTap(this.sureBtn, this.onTap_CloseBtn)
}
private onTap_CloseBtn(e: egret.TouchEvent) {
......
......@@ -69,7 +69,7 @@ export default class PrizePanel extends Panel {
initEvents() {
super.initEvents();
this.onTap(this.closeBtn, this.onTap_CloseBtn)
this.onTap(this.sureBtn, this.onTap_CloseBtn)
this.onTap(this.sureBtn, this.onTap_GetPrize)
this.onTap(this.prizeImg, this.onTap_GetPrize)
}
......
......@@ -6,8 +6,12 @@ import Panel from "../../views/Panel";
import ToastCtrl from '../../ctrls/toastCtrl';
export default class RulePanel extends Panel {
public labContent: eui.Label;
public closeBtn0: eui.Button;
public scroller: eui.Scroller;
public group: eui.Group;
public labContent: eui.Label;
public closeBtn: eui.Button;
start() {
if (window['ruleTxt']) {
this.labContent.textFlow = (new HtmlTextParser).parser(window['ruleTxt']);
......@@ -28,11 +32,20 @@ export default class RulePanel extends Panel {
}
}
group: eui.Group;
private addRule() {
const text = DataManager.ins.getData("gameAjaxElement").data.rule;
this.labContent.textFlow = (new HtmlTextParser).parser(text);
}
initEvents() {
super.initEvents()
this.onTap(this.closeBtn0, this.onTouchTap)
}
removeEvents() {
super.removeEvents()
this.clearTap(this.closeBtn0, this.onTouchTap)
}
get skinKey() { return 'Rule' }
}
\ No newline at end of file
......@@ -135,7 +135,7 @@ export default class StartScene extends Scene {
if (DataManager.ins.getData('gameAjaxElement').data.element.status == 3) {
ToastCtrl.instance.show(`游戏次数已用完`);
} else if (DataManager.ins.getData('gameAjaxElement').data.element.status == 4) {
ToastCtrl.instance.show(`今日次数已用完,请明日再来吧~`);
PanelCtrl.instance.show(ModuleTypes.MSG_PANEL, { msg: "抱歉,今日次数已用完,\n明日再来吧~", title: "次数不足", type: "tips" })
} else if (DataManager.ins.getData('gameAjaxElement').data.element.status == 5 && DataManager.ins.getData('gameAjaxElement').data.element.freeLimit > 0) {
this.doStart();
} else if (DataManager.ins.getData('gameAjaxElement').data.element.status == 2 || DataManager.ins.getData('gameAjaxElement').data.element.needCreditsLong > DataManager.ins.getData('gameAjaxElement').data.element.myCreditsLong) {
......
import { arr } from './../../consts/GameConst';
import { DataManager } from './../../../libs/tw/manager/DataManager';
import { NetPromise } from './../../promises/NetPromise';
import { arr } from '../../consts/GameConst';
import { GDispatcher } from '../../../libs/tc/util/GDispatcher';
import { GCache } from '../../../libs/tc/util/GCache';
import Scene from "../../views/Scene";
import SVGACtrl from "../../ctrls/svgaCtrl";
import GameConst from '../../consts/GameConst';
import Ballon from './Ballon';
import PanelCtrl from '../../ctrls/panelCtrl';
import { ModuleTypes } from '../../types/ModuleTypes';
import NetConst from '../../consts/NetConst';
import ToastCtrl from '../../ctrls/toastCtrl';
import Barrier, { BarrierType } from './Barrier';
import LoopBg from './LoopBg';
export default class PlayScene extends Scene {
get skinKey() { return "Play" }
public gameLayer: eui.Group;
public user: eui.Group;
public musicOn: eui.Image;
public musicOff: eui.Image;
public topLayer: eui.Group;
public scoreTxt: eui.Label;
public bg: eui.Image;
public countDownTxt: eui.Label;
public ssBallon1: eui.Image;
public ssBallon2: eui.Image;
public ssBallon3: eui.Image;
public ssBallon4: eui.Image;
public rope: eui.Image;
public pumpBtn: eui.Image;
public sBallon: eui.Image;
public sBallonGroup: eui.Group;
public leftCount: eui.Label;
public ready: eui.Component;
public guideLayer: eui.Group;
public step1: eui.Group;
public step2: eui.Group;
public step3: eui.Group;
public step4: eui.Group;
public nextBtn: eui.Button;
public startBtn: eui.Button;
public skipBtn: eui.Button;
private bg: LoopBg;
viewport: number = 1206;
bgSpeed: number = -3;
currBarriers: any[] = [];
score: number = 0;
constructor() {
super()
// 成功打气球次数
public sucCount = 0;
public sBallonsArr = []
public ballonsPool = [];
public currBallon
start() {
this.ballonsPool = ["yellow", "blue", "pink", "red"]
this.sBallonsArr = ["y", "b", "p", "r"]
}
start() {
if (GameConst.isPlayMusic) {
this.musicOn.visible = true;
this.musicOff.visible = false;
initUI() {
let turkey = new window['SVGA'].EgretMovieClip(SVGACtrl.instance.getSVGAByName("playTurkey"));
turkey.x = 400
turkey.y = 680
this.gameLayer.addChildAt(turkey, 10)
this.ballonsPool = ["yellow", "blue", "pink", "red"]
this.sBallonsArr = ["y", "b", "p", "r"]
this.initSmallBallons()
// 没引导过进引导
if (!GCache.readCache("isGuide" + DataManager.ins.customCfgData.consumerId)) {
GCache.writeCache("isGuide" + DataManager.ins.customCfgData.consumerId, "1")
this.initGuide()
} else {
this.musicOn.visible = false;
this.musicOff.visible = true;
this.restartGame()
}
}
sBallonsPool;
initSmallBallons() {
// arr.shuffle(this.sBallonsArr);
this.sBallonsPool = [];
for (let i = this.sBallonsArr.length - 1; i > 0; i--) {
let color = this.sBallonsArr[i]
let sBallon = new eui.Image()
sBallon.source = "ssBallon_" + color + "_png"
sBallon.scaleX = 0.9
sBallon.scaleY = 0.9
this.sBallonGroup.addChild(sBallon)
this.sBallonsPool.push(sBallon)
}
this.gameLayer.touchThrough = true
this.gameLayer.touchEnabled = true
}
this.bg = new LoopBg(["playBg_jpg", "playBg_jpg"]);
this.bg.speed = 3
this.addChildAt(this.bg, 0)
guideStep = 1
initGuide() {
this.guideLayer.visible = true;
this.guideStep1()
GDispatcher.addEvent("guideStep2", this.guideStep2, this)
GDispatcher.addEvent("guideStep3", this.guideStep3, this)
GDispatcher.addEvent("guideStep4", this.guideStep4, this)
this.initScene()
this.onTap(this.skipBtn, this.onTap_startBtn)
this.onTap(this.nextBtn, this.onTap_nextBtn)
this.onTap(this.startBtn, this.onTap_startBtn)
let user = new window['SVGA'].EgretMovieClip(SVGACtrl.instance.getSVGAByName("user"));
user.x = -11;
user.y = 60;
this.user.y = GameConst.stage.stageHeight - 300;
}
this.user.addChild(user)
guideBallon
guideStep1() {
let mask = GameConst.drawCircleMask(375, 940, 150)
this.step1.visible = true;
this.step1.addChild(mask)
this.user.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBegin, this)
this.user.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onTouchEnd, this)
this.user.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.onTouchEnd, this)
this.user.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEnd, this)
let tips = new eui.Label()
tips.text = `连续点击按钮即可为气球打气`
tips.horizontalCenter = 0;
tips.y = 700
this.step1.addChild(tips)
this.endTime = GameConst.time.now() + 30000
// this.initBarriers()
this.pumpBtn.source = `pumpDownBtn_png`
this.pumpBtn.y = 825 + 24
egret.Tween.removeTweens(this.pumpBtn)
egret.Tween.get(this.pumpBtn, { loop: true })
.set({ y: 825 + 24 })
.to({ y: 825 + 22 }, 67)
.to({ y: 825 + 24 }, 67)
let finger = new eui.Image()
finger.source = `finger_png`;
finger.x = 375 + 15
finger.y = 940 + 15
this.step1.addChild(finger)
egret.Tween.get(finger, { loop: true })
.to({ scaleX: 0.95, scaleY: 0.95 }, 67)
.to({ scaleX: 1, scaleY: 1 }, 67)
this.guideBallon = new Ballon()
this.guideBallon.anchorOffsetX = 161
this.guideBallon.anchorOffsetY = 376;
this.guideBallon.x = 361
this.guideBallon.y = 802
this.guideBallon.scaleX = .5
this.guideBallon.scaleY = .5
this.gameLayer.addChildAt(this.guideBallon, 5)
egret.Tween.get(this.guideBallon)
.to({ scaleX: .7, scaleY: .7 }, 1000)
}
// 初始化场景
initScene() {
guideStep2() {
let mask = GameConst.drawCircleMask(375, 600, 200)
this.step1.visible = false;
this.step2.visible = true;
this.step2.addChild(mask)
let tips = new eui.Label()
tips.text = `当气球在虚线间内松开按钮停止打气,\n则打气成功即可放飞感恩气球`
tips.textAlign = "center"
tips.verticalAlign = "center"
tips.lineSpacing = 15;
tips.horizontalCenter = 0;
tips.y = 850
this.step2.addChild(tips)
this.pumpBtn.source = `pumpDownBtn_png`
this.pumpBtn.y = 825 + 24
this.countDownTxt.size = 30
this.countDownTxt.textColor = 0xffffff
egret.Tween.removeTweens(this.pumpBtn)
egret.Tween.get(this.pumpBtn, { loop: true })
.set({ y: 825 + 24 })
.to({ y: 825 + 22 }, 50)
.to({ y: 825 + 24 }, 50)
if (localStorage.getItem('isGuide' + window['CFG'].comsumerId) !== '1') {
this.startMark = false;
this.initGuide()
egret.Tween.get(this.guideBallon)
.to({ scaleX: 1, scaleY: 1 }, 1000)
}
guideStep3() {
let mask = GameConst.drawCircleMask(375, 600, 220)
this.step2.visible = false;
this.step3.visible = true;
this.step3.addChild(mask)
let tips = new eui.Label()
tips.text = `当气球大小超过虚线区间范围,\n气球爆破,游戏失败`
tips.textAlign = "center"
tips.verticalAlign = "center"
tips.lineSpacing = 15;
tips.horizontalCenter = 0;
tips.y = 850
this.step3.addChild(tips)
this.pumpBtn.source = `pumpDownBtn_png`
this.pumpBtn.y = 825 + 24
egret.Tween.removeTweens(this.pumpBtn)
egret.Tween.get(this.pumpBtn, { loop: true })
.set({ y: 825 + 24 })
.to({ y: 825 + 22 }, 50)
.to({ y: 825 + 24 }, 50)
egret.Tween.get(this.guideBallon)
.to({ scaleX: 1.1, scaleY: 1.1 }, 1000)
}
guideStep4() {
this.nextBtn.visible = false;
this.startBtn.visible = true;
this.skipBtn.visible = false;
let mask = GameConst.drawRectMask(150, 25, 450, 275)
this.step3.visible = false;
this.step4.visible = true;
this.step4.addChild(mask)
let tips = new eui.Label()
tips.text = `在规定时间内放飞四个感恩\n气球,则游戏成功`
tips.textAlign = "center"
tips.verticalAlign = "center"
tips.lineSpacing = 15;
tips.horizontalCenter = 0;
tips.y = 350
this.step4.addChild(tips)
}
// 开始游戏
restartGame() {
if (arr.contain(this.gameLayer.$children, this.guideBallon)) {
this.gameLayer.removeChild(this.guideBallon);
}
if (arr.contain(this.gameLayer.$children, this.currBallon)) {
this.gameLayer.removeChild(this.currBallon);
}
this.currBallon = new Ballon(this.ballonsPool[this.sucCount])
this.currBallon.anchorOffsetX = 161
this.currBallon.anchorOffsetY = 376;
this.currBallon.x = 361
this.currBallon.y = 802
this.currBallon.scaleX = .5
this.currBallon.scaleY = .5
this.gameLayer.addChildAt(this.currBallon, 5)
this.startCountDown();
}
// 确认游戏状态
async checkGameStatus() {
if (this.currBallon.scaleX > 0.98 && this.currBallon.scaleX <= 1.02) {
this.pumpBtn.touchEnabled = false
this.sucCount++;
console.log("成功次数:" + this.sucCount + "次");
// 气球飞上进度条 重置新气球
await this.currBallonFadeOut()
await this.smallBallonFadeIn()
if (this.sucCount >= 4) {
// 发送分数
this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame_countDown, this)
this.gameSuc()
return
}
this.leftCount.text = `X${4 - this.sucCount}`
await this.jumpToPump()
// this.pumpMark = false;
this.resetBallon()
} else {
this.startMark = true
// 不发分数
this.gameFail()
}
}
currBallonFadeOut() {
return new Promise(r => {
egret.Tween.get(this.currBallon)
.to({ y: 780, alpha: 0 }, 500)
.call(() => {
r()
})
guideStep = 1
initGuide() {
this.guideLayer.visible = true
// 未引导
this.bgSpeed = 0;
let snowBall = this.getNewBarrierByType(BarrierType.SNOWBALL);
snowBall.x = 550;
snowBall.y = 650;
this.currBarriers.push(snowBall);
this.gameLayer.addChildAt(snowBall, 0);
let stone = this.getNewBarrierByType(BarrierType.STONE);
stone.x = 200;
stone.y = 350;
this.currBarriers.push(stone);
this.gameLayer.addChildAt(stone, 0);
let giftBox = this.getNewBarrierByType(BarrierType.GIFTBOX);
giftBox.x = 200;
giftBox.y = 600;
this.currBarriers.push(giftBox);
this.gameLayer.addChildAt(giftBox, 0);
let hole = this.getNewBarrierByType(BarrierType.HOLE);
hole.x = 375;
hole.y = 750;
this.currBarriers.push(hole);
this.gameLayer.addChildAt(hole, 0);
let socks = this.getNewBarrierByType(BarrierType.SOCKS);
socks.x = 545;
socks.y = 455;
this.currBarriers.push(socks);
this.gameLayer.addChildAt(socks, 0);
let bell = this.getNewBarrierByType(BarrierType.BELL);
bell.x = 375;
bell.y = 300;
this.currBarriers.push(bell);
this.gameLayer.addChildAt(bell, 0);
localStorage.setItem('isGuide' + window['CFG'].comsumerId, "1");
this.guideStep1();
this.onTap(this.step1, this.guideStep2)
})
}
smallBallonFadeIn() {
return new Promise(r => {
let ballon = new eui.Image()
ballon.source = `ssBallon_${this.sBallonsArr[this.sucCount - 1]}_png`
ballon.alpha = 0;
ballon.scaleX = .8;
ballon.scaleY = .8;
ballon.x = this[`ssBallon${this.sucCount}`].x
ballon.y = this[`ssBallon${this.sucCount}`].y + 20
this.addChild(ballon)
egret.Tween.get(ballon)
.to({ y: this[`ssBallon${this.sucCount}`].y - 20, alpha: 1 }, 300)
.to({ y: this[`ssBallon${this.sucCount}`].y }, 100)
.call(() => {
r()
})
})
}
jumpToPump() {
return new Promise((r) => {
let sBallon = this.sBallonsPool[3 - this.sucCount]
sBallon.x = 81
sBallon.y = 863
this.gameLayer.addChild(sBallon)
let data = { a: 0 }
egret.Tween.get(data, {
onChange: () => {
sBallon.x = GameConst.bezier(data.a, 81, 150, 320)
sBallon.y = GameConst.bezier(data.a, 863, 650, 670)
// 开始游戏
restartGame() {
this.score = 0;
this.bgSpeed = -3;
this.guideLayer.visible = false;
this.startMark = true;
this.endTime = GameConst.time.now() + 30000
}
})
.to({ a: 1 }, 500)
.call(() => {
this.gameLayer.removeChild(sBallon)
r()
})
})
}
resetMark = false
resetBallon() {
if (arr.contain(this.gameLayer.$children, this.currBallon)) {
this.gameLayer.removeChild(this.currBallon);
}
this.currBallon = new Ballon(this.ballonsPool[this.sucCount])
this.currBallon.anchorOffsetX = 161
this.currBallon.anchorOffsetY = 376;
this.currBallon.x = 361
this.currBallon.y = 802
this.currBallon.scaleX = .5
this.currBallon.scaleY = .5
this.gameLayer.addChildAt(this.currBallon, 5)
this.pumpBtn.touchEnabled = true;
setTimeout(() => {
this.resetMark = false;
}, 500);
}
gameSuc() {
let orderId = DataManager.ins.getData("getNgameStartStatus").data.orderId
let orderId = DataManager.ins.getData("doJoin").data
let score = 1
let submitToken = DataManager.ins.getData("getNgameStartStatus").data.submitToken
NetPromise.submit(orderId, this.score, submitToken)
NetPromise.submit(orderId, score, submitToken)
.then(() => {
return NetPromise.getOrderStatus()
})
......@@ -172,440 +375,230 @@ export default class PlayScene extends Scene {
})
.catch(e => {
console.error(e);
PanelCtrl.instance.show(ModuleTypes.MSG_PANEL, { msg: "网络异常,请稍后重试~", type: "reload" })
let data = { type: noPrizeTypes.NOPRIZE }
PanelCtrl.instance.show(ModuleTypes.NOPRIZE_PANEL, data)
})
}
gameFail(type) {
PanelCtrl.instance.show(ModuleTypes.GAMEFAIL_PANEL, { type: type })
}
endTime: number;
initEvents() {
super.initEvents()
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
}
gameFail() {
let orderId = DataManager.ins.getData("doJoin").data
let score = 1
let submitToken = DataManager.ins.getData("getNgameStartStatus").data.submitToken
private startX: number = 375;
private startY: number = 0;
onTouchBegin(e) {
console.log(e);
this.startX = e.stageX;
this.startY = e.stageY;
this.user.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouchMove, this);
NetConst.ngameSubmit(() => {
let data = { type: noPrizeTypes.FAIL }
PanelCtrl.instance.show(ModuleTypes.NOPRIZE_PANEL, data)
}, orderId, score, '[]', '[]', submitToken)
}
onTouchMove(e) {
let offsetX = e.stageX - this.startX;
let offsetY = e.stageY - this.startY;
this.startX = e.stageX;
this.startY = e.stageY;
this.user.x += offsetX;
this.user.y += offsetY;
if (this.user.x > this.rightLimit) {
this.user.x = this.rightLimit;
}
endTime: number;
private async startCountDown() {
this.ready.visible = true;
if (this.user.x < this.leftLimit) {
this.user.x = this.leftLimit;
}
await this.aniNum3()
await this.aniNum2()
await this.aniNum1()
await this.aniReady()
await this.aniGo()
if (this.user.y > this.bottomLimit) {
this.user.y = this.bottomLimit
}
this.ready.visible = false;
if (this.user.y < this.topLimit) {
this.user.y = this.topLimit
}
}
let now = GameConst.time.now();
this.endTime = now + 30000
onTouchEnd() {
this.startX = 375;
this.user.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouchMove, this);
this.countDownTxt.text = `30S`
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame_countDown, this)
}
startMark: boolean = false
onEnterFrame() {
this.musicOn.rotation += 1;
if (this.startMark) {
// 倒计时 结束游戏
if (GameConst.time.now() > this.endTime) {
this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this)
this.bg.isPause = true;
this.gameSuc()
}
let time = Math.floor(GameConst.time.getEndTime(this.endTime).s)
this.countDownTxt.text = `时间:${time}S`
this.bgSpeed -= 0.002
this.bg.speed = -this.bgSpeed
let collisionBarrier = null;
if (this.currBarriers && this.currBarriers.length > 0) {
for (let i = this.currBarriers.length - 1; i >= 0; i--) {
let barrier = this.currBarriers[i]
// 碰撞
if (GameConst.collisionDetection(this.user, barrier, -20)) {
collisionBarrier = barrier;
break
}
initEvents() {
super.initEvents()
this.pumpBtn.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onDown_pumpBtn, this);
if (barrier.barrierType == BarrierType.SNOWBALL) {
barrier.y = barrier.y - this.bgSpeed + 3
} else {
barrier.y -= this.bgSpeed
}
this.pumpBtn.addEventListener(egret.TouchEvent.TOUCH_END, this.onUp_pumpBtn, this);
this.pumpBtn.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onUp_pumpBtn, this);
this.pumpBtn.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.onUp_pumpBtn, this);
if (barrier.y > 1800) {
arr.removeEle(barrier, this.currBarriers)
this.gameLayer.removeChild(barrier)
}
}
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame_smaller, this)
}
if (collisionBarrier) {
switch (collisionBarrier.barrierType) {
case BarrierType.BELL:
case BarrierType.GIFTBOX:
case BarrierType.SOCKS:
this.score += 10;
this.scoreTxt.text = this.score + "";
arr.removeEle(collisionBarrier, this.currBarriers)
let collect = new window['SVGA'].EgretMovieClip(SVGACtrl.instance.getSVGAByName("collect"));
collect.x = -30;
collect.y = -30;
this.user.addChildAt(collect, 0)
collisionBarrier.x = 70;
collisionBarrier.y = 100;
this.user.addChildAt(collisionBarrier, 0)
setTimeout(() => {
this.user.removeChild(collect)
egret.Tween.get(collisionBarrier)
.to({ scaleX: 0, scaleY: 0 }, 330)
.call(() => {
this.user.removeChild(collisionBarrier)
})
}, 200);
break;
case BarrierType.HOLE:
this.gamePuase()
this.user.visible = false;
let smoke = new window['SVGA'].EgretMovieClip(SVGACtrl.instance.getSVGAByName("fall"));
smoke.x = collisionBarrier.x - 80;
smoke.y = collisionBarrier.y - 150;
this.gameLayer.addChild(smoke)
setTimeout(() => {
this.gameLayer.removeChild(smoke)
}, 200);
setTimeout(() => {
this.gameFail(BarrierType.HOLE)
}, 1000);
break;
case BarrierType.STONE:
this.gamePuase()
let impact_user = new window['SVGA'].EgretMovieClip(SVGACtrl.instance.getSVGAByName("impact_user"));
impact_user.x = this.user.x - 40;
impact_user.y = this.user.y - 90;
this.gameLayer.addChild(impact_user)
let impact_stone = new window['SVGA'].EgretMovieClip(SVGACtrl.instance.getSVGAByName("impact_stone"));
impact_stone.x = -60;
impact_stone.y = -100;
this.user.addChildAt(impact_stone, 0)
setTimeout(() => {
this.user.removeChild(impact_stone)
}, 200);
setTimeout(() => {
this.gameFail(BarrierType.STONE)
}, 1000);
break;
case BarrierType.SNOWBALL:
this.gamePuase()
this.snowCrash().then(() => {
this.gameFail(BarrierType.SNOWBALL)
})
break
}
}
onTap_startBtn() {
// 移除引导层
this.guideLayer.visible = false;
egret.Tween.removeTweens(this.pumpBtn)
this.pumpBtn.source = "pumpUpBtn_png"
this.pumpBtn.y = 825
}
if (this.currBarriers.length < 6) {
let type = arr.getRandomOne([BarrierType.BELL, BarrierType.GIFTBOX, BarrierType.HOLE, BarrierType.SNOWBALL, BarrierType.SOCKS, BarrierType.STONE])
let barrier = this.getNewBarrierByType(type);
let collsionMark = false;
let horizontalMark = false;
for (let t = this.currBarriers.length - 1; t >= 0; t--) {
let ba = this.currBarriers[t]
if (GameConst.collisionDetection(barrier, ba, -25)) {
collsionMark = true
}
if (Math.abs(barrier.y - ba.y) < 100) {
horizontalMark = true
}
}
this.restartGame()
}
// 新建的障碍不在同一水平面上
// 新建的障碍没有碰撞 加到场景中
if (!collsionMark && !horizontalMark) {
if (barrier.barrierType == BarrierType.SNOWBALL) {
this.gameLayer.addChildAt(barrier, 7)
} else {
this.gameLayer.addChildAt(barrier, 0)
}
this.gameLayer.addChild(barrier)
this.currBarriers.push(barrier)
}
}
onEnterFrame_smaller() {
if (this.currBallon && this.currBallon.scaleX > .5 && !this.resetMark) {
this.currBallon.scaleX -= this.pumpSpeed / 20
this.currBallon.scaleY -= this.pumpSpeed / 20
}
}
if (!this.bg.isPause) {
if (this.bg.displayArr.length >= 2) {
let bg = this.bg.displayArr[0]
let bg2 = this.bg.displayArr[1]
if (bg.y >= 1624) {
bg.y = bg2.y - 1624
} else {
bg.y += this.bg.speed;
}
if (bg2.y >= 1624) {
bg2.y = bg.y - 1624
} else {
bg2.y += this.bg.speed;
}
}
}
onEnterFrame_countDown() {
let time = Math.floor(GameConst.time.getEndTime(this.endTime).s)
if (time <= 5) {
this.countDownTxt.size = 56
this.countDownTxt.textColor = 0xff0000
} else {
this.countDownTxt.size = 42
this.countDownTxt.textColor = 0xEA7244
}
this.countDownTxt.text = `${time}S`
if (GameConst.time.now() > this.endTime) {
this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame_countDown, this)
this.checkGameStatus()
}
}
removeEvents() {
super.removeEvents()
this.user.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBegin, this);
this.user.removeEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEnd, this);
this.user.removeEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onTouchEnd, this);
this.user.removeEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.onTouchEnd, this);
this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this)
onTap_nextBtn() {
this.guideStep++
}
}
gamePuase() {
this.bg.isPause = true;
this.user.touchEnabled = false;
this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this)
this.user.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBegin, this);
this.user.removeEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEnd, this);
this.user.removeEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onTouchEnd, this);
this.user.removeEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.onTouchEnd, this);
// pumpMark = false;
pumpSpeed = window["pumpSpeed"] || 0.01
pumpAddSpeed = window["pumpAddSpeed"] || 0.005
onDown_pumpBtn() {
if (this.resetMark) {
return
}
// this.pumpMark = true;
this.pumpBtn.source = "pumpDownBtn_png"
this.pumpBtn.y = 825 + 24
egret.Tween.get(this.pumpBtn, { loop: true })
.set({ y: 825 + 24 })
.to({ y: 825 + 22 }, 50)
.to({ y: 825 + 24 }, 50)
if (this.currBallon.scaleX < 1.2) {
this.currBallon.scaleX += this.pumpSpeed
this.currBallon.scaleY += this.pumpSpeed
this.pumpSpeed += this.pumpAddSpeed
} else {
}
this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame_countDown, this)
this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame_smaller, this)
this.pumpBtn.touchEnabled = false
let svga = new window['SVGA'].EgretMovieClip(SVGACtrl.instance.getSVGAByName("explode"))
this.gameLayer.addChild(svga)
this.currBallon.explodeMark.alpha = 1;
setTimeout(() => {
this.gameLayer.removeChild(svga)
this.gameFail()
}, 500);
// 新建障碍
private leftLimit = 100;
private rightLimit = 650;
private topLimit = 200;
private bottomLimit = GameConst.stage.stageHeight - 200;
getNewBarrierByType(type: BarrierType) {
let barrier: Barrier;
switch (type) {
case BarrierType.BELL:
barrier = new Barrier(BarrierType.BELL);
barrier.source = `bell_png`;
barrier.score = 10;
barrier.anchorOffsetX = 93 / 2;
barrier.anchorOffsetY = 102 / 2;
barrier.x = Math.min(this.rightLimit, Math.max(this.leftLimit, Math.random() * 750));
barrier.y = Math.min(Math.random() * -1500, -500);
break;
case BarrierType.GIFTBOX:
barrier = new Barrier(BarrierType.GIFTBOX);
barrier.source = `giftBox_png`;
barrier.score = 10;
barrier.anchorOffsetX = 113 / 2;
barrier.anchorOffsetY = 112 / 2;
barrier.x = Math.min(this.rightLimit, Math.max(this.leftLimit, Math.random() * 750));
barrier.y = Math.min(Math.random() * -1500, -500);
break;
case BarrierType.HOLE:
barrier = new Barrier(BarrierType.HOLE);
barrier.source = `hole_png`;
barrier.score = 10;
barrier.anchorOffsetX = 223 / 2;
barrier.anchorOffsetY = 86 / 2;
barrier.x = Math.min(this.rightLimit, Math.max(this.leftLimit, Math.random() * 750));
barrier.y = Math.min(Math.random() * -1500, -500);
break;
case BarrierType.SOCKS:
barrier = new Barrier(BarrierType.SOCKS);
barrier.source = `socks_png`;
barrier.anchorOffsetX = 103 / 2;
barrier.anchorOffsetY = 109 / 2;
barrier.x = Math.min(this.rightLimit, Math.max(this.leftLimit, Math.random() * 750));
barrier.y = Math.min(Math.random() * -1500, -500);
break;
case BarrierType.SNOWBALL:
barrier = new Barrier(BarrierType.SNOWBALL);
barrier.source = `snowBall_png`;
barrier.anchorOffsetX = 88 / 2;
barrier.anchorOffsetY = 100 / 2;
barrier.x = Math.min(this.rightLimit, Math.max(this.leftLimit, Math.random() * 750));
barrier.y = Math.min(Math.random() * -1500, -500);
break;
case BarrierType.STONE:
barrier = new Barrier(BarrierType.STONE);
barrier.source = `stone_png`;
barrier.anchorOffsetX = 130 / 2;
barrier.anchorOffsetY = 106 / 2;
barrier.x = Math.min(this.rightLimit, Math.max(this.leftLimit, Math.random() * 750));
barrier.y = Math.min(Math.random() * -1500, -500);
break;
}
// barrier.barrierType = type;
return barrier;
}
guideStep1() {
let mask = GameConst.drawCircleMask(this.user.x, this.user.y, 120)
this.step1.addChild(mask)
let up = new eui.Image();
up.source = `guideDir_png`;
up.anchorOffsetX = 30;
up.anchorOffsetY = 30;
up.x = this.user.x;
up.y = this.user.y - 180;
this.step1.addChild(up)
let down = new eui.Image();
down.source = `guideDir_png`;
down.anchorOffsetX = 30;
down.anchorOffsetY = 30;
down.rotation = 180;
down.x = this.user.x;
down.y = this.user.y + 180;
this.step1.addChild(down)
let right = new eui.Image();
right.source = `guideDir_png`;
right.anchorOffsetX = 30;
right.anchorOffsetY = 30;
right.rotation = 90;
right.x = this.user.x + 180;
right.y = this.user.y;
this.step1.addChild(right)
let left = new eui.Image();
left.source = `guideDir_png`;
left.anchorOffsetX = 30;
left.anchorOffsetY = 30;
left.rotation = 270;
left.x = this.user.x - 180;
left.y = this.user.y;
this.step1.addChild(left)
egret.Tween.get(up, { loop: true })
.to({ y: this.user.y - 200 }, 1000)
egret.Tween.get(down, { loop: true })
.to({ y: this.user.y + 200 }, 1000)
egret.Tween.get(left, { loop: true })
.to({ x: this.user.x - 200 }, 1000)
egret.Tween.get(right, { loop: true })
.to({ x: this.user.x + 200 }, 1000)
let tips = new eui.Image();
tips.source = `step1Tips_png`;
tips.horizontalCenter = 0;
tips.y = 700;
this.step1.addChild(tips)
this.onTap(this.step2, this.guideStep3)
onUp_pumpBtn() {
if (this.resetMark) {
return
}
egret.Tween.removeTweens(this.pumpBtn)
this.pumpBtn.source = "pumpUpBtn_png"
this.pumpBtn.y = 825
if (this.currBallon.scaleX > 0.98 && this.currBallon.scaleX <= 1.02) {
this.resetMark = true
this.checkGameStatus()
}
}
guideStep2() {
this.step1.visible = false;
this.step2.visible = true;
let mask: egret.Shape = new egret.Shape();
// 画方形
mask.graphics.beginFill(0x000000, 0.7);
mask.graphics.moveTo(0, 0);
mask.graphics.lineTo(750, 0);
mask.graphics.lineTo(750, GameConst.stage.stageHeight);
mask.graphics.lineTo(0, GameConst.stage.stageHeight);
mask.graphics.lineTo(0, 0);
// 画圆
mask.graphics.drawArc(550, 650, 70, 0, Math.PI * 2, true)
mask.graphics.drawArc(200, 350, 70, 0, Math.PI * 2, true)
mask.graphics.drawArc(375, 750, 90, 0, Math.PI * 2, true)
mask.graphics.endFill();
mask.touchEnabled = true;
this.step2.addChild(mask)
removeEvents() {
super.removeEvents()
this.pumpBtn.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onDown_pumpBtn, this);
let tips = new eui.Image();
tips.source = `step2Tips_png`;
tips.horizontalCenter = 0;
tips.y = 450;
this.step2.addChild(tips)
this.pumpBtn.removeEventListener(egret.TouchEvent.TOUCH_END, this.onUp_pumpBtn, this);
this.pumpBtn.removeEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onUp_pumpBtn, this);
this.pumpBtn.removeEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.onUp_pumpBtn, this);
this.clearTap(this.skipBtn, this.onTap_startBtn)
this.clearTap(this.nextBtn, this.onTap_nextBtn)
this.clearTap(this.startBtn, this.onTap_startBtn)
}
guideStep3() {
this.step2.visible = false;
this.step3.visible = true;
let mask = GameConst.drawRectMask(200, 0, 350, 250)
this.step3.addChild(mask)
aniNum3() {
return new Promise((r) => {
this.ready['num3'].alpha = 1;
egret.Tween.get(this.ready['num3'])
.to({ scaleX: 1, scaleY: 1 }, 200)
.wait(600)
.to({ scaleX: 0, scaleY: 0 }, 200)
.call(() => {
r()
})
})
}
let tips = new eui.Image();
tips.source = `step3Tips_png`;
tips.horizontalCenter = 0;
tips.y = 300;
this.step3.addChild(tips)
this.onTap(this.step3, this.restartGame)
aniNum2() {
return new Promise((r) => {
this.ready['num2'].alpha = 1;
egret.Tween.get(this.ready['num2'])
.to({ scaleX: 1, scaleY: 1 }, 200)
.wait(600)
.to({ scaleX: 0, scaleY: 0 }, 200)
.call(() => {
r()
})
})
}
aniNum1() {
return new Promise((r) => {
this.ready['num1'].alpha = 1;
egret.Tween.get(this.ready['num1'])
.to({ scaleX: 1, scaleY: 1 }, 200)
.wait(600)
.to({ scaleX: 0, scaleY: 0 }, 200)
.call(() => {
r()
})
})
}
// 动效部分
snowCrash() {
aniReady() {
return new Promise((r) => {
let a = { t: 0 }
let y = this.user.y;
egret.Tween.get(a, {
onChange: () => {
this.user.x = GameConst.bezier(a.t, this.user.x, 700, 900)
this.user.y = GameConst.bezier(a.t, y, y - 300, y)
this.user.rotation = 2880 * a.t;
this.user.scaleX = 1 - a.t
this.user.scaleY = 1 - a.t
}
})
.to({ t: 1 }, 1500)
this.ready['ready'].alpha = 1;
egret.Tween.get(this.ready['ready'])
.to({ scaleX: 1, scaleY: 1 }, 200)
.wait(600)
.to({ scaleX: 0, scaleY: 0 }, 200)
.call(() => {
r()
})
})
}
aniGo() {
return new Promise((r) => {
this.ready['go'].alpha = 1;
egret.Tween.get(this.ready['go'])
.to({ scaleX: 1, scaleY: 1 }, 200)
.wait(600)
.to({ scaleX: 0, scaleY: 0 }, 200)
.call(() => {
r()
})
})
}
}
export enum noPrizeTypes {
......
......@@ -59,14 +59,14 @@
"type": "hdtool",
"element": {
"isCreditsTypeOpen": false,
"myCreditsLong": 1000,
"freeLimit": 1,
"myCreditsLong": 100,
"freeLimit": 0,
"success": false,
"myCredits": "999999632167",
"needCredits": "100",
"freeEmpty": true,
"needCreditsLong": 100,
"status": 5
"status": 0
}
},
"success": true,
......
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