Commit bdb50bfc authored by XieChuanJin's avatar XieChuanJin

终版

parent cfb218f8
......@@ -8,7 +8,7 @@
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" />
<meta name="full-screen" content="true" />
<meta name="screen-orientation" content="portrait" />
<meta name="screen-orientation" content="landscapeFlipped" />
<meta name="x5-fullscreen" content="true" />
<meta name="360-fullscreen" content="true" />
<style>
......@@ -46,7 +46,59 @@
<script src="output.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript" src="libs/svga.egret.min.js"></script>
<script>
var ant = {
speedValue: 10
}
/**腿动效参数 */
var legTweenParam = {
//垂直方向上升阶段
rise: {
duration: { //以下3个阶段的时间
speedUp: 200, //从0加速到maxSpeed的持续时间
keep: 200, //保持maxSpeed的时间
slowDown: 100 //从maxSpeed减速到0的时间
},
maxSpeed: 10
},
fall: { //垂直方向下落阶段
speedUp1: { //加速阶段1
duration: 300,
value: 15 //加速到的速度值
},
speedUp2: { //加速阶段2
duration: 1200, //这个持续时间不是真正的持续时间,因为腿落地就会停止动效,所以这个是最大值,一般达不到
value: 20 //加速到的速度值
}
},
horizontal: { //水平方向
phase1Speed: 16, //水平方向1阶段最大速度。1阶段持续时间等于垂直方向上升阶段之和
phase2Speed: 10 //水平方向2阶段最大速度。2阶段持续时间等于垂直方向下落阶段之和
}
}
/**蚂蚁和腿之间可以引起蚂蚁注视的距离 */
var distanceAntToLegWhenAntLook = 400;
/**腿超出舞台边界会被销毁的距离 */
var distanceOverStageWhlieLegDestroy = 10;
//蚂蚁动效参数
var antTween = {
leg: { //腿部
maxRotationValue: 6, //最大旋转角度,角度制
duration: 40 //旋转周期的时长
},
turnVelocityCoefficient: 0.12 //蚂蚁各个部分的速度系数,具体机制不用了解,只需知道增大此值蚂蚁转向的速度变快,反之变慢
}
var goldCoin = {
gravity: 0.6, //掉落阶段受到的重力加速度
bounceCoefficient: 0.5, //弹性系数,即掉落到地面能量损失率,取值区间[0,1]
moveAccelerationX: 1, //被脚踩后弹开的加速阶段的水平加速度
moveSlowDownDuration: 50, //离开脚后减速到0所需的时间,单位毫秒
moveVelocityY: 15 //被脚踩之后的垂直速率
}
</script>
<script>
var development = true;
var CFG = {
......
......@@ -67,6 +67,7 @@ export enum NetName {
PETS_GET_VISIT_INFO,
PETS_VISIT_DETAIL,
PETS_COLLECT_GIFT_RECORD,
DO_JOIN_DATA2,
//携程养成
PETS_USE_TOYS_XCH,
TOY_EXCHANGES_DATA_XC,
......
......@@ -309,9 +309,9 @@ export class NetManager extends ABNetManager {
* @param {number} pollingCount 最大轮询次数
* @param {number} customizedType
*/
public getStartStatus(callback: Function, ticketId: number, pollingCheck: Function, pollingCount = 5, customizedType?: number): void {
public getStartStatus(callback: Function, orderId: number, pollingCheck: Function, pollingCount = 5, customizedType?: number): void {
const param: any = {
ticketId: ticketId
orderId: orderId
};
if (customizedType) {
param.customizedType = customizedType
......@@ -319,7 +319,7 @@ export class NetManager extends ABNetManager {
const net: INetData = {
name: NetName.GAME_START_STATUS_NEW,
uri: '/ngapi/getStartStatus',
uri: '/hdtool/recon/ngame/getNgameStartStatus',
type: 'post',
dataType: 'json',
param: param,
......@@ -841,6 +841,29 @@ export class NetManager extends ABNetManager {
this.getToken(net);
}
/**
* 活动工具抽奖
* @param {number} collectRuleId 集卡规则ID,活动与集卡规则关联才能获得发卡资格
*/
public doJoin2(callback: Function, collectRuleId?: number): void {
const param: any = {
actId: DataManager.ins.customCfgData.actId,
oaId: DataManager.ins.customCfgData.oaId
};
if (collectRuleId) {
param.collectRuleId = collectRuleId;
}
const net: INetData = {
name: NetName.DO_JOIN_DATA2,
uri: window['CFG'].doJoin,
type: 'post',
dataType: 'json',
param: param,
callback: callback
};
this.getToken(net);
}
/**
* 活动工具查询订单结果
* @param orderId
......@@ -2023,6 +2046,7 @@ export class NetManager extends ABNetManager {
protected onResponse(net: INetData, result: any): void {
//数据处理
const data: Data = DataManager.ins.updateData(net.name, result, net.param);
window["netData"][net.uri] = result;
if (net.pollingCheck) {
console.log('result=====', result);
console.log('data=====', data);
......@@ -2087,8 +2111,8 @@ export class NetManager extends ABNetManager {
let msg: string = null;
switch (res["code"]) {
case "100201001":
msg = "您还未登录,请先登录";
GameMgr.instance.isLogined = false;
// msg = "您还未登录,请先登录";
return;
break;
case "100201007":
return; //交给回调逻辑处理
......
{
"type": "activity",
"name": "zhonghe20190918"
"name": "ant_race_2019"
}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"load_scene","version":5,"files":["..\\assets\\load_scene\\load_ant.png","..\\assets\\load_scene\\load_landscape.png","..\\assets\\load_scene\\load_progress_bg.png","..\\assets\\load_scene\\load_progress_fill.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"main_res","version":5,"files":["..\\assets\\main_res\\ant.png","..\\assets\\main_res\\leg.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"main_res","version":5,"files":["..\\assets\\main_res\\ant.png","..\\assets\\main_res\\gold_coin.png","..\\assets\\main_res\\leg6.png","..\\assets\\main_res\\leg1.png","..\\assets\\main_res\\leg2.png","..\\assets\\main_res\\leg3.png","..\\assets\\main_res\\leg4.png","..\\assets\\main_res\\leg5.png","..\\assets\\main_res\\gold_coin_shadow.png","..\\assets\\main_res\\leg_shadow.png","..\\assets\\main_res\\ant_body.png","..\\assets\\main_res\\ant_head.png","..\\assets\\main_res\\ant_leg.png","..\\assets\\main_res\\ant_tail.png","..\\assets\\main_res\\ant_tentacle.png","..\\assets\\main_res\\ant_eyeball.png","..\\assets\\main_res\\ant_eyewhite.png","..\\assets\\main_res\\ant_face.png","..\\assets\\main_res\\ant_mouth_smile.png","..\\assets\\main_res\\ant_mouth_fear.png","..\\assets\\main_res\\ant_shadow.png","..\\assets\\main_res\\guide.png","..\\assets\\main_res\\guide_arrows.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"main_scene","version":5,"files":["..\\assets\\main_scene\\main_btnSound.png","..\\assets\\main_scene\\main_score_bg.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"not_winning_panel","version":5,"files":["..\\assets\\not_winning_panel\\not_winning_bg.png","..\\assets\\not_winning_panel\\not_winning_btn_restart.png","..\\assets\\not_winning_panel\\not_winning_example.png","..\\assets\\common\\list_line.png","..\\assets\\common\\btn_close.png","..\\assets\\common\\panel_bg.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"rank_list_panel","version":5,"files":["..\\assets\\rank_list_panel\\rank_list_bg.png","..\\assets\\rank_list_panel\\rank_list_example.png","..\\assets\\rank_list_panel\\rank_list_separator.png","..\\assets\\rank_list_panel\\rank_list_sliderbar.png","..\\assets\\common\\panel_bg.png","..\\assets\\common\\btn_close.png","..\\assets\\common\\list_line.png","..\\assets\\rank_list_panel\\rank_list_title_icon.png","..\\assets\\rank_list_panel\\rank_list_empty.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"rule_panel","version":5,"files":["..\\assets\\common\\btn_close.png","..\\assets\\rule_panel_example.png","..\\assets\\rule_panel\\rule_bg.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"sound_panel","version":5,"files":["..\\assets\\sound_panel\\sound_bg.png","..\\assets\\sound_panel\\sound_example.png","..\\assets\\sound_panel\\sound_toggle_off.png","..\\assets\\sound_panel\\sound_toggle_on.png","..\\assets\\common\\btn_close.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"start_scene","version":5,"files":["..\\assets\\start_scene\\start_btn_login.png","..\\assets\\start_scene\\start_btn_rank.png","..\\assets\\start_scene\\start_btn_record.png","..\\assets\\start_scene\\start_btn_rule.png","..\\assets\\start_scene\\start_btn_sound.png","..\\assets\\start_scene\\start_btn_start.png","..\\assets\\start_scene\\start_title.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"toast","version":5,"files":["..\\assets\\common\\toast_bg.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"winning_panel","version":5,"files":["..\\assets\\winning_panel\\winning_bg.png","..\\assets\\winning_panel\\winning_btn_restart.png","..\\assets\\winning_panel\\winning_example.png","..\\assets\\winning_panel\\winning_light.png","..\\assets\\winning_panel\\winning_light_bg.png","..\\assets\\winning_panel\\winning_receive.png","..\\assets\\winning_panel\\winning_ribbon.png"]}
\ No newline at end of file
{"mc":{
"eat_gold_coin":{
"frameRate":24,
"frameRate":48,
"events":[
],
......
......@@ -13,11 +13,11 @@
"name":"main_scene"
},
{
"keys":"btn_close_png",
"keys":"btn_close_png,rule_panel_example_png,rule_bg_png",
"name":"rule_panel"
},
{
"keys":"ant_png,gold_coin_png,bg2_jpg,bg3_jpg,bg1_jpg,leg6_png,leg1_png,leg2_png,leg3_png,leg4_png,leg5_png,gold_coin_shadow_png,leg_shadow_png,ant_body_png,ant_head_png,ant_leg_png,ant_tail_png,ant_tentacle_png,ant_eyeball_png,ant_eyewhite_png,ant_face_png,ant_mouth_smile_png,ant_mouth_fear_png,ant_shadow_png",
"keys":"ant_png,gold_coin_png,bg2_jpg,bg3_jpg,bg1_jpg,leg6_png,leg1_png,leg2_png,leg3_png,leg4_png,leg5_png,gold_coin_shadow_png,leg_shadow_png,ant_body_png,ant_head_png,ant_leg_png,ant_tail_png,ant_tentacle_png,ant_eyeball_png,ant_eyewhite_png,ant_face_png,ant_mouth_smile_png,ant_mouth_fear_png,ant_shadow_png,guide_png,guide_arrows_png",
"name":"main_res"
},
{
......@@ -482,6 +482,26 @@
"name":"ant_shadow_png",
"type":"image",
"url":"assets/main_res/ant_shadow.png"
},
{
"name":"rule_panel_example_png",
"type":"image",
"url":"assets/rule_panel_example.png"
},
{
"name":"guide_png",
"type":"image",
"url":"assets/main_res/guide.png"
},
{
"name":"rule_bg_png",
"type":"image",
"url":"assets/rule_panel/rule_bg.png"
},
{
"name":"guide_arrows_png",
"type":"image",
"url":"assets/main_res/guide_arrows.png"
}
]
}
\ No newline at end of file
{
"skins": {},
"autoGenerateExmlsList": true,
"exmls": [
"resource/skins/AlertSkin.exml",
"resource/skins/LoadingSkin.exml",
"resource/skins/RulePanelSkin.exml",
"resource/skins/RankItem.exml"
],
"path": "resource/default.thm.json"
"skins": {},
"autoGenerateExmlsList": true,
"exmls": [
"resource/skins/AlertSkin.exml",
"resource/skins/Ant.exml",
"resource/skins/LoadingSkin.exml",
"resource/skins/LoadSceneSkin.exml",
"resource/skins/MainSceneUI.exml",
"resource/skins/NotWinningPanelSkin.exml",
"resource/skins/ProgressBar.exml",
"resource/skins/RankItem.exml",
"resource/skins/RankListPanelSkin.exml",
"resource/skins/RulePanelSkin.exml",
"resource/skins/SoundPanelSkin.exml",
"resource/skins/StartSceneUI.exml",
"resource/skins/ToastPanelSkin.exml",
"resource/skins/WinningPanelSkin.exml"
],
"path": "resource/default.thm.json"
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
<e:Image source="load_bg_jpg" horizontalCenter="0" verticalCenter="0"/>
<e:Image source="load_landscape_png" x="767.07" y="560.19"/>
<e:Label text="请使用横屏开始游戏" x="736.44" y="658.08" textColor="0x333333" size="20"/>
<e:Image source="load_ant_png" x="787" y="388"/>
<e:Image id="ant" source="load_ant_png" x="787" y="388" visible="false"/>
<e:Label id="labelProgress" text="50%" x="795" y="480" textColor="0xfd4281" size="30"/>
</e:Group>
<e:Image source="load_example_jpg" horizontalCenter="0" verticalCenter="0" alpha="0.5" visible="false"/>
......
......@@ -7,6 +7,7 @@
cacheAsBitmap="false" width="656"/>
<e:Image id="mask" source="load_progress_fill_png" anchorOffsetX="0"
cacheAsBitmap="false" scale9Grid="31,4,591,28"/>
<e:Image id="ant" source="load_ant_png" x="33" y="-37" scaleX="1" scaleY="1"/>
</e:Group>
</e:Group>
</e:Skin>
\ No newline at end of file
......@@ -3,10 +3,10 @@
<e:Group height="56" anchorOffsetX="0" anchorOffsetY="0" left="0" right="0" y="0" x="0" scaleX="1" scaleY="1">
<e:Label id="labelRank" text="1" textColor="0x333333" size="20" left="20" verticalCenter="0" x="17" y="15" scaleX="1"
scaleY="1" />
<e:Label id="labelNickname" text="昵称昵称昵称昵称 " textColor="0x333333" size="20" left="108" verticalCenter="0" x="107" y="15" scaleX="1"
scaleY="1" />
<e:Label id="labelScore" text="123456" textColor="0x333333" size="20" left="403" verticalCenter="0" x="422" y="15" scaleX="1"
scaleY="1" />
<e:Label id="labelNickname" text="昵称昵称" textColor="0x333333" size="20" verticalCenter="0" y="15" scaleX="1"
scaleY="1" horizontalCenter="-72"/>
<e:Label id="labelScore" text="12" textColor="0x333333" size="20" verticalCenter="0" y="15" scaleX="1"
scaleY="1" horizontalCenter="186.5"/>
<e:Image source="list_line_png" horizontalCenter="0" bottom="0" />
</e:Group>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="RulePanel" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing" width="750" height="1624">
<e:Skin class="RulePanel" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing" width="1624" height="750">
<w:Config id="16d19576d08" />
<e:Group width="640" verticalCenter="-50" horizontalCenter="0" alpha="0.9">
<e:Scroller left="50" right="50" top="100" height="640" bounces="false">
<e:Group width="573" verticalCenter="-1" horizontalCenter="0.5" alpha="1" height="638" anchorOffsetY="0">
<e:Image source="panel_bg_png" scaleX="1" scaleY="1" anchorOffsetY="0" height="638"/>
<e:Image horizontalCenter="0.5" top="81" anchorOffsetY="0" height="546" source="rule_bg_png"/>
<e:Scroller left="70" right="70" top="128" height="424.12" bounces="false" anchorOffsetY="0" anchorOffsetX="0">
<e:Group>
<e:Label id="text" text="" textColor="0xcccccc" left="0" right="0" size="23" lineSpacing="20" top="10"
width="460" />
<e:Label id="text" text="" left="0" right="0" size="24" lineSpacing="20" top="10"
width="460" textColor="0x333333"/>
</e:Group>
</e:Scroller>
<e:Label id="title" text="活动规则" horizontalCenter="0" top="40" size="40" textAlign="center" textColor="0xcccccc" />
<e:Button id="closeBtn" horizontalCenter="0" verticalCenter="386">
<e:Label id="title" text="活动规则" horizontalCenter="0" top="20" size="36" textAlign="center" textColor="0xffffff"/>
<e:Button id="closeBtn" horizontalCenter="255.5" verticalCenter="-285">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="btn_close_png" />
......@@ -17,5 +19,8 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Image source="rank_list_title_icon_png" x="146" y="34"/>
<e:Image source="rank_list_title_icon_png" x="433" y="34" scaleX="-1"/>
</e:Group>
<e:Image source="rule_panel_example_png" horizontalCenter="0" verticalCenter="0" alpha="0.5" visible="false"/>
</e:Skin>
\ No newline at end of file
......@@ -3,9 +3,11 @@
xmlns:w="http://ns.egret.com/wing">
<e:Group width="391" height="289" anchorOffsetY="0" anchorOffsetX="0" top="230" horizontalCenter="0">
<e:Image source="sound_bg_png" />
<e:Button id="closeBtn" label="" horizontalCenter="172.5" verticalCenter="-180.5" x="376" y="-55" scaleX="1" scaleY="1">
<e:Button id="closeBtn" label="" horizontalCenter="172.5" verticalCenter="-180.5" x="376" y="-55" scaleX="1"
scaleY="1">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Rect fillColor="0xffffff" alpha="0" left="0" right="0" top="0" bottom="0" />
<e:Image width="100%" height="100%" source="btn_close_png" />
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0" />
</e:Skin>
......@@ -26,5 +28,6 @@
</e:Skin>
</e:ToggleSwitch>
</e:Group>
<e:Image source="sound_example_png" horizontalCenter="0" verticalCenter="0" alpha="0.5" locked="true" visible="false"/>
<e:Image source="sound_example_png" horizontalCenter="0" verticalCenter="0" alpha="0.5" locked="true"
visible="false" />
</e:Skin>
\ No newline at end of file
......@@ -3,7 +3,7 @@
xmlns:w="http://ns.egret.com/wing">
<e:Group width="1624" height="750" verticalCenter="0" horizontalCenter="0">
<e:Image source="start_bg_jpg" horizontalCenter="0" verticalCenter="0" visible="false"/>
<e:Image source="start_title_png" x="391.35" y="20" />
<e:Image source="start_title_png" y="20" horizontalCenter="0"/>
<e:Button id="btnLogin" label="" horizontalCenter="-15" verticalCenter="205" visible="false">
<e:skinName>
<e:Skin states="up,down,disabled">
......@@ -12,7 +12,7 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="btnStart" label="" horizontalCenter="-15" verticalCenter="205">
<e:Button id="btnStart" label="" horizontalCenter="0" verticalCenter="205">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" scaleX.down="0.9" scaleY.down="0.9" source="start_btn_start_png" />
......@@ -20,7 +20,7 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="btnRank" label="" horizontalCenter="-486.5" verticalCenter="-276">
<e:Button id="btnRank" label="" verticalCenter="-276" horizontalCenter="-511.5">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" scaleX.down="0.9" scaleY.down="0.9" source="start_btn_rank_png" />
......@@ -28,7 +28,7 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="btnRule" label="" horizontalCenter="-486.5" verticalCenter="-339">
<e:Button id="btnRule" label="" verticalCenter="-339" horizontalCenter="-511.5">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" scaleX.down="0.9" scaleY.down="0.9" source="start_btn_rule_png"/>
......@@ -36,7 +36,7 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="btnRecord" label="" horizontalCenter="512" verticalCenter="-340">
<e:Button id="btnRecord" label="" verticalCenter="-340" horizontalCenter="512">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" scaleX.down="0.9" scaleY.down="0.9" source="start_btn_record_png"/>
......@@ -44,7 +44,7 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="btnSound" label="" horizontalCenter="510" verticalCenter="-276">
<e:Button id="btnSound" label="" verticalCenter="-276" right="224">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" scaleX.down="0.9" scaleY.down="0.9" source="start_btn_sound_png"/>
......
......@@ -7,7 +7,7 @@
anchorOffsetY="327.27" x="288.21" y="151.26999999999998" />
<e:Image source="panel_bg_png" y="-1" x="0" />
<e:Image source="winning_ribbon_png" x="137.42" y="-64.15" scaleX="1" scaleY="1" />
<e:Image source="winning_bg_png" y="181" x="28" />
<e:Image source="winning_bg_png" horizontalCenter="-2.5" verticalCenter="10" visible="false"/>
<e:Button id="btnClose" label="" horizontalCenter="252.5" verticalCenter="-261">
<e:skinName>
<e:Skin states="up,down,disabled">
......@@ -37,7 +37,7 @@
</e:skinName>
</e:Button>
<e:Label id="labelHighestScore" text="历史最高分:1120" y="546" textColor="0x333333" size="20" horizontalCenter="0"/>
<e:Image id="imgReward" width="512" height="240" y="181" x="28"/>
<e:Image id="imgReward" horizontalCenter="0" verticalCenter="10" scaleX="0.8" scaleY="0.8"/>
</e:Group>
<e:Image source="winning_example_png" alpha="0.5" top="0" horizontalCenter="0.5" locked="true" visible="false"/>
</e:Skin>
\ No newline at end of file
......@@ -14,7 +14,10 @@ export class MyExmlPlugin extends ExmlPlugin2 implements plugins.Command {
'msgBg1.png',
'msgBg2.png',
'msgBg3.png',
'main_star_an.png'
'main_star_an.png',
"ant_die.png",
"eat_gold_coin.png",
"leg_trample.png"
];
if (excludes.indexOf(file.basename) != -1) {
return file;
......
......@@ -3,17 +3,20 @@ import { ControllerDirection } from "../PlayerController";
import { Tag } from "../DisplayCollider";
import DebugMgr from "../../Mgr/DebugMgr";
import GameMgr from "../../Mgr/GameMgr";
import { MConfigs } from "../../MConfigs";
// import { MConfigs } from "../../MConfigs";
import SoundMgr from "../../Mgr/SoundMgr";
import GameStage from "../GameStage";
import { AntLeg, AntLegGroup, LegTurnGroup } from "./AntLeg";
import AntPart from "./AntPart";
import AntHead from "./AntHead";
const MConfigs: any = window;
export default class Ant extends GameObject {
public onDie = () => { };
public isPlayingTouchEffect = false;
private speedValue: number = MConfigs.ant.speedValue;
public contactToLeg: number = null;
public contactWall: number = null;
protected legGroup0: AntLegGroup;
protected legGroup1: AntLegGroup;
public doLookAt: (target?: egret.Point) => void;
......@@ -91,12 +94,12 @@ export default class Ant extends GameObject {
let dirVec: egret.Point = new egret.Point(0, 0); //默认为0
switch (direction) {
case ControllerDirection.Left:
if (this.contactToLeg != 0) {
if (this.contactToLeg != 0 && this.contactWall != 0) {
dirVec = new egret.Point(-1, 0);
}
break;
case ControllerDirection.Right:
if (this.contactToLeg != 1) {
if (this.contactToLeg != 1 && this.contactWall != 1) {
dirVec = new egret.Point(1, 0);
}
break;
......@@ -128,10 +131,12 @@ export default class Ant extends GameObject {
this.onDie();
}
private playDieAnim() {
public playDieAnim() {
let clip = GameMgr.instance.particleMgr.get("ant_die");
clip.x = this.x;
clip.y = this.y;
let bodyPos = this.body.parent.localToGlobal(this.body.x, this.body.y);
let local = this.gameStage.shadowLayer.globalToLocal(bodyPos.x, bodyPos.y);
clip.x = local.x + this.body.width / 2 - 95;
clip.y = local.y + this.body.height / 2 - 25;
clip.gotoAndPlay(0);
}
......
import AntPart from "./AntPart";
import Ant from "./Ant";
import { MTweenObject } from "../MTween";
export default class AntHead extends AntPart {
private leftEye: Eye = null;
......@@ -13,6 +14,7 @@ export default class AntHead extends AntPart {
this.onDraw();
this.width = width;
this.height = height;
this.localRect = new egret.Rectangle(0, 15, width, height - 15);
context.doLookAt = (target: egret.Point) => {
if (target) {
this.leftEye.lookAt(this.globalToLocal(target.x, target.y));
......@@ -71,7 +73,7 @@ export default class AntHead extends AntPart {
this.mouthFear = new egret.Bitmap(RES.getRes("ant_mouth_fear_png"));
this.mouthFear.x = 9.13;
this.mouthFear.y = 36.33;
this.mouthFear.y = 37;
this.mouthFear.visible = false;
this.addChild(this.mouthFear);
}
......
import { MConfigs } from "../../MConfigs";
// import { MConfigs } from "../../MConfigs";
import Ant from "./Ant";
import { MTweenObject } from "../MTween";
const MConfigs: any = window;
export class AntLeg extends egret.Bitmap {
constructor(textrue: egret.Texture, x: number) {
......
import DisplayCollider, { Tag, Contact } from "../DisplayCollider";
import Ant from "./Ant";
import { MConfigs } from "../../MConfigs";
// import { MConfigs } from "../../MConfigs";
import Leg from "../Leg";
import SoundMgr from "../../Mgr/SoundMgr";
import { ThroughSubmitData } from "../../../libs/tw/data/custom/throughSubmit/ThroughSubmitData";
const MConfigs: any = window;
export default class AntPart extends DisplayCollider {
private context: Ant = null;
......@@ -31,6 +35,21 @@ export default class AntPart extends DisplayCollider {
onCollisionEnter(other: DisplayCollider, contact: Contact) {
if (other.tag == Tag.Leg) {
this.context.contactToLeg = contact.self;
if ((other as Leg).isFalling) {
this.context.die();
} else {
if (!this.context.isPlayingTouchEffect) {
this.context.isPlayingTouchEffect = true;
SoundMgr.instance.playEffect("ant_touch_leg_mp3").then(() => {
this.context.isPlayingTouchEffect = false;
});
}
}
}
if (other.tag == Tag.Wall) {
this.context.contactWall = contact.self;
}
}
......@@ -38,12 +57,20 @@ export default class AntPart extends DisplayCollider {
if (other.tag == Tag.Leg) {
this.context.contactToLeg = contact.self;
}
if (other.tag == Tag.Wall) {
this.context.contactWall = contact.self;
}
}
onCollisionExit(other: DisplayCollider) {
if (other.tag == Tag.Leg) {
this.context.contactToLeg = null;
}
if (other.tag == Tag.Wall) {
this.context.contactWall = null;
}
}
}
......
......@@ -75,7 +75,8 @@ export enum Tag {
Ant,
Leg,
Ground,
GoldCoin
GoldCoin,
Wall
}
export interface Contact { self: number, other: number }
\ No newline at end of file
......@@ -4,6 +4,7 @@ import { Decorator } from "../Decorator/Decorator";
import GameMgr from "../Mgr/GameMgr";
import DebugMgr from "../Mgr/DebugMgr";
import GameStage from "./GameStage";
import { MTweenObject } from "./MTween";
export default abstract class GameObject extends DisplayCollider {
/**每帧速率的增量。x坐标表示水平方向速率的增量,为标量,单位为像素/帧;y轴同上。 */
......@@ -11,7 +12,7 @@ export default abstract class GameObject extends DisplayCollider {
private timerList: MTimer[] = [];
protected shadow: Shadow;
public shadow: Shadow;
protected gameStage: GameStage
protected _center: egret.Point = new egret.Point();
......@@ -26,12 +27,20 @@ export default abstract class GameObject extends DisplayCollider {
super(tag, localRect);
this.gameStage = gameStage;
this.onDraw();
this.addEventListener(egret.Event.ADDED_TO_STAGE, () => {
this.shadow.visible = true;
this.shadow.update();
}, this);
// egret.Ticker.getInstance().register(this.onFixedUpdate, this);
// egret.startTick(this.onFixedUpdate, this);
}
/**@virtual */
protected onDraw() {
this.onCreateShadow();
this.gameStage.addChild(this.shadow);
this.gameStage.shadowLayer.addChild(this.shadow);
}
protected abstract onCreateShadow(): void;
......@@ -92,22 +101,31 @@ export default abstract class GameObject extends DisplayCollider {
/**@override */
onUpdate() {
super.onUpdate();
this.onFixedUpdate();
this.shadow && this.shadow.update();
}
/**@virtual */
onFixedUpdate() {
this.velocity.x += this.acceleration.x;
this.velocity.y += this.acceleration.y;
if (this.velocity.length > 0) {
this.moveTo(this.position.add(this.velocity));
}
this.shadow && this.shadow.update();
return false;
}
/**@override */
onDestroy() {
super.onDestroy();
MTweenObject.removeTweens(this);
egret.Tween.removeTweens(this);
this.timerList.forEach(e => e.destroy());
this.timerList = null;
this.shadow.destroy();
// egret.Ticker.getInstance().unregister(this.onFixedUpdate, this);
// egret.stopTick(this.onFixedUpdate, this);
}
public setTimer(time: number, onTimeOut: () => void, repeat?: number, onRepeated?: () => void): MTimer {
......@@ -161,6 +179,7 @@ export class Shadow extends egret.Bitmap {
this.anchorOffsetY = texture.textureHeight / 2;
this.target = target;
this.y = GameMgr.instance.groundLineInGameStage;
this.visible = false;
}
/**@virtual */
......
import Leg from "./Leg";
import GoldCoin from "./GoldCoin";
import DisplayCollider, { Tag } from "./DisplayCollider";
import GameMgr from "../Mgr/GameMgr";
import { MUtils } from "../MUtils";
import { MConst } from "../MConst";
import { Decorator } from "../Decorator/Decorator";
import PhysicalSystem from "./PhysicalSystem";
import { ThroughSubmitData } from "../../libs/tw/data/custom/throughSubmit/ThroughSubmitData";
@Decorator.OnUpdate
@Decorator.OnDestroy
export default class GameStage extends egret.DisplayObjectContainer {
public onGoldCoinEated: (score: number) => void;
private shakeDirection = 0;
public shadowLayer: egret.DisplayObjectContainer = null;
public legLayer: egret.DisplayObjectContainer = null;
public antLayer: egret.DisplayObjectContainer = null;
public goldCoinLayer: egret.DisplayObjectContainer = null;
constructor(randomBg: boolean) {
super();
let bgId: number = 1;
if (randomBg) {
bgId = MUtils.randomInt(1, 4);
}
let bg = new egret.Bitmap(RES.getRes(`bg${bgId}_jpg`));
bg.y = -10;
this.addChild(bg);
this.shadowLayer = new egret.DisplayObjectContainer();
this.addChild(this.shadowLayer);
this.legLayer = new egret.DisplayObjectContainer();
this.addChild(this.legLayer);
this.goldCoinLayer = new egret.DisplayObjectContainer();
this.addChild(this.goldCoinLayer);
this.antLayer = new egret.DisplayObjectContainer();
this.addChild(this.antLayer);
let leftWall = new DisplayCollider(Tag.Wall, new egret.Rectangle(0, 0, 100, 750));
leftWall.width = 100;
leftWall.height = 750;
leftWall.x = -100;
this.addChild(leftWall);
let rightWall = new DisplayCollider(Tag.Wall, new egret.Rectangle(0, 0, 100, 750));
rightWall.width = 100;
rightWall.height = 750;
rightWall.x = GameMgr.instance.stage.stageWidth;
this.addChild(rightWall);
//创建地面碰撞器
let groundCollider = new DisplayCollider(Tag.Ground, MConst.GroundLocalRect);
this.addChild(groundCollider);
// egret.startTick(this.onFixedUpdate, this);
}
onDestroy() {
// egret.startTick(this.onFixedUpdate, this);
}
onFixedUpdate() {
//物理引擎运行
PhysicalSystem.instance.detectCollision();
return false;
}
onUpdate() {
if (this.shakeDirection > 0) {
this.y += 1;
if (this.y >= 9) {
this.shakeDirection = -1;
}
} else if (this.shakeDirection < 0) {
this.y -= 1;
if (this.y <= 0) {
this.y = 0;
this.shakeDirection = 0;
}
}
this.onFixedUpdate();
}
public shake() {
return new Promise((resolve) => {
let back = false;
let onUpdate = () => {
let gameStage: GameStage = this;
if (!back) {
gameStage.y += 1;
if (gameStage.y >= 9) {
back = true;
}
} else {
gameStage.y -= 1;
if (gameStage.y <= 0) {
gameStage.y = 0;
this.removeEventListener(egret.Event.ENTER_FRAME, onUpdate, this);
resolve();
}
/* return new Promise((resolve) => {
let callback = () => {
if (this.shakeDirection == 0) {
this.removeEventListener(egret.Event.ENTER_FRAME, callback, this);
resolve();
}
};
this.addEventListener(egret.Event.ENTER_FRAME, callback, this);
}); */
this.addEventListener(egret.Event.ENTER_FRAME, onUpdate, this);
});
if (this.shakeDirection == 0) {
this.shakeDirection = 1;
}
}
createGoldCoin(x: number) {
let goldCoin = new GoldCoin(this);
goldCoin.onEated = this.onGoldCoinEated;
goldCoin.land(x, -500);
this.addChild(goldCoin);
this.goldCoinLayer.addChild(goldCoin);
return goldCoin;
}
......
......@@ -2,11 +2,12 @@ import GameObject, { Shadow } from "./GameObject";
import DisplayCollider, { Tag, Contact } from "./DisplayCollider";
import { MConst } from "../MConst";
import { Decorator } from "../Decorator/Decorator";
import { MConfigs } from "../MConfigs";
// import { MConfigs } from "../MConfigs";
import GameMgr from "../Mgr/GameMgr";
import MainScene from "../Scene/MainScene";
import SoundMgr from "../Mgr/SoundMgr";
import GameStage from "./GameStage";
const MConfigs: any = window;
export default class GoldCoin extends GameObject {
/**标识是否落地。这个落地不是只接触了地面,而是弹跳完毕,完全落在地面上。 */
......@@ -15,7 +16,7 @@ export default class GoldCoin extends GameObject {
private beTrampled = false;
private contactGroundFrameCount = 0;
private bounceCoefficient = 1;
private scoreValue = 10;
private scoreValue = 2;
private isPlayedSoundEffect = false;
protected get shadowFileName() { return "gold_coin_shadow_png" }
......
import GameObject, { Shadow } from "./GameObject";
import { MConst } from "../MConst";
import { MConfigs } from "../MConfigs";
// import { MConfigs } from "../MConfigs";
import DisplayCollider, { Tag } from "./DisplayCollider";
import DebugMgr from "../Mgr/DebugMgr";
import GameMgr from "../Mgr/GameMgr";
......@@ -8,11 +8,16 @@ import { Decorator } from "../Decorator/Decorator";
import GameStage from "./GameStage";
import Ant from "./Ant/Ant";
import SoundMgr from "../Mgr/SoundMgr";
import AntPart from "./Ant/AntPart";
import { MTweenObject } from "./MTween";
const MConfigs: any = window;
export default class Leg extends GameObject {
private isFalling = false;
public isFalling = false;
public toward: LegToward;
public get towardCoefficient() { return this.toward == LegToward.Right ? 1 : -1; }
public colliderOffset: number = 0;
/**@override */
public get center(): egret.Point {
this._center.x = this.x + this.towardCoefficient * this.width / 2;
......@@ -20,7 +25,7 @@ export default class Leg extends GameObject {
return this._center;
}
constructor(gameStage: GameStage, rect: egret.Rectangle, texture: egret.Texture, toward: LegToward) {
constructor(gameStage: GameStage, rect: egret.Rectangle, texture: egret.Texture, toward: LegToward, colliderOffset: number) {
super(Tag.Leg, rect, gameStage);
this.gameStage = gameStage;
let bitmap = new egret.Bitmap(texture);
......@@ -38,6 +43,8 @@ export default class Leg extends GameObject {
}
gameStage.addLeg(this);
this.colliderOffset = colliderOffset;
}
protected onCreateShadow() {
......@@ -50,15 +57,16 @@ export default class Leg extends GameObject {
public update() {
super.update();
if (leg.toward == LegToward.Right) {
this.x = leg.x + 12 * leg.scaleX;
this.x = leg.x + leg.colliderOffset;
} else {
this.x = leg.x - 12 - leg.localRect.width * leg.scaleX;
this.x = leg.x - leg.colliderOffset - leg.localRect.width;
}
}
}(RES.getRes("leg_shadow_png"), this);
}
public updateCallback: () => void;
onUpdate() {
super.onUpdate();
this.updateCallback && this.updateCallback();
......@@ -76,13 +84,13 @@ export default class Leg extends GameObject {
this.playAnim();
this.isFalling = false;
egret.Tween.removeTweens(this);
MTweenObject.removeTweens(this);
this.velocity = new egret.Point();
//震动地面
this.gameStage.shake().then(() => {
this.onActed();
});
this.gameStage.shake();
this.onActed();
}
private playAnim() {
......@@ -98,7 +106,7 @@ export default class Leg extends GameObject {
private doTween() {
let param = MConfigs.legTweenParam;
egret.Tween.get(this.velocity)
MTweenObject.get(this.velocity)
.to({ y: -param.rise.maxSpeed }, param.rise.duration.speedUp)
.wait(param.rise.duration.keep)
.to({ y: 0 }, param.rise.duration.slowDown)
......@@ -110,10 +118,10 @@ export default class Leg extends GameObject {
+ param.rise.duration.slowDown
let p2Time = param.fall.speedUp1.duration
+ param.fall.speedUp2.duration;
egret.Tween.get(this.velocity)
.to({ x: 8 * this.towardCoefficient }, p1Time)
MTweenObject.get(this.velocity)
.to({ x: param.horizontal.phase1Speed * this.towardCoefficient }, p1Time)
.call(() => this.isFalling = true)
.to({ x: 14 * this.towardCoefficient }, p2Time);
.to({ x: param.horizontal.phase2Speed * this.towardCoefficient }, p2Time);
}
/**@override */
......@@ -121,14 +129,6 @@ export default class Leg extends GameObject {
if (other.tag == Tag.Ground && this.isFalling) {
this.touchGround();
}
if (other.tag == Tag.Ant) {
if (this.isFalling) {
(other as Ant).die();
} else {
SoundMgr.instance.playEffect("ant_touch_leg_mp3");
}
}
}
/**@override */
......
......@@ -4,7 +4,8 @@ import GameMgr from "../Mgr/GameMgr";
import { ControllerDirection } from "./PlayerController";
import DebugMgr from "../Mgr/DebugMgr";
import GameStage from "./GameStage";
import { MConfigs } from "../MConfigs";
// import { MConfigs } from "../MConfigs";
const MConfigs: any = window;
export default class Legs {
public get toward(): LegToward {
......@@ -17,12 +18,13 @@ export default class Legs {
private initPosX: number = null;
constructor(gameStage: GameStage, rect: egret.Rectangle, texture: egret.Texture, toward: LegToward) {
this.left = new Leg(gameStage, rect, texture, toward);
gameStage.addChild(this.left);
constructor(gameStage: GameStage, rect: egret.Rectangle, texture: egret.Texture, toward: LegToward, colliderOffset: number) {
this.left = new Leg(gameStage, rect, texture, toward, colliderOffset);
gameStage.legLayer.addChild(this.left);
this.right = new Leg(gameStage, rect, texture, toward, colliderOffset);
gameStage.legLayer.addChild(this.right);
this.right = new Leg(gameStage, rect, texture, toward);
gameStage.addChild(this.right);
this.left.updateCallback = () => {
if (this.toward == LegToward.Right) {
......@@ -57,6 +59,10 @@ export default class Legs {
this.initPosX = x;
this.left.land(x, -5);
this.right.land(x, -5);
this.left.shadow.update();
this.right.shadow.update();
}
public get posX() {
if (this.toward == LegToward.Right) {
......
export class MTweenObject {
public static readonly frameRate = 60;
private tweenList: MTweenBase[] = [];
private currentTween: MTweenBase = null;
public target: object = null
constructor(target: object) {
this.target = target;
MTweenMgr.add(this);
}
public static get(target: object) {
return new MTweenObject(target);
}
public static removeTweens(target: object) {
MTweenMgr.remove(target);
}
public wait(duration: number) {
this.addTween(new WaitTween(this.toFrameRate(duration), this));
return this;
}
private addTween(tween: MTweenBase) {
if (this.currentTween == null) {
this.currentTween = tween;
} else {
this.tweenList.push(tween);
}
}
public to(props: object, duration: number) {
this.addTween(new LinearTween(props, this.toFrameRate(duration), this));
return this;
}
public call(callback: () => void) {
this.addTween(new CallbackTween(callback, this.toFrameRate(0), this));
return this;
}
private toFrameRate(duration: number) {
return duration / 1000 * MTweenObject.frameRate;
}
public update() {
if (!this.currentTween) return;
this.currentTween.apply();
if (this.currentTween.frameCount <= 0) {
if (this.tweenList.length > 0) {
this.currentTween = this.tweenList.shift();
} else {
this.currentTween = null;
}
}
}
}
abstract class MTweenBase {
private started = false;
public frameCount: number = 0;
protected tweenObjet: MTweenObject = null;
constructor(frameCount: number, tweenObject: MTweenObject) {
this.tweenObjet = tweenObject;
this.frameCount = frameCount;
}
protected start() { }
public apply() {
if (this.started == false) {
this.start();
this.started = true;
}
this.frameCount--;
}
}
class LinearTween extends MTweenBase {
private once: object = null;
constructor(props: object, frameCount: number, tweenObject: MTweenObject) {
super(frameCount, tweenObject);
this.once = props;
}
public start() {
Object.keys(this.once).forEach(key => {
this.getOnceValue(this.once, key, this.once[key]);
});
}
private getOnceValue(props: object, key: string, value: number) {
if (!value) return props[key] = value;
if (this.frameCount == 0) {
return props[key] = value;
} else {
if (typeof this.tweenObjet.target[key] == "number") {
let delta = value - this.tweenObjet.target[key];
let once = delta / this.frameCount
props[key] = once;
} else {
console.error("prop is not number");
delete props[key];
}
}
}
public apply() {
super.apply();
Object.keys(this.once).forEach(key => {
this.tweenObjet.target[key] += this.once[key];
});
}
}
class WaitTween extends MTweenBase {
}
class CallbackTween extends MTweenBase {
private callback: () => void = null;
constructor(callback: () => void, frameCount: number, tweenObject: MTweenObject) {
super(frameCount, tweenObject);
this.callback = callback;
}
public start() {
this.callback();
}
}
export class MTweenMgr {
public static remove(target: object) {
MTweenMgr.tweenObjectList = MTweenMgr.tweenObjectList.filter(e => e.target !== target);
}
public static add(tweenObject: MTweenObject) {
MTweenMgr.tweenObjectList.push(tweenObject);
}
public static tweenObjectList: MTweenObject[] = [];
public static update() {
this.tweenObjectList.forEach(e => {
e.update();
})
}
}
\ No newline at end of file
import Ant from "./Ant/Ant";
export default class PlayerController extends eui.UILayer {
private touchPointIDList = [];
// private touchPointIDMap: { [touchPointID: number]: ControllerDirection } = {}
constructor() {
super();
this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBegin, this);
......@@ -13,14 +16,27 @@ export default class PlayerController extends eui.UILayer {
private onTouchBegin(event: egret.TouchEvent) {
if (event.stageX >= this.stage.stageWidth / 2) {
this.touchPointIDList.push({
touchPointID: event.touchPointID,
direction: ControllerDirection.Right
});
this.direction = ControllerDirection.Right;
} else {
this.touchPointIDList.push({
touchPointID: event.touchPointID,
direction: ControllerDirection.Left
});
this.direction = ControllerDirection.Left;
}
}
private onTouchEnd() {
this.direction = ControllerDirection.None;
private onTouchEnd(event: egret.TouchEvent) {
this.touchPointIDList = this.touchPointIDList.filter(e => e.touchPointID != event.touchPointID);
if (this.touchPointIDList.length <= 0)
this.direction = ControllerDirection.None;
else {
this.direction = this.touchPointIDList.pop().direction;
}
}
}
......
export namespace MConfigs {
//蚂蚁移动速度
export const ant = {
speedValue: 6
}
/**腿动效参数 */
export const legTweenParam = {
//垂直方向上升阶段
rise: {
duration: {
speedUp: 400,
keep: 1000,
slowDown: 400
duration: { //以下3个阶段的时间
speedUp: 400, //从0加速到maxSpeed的持续时间
keep: 100, //保持maxSpeed的时间
slowDown: 100 //从maxSpeed减速到0的时间
},
maxSpeed: 5
maxSpeed: 10
},
fall: {
speedUp1: {
fall: { //垂直方向下落阶段
speedUp1: { //加速阶段1
duration: 400,
value: 10
value: 15 //加速到的速度值
},
speedUp2: {
duration: 1200,
value: 17
speedUp2: { //加速阶段2
duration: 1200, //这个持续时间不是真正的持续时间,因为腿落地就会停止动效,所以这个是最大值,一般达不到
value: 20 //加速到的速度值
}
},
horizontal: { //水平方向
phase1Speed: 17, //水平方向1阶段最大速度。1阶段持续时间等于垂直方向上升阶段之和
phase2Speed: 10 //水平方向2阶段最大速度。2阶段持续时间等于垂直方向下落阶段之和
}
}
......@@ -29,21 +36,21 @@ export namespace MConfigs {
export const distanceAntToLegWhenAntLook = 400;
/**腿超出舞台边界会被销毁的距离 */
export const distanceOverStageWhlieLegDestroy = 10;
// export const distanceCoinToAntWhileCreate=
//蚂蚁动效参数
export const antTween = {
leg: {
maxRotationValue: 6,
duration: 40
leg: { //腿部
maxRotationValue: 6, //最大旋转角度,角度制
duration: 40 //旋转周期的时长
},
turnVelocityCoefficient: 0.12
turnVelocityCoefficient: 0.12 //蚂蚁各个部分的速度系数,具体机制不用了解,只需知道增大此值蚂蚁转向的速度变快,反之变慢
}
export const goldCoin = {
gravity: 0.6, //掉落阶段受到的重力加速度
bounceCoefficient: 0.5, //弹性系数,即掉落到地面能量损失率,取值区间[0,1]
moveAccelerationX: 0.5, //被脚踩后弹开的加速阶段的水平加速度
moveSlowDownDuration: 100, //离开脚后减速到0所需的时间,单位毫秒
moveAccelerationX: 1, //被脚踩后弹开的加速阶段的水平加速度
moveSlowDownDuration: 50, //离开脚后减速到0所需的时间,单位毫秒
moveVelocityY: 15 //被脚踩之后的垂直速率
}
}
\ No newline at end of file
export namespace MConst {
/**地线的游戏舞台坐标 */
export const GroundLine = 534;
export const GroundLine = 524;
export const AntLocalRect = new egret.Rectangle(0, 14, 80, 48);
export const LegLocalRect = new egret.Rectangle(52, 462, 236, 75);
export const GroundLocalRect = new egret.Rectangle(-1000, GroundLine, 3000, 200);
export const GroundLocalRect = new egret.Rectangle(-1000, GroundLine, 5000, 200);
export const GoldCoinLocalRect = new egret.Rectangle(0, 0, 40, 40);
export const LocalRect = {
Leg: {
1: new egret.Rectangle(12, 459, 208, 77),
2: new egret.Rectangle(52, 462, 236, 75),
3: new egret.Rectangle(52, 462, 236, 72),
3: new egret.Rectangle(52, 462, 212, 72),
4: new egret.Rectangle(44, 466, 208, 68),
5: new egret.Rectangle(53, 466, 231, 68),
6: new egret.Rectangle(48, 477, 196, 64)
}
}
export const legColliderOffset = {
1: 12,
2: 54,
3: 54,
4: 44,
5: 56,
6: 50,
}
}
......@@ -93,4 +93,12 @@ export namespace MUtils {
radians = point.y > 0 ? radians : -radians;
return toDegress(radians);
}
export function stringOverEllipsis(str: string, limit: number) {
if (str.length > limit) {
return str.substring(0, limit) + "...";
} else {
return str;
}
}
}
\ No newline at end of file
......@@ -14,13 +14,17 @@ import LoadScene from "./Scene/LoadScene";
import MainScene from "./Scene/MainScene";
import { NetName } from "../libs/tw/enum/NetName";
import SoundMgr from "./Mgr/SoundMgr";
import { MTweenMgr, MTweenObject } from "./Game/MTween";
import { Decorator } from "./Decorator/Decorator";
@Decorator.OnUpdate
class Main extends eui.UILayer {
constructor() {
super();
}
protected createChildren() {
super.createChildren();
this.stage.orientation = egret.OrientationMode.LANDSCAPE_FLIPPED;
GameMgr.instance.stage = this.stage;
//inject the custom material parser
......@@ -42,7 +46,11 @@ class Main extends eui.UILayer {
this.runGame().catch(e => {
console.log(e);
})
});
}
onUpdate() {
MTweenMgr.update();
}
private async runGame() {
......@@ -89,4 +97,5 @@ class Main extends eui.UILayer {
}
window['Main'] = Main;
window["netData"] = {};
customClassPrototype();
......@@ -2,6 +2,7 @@ import GameMgr from "./GameMgr";
import Leg from "../Game/Leg";
export default class DebugMgr extends egret.DisplayObjectContainer {
public enabled = false;
private shapeMap = {};
private graphicDebugLayer: egret.DisplayObjectContainer = null;
private uiLayer: eui.UILayer = null;
......@@ -15,6 +16,7 @@ export default class DebugMgr extends egret.DisplayObjectContainer {
constructor() {
super();
if (!this.enabled) return;
//创建图形调试层
this.graphicDebugLayer = new egret.DisplayObjectContainer();
this.graphicDebugLayer.touchEnabled = false;
......@@ -45,10 +47,12 @@ export default class DebugMgr extends egret.DisplayObjectContainer {
}
public setLog(msg: string) {
if (!this.enabled) return;
this.log.text = msg;
}
public drawCollider(rect: egret.Rectangle, style: GraphicDebug.Style = { color: 0xff0000, lineSize: 1 }) {
if (!this.enabled) return;
let shape = new egret.Shape();
shape.graphics.lineStyle(style.lineSize, style.color);
shape.graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
......@@ -56,6 +60,7 @@ export default class DebugMgr extends egret.DisplayObjectContainer {
}
public drawLine(line: GraphicDebug.Line, style: GraphicDebug.Style = { color: 0xff0000, lineSize: 1 }) {
if (!this.enabled) return;
let shape = new egret.Shape();
shape.graphics.lineStyle(style.lineSize, style.color);
shape.graphics.moveTo(line.startX, line.startY);
......@@ -64,6 +69,7 @@ export default class DebugMgr extends egret.DisplayObjectContainer {
}
public updateLine(key: string, line: GraphicDebug.Line, style: GraphicDebug.Style = { color: 0xff0000, lineSize: 1 }) {
if (!this.enabled) return;
let shape: egret.Shape = this.shapeMap[key];
if (!shape) {
shape = new egret.Shape();
......@@ -78,6 +84,7 @@ export default class DebugMgr extends egret.DisplayObjectContainer {
}
public updateCollider(key: string, rect: egret.Rectangle, style: GraphicDebug.Style = { color: 0xff0000, lineSize: 1 }) {
if (!this.enabled) return;
let shape: egret.Shape = this.shapeMap[key];
if (!shape) {
shape = new egret.Shape();
......@@ -91,6 +98,7 @@ export default class DebugMgr extends egret.DisplayObjectContainer {
}
public clearCollider(key: string) {
if (!this.enabled) return;
let shape: egret.Shape = this.shapeMap[key];
if (!shape) {
console.warn("collider is nonexistent");
......
import { MConst } from "../MConst";
import ParticleMgr from "./ParticleMgr";
import Leg from "../Game/Leg";
import PlayerController from "../Game/PlayerController";
export default class GameMgr {
private static _instance: GameMgr = null;
......@@ -19,7 +20,9 @@ export default class GameMgr {
return MConst.GroundLine;
}
public isLogined = true;
public particleMgr: ParticleMgr = null;
public playerController: PlayerController = null;
public second: eui.Label = null;
}
\ No newline at end of file
import Pool, { PoolGroup } from "../components/Pool";
import SVGAClip from "../components/SVGAClip";
import GameMgr from "./GameMgr";
import GameStage from "../Game/GameStage";
export default class ParticleMgr {
public gameStage: egret.DisplayObjectContainer = null;
constructor(gameStage: egret.DisplayObjectContainer) {
public gameStage: GameStage = null;
constructor(gameStage: GameStage) {
this.gameStage = gameStage;
}
......@@ -30,7 +31,12 @@ export default class ParticleMgr {
let movieClip = new egret.MovieClip(factory.generateMovieClipData(name));
if (movieClip.$movieClipData.frames.length <= 0) console.error("frame is null");
this.gameStage.addChild(movieClip);
if (name == "ant_die") {
this.gameStage.shadowLayer.addChild(movieClip);
} else {
this.gameStage.addChild(movieClip);
}
return movieClip;
}
......
......@@ -26,12 +26,14 @@ export default class SoundMgr {
private musicChannel: egret.SoundChannel = null;
private loopChannelMap: { [name: string]: egret.SoundChannel } = {}
private effectPool: { [name: string]: PoolSound[] } = {}
public firstSeted = false;
public playMusic() {
if (this.music == null) {
this.music = RES.getRes("music_mp3");
}
this.musicChannel = this.music.play(-1);
this.musicChannel && this.musicChannel.stop();
this.musicChannel = this.music.play(0, 0);
}
public stopMusic() {
......@@ -49,9 +51,12 @@ export default class SoundMgr {
}
this.loopChannelMap[name] = channel;
} else {
channel.addEventListener(egret.Event.SOUND_COMPLETE, () => {
this.recycleSound(poolSound);
}, this);
return new Promise<void>(resolve => {
channel.addEventListener(egret.Event.SOUND_COMPLETE, () => {
this.recycleSound(poolSound);
resolve();
}, this);
});
}
}
......
......@@ -7,6 +7,12 @@ import StartScene from "../Scene/StartScene";
import PanelCtrl from "../ctrls/PanelCtrl";
import RankListPanel from "./RankListPanel";
import RankListItem from "./RankListItem";
import { startGameRequest } from "../utils";
import Loading from "../loading/Loading";
import ToastPanel from "../components/ToastPanel";
import MainScene from "../Scene/MainScene";
import GameMgr from "../Mgr/GameMgr";
import { MUtils } from "../MUtils";
export default class NotWinningPanel extends Panel {
get skinKey() { return "NotWinningPanel" }
......@@ -31,7 +37,34 @@ export default class NotWinningPanel extends Panel {
this.labelHighestScore.text = "历史最高分:" + this.data.highestScore.toString();
this.btnRestart.onTap(this, () => {
this.hidePanel();
SceneCtrl.instance.change(StartScene);
// SceneCtrl.instance.change(StartScene);
Loading.instace.show()
NetManager.ins.doJoin2((success: any) => {
if (!success) {
Loading.instace.hide();
SceneCtrl.instance.change(StartScene);
return;
}
NetManager.ins.getStartStatus((success: any) => {
Loading.instace.hide()
let res = DataManager.ins.getData(NetName.GAME_START_STATUS_NEW);
if (!success) {
SceneCtrl.instance.change(StartScene);
return;
}
if (res.code && res.code == "100201007") {
PanelCtrl.instance.show(ToastPanel, { msg: `${res["data"]["unitName"]}不足,多赚点${res["data"]["unitName"]}再来吧` });
SceneCtrl.instance.change(StartScene);
return;
}
if (res.code && res.code != "0000000000") return;
//开始游戏
SceneCtrl.instance.change(MainScene);
}, /* DataManager.ins.getData(NetName.DO_JOIN_DATA2).data */window["netData"][window['CFG'].doJoin]["orderId"], () => {
return DataManager.ins.getData(NetName.GAME_START_STATUS_NEW).code != "0000000000";
}, 10);
});
});
this.btnViewAllRank.onTap(this, () => {
PanelCtrl.instance.show(RankListPanel);
......@@ -48,13 +81,14 @@ export default class NotWinningPanel extends Panel {
//我的数据
let myData = rankData["currentUserRankInfo"];
this.labelMyRank.text = myData["rank"];
this.labelMyNickname.text = myData["nickName"];
this.labelMyNickname.text = /* MUtils.stringOverEllipsis(myData["nickName"], 16); */"我自己";
this.labelMyScore.text = myData["maxScore"];
//取前三
let three = [];
for (let i = 0; i < 3; i++) {
three.push(rankData["userRankList"][i]);
if (rankData["userRankList"][i])
three.push(rankData["userRankList"][i]);
}
this.dataGroup.itemRenderer = RankListItem;
this.dataGroup.dataProvider = new eui.ArrayCollection(three);
......
import MItem from "../components/MItem";
import { MUtils } from "../MUtils";
export default class RankListItem extends MItem {
public labelRank: eui.Label;
......@@ -13,7 +14,7 @@ export default class RankListItem extends MItem {
dataChanged() {
this.labelRank.text = this.data.rank.toString();
this.labelNickname.text = this.data.nickName.toString();
this.labelNickname.text = MUtils.stringOverEllipsis(this.data.nickName, 16).toString();
this.labelScore.text = this.data.maxScore.toString();
}
}
\ No newline at end of file
......@@ -6,21 +6,20 @@ import { HtmlTextParser } from "../../libs/tc/util/HtmlTextParser";
export default class RulePanel extends Panel {
get skinKey() { return "RulePanel" }
get groupName() { return "rule_panel" }
public closeBtn: eui.Button;
public text: eui.Label;
constructor() {
super();
this.top = 0
this.left = 0
this.right = 0
this.bottom = 0;
egret.DisplayObject
}
onSkinComplete() {
super.onSkinComplete();
this.closeBtn.onTap(this, this.hidePanel);
this.text.textFlow = new HtmlTextParser().parse(DataManager.ins.ajaxElementData.rule);
// this.text.text = text;
}
}
\ No newline at end of file
}
let text = `1111111111111111111111111111111111111111
1111111111111111111111111111111111111111
1111111111111111111111111111111111111111
1111111111111111111111111111111111111111
1111111111111111111111111111111111111111
1111111111111111111111111111111111111111
1111111111111111111111111111111111111111
1111111111111111111111111111111111111111`
\ No newline at end of file
......@@ -10,8 +10,8 @@ export default class SoundPanel extends Panel {
onSkinComplete() {
super.onSkinComplete();
SoundMgr.instance.musicEnabled= !!SoundMgr.instance.musicEnabled;
SoundMgr.instance.effectEnabled= !!SoundMgr.instance.effectEnabled;
SoundMgr.instance.firstSeted = true;
this.toggleBack.selected = SoundMgr.instance.musicEnabled;
this.toggleEffect.selected = SoundMgr.instance.effectEnabled;
......
......@@ -5,6 +5,13 @@ import SceneCtrl from "../ctrls/SceneCtrl";
import MainScene from "../Scene/MainScene";
import LoadScene from "../Scene/LoadScene";
import StartScene from "../Scene/StartScene";
import { startGameRequest } from "../utils";
import Loading from "../loading/Loading";
import { NetManager } from "../../libs/tw/manager/NetManager";
import { DataManager } from "../../libs/tw/manager/DataManager";
import { NetName } from "../../libs/tw/enum/NetName";
import PanelCtrl from "../ctrls/PanelCtrl";
import ToastPanel from "../components/ToastPanel";
export default class WinningPanel extends Panel {
get skinKey() { return "WinningPanel" }
......@@ -42,7 +49,35 @@ export default class WinningPanel extends Panel {
});
this.btnRestart.onTap(this, () => {
this.hidePanel();
SceneCtrl.instance.change(StartScene);
// SceneCtrl.instance.change(StartScene);
startGameRequest();
Loading.instace.show()
NetManager.ins.doJoin2((success: any) => {
if (!success) {
Loading.instace.hide();
SceneCtrl.instance.change(StartScene);
return;
}
NetManager.ins.getStartStatus((success: any) => {
Loading.instace.hide()
let res = DataManager.ins.getData(NetName.GAME_START_STATUS_NEW);
if (!success) {
SceneCtrl.instance.change(StartScene);
return;
}
if (res.code && res.code == "100201007") {
PanelCtrl.instance.show(ToastPanel, { msg: `${res["data"]["unitName"]}不足,多赚点${res["data"]["unitName"]}再来吧` });
SceneCtrl.instance.change(StartScene);
return;
}
if (res.code && res.code != "0000000000") return;
//开始游戏
SceneCtrl.instance.change(MainScene);
}, /* DataManager.ins.getData(NetName.DO_JOIN_DATA2).data */window["netData"][window['CFG'].doJoin]["orderId"], () => {
return DataManager.ins.getData(NetName.GAME_START_STATUS_NEW).code != "0000000000";
}, 10);
});
});
this.score.text = this.data.score.toString();
this.labelHighestScore.text = `历史最高分:` + this.data.highestScore.toString();
......
......@@ -9,7 +9,9 @@ import MainScene from "./MainScene";
@Decorator.OnUpdate
export default class extends SkinScene {
get skinKey() { return "LoadScene" }
get groupName() { return "load_scene" }
private progress: ProgressBar = null;
public labelProgress: eui.Label;
onSkinComplete() {
super.onSkinComplete();
......@@ -22,21 +24,41 @@ export default class extends SkinScene {
}
async loadRes() {
this.progress.value = 0;
this.updateAntPos();
this.labelProgress.text = "0%"
await RES.loadGroup("main_res");
this.progress.value = 0.2;
this.updateAntPos();
this.labelProgress.text = "20%"
await RES.loadGroup("start_scene");
this.progress.value = 0.4;
this.updateAntPos();
this.labelProgress.text = "40%"
await RES.loadGroup("main_scene");
this.progress.value = 0.6;
this.updateAntPos();
this.labelProgress.text = "60%"
await RES.loadGroup("sound");
this.progress.value = 0.8;
this.updateAntPos();
this.labelProgress.text = "80%"
await RES.loadGroup("animation");
SceneCtrl.instance.change(MainScene);
return;
this.progress.value = 0;
this.progress.value = 1;
this.updateAntPos();
this.labelProgress.text = "100%"
setTimeout(async () => {
this.progress.value = 0.5;
setTimeout(async () => {
this.progress.value = 1;
setTimeout(() => {
}, 500);
}, 500);
SceneCtrl.instance.change(StartScene);
}, 500);
}
private updateAntPos() {
// this.ant.x = this.ant.parent.globalToLocal(this.progress.parent.localToGlobal(this.progress.fill.x).x).x;
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -27,6 +27,9 @@ import SoundPanel from "../Panel/SoundPanel";
import ParticleMgr from "../Mgr/ParticleMgr";
import GameStage from "../Game/GameStage";
import { MUtils } from "../MUtils";
import RulePanel from "../Panel/RulePanel";
import { startGameRequest } from "../utils";
import { MTweenObject, MTweenMgr } from "../Game/MTween";
@Decorator.OnUpdate
export default class StartScene extends Scene {
......@@ -36,9 +39,9 @@ export default class StartScene extends Scene {
constructor() {
super();
let bg = new eui.Image(RES.getRes("start_bg_jpg"));
this.addChild(bg);
this.gameStage = new GameStage();
/* let bg = new eui.Image(RES.getRes("start_bg_jpg"));
this.addChild(bg); */
this.gameStage = new GameStage(false);
this.addChild(this.gameStage);
GameMgr.instance.particleMgr = new ParticleMgr(this.gameStage);
......@@ -48,12 +51,9 @@ export default class StartScene extends Scene {
}
private playGameDemo() {
//创建地面碰撞器
let groundCollider = new DisplayCollider(Tag.Ground, MConst.GroundLocalRect);
this.gameStage.addChild(groundCollider);
//创建蚂蚁
let ant = new Ant(this.gameStage);
this.gameStage.addChild(ant);
this.gameStage.antLayer.addChild(ant);
ant.land(300);
this.ant = ant;
......@@ -99,8 +99,7 @@ export default class StartScene extends Scene {
}
onUpdate() {
//物理引擎运行
PhysicalSystem.instance.detectCollision();
// this.ant.move(this.playerController.direction);
}
}
......@@ -117,21 +116,52 @@ class StartSceneUI extends SceneUILayer {
public labelMyCredit: eui.Label;
onSkinComplete() {
this.btnLogin.visible = !GameMgr.instance.isLogined;
this.btnStart.visible = GameMgr.instance.isLogined;
this.btnLogin.visible = false;
this.btnStart.visible = false;
this.btnLogin.onTap(this, () => {
window["requirelogin"]();
});
let cfgRes = DataManager.ins.getData(NetName.CUSTOM_ELEMENT);
if (cfgRes) {
let element = cfgRes["data"]["element"];
if (element["freeLimit"] >= 0) {
this.labelFreeTime.text = element["freeLimit"];
this.btnRule.onTap(this, () => {
PanelCtrl.instance.show(RulePanel);
});
NetManager.ins.ajaxElement((success: any, res: any) => {
if (!success && res["code"] != "100201001") { //错误码不是未登录
return;
}
this.labelMyCredit.text = element["myCredits"];
}
let cfgRes = window["netData"][window['CFG'].getElement];
if (cfgRes) {
let element = cfgRes["element"];
let result: string = "";
switch (element.status) {
case 4:
result = '今日无游戏次数';
break;
case 5:
result = "今日免费次数:" + element["freeLimit"];
break;
case 6:
result = `${element.needCredits}${window['CFG'].unitName}/次`;
break;
}
this.labelFreeTime.text = result;
this.labelMyCredit.text = "我的积分:" + element["myCredits"];
if (DataManager.ins.customCfgData["isNotLoginUser"]) {
this.btnLogin.visible = true;
this.btnStart.visible = false;
PanelCtrl.instance.show(ToastPanel, { msg: "您还未登录,请先登录" });
} else {
this.btnLogin.visible = false;
this.btnStart.visible = true;
}
}
});
this.btnRank.onTap(this, () => {
PanelCtrl.instance.show(RankListPanel);
......@@ -141,8 +171,13 @@ class StartSceneUI extends SceneUILayer {
});
this.btnStart.onTap(this, () => {
if (!SoundMgr.instance.firstSeted) {
SoundMgr.instance.musicEnabled = true;
SoundMgr.instance.effectEnabled = true;
}
Loading.instace.show()
NetManager.ins.doJoin((success: any) => {
NetManager.ins.doJoin2((success: any) => {
if (!success) {
Loading.instace.hide();
return;
......@@ -161,10 +196,34 @@ class StartSceneUI extends SceneUILayer {
//开始游戏
SceneCtrl.instance.change(MainScene);
}, DataManager.ins.getData(NetName.DO_JOIN_DATA).data, () => {
}, /* DataManager.ins.getData(NetName.DO_JOIN_DATA2).data */window["netData"][window['CFG'].doJoin]["orderId"], () => {
return DataManager.ins.getData(NetName.GAME_START_STATUS_NEW).code != "0000000000";
}, 10);
});
});
this.btnRecord.onTap(this, () => {
window.location.href = this.gotoRecord();//window["recordUrl"];
});
}
private gotoRecord(): string {
let recordUrl: string;
let oaId: number;
if (DataManager.ins.customCfgData) {
oaId = DataManager.ins.customCfgData.oaId;
recordUrl = DataManager.ins.customCfgData.recordUrl;
} else {
oaId = DataManager.ins.gameCfgData.gameInfo.oaId;
recordUrl = window['recordUrl'];
}
if (recordUrl.indexOf('?') != -1) {
recordUrl += '&origins=' + oaId + '00';
} else {
recordUrl += '?origins=' + oaId + '00';
}
return recordUrl;
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ import { Decorator } from "../Decorator/Decorator";
// @Decorator.Skin("ProgressBar")
export default class ProgressBar extends eui.Component {
public ant: egret.Bitmap;
constructor() {
super();
this.skinName = `<?xml version="1.0" encoding="utf-8"?>
......@@ -13,6 +15,7 @@ export default class ProgressBar extends eui.Component {
cacheAsBitmap="false" width="656"/>
<e:Image id="mask" source="load_progress_fill_png" anchorOffsetX="0"
cacheAsBitmap="false" scale9Grid="31,4,591,28"/>
<e:Image id="ant" source="load_ant_png" x="33" y="-37" scaleX="1" scaleY="1"/>
</e:Group>
</e:Group>
</e:Skin>`;
......@@ -35,5 +38,6 @@ export default class ProgressBar extends eui.Component {
this._value = v;
(this.fill.mask as egret.DisplayObject).width = this.fill.width * v; //皮肤中要显示指定fill的width,不然开始时会获取不到width
this.ant.x = this.fill.x + this.fill.mask.width - this.ant.width;
}
}
\ No newline at end of file
......@@ -6,6 +6,10 @@ export default class ToastPanel extends Panel {
private readonly margin = 55;
constructor(data?: any) {
super(data, false);
}
private mdata: {
msg: string
}
......@@ -19,8 +23,6 @@ export default class ToastPanel extends Panel {
onSkinComplete() {
super.onSkinComplete();
this.pMask.visible = false;
this.once(egret.Event.ADDED_TO_STAGE, this.onLoad, this);
if (this.stage) {
this.onLoad();
......
import Panel from "../views/Panel";
import Loading from "../loading/Loading";
import GameMgr from "../Mgr/GameMgr";
export default class PanelCtrl {
private _parent: eui.UILayer;
private _mask: egret.Shape;
private hasMaskCount = 0;
static _instance: PanelCtrl;
static get instance() {
......@@ -11,6 +14,13 @@ export default class PanelCtrl {
init(parent: eui.UILayer) {
this._parent = parent;
let mask = new egret.Shape();
mask.graphics.beginFill(0, 0.8);
mask.graphics.drawRect(0, 0, 2200, 760);
mask.graphics.endFill();
mask.touchEnabled = false;
this._parent.addChild(mask);
this._mask = mask;
}
show(cls: any, data?: any, hasMask: boolean = true, time: number = 2500) {
......@@ -19,6 +29,20 @@ export default class PanelCtrl {
this._current = panel;
this.add(panel);
this._parent.visible = true;
if (panel.hasMask) {
this.hasMaskCount++;
}
this.updateMask();
}
private updateMask() {
if (this.hasMaskCount > 0) {
this._mask.visible = true;
} else {
this._mask.visible = false;
}
}
/**
......@@ -45,11 +69,15 @@ export default class PanelCtrl {
private onPanelHide(e: egret.Event) {
const panel = e.target as Panel;
if (panel.hasMask) {
this.hasMaskCount--;
}
this.updateMask();
panel.removeEventListener('onDestroy', this.onPanelHide, this);
panel.removeEventListener('onCreditsOut', this.onCreditsOut, this);
this.remove(panel);
if (this._parent.numChildren == 0) {
if (this._parent.numChildren == 1) {
this._parent.visible = false;
}
}
......
import Loading from "./loading/Loading";
import { NetManager } from "../libs/tw/manager/NetManager";
import { DataManager } from "../libs/tw/manager/DataManager";
import { NetName } from "../libs/tw/enum/NetName";
import PanelCtrl from "./ctrls/PanelCtrl";
import ToastPanel from "./components/ToastPanel";
import SceneCtrl from "./ctrls/SceneCtrl";
import MainScene from "./Scene/MainScene";
export const getResPath = () => window['resPath'] || '';
export const getSkinPath = (key: any) => `resource/skins/${key}Skin.exml`
......@@ -24,4 +33,8 @@ export function clearShareImg() {
shareImg.style.width = "0px";
shareImg.style.height = "0px";
shareImg.style.visibility = "hidden";
}
export function startGameRequest() {
}
\ No newline at end of file
......@@ -2,30 +2,12 @@ import ComponentBase from "../components/ComponentBase";
import Loading from "../loading/Loading";
export default class Panel extends ComponentBase {
public pMask: egret.Shape;
private hasMask: boolean;
public hasMask: boolean = true;
constructor(data?: any, hasMask: boolean = true) {
super(data);
this.hasMask = hasMask;
}
/**
*
* @param hasColor true 有颜色 false为没有颜色
*/
setMask(): void {
if (!this.pMask) {
this.pMask = new egret.Shape();
this.pMask.graphics.beginFill(0, 0.8);
this.pMask.graphics.drawRect(0, 0, this.stage.width, this.stage.height);
this.pMask.graphics.endFill();
this.addChildAt(this.pMask, 0);
this.pMask.touchEnabled = false;
}
}
setShowAct(): void {
this.alpha = 0;
// this.y = document.body.clientHeight;
......@@ -78,14 +60,6 @@ export default class Panel extends ComponentBase {
protected onSkinComplete() {
super.onSkinComplete();
Loading.instace.hide();
this.setMask();
if (!this.hasMask) {
this.pMask.alpha = 0;
}
console.log('this.pMask' + this.hasMask);
this.setShowAct();
}
......
import { ThroughSubmitData } from "../../libs/tw/data/custom/throughSubmit/ThroughSubmitData";
import GameMgr from "../Mgr/GameMgr";
class Layers extends eui.UILayer {
private _topLayer: eui.UILayer;
......@@ -12,9 +14,18 @@ class Layers extends eui.UILayer {
this.addChild(this._popupLayer);
this.addChild(this._topLayer);
this._popupLayer.visible = false;
this._topLayer.visible = false;
// this._sceneLayer.percentHeight = 100;
this._popupLayer.visible = false;
this._topLayer.visible = false;
/* let label = new eui.Label();
label.size = 40;
label.textColor = 0x000000;
label.top = 30;
label.horizontalCenter = 0;
GameMgr.instance.second = label;
this._topLayer.addChild(label);
this._topLayer.visible = true;
this._topLayer.touchEnabled = false; */
}
get topLayer() { return this._topLayer }
......
......@@ -4,14 +4,16 @@
<head>
<meta charset="utf-8">
<title>Egret</title>
<meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<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" />
<meta name="full-screen" content="true" />
<meta name="screen-orientation" content="portrait" />
<meta name="x5-fullscreen" content="true" />
<meta name="360-fullscreen" content="true" />
<style>
html, body {
html,
body {
-ms-touch-action: none;
background: #888888;
padding: 0;
......@@ -23,74 +25,69 @@
</head>
<body>
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player"
data-entry-class="Main"
data-orientation="auto"
data-scale-mode="showAll"
data-frame-rate="30"
data-content-width="750"
data-content-height="1206"
data-show-paint-rect="false"
data-multi-fingered="2"
data-show-fps="false" data-show-log="false"
data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main"
data-orientation="auto" data-scale-mode="showAll" data-frame-rate="30" data-content-width="750"
data-content-height="1206" data-show-paint-rect="false" data-multi-fingered="2" data-show-fps="false"
data-show-log="false" data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
</div>
<script>
var loadScript = function (list, callback) {
var loaded = 0;
var loadNext = function () {
loadSingleScript(list[loaded], function () {
loaded++;
if (loaded >= list.length) {
callback();
}
else {
loadNext();
}
})
<script>
var loadScript = function (list, callback) {
var loaded = 0;
var loadNext = function () {
loadSingleScript(list[loaded], function () {
loaded++;
if (loaded >= list.length) {
callback();
}
else {
loadNext();
}
})
};
loadNext();
};
loadNext();
};
var loadSingleScript = function (src, callback) {
var s = document.createElement('script');
s.async = false;
s.src = src;
s.addEventListener('load', function () {
s.parentNode.removeChild(s);
s.removeEventListener('load', arguments.callee, false);
callback();
}, false);
document.body.appendChild(s);
};
var loadSingleScript = function (src, callback) {
var s = document.createElement('script');
s.async = false;
s.src = src;
s.addEventListener('load', function () {
s.parentNode.removeChild(s);
s.removeEventListener('load', arguments.callee, false);
callback();
}, false);
document.body.appendChild(s);
};
var xhr = new XMLHttpRequest();
xhr.open('GET', './manifest.json?v=' + Math.random(), true);
xhr.addEventListener("load", function () {
var manifest = JSON.parse(xhr.response);
var list = manifest.initial.concat(manifest.game);
loadScript(list, function () {
/**
* {
* "renderMode":, //Engine rendering mode, "canvas" or "webgl"
* "audioType": 0 //Use the audio type, 0: default, 2: web audio, 3: audio
* "antialias": //Whether the anti-aliasing is enabled in WebGL mode, true: on, false: off, defaults to false
* "calculateCanvasScaleFactor": //a function return canvas scale factor
* }
**/
egret.runEgret({ renderMode: "webgl", audioType: 0, calculateCanvasScaleFactor:function(context) {
var backingStore = context.backingStorePixelRatio ||
context.webkitBackingStorePixelRatio ||
context.mozBackingStorePixelRatio ||
context.msBackingStorePixelRatio ||
context.oBackingStorePixelRatio ||
context.backingStorePixelRatio || 1;
return (window.devicePixelRatio || 1) / backingStore;
}});
var xhr = new XMLHttpRequest();
xhr.open('GET', './manifest.json?v=' + Math.random(), true);
xhr.addEventListener("load", function () {
var manifest = JSON.parse(xhr.response);
var list = manifest.initial.concat(manifest.game);
loadScript(list, function () {
/**
* {
* "renderMode":, //Engine rendering mode, "canvas" or "webgl"
* "audioType": 0 //Use the audio type, 0: default, 2: web audio, 3: audio
* "antialias": //Whether the anti-aliasing is enabled in WebGL mode, true: on, false: off, defaults to false
* "calculateCanvasScaleFactor": //a function return canvas scale factor
* }
**/
egret.runEgret({
renderMode: "webgl", audioType: 0, calculateCanvasScaleFactor: function (context) {
var backingStore = context.backingStorePixelRatio ||
context.webkitBackingStorePixelRatio ||
context.mozBackingStorePixelRatio ||
context.msBackingStorePixelRatio ||
context.oBackingStorePixelRatio ||
context.backingStorePixelRatio || 1;
return (window.devicePixelRatio || 1) / backingStore;
}
});
});
});
});
xhr.send(null);
</script>
xhr.send(null);
</script>
</body>
</html>
\ No newline at end of file
......@@ -2,7 +2,7 @@
"compilerOptions": {
"module": "es6",
"target": "es5",
"sourceMap": false,
"sourceMap": true,
"experimentalDecorators": true,
"lib": [
"es5",
......
......@@ -249,7 +249,7 @@ const config = {
data: './json/recentRankListNew.json'
},
'/hdtool/recon/ngame/getNgameStartStatus': {
data: './json/getNgameStartStatus.json'
data: './json/getStartStatus.json'
},
'/customActivity/pufaBank/moonCake/getPhone': {
data: './json/getPhone.json'
......
......@@ -65,18 +65,18 @@
}
],
"rule": "adsfasdf",
"type": "hdtool",
"element": {
"isCreditsTypeOpen": false,
"myCreditsLong": 999999632167,
"freeLimit": -1,
"success": false,
"myCredits": "999999632167",
"needCredits": "100",
"freeEmpty": true,
"needCreditsLong": 100,
"status": 1
}
"type": "hdtool"
},
"element": {
"isCreditsTypeOpen": false,
"myCreditsLong": 999999632167,
"freeLimit": -1,
"success": false,
"myCredits": "999999632167",
"needCredits": "100",
"freeEmpty": true,
"needCreditsLong": 100,
"status": 1
},
"success": true,
"desc": "OK",
......
......@@ -6,7 +6,7 @@
"avatar": "111",
"consumerId": "231fds",
"maxScore": "20000",
"nickName": "me",
"nickName": "1234567890123456",
"rank": "1",
"uid": "s322"
},
......@@ -15,7 +15,7 @@
"avatar": "111",
"consumerId": "231fds",
"maxScore": "20000",
"nickName": "me",
"nickName": "1234567890123456789012345678901234567890",
"rank": "1",
"uid": "s322"
},
......
......@@ -20,12 +20,6 @@
data-content-height="1624" data-multi-fingered="2" data-show-fps="false" data-show-log="false"
data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
</div>
<audio id="bgmusic" src="//yun.duiba.com.cn/db_games/activity/typfzq-20190903/bgm.mp3" autoplay preload
loop></audio>
<img id="shareImg" />
<div id="sCloseBtn"></div>
<img id="shareImg" src="" />
<style>
html,
body {
......@@ -44,11 +38,11 @@
</style>
<script>
//皮肤id
var skinID = 386;
//var skinID = 386;
var recordUrl = "//activity.m.duiba.com.cn/crecord/record" //发布皮肤时注意确认
var resPath = "https://yun.duiba.com.cn/db_games/activity/typfzq-20190903/1568790971/";
var resPath = "https://yun.duiba.com.cn/db_games/activity/zhonghe20190918/1568898894/";
function resolve(a) {
var b = eval(a);
return b;
......@@ -56,50 +50,9 @@
</script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/db_games/lib2_game.min.js"></script>
<script crossorigin="anonymous"
src="//yun.duiba.com.cn/db_games/activity/typfzq-20190903/1568790971/output.js"></script>
src="//yun.duiba.com.cn/db_games/activity/zhonghe20190918/1568898894/output.js"></script>
<script crossorigin="anonymous"
src="//yun.duiba.com.cn/db_games/activity/typfzq-20190903/1568790971/resource/default.thm.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
var shareData = {
title: "我的前世农生",//标题
desc: "秋分时节,测一测你的前世是什么",//描述
link: "http://10.10.35.181:8080/egret/index.html",//链接
imgUrl: 'http://duiba.oss-cn-hangzhou.aliyuncs.com/db_games/activity/zhonghe_answer/share.jpg',//图片
}
wx.config({
debug: $wxdebug,
appId: '$wxappid',
timestamp: '$wxtimestamp',
nonceStr: '$wxnonceStr',
signature: '$wxsignature',
jsApiList: ['checkJsApi', 'onMenuShareTimeline', 'onMenuShareAppMessage']
});
function invokeWX(shareData) {
wx.onMenuShareTimeline({
title: shareData.title, //标题
desc: shareData.desc, //描述
link: shareData.link, //链接
imgUrl: shareData.imgUrl, //图片
success: function () { },
cancel: function () { }
});
wx.onMenuShareAppMessage({
title: shareData.title, //标题
desc: shareData.desc, //描述
link: shareData.link, //链接
imgUrl: shareData.imgUrl, //图片
success: function (e) { },
cancel: function () { }
});
}
wx.ready(function () {
invokeWX(shareData);
});
</script>
src="//yun.duiba.com.cn/db_games/activity/zhonghe20190918/1568898894/resource/default.thm.js"></script>
<script>
egret.ImageLoader.crossOrigin = "anonymous";
/**
......
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