Commit c7a6a3c2 authored by XieChuanJin's avatar XieChuanJin

Merge branch 'zhonghe_answer' of http://gitlab2.dui88.com/clq/db-game-template into zhonghe_answer

# Conflicts:
#	egret/resource/TextureMerger/answer_scene.tmproject
#	egret/resource/TextureMerger/result_scene.tmproject
#	egret/resource/assets/ResultScene/example.jpg
#	egret/resource/assets/ResultScene/result_bg.jpg
#	egret/resource/assets/ResultScene/result_btn_restart.png
#	egret/resource/assets/answer_scene/answer_bg.jpg
#	egret/resource/assets/common/result_1.png
#	egret/resource/assets/common/result_2.png
#	egret/resource/assets/common/result_3.png
#	egret/resource/assets/common/result_4.png
#	egret/resource/assets/main_scene/main_bg.jpg
#	egret/resource/assets/main_scene/main_qrcode_img.png
#	egret/resource/assets/share_img/share_qrcode.png
#	egret/resource/default.res.json
#	egret/resource/skins/AnswerSceneSkin.exml
#	egret/resource/skins/MainSceneSkin.exml
#	egret/resource/skins/ResultSceneSkin.exml
#	egret/resource/skins/ShareImg.exml
#	egret/src/MUtils.ts
#	egret/src/Main.ts
#	egret/src/RulePanel.ts
#	egret/src/Scene/MainScene.ts
#	egret/src/Scene/ResultScene.ts
#	egret/src/ctrls/sceneCtrl.ts
#	egret/src/views/Panel.ts
#	egret/src/views/SkinScene.ts
parents abbd3c06 fa48b171
......@@ -2,7 +2,26 @@ module.exports = {
opn: 0,
devPort: 8080,
proxy: {
"/wechatThirdParty/*": 'http://localhost:3000',
"/hdtool/*": 'http://localhost:3000',
'/ngapi/*': 'http://localhost:3000',
'/plugin/*': 'http://localhost:3000',
'/ngame/*': 'http://localhost:3000',
'/activityCommon/*': 'http://localhost:3000',
'/ctool/*': 'http://localhost:3000',
'/activityVist/*': 'http://localhost:3000',
'/collectGoods/*': 'http://localhost:3000',
'/activityPlugDrawInfo/*': 'http://localhost:3000',
'/collectRule/*': 'http://localhost:3000',
'/hdtool/*': 'http://localhost:3000',
'/activityPlugin/*': 'http://localhost:3000',
'/summer/*': 'http://localhost:3000',
'/signpet/*': 'http://localhost:3000',
'/signactivity/*': 'http://localhost:3000',
'/activityPlugDrawInfo/*': 'http://localhost:3000',
'/Crecord/*': 'http://localhost:3000',
'/sign/*': 'http://localhost:3000',
'/duiba/*': 'http://localhost:3000',
'/senstiveword/*': 'http://localhost:3000',
'/customActivity/*': 'http://localhost:3000',
'/activtyShareCode/*': 'http://localhost:3000'
}
}
\ No newline at end of file
......@@ -26,8 +26,8 @@
<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="60" data-content-width="750"
data-content-height="1624" data-multi-fingered="2" data-show-fps="false" data-show-log="false"
data-orientation="auto" data-scale-mode="showAll" data-frame-rate="60" data-content-width="1624"
data-content-height="750" 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>
<img id="shareImg" />
......
declare class AlertSkin extends eui.Skin{
/* declare class AlertSkin extends eui.Skin{
}
declare class AnswerSceneSkin extends eui.Skin{
}
......@@ -14,3 +14,4 @@ declare class RulePanel extends eui.Skin{
}
declare class ShareImg extends eui.Skin{
}
*/
\ 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"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"RulePanel","version":5,"files":["..\\assets\\common\\btn_close.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"common","version":5,"files":["..\\assets\\common\\result_4.png","..\\assets\\common\\result_1.png","..\\assets\\common\\result_2.png","..\\assets\\common\\result_3.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"share_img","version":5,"files":["..\\assets\\share_img\\share_qrcode.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_scene","version":5,"files":["..\\assets\\main_scene\\main_btn.png","..\\assets\\main_scene\\main_btn_rule.png","..\\assets\\main_scene\\main_title.png","..\\assets\\main_scene\\main_qr_code_bg.png","..\\assets\\main_scene\\main_qrcode_img.png","..\\assets\\main_scene\\main_qrcode_img_bg.png"]}
\ No newline at end of file
This diff is collapsed.
{
"skins": {},
"autoGenerateExmlsList": true,
"exmls": [
"resource/skins/AlertSkin.exml",
"resource/skins/AnswerSceneSkin.exml",
"resource/skins/LoadingSkin.exml",
"resource/skins/MainSceneSkin.exml",
"resource/skins/OptionItem.exml",
"resource/skins/ResultSceneSkin.exml",
"resource/skins/RulePanelSkin.exml",
"resource/skins/ShareImg.exml",
"resource/skins/ToastPanelSkin.exml"
],
"path": "resource/default.thm.json"
"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"
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="LoadSceneSkin" width="1624" height="750" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Group width="1624" height="750" verticalCenter="0" horizontalCenter="0">
<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: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"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="MainSceneUI" width="1624" height="750" xmlns:e="http://ns.egret.com/eui"
xmlns:w="http://ns.egret.com/wing">
<e:Group touchThrough="truerank_list_" width="1624" height="750" verticalCenter="0" horizontalCenter="0">
<e:Button id="btnSound" label="" x="1301.7" y="14.7">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="main_btnSound_png" />
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0" />
</e:Skin>
</e:skinName>
</e:Button>
<e:Group width="445" height="89" horizontalCenter="-28.5" top="-5">
<e:Image source="main_score_bg_png" scaleX="1" scaleY="1" />
<e:Label text="我的分数" x="66" y="29" textColor="0x333333" size="24" />
<e:Label id="labelScore" text="0" textColor="0x333333" size="40" horizontalCenter="71" verticalCenter="-3.5" />
</e:Group>
</e:Group>
<e:Image source="main_example_jpg" horizontalCenter="0" verticalCenter="0" alpha="0.5" locked="true" visible="false" />
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="NotWinningPanel" width="1624" height="750" xmlns:e="http://ns.egret.com/eui"
xmlns:w="http://ns.egret.com/wing">
<e:Group height="582" anchorOffsetX="0" width="573" anchorOffsetY="0" horizontalCenter="-18.5" top="76">
<e:Image source="panel_bg_png" y="-1" x="0" />
<e:Image source="not_winning_bg_png" y="104" x="14" />
<e:Button id="closeBtn" label="" horizontalCenter="252.5" verticalCenter="-261">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="btn_close_png" />
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0" />
</e:Skin>
</e:skinName>
</e:Button>
<e:Label text="本局得分" x="235" y="17" size="24" />
<e:Label id="score" text="3156" size="60" bold="true" horizontalCenter="0" top="51" />
<e:Group width="510" height="327" x="30" y="120" anchorOffsetX="0" anchorOffsetY="0">
<e:Group height="51.33" anchorOffsetX="0" anchorOffsetY="0" left="0" right="0" top="0">
<e:Label id="labelMyRank" text="" textColor="0x333333" size="24" left="17" verticalCenter="0" x="17" y="15" scaleX="1" scaleY="1"/>
<e:Label id="labelMyNickname" text="" textColor="0x333333" size="24" left="107" verticalCenter="0" x="107" y="15" scaleX="1" scaleY="1"/>
<e:Label id="labelMyScore" text="" textColor="0x333333" size="24" left="422" verticalCenter="0" x="422" y="15" scaleX="1" scaleY="1"/>
</e:Group>
<e:Group height="49.33" anchorOffsetX="0" anchorOffsetY="0" left="0" right="0" top="51">
<e:Label text="排名" textColor="0x333333" size="20" left="18" verticalCenter="5.335000000000001" x="17" y="15" scaleX="1" scaleY="1"/>
<e:Label text="用户ID" textColor="0x333333" size="20" left="150" verticalCenter="4.335000000000001" x="107" y="15" scaleX="1" scaleY="1"/>
<e:Label text="得分" textColor="0x333333" size="20" left="420" verticalCenter="4.335000000000001" x="422" y="15" scaleX="1" scaleY="1"/>
<e:Image source="list_line_png" horizontalCenter="0" bottom="0"/>
</e:Group>
<e:DataGroup id="dataGroup" height="170" left="0" right="0" top="101" anchorOffsetY="0" itemRendererSkinName="RankItem">
</e:DataGroup>
<e:Label text="查看所有排行榜" textColor="0x333333" size="24" horizontalCenter="2" top="295" touchEnabled="false"/>
<e:Button id="btnViewAllRank" label="" anchorOffsetY="0" height="52" anchorOffsetX="0" left="0" right="0" bottom="0"/>
</e:Group>
<e:Button id="btnRestart" label="" horizontalCenter="-5.5" verticalCenter="214">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" scaleX.down="0.9" scaleY.down="0.9" source="not_winning_btn_restart_png" />
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0" />
</e:Skin>
</e:skinName>
</e:Button>
<e:Label id="labelHighestScore" text="历史最高分:" y="550" textColor="0x333333" size="20" horizontalCenter="0.5" />
</e:Group>
<e:Image alpha="0.5" top="75" horizontalCenter="-20.5" source="not_winning_example_png" visible="false"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="OptionItem" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Group width="493" height="90" anchorOffsetX="0" anchorOffsetY="0">
<e:RadioButton id="btn" label="">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="answer_not_select_png" source.down="answer_select_png" />
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
</e:skinName>
</e:RadioButton>
<e:Label id="label" text="C.存起来,买什么买,会不会过日子" textColor="0x9E3400" verticalCenter="0" size="29" horizontalCenter="0" touchEnabled="false"/>
</e:Group>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="ProgressBar" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Group>
<e:Image source="load_progress_bg_png" scaleX="1" scaleY="1" />
<e:Group x="2" y="2" scaleX="1" scaleY="1">
<e:Image id="fill" source="load_progress_fill_png" anchorOffsetX="0" scaleX="1" scaleY="1"
cacheAsBitmap="false" width="656"/>
<e:Image id="mask" source="load_progress_fill_png" anchorOffsetX="0"
cacheAsBitmap="false" scale9Grid="31,4,591,28"/>
</e:Group>
</e:Group>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="RankItem" xmlns:e="http://ns.egret.com/eui">
<e:Group height="56" anchorOffsetX="0" anchorOffsetY="0" left="0" right="0" y="0" x="0" scaleX="1" scaleY="1">
<e:Label text="1" textColor="0x333333" size="20" left="20" verticalCenter="0" x="17" y="15" scaleX="1"
scaleY="1" />
<e:Label text="昵称昵称昵称昵称 " textColor="0x333333" size="20" left="108" verticalCenter="0" x="107" y="15" scaleX="1"
scaleY="1" />
<e:Label text="123456" textColor="0x333333" size="20" left="403" verticalCenter="0" x="422" y="15" scaleX="1"
scaleY="1" />
<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="NotWinningPanel" width="1624" height="750" xmlns:e="http://ns.egret.com/eui"
xmlns:w="http://ns.egret.com/wing">
<e:Group height="636.67" anchorOffsetX="0" width="573" anchorOffsetY="0" horizontalCenter="-18.5" top="76">
<e:Image source="panel_bg_png" y="-1" x="0" scale9Grid="118,247,330,220" anchorOffsetY="0" height="636" />
<e:Image y="161" source="rank_list_bg_png" anchorOffsetY="0" horizontalCenter="0" />
<e:Button id="closeBtn" label="" horizontalCenter="252.5" verticalCenter="-288.335">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="btn_close_png" />
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0" />
</e:Skin>
</e:skinName>
</e:Button>
<e:Image source="rank_list_title_icon_png" x="143.67" y="31.32" />
<e:Image source="rank_list_title_icon_png" x="430.86" y="31.32" scaleX="-1" />
<e:Label text="排行榜" y="17" size="36" horizontalCenter="0" />
<e:Label id="labelHighestScore" text="3156" size="46" bold="true" horizontalCenter="-139" top="81" />
<e:Label id="labelHighestRank" text="3156" size="46" bold="true" horizontalCenter="131" top="81" />
<e:Label text="历史最高成绩" x="78" y="137" size="24" />
<e:Label text="最佳排名" x="374" y="137" size="24" />
<e:Image source="rank_list_separator_png" x="284" y="95" />
<e:Group id="groupEmpty" width="510" height="439.33" x="30" y="175" anchorOffsetX="0" anchorOffsetY="0" visible="false">
<e:Image source="rank_list_empty_png" horizontalCenter="0" verticalCenter="-40"/>
<e:Label text="目前还没有" y="260" textColor="0x333333" size="24" anchorOffsetX="0" horizontalCenter="16" fontFamily="Microsoft YaHei"/>
<e:Label text="排名记录哦~" y="295.02" textColor="0x333333" size="24" anchorOffsetX="0" horizontalCenter="16" fontFamily="Microsoft YaHei"/>
</e:Group>
<e:Group id="groupNotEmpty" width="510" height="439.33" x="30" y="175" anchorOffsetX="0" anchorOffsetY="0">
<e:Group height="49.33" anchorOffsetX="0" anchorOffsetY="0" left="0" right="0" top="0">
<e:Label text="排名" textColor="0x333333" size="20" left="18" verticalCenter="5.335000000000001" x="17"
y="15" scaleX="1" scaleY="1" />
<e:Label text="用户ID" textColor="0x333333" size="20" left="150" verticalCenter="4.335000000000001"
x="107" y="15" scaleX="1" scaleY="1" />
<e:Label text="得分" textColor="0x333333" size="20" left="420" verticalCenter="4.335000000000001" x="422"
y="15" scaleX="1" scaleY="1" />
<e:Image source="list_line_png" horizontalCenter="0" bottom="0" />
</e:Group>
<e:Scroller height="338" left="0" right="0" top="50" anchorOffsetY="0">
<e:Skin>
<e:VScrollBar id="verticalScrollBar" width="7" height="100%" right="0">
<e:Skin>
<e:Image id="thumb" width="7" height="77" source="rank_list_sliderbar_png"
scale9Grid="2,5,3,67" />
</e:Skin>
</e:VScrollBar>
</e:Skin>
<e:List id="list" itemRendererSkinName="RankItem">
<e:ArrayCollection>
<e:Array>
<e:Object test="null" />
<e:Object test="null" />
<e:Object test="null" />
<e:Object test="null" />
</e:Array>
</e:ArrayCollection>
</e:List>
</e:Scroller>
</e:Group>
</e:Group>
<e:Image alpha="0.5" top="75" horizontalCenter="-20.5" source="rank_list_example_png" locked="true" visible="false" />
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="StartSceneSkin" width="1624" height="750" xmlns:e="http://ns.egret.com/eui"
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:Button id="btnLogin" label="" horizontalCenter="-15" verticalCenter="205" visible="false">
<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_login_png" />
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0" />
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="btnStart" label="" horizontalCenter="-15" bottom="105">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="start_btn_start_png" />
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0" />
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="btnRank" label="" left="249" top="67">
<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" />
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0" />
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="btnRule" label="" left="249" top="4">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="start_btn_rule_png"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="btnRecord" label="" top="-5" right="224">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="start_btn_record_png"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="btnSound" label="" top="42" right="224">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="start_btn_sound_png"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
</e:skinName>
</e:Button>
<e:Label id="labelFreeTime" text="今日免费次数:" textColor="0x333333" size="30" bottom="57" horizontalCenter="-38"/>
<e:Label id="labelMyCredit" text="我的积分:" textColor="0x333333" size="30" bottom="15" horizontalCenter="-41"/>
</e:Group>
<e:Image source="start_example_jpg" horizontalCenter="0" verticalCenter="0" alpha="0.5" visible="false"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="ToastPanel" width="750" height="1206" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Rect width="100%" height="100%" fillAlpha="0" strokeAlpha="0" locked="true"/>
<e:Rect id="bgRect" width="565.91" height="150" anchorOffsetX="0" anchorOffsetY="0" strokeAlpha="0" ellipseWidth="35" ellipseHeight="35" horizontalCenter="0" verticalCenter="0"/>
<e:Label id="msgLb" text="" height="125" width="539.37" textAlign="center" verticalCenter="-0.5" verticalAlign="middle" anchorOffsetX="0" anchorOffsetY="0" x="105"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="NotWinningPanel" width="1624" height="750" xmlns:e="http://ns.egret.com/eui"
xmlns:w="http://ns.egret.com/wing">
<e:Group height="582" anchorOffsetX="0" width="573" anchorOffsetY="0" horizontalCenter="-18.5" top="76">
<e:Image source="winning_light_bg_png" scaleX="1" scaleY="1" x="-154" y="-76" />
<e:Image id="light" source="winning_light_png" scaleX="1" scaleY="1" anchorOffsetX="321.21"
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:Button id="closeBtn" label="" horizontalCenter="252.5" verticalCenter="-261">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="btn_close_png" />
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0" />
</e:Skin>
</e:skinName>
</e:Button>
<e:Label text="本局得分" x="235" y="17" size="24" />
<e:Label id="score" text="3156" size="60" bold="true" horizontalCenter="0" top="51" />
<e:Label text="蚂蚁竞走了这么久,发个奖励鼓励下" x="73" y="139" size="26" />
<e:Button id="btnRestart" label="" horizontalCenter="-139" verticalCenter="191">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" scaleX.down="0.9" scaleY.down="0.9"
source="winning_btn_restart_png" />
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0" />
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="btnReceive" label="" horizontalCenter="131" verticalCenter="191">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="winning_receive_png" scaleX.down="0.9" scaleY.down="0.9"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
</e:skinName>
</e:Button>
<e:Label id="labelHighestScore" text="历史最高分:1120" y="546" textColor="0x333333" size="20" horizontalCenter="0"/>
</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
......@@ -55,31 +55,39 @@ export namespace Decorator {
return class extends target {
constructor(...arg: any[]) {
super(...arg);
this["onDestroy"] = this["onDestroy"] || (() => { });
this["addEventListener"](egret.Event.REMOVED_FROM_STAGE, this["onDestroy"], this);
this["addEventListener"](egret.Event.REMOVED_FROM_STAGE, () => {
this["onDestroy"] && this["onDestroy"]();
}, this);
}
}
}
export function ClassNameSkin(name: string) {
return function <T extends { new(...arg: any[]): {} }>(target: T) {
return class extends target {
export function OnUpdate<T extends { new(...arg: any[]): {} }>(target: T) {
return class extends target {
constructor(...arg: any[]) {
super(...arg);
this["onUpdate"] = this["onUpdate"] || (() => { });
this["addEventListener"](egret.Event.ENTER_FRAME, this["onUpdate"], this);
/* private preLoad() {
return new Promise(resolve => {
resolve();
});
} */
this["addEventListener"](egret.Event.REMOVED_FROM_STAGE, () => {
this["removeEventListener"](egret.Event.ENTER_FRAME, this["onUpdate"], this);
}, this);
}
}
}
export function Skin(name: string) {
return function <T extends { new(...arg: any[]): {} }>(target: T) {
return class extends target {
constructor(...arg: any[]) {
super(...arg);
let setSkin = () => {
this["skinName"] = `resource/skins/${name}.exml`;
if (this["skin"]) {
this["onLoad"] && this["onLoad"]();
this["onSkinComplete"] && this["onSkinComplete"]();
} else {
this["addEventListener"](eui.UIEvent.COMPLETE, this["onLoad"] || (() => { }), this);
this["addEventListener"](eui.UIEvent.COMPLETE, this["onSkinComplete"] || (() => { }), this);
}
}
......@@ -88,8 +96,6 @@ export namespace Decorator {
} else {
setSkin();
}
}
}
}
......
import { MConst } from "../MConst";
import GameObject from "./GameObject";
import { ControllerDirection } from "./PlayerController";
import DisplayCollider, { Tag, Contact } from "./DisplayCollider";
import DebugMgr from "../Mgr/DebugMgr";
import GameMgr from "../Mgr/GameMgr";
import { MConfigs } from "../MConfigs";
export default class Ant extends GameObject {
private speedValue: number = MConfigs.ant.speedValue;
private contactToLeg: number = null;
constructor() {
super(Tag.Ant, MConst.AntLocalRect);
}
/**@override */
protected onDraw() {
this.addChild(new egret.Bitmap(RES.getRes("ant_png")));
}
public move(direction: ControllerDirection) {
let dirVec: egret.Point = new egret.Point(0, 0); //默认为0
switch (direction) {
case ControllerDirection.Left:
if (this.contactToLeg != 0) {
dirVec = new egret.Point(-1, 0);
}
break;
case ControllerDirection.Right:
if (this.contactToLeg != 1) {
dirVec = new egret.Point(1, 0);
}
break;
case ControllerDirection.None:
// dirVec = new egret.Point(0, 0);
break;
default:
break;
}
dirVec.normalize(this.speedValue)
this.velocity = dirVec;
}
public die() {
this.visible = false;
}
onCollisionEnter(other: DisplayCollider, contact: Contact) {
if (other.tag == Tag.Leg) {
this.contactToLeg = contact.self;
}
}
onCollisionStay(other: DisplayCollider, contact: Contact) {
if (other.tag == Tag.Leg) {
this.contactToLeg = contact.self;
}
}
onCollisionExit(other: DisplayCollider) {
if (other.tag == Tag.Leg) {
this.contactToLeg = null;
}
}
}
\ No newline at end of file
import { Decorator } from "../Decorator/Decorator";
import DebugMgr from "../Mgr/DebugMgr";
import PhysicalSystem from "./PhysicalSystem";
@Decorator.OnUpdate
@Decorator.OnDestroy
export default class DisplayCollider extends egret.DisplayObjectContainer {
public tag: Tag;
/**是否开启调试模式 */
private debug: boolean = true;
/**本地坐标rect */
public get localRect() {
return this._localRect;
}
public set localRect(v: egret.Rectangle) {
this._localRect = v;
}
private _localRect: egret.Rectangle = new egret.Rectangle(0, 0, 0, 0);
/**世界坐标rect */
public get rect() {
let pos = this.localToGlobal(this.localRect.x, this.localRect.y);
return new egret.Rectangle(
pos.x,
pos.y,
this.localRect.width,
this.localRect.height
);
}
constructor(tag: Tag, localRect: egret.Rectangle) {
super();
this.tag = tag;
this.localRect = localRect;
PhysicalSystem.instance.addCollider(this);
}
/**@virtual */
public onCollisionEnter(otherCollider: DisplayCollider, contact: Contact) {
}
/**@virtual */
public onCollisionStay(otherCollider: DisplayCollider, contact: Contact) {
}
/**@virtual */
public onCollisionExit(otherCollider: DisplayCollider) {
}
/**@override */
onUpdate() {
if (this.debug) {
DebugMgr.instance.updateCollider(this.hashCode.toString(), this.rect, { color: 0x00ff00, lineSize: 1 });
}
}
/**
* @override
*/
onDestroy() {
PhysicalSystem.instance.removeCollider(this);
DebugMgr.instance.clearCollider(this.hashCode.toString());
}
}
export enum Tag {
Ant,
Leg,
Ground,
GoldCoin
}
export interface Contact { self: number, other: number }
\ No newline at end of file
import DisplayCollider, { Tag } from "./DisplayCollider";
import { MConst } from "../MConst";
import { Decorator } from "../Decorator/Decorator";
import GameMgr from "../Mgr/GameMgr";
import DebugMgr from "../Mgr/DebugMgr";
export default abstract class GameObject extends DisplayCollider {
/**@abstract */
protected abstract onDraw(): void;
/**每帧速率的增量。x坐标表示水平方向速率的增量,为标量,单位为像素/帧;y轴同上。 */
protected acceleration: egret.Point = new egret.Point();
private timerList: MTimer[] = [];
constructor(tag: Tag, localRect: egret.Rectangle) {
super(tag, localRect);
this.onDraw();
}
public moveTo(x: number | egret.Point, y?: number) {
if (typeof x == "number") {
if (!y) {
console.error("invalid param");
return;
}
this.moveTo(new egret.Point(x, y));
} else {
let target: egret.Point = x;
let bottomY = this.y + this.height;
let curBottomcPos = new egret.Point(this.x, bottomY);
let bottomTarget = new egret.Point(target.x, target.y + this.height);
if (bottomTarget.y == bottomY) { //防止下面的除零异常
this.x = target.x;
return;
}
let groundLine = GameMgr.instance.groundLineInWorld;
let targetBottomToGroundLine = groundLine - bottomTarget.y;
let displace = bottomTarget.subtract(curBottomcPos);
if (displace.y >= 0 && targetBottomToGroundLine <= 0) {
let ratio = (groundLine - bottomY) / (bottomTarget.y - bottomY);
displace.x *= ratio;
displace.y *= ratio;
bottomTarget = curBottomcPos.add(displace);
this.x = bottomTarget.x;
this.y = bottomTarget.y - this.height;
} else {
this.x = target.x;
this.y = target.y;
}
}
}
public land(x: number, y: number = 0) {
this.x = x;
this.y = (GameMgr.instance.groundLineInWorld - this.height) + y;
}
public get position() {
return new egret.Point(this.x, this.y);
}
/**速度 单位:像素/帧 */
public get velocity() {
return this._velocity;
}
public set velocity(v: egret.Point) {
this._velocity = v;
}
private _velocity: egret.Point = new egret.Point();
/**@override */
onUpdate() {
super.onUpdate();
this.velocity.x += this.acceleration.x;
this.velocity.y += this.acceleration.y;
if (this.velocity.length > 0) {
this.moveTo(this.position.add(this.velocity));
}
}
/**@override */
onDestroy() {
super.onDestroy();
egret.Tween.removeTweens(this);
this.timerList.forEach(e => e.destroy());
this.timerList = null;
}
public setTimer(time: number, onTimeOut: () => void, repeat?: number, onRepeated?: () => void): MTimer {
let timer = new MTimer(time, onTimeOut, repeat, () => {
onRepeated && onRepeated();
//执行完毕,在列表中删除自身
this.timerList.splice(this.timerList.indexOf(timer), 1);
});
this.timerList.push(timer);
return timer;
}
public delay(time: number): Promise<void> {
return new Promise<void>(resolve => {
this.setTimer(time, () => {
resolve();
});
});
}
}
export class MTimer {
private timer: egret.Timer = null;
constructor(time: number, onTimeOut: () => void, repeat?: number, onRepeated?: () => void) {
//创建一个计时器对象
let timer: egret.Timer = new egret.Timer(time, repeat || 1);
//注册事件侦听器
timer.addEventListener(egret.TimerEvent.TIMER, onTimeOut, this);
timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, onRepeated || (() => { }), this);
//开始计时
timer.start();
this.timer = timer;
}
stop() {
this.timer.stop();
}
destroy() {
this.stop();
this.timer = null;
}
}
\ No newline at end of file
export default class GameStage extends egret.DisplayObjectContainer {
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();
}
}
};
this.addEventListener(egret.Event.ENTER_FRAME, onUpdate, this);
});
}
}
\ No newline at end of file
import GameObject from "./GameObject";
import DisplayCollider, { Tag, Contact } from "./DisplayCollider";
import { MConst } from "../MConst";
import { Decorator } from "../Decorator/Decorator";
import { MConfigs } from "../MConfigs";
import GameMgr from "../Mgr/GameMgr";
import MainScene from "../Scene/MainScene";
export default class GoldCoin extends GameObject {
/**标识是否落地。这个落地不是只接触了地面,而是弹跳完毕,完全落在地面上。 */
private onGround = false;
/**标识是否被脚踩 */
private beTrampled = false;
private contactGroundFrameCount = 0;
private bounceCoefficient = 1;
private context: MainScene = null;
private scoreValue = 10;
constructor(context?: MainScene) {
super(Tag.GoldCoin, MConst.GoldCoinLocalRect);
this.context = context || null;
this.bounceCoefficient = MConfigs.goldCoin.bounceCoefficient;
this.acceleration.y = MConfigs.goldCoin.gravity;
}
/**@override */
onDraw() {
this.addChild(new egret.Bitmap(RES.getRes("gold_coin_png")));
}
onCollisionEnter(other: DisplayCollider, contact: Contact) {
if (other.tag == Tag.Leg) { //被踩
if (!this.onGround) { //在空中被踩
//给予垂直速度增量
this.velocity.y += MConfigs.goldCoin.moveVelocityY;
this.bounceCoefficient = 0;
} else { //在地面上被踩
this.slide(contact);
}
this.beTrampled = true;
}
if (other.tag == Tag.Ground) {
if (!this.onGround) { //未落地
this.contactGroundFrameCount = 0;
this.velocity.y = -(this.bounceCoefficient * this.velocity.y);
}
}
if (other.tag == Tag.Ant) {
this.destroy();
this.context && (this.context.score += this.scoreValue);
}
}
private slide(contact: Contact) {
//根据位置给予水平加速度
if (contact.other >= 0.5) {
this.acceleration.x = MConfigs.goldCoin.moveAccelerationX;
} else {
this.acceleration.x = - MConfigs.goldCoin.moveAccelerationX;
}
}
onCollisionStay(other: DisplayCollider, contact: Contact) {
if (this.onGround && other.tag == Tag.Leg) { //在地面上被踩
this.slide(contact);
}
//判断落地
if (other.tag == Tag.Ground && !this.onGround) {
this.contactGroundFrameCount++;
if (this.contactGroundFrameCount > 2) { //长时间接触地面
//判断为落地
this.onGround = true;
if (this.beTrampled) { //被踩的过程中转换为落地状态
this.slide(contact);
}
this.velocity.y = 0;
this.acceleration.y = 0;
}
}
}
onCollisionExit(other: DisplayCollider) {
if (other.tag == Tag.Leg) {
//停止滑动
this.acceleration.x = 0;
egret.Tween.get(this.velocity).to({ x: 0 }, MConfigs.goldCoin.moveSlowDownDuration);
this.beTrampled = false;
}
}
}
\ No newline at end of file
import GameObject from "./GameObject";
import { MConst } from "../MConst";
import { MConfigs } from "../MConfigs";
import DisplayCollider, { Tag } from "./DisplayCollider";
import DebugMgr from "../Mgr/DebugMgr";
import GameMgr from "../Mgr/GameMgr";
import { Decorator } from "../Decorator/Decorator";
import GameStage from "./GameStage";
export default class Leg extends GameObject {
private acting = false;
public toward: LegToward;
public get towardCoefficient() { return this.toward == LegToward.Right ? 1 : -1; }
private gameStage: GameStage = null;
constructor(gameStage: GameStage, rect: egret.Rectangle, texture: egret.Texture, toward: LegToward) {
super(Tag.Leg, rect);
this.gameStage = gameStage;
let bitmap = new egret.Bitmap(texture);
this.addChild(bitmap);
this.toward = toward;
if (toward == LegToward.Left) {
bitmap.scaleX = -1;
this.localRect = new egret.Rectangle(
-(this.localRect.x + this.localRect.width),
this.localRect.y,
this.localRect.width,
this.localRect.height
);
}
}
public updateCallback = () => { }
onUpdate() {
super.onUpdate();
this.updateCallback();
}
protected onDraw(): void { }
/**一次行动完毕的回调 */
public onActed: () => void = () => { }
/**行动 */
public act() {
this.acting = true;
this.doTween();
}
private stopAct() {
this.acting = false;
egret.Tween.removeTweens(this);
this.velocity = new egret.Point();
//震动地面
this.gameStage.shake().then(() => {
this.onActed();
});
}
private doTween() {
let param = MConfigs.legTweenParam;
egret.Tween.get(this.velocity)
.to({ y: -param.rise.maxSpeed }, param.rise.duration.speedUp)
.wait(param.rise.duration.keep)
.to({ y: 0 }, param.rise.duration.slowDown)
.to({ y: param.fall.speedUp1.value }, param.fall.speedUp1.duration)
.to({ y: param.fall.speedUp2.value }, param.fall.speedUp2.duration);
let p1Time = param.rise.duration.speedUp
+ param.rise.duration.keep
+ param.rise.duration.slowDown
let p2Time = param.fall.speedUp1.duration
+ param.fall.speedUp2.duration;
egret.Tween.get(this.velocity)
.to({ x: 5 * this.towardCoefficient }, p1Time)
.to({ x: 8 * this.towardCoefficient }, p2Time);
}
/**@override */
onCollisionEnter(other: DisplayCollider) {
if (other.tag == Tag.Ground && this.acting) {
this.stopAct();
}
if (other.tag == Tag.Ant) {
if (this.acting) {
// GameMgr.instance.ant.die();
}
}
}
/**@override */
onCollisionStay(other: DisplayCollider) {
}
/**@override */
onCollisionExit(other: DisplayCollider) {
}
}
export enum LegToward {
Left,
Right
}
\ No newline at end of file
import GameObject from "./GameObject";
import Leg, { LegToward } from "./Leg";
import GameMgr from "../Mgr/GameMgr";
import { ControllerDirection } from "./PlayerController";
import DebugMgr from "../Mgr/DebugMgr";
import GameStage from "./GameStage";
export default class Legs {
public get toward(): LegToward {
return this.left.toward;
}
private left: Leg = null;
private right: Leg = null;
/**是否测量过步长 */
private stepLength = null;
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);
this.right = new Leg(gameStage, rect, texture, toward);
gameStage.addChild(this.right);
// return;
//两腿交替行动
this.left.act();
this.left.onActed = () => {
if (!this.stepLength) {
this.stepLength = Math.abs(this.left.x - this.initPosX);
this.right.land(this.initPosX + this.right.towardCoefficient * (this.stepLength / 2), -5);
}
this.right.act();
}
this.right.onActed = () => {
this.left.act();
}
this.left.updateCallback = () => {
if (this.toward == LegToward.Right) {
if (this.posX > GameMgr.instance.stage.stageWidth + 600) {
this.left.destroy();
this.right.destroy();
console.error("destroy");
}
} else {
if (this.posX < - 600) {
this.left.destroy();
this.right.destroy();
console.error("destroy");
}
}
// DebugMgr.instance.updateLine(this.left.hashCode.toString() + "1", { startX: this.left.x, startY: 0, endX: this.left.x, endY: 750 });
// DebugMgr.instance.updateLine(this.left.hashCode.toString() + "2", { startX: this.right.x, startY: 0, endX: this.right.x, endY: 750 });
// DebugMgr.instance.updateLine(this.left.hashCode.toString() + "3", { startX: this.posX, startY: 0, endX: this.posX, endY: 750 }, { lineSize: 2, color: 0x0000ff });
}
}
public setInitPosX(x: number) {
this.initPosX = x;
this.left.land(x, -2);
this.right.land(x, -5);
}
public get posX() {
if (this.toward == LegToward.Right) {
return Math.min(this.right.x, this.left.x);
} else {
return Math.max(this.right.x, this.left.x);
}
}
}
\ No newline at end of file
import { Decorator } from "../Decorator/Decorator";
import DisplayCollider from "./DisplayCollider";
import DebugMgr from "../Mgr/DebugMgr";
export default class PhysicalSystem {
private colliderList: Array<DisplayCollider> = new Array<DisplayCollider>();
private collisionMap: { [hashCode: number]: number[] } = {};
private collisions: Array<{ collider1: number, collider2: number }> = [];
/**
* @returns 未找到返回-1
*/
private getCollisionIndex(collider1: number, collider2: number): number {
for (let i = 0; i < this.collisions.length; i++) {
if ((this.collisions[i].collider1 == collider1 && this.collisions[i].collider2 == collider2) || (this.collisions[i].collider1 == collider2 && this.collisions[i].collider2 == collider1)) {
return i;
}
}
//未碰撞
return -1;
}
public addCollider(collider: DisplayCollider) {
for (let i of this.colliderList) {
if (i.hashCode === collider.hashCode) {
console.warn("repeat to add collider");
return;
}
}
this.colliderList.push(collider);
}
public removeCollider(collider: DisplayCollider) {
let index = this.colliderList.indexOf(collider);
if (index >= 0) {
this.colliderList.splice(index, 1);
} else {
console.warn("remove the nonexistent collider");
}
}
/**检测碰撞 */
public detectCollision() {
DebugMgr.instance.setLog(this.colliderList.length.toString());
//查找所有碰撞
for (let i = 0; i <= this.colliderList.length - 1; i++) {
for (let j = i + 1; j <= this.colliderList.length - 1; j++) {
this.detectTraverse(this.colliderList[i], this.colliderList[j]);
}
}
}
private detectTraverse(collider1: DisplayCollider, collider2: DisplayCollider) {
let collisionIndex = this.getCollisionIndex(collider1.hashCode, collider2.hashCode);
let rect1 = collider1.rect,
rect2 = collider2.rect,
rectW1 = rect1.x + rect1.width,
rectW2 = rect2.x + rect2.width,
rectH1 = rect1.height + rect1.y,
rectH2 = rect2.y + rect2.height;
if (rect1.x <= rectW2 &&
rectW1 >= rect2.x &&
rect1.y <= rectH2 &&
rectH1 >= rect2.y) { //发生碰撞
//判断碰撞位置
let contact1: number = null, contact2: number = null;
if (rect1.x < rect2.x && rectW1 < rectW2) { //相交,1在左,2在右
contact1 = 1;
contact2 = 0;
} else if (rect2.x < rect1.x && rectW2 < rectW1) { //相交,2在左,1在右
contact1 = 0;
contact2 = 1;
} else if (rect1.x <= rect2.x && rectW1 >= rectW2) { //1包含2
contact1 = ((rect2.x - rect1.x) + rect2.width / 2) / rect1.width;
contact2 = 0.5;
} else if (rect1.x >= rect2.x && rectW1 <= rectW2) { //2包含1
contact1 = 0.5;
contact2 = ((rect1.x - rect2.x) + rect1.width / 2) / rect2.width;
} else {
console.error("logic error");
}
if (collisionIndex > -1) { //之前就发生了碰撞
collider1.onCollisionStay(collider2, { self: contact1, other: contact2 });
collider2.onCollisionStay(collider1, { self: contact2, other: contact1 });
} else { //之前没有碰撞
//添加到索引表
this.collisions.push({
collider1: collider1.hashCode,
collider2: collider2.hashCode
});
collider1.onCollisionEnter(collider2, { self: contact1, other: contact2 });
collider2.onCollisionEnter(collider1, { self: contact2, other: contact1 });
}
} else { //未发生碰撞
//碰撞退出
if (collisionIndex > -1) { //之前有发生碰撞
//在碰撞列表中删除这一对碰撞
this.collisions.splice(collisionIndex, 1);
collider1.onCollisionExit(collider2);
collider2.onCollisionExit(collider1);
}
}
}
private static _instance: PhysicalSystem = null;
public static get instance(): PhysicalSystem {
if (!this._instance) {
this._instance = new PhysicalSystem();
}
return this._instance;
}
}
\ No newline at end of file
import Ant from "./Ant";
export default class PlayerController extends eui.UILayer {
constructor() {
super();
this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBegin, this);
this.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEnd, this);
}
public direction: ControllerDirection = ControllerDirection.None;
public onLeft: () => void = () => { };
public onRight: () => void = () => { };
private onTouchBegin(event: egret.TouchEvent) {
if (event.stageX >= this.stage.stageWidth / 2) {
this.direction = ControllerDirection.Right;
} else {
this.direction = ControllerDirection.Left;
}
}
private onTouchEnd() {
this.direction = ControllerDirection.None;
}
}
export enum ControllerDirection {
None,
Left,
Right
}
\ No newline at end of file
export namespace MConfigs {
export const question: {
[key: string]: {
id: string,
stem: string,
options: { [key: string]: string }
}
} = {
0: {
id: "0",
stem: "秋分是秋天最后一个节气了,天气逐渐转凉,你会开始保暖吗?",
options: {
"A": "煤球炉子、火炕烧起来",
"B": "有,但是不多",
"C": "从来不知道秋裤是什么"
}
},
1: {
id: "1",
stem: "都说求人吃秋菜,秋分这一天,你会选择吃什么?",
options: {
"A": "当然是传统秋菜——苋菜啦",
"B": "吃什么都是吃,还分季节?",
"C": "我就想吃这个季节没有的东西"
}
},
2: {
id: "2",
stem: "朋友送你一筐鱼苗,你会怎么做?",
options: {
"A": "挖一个鱼塘,好好照料",
"B": "借邻居的鱼塘养鱼苗",
"C": "烧点水,吃了吧"
}
},
3: {
id: "3",
stem: "大丰收了,赚钱后你想买点什么?",
options: {
"A": "扩大生产,明年赚更多",
"B": "买貂,准备过冬",
"C": "存起来,买什么买,会不会过日子"
}
export const ant = {
speedValue: 6
}
export const legTweenParam = {
rise: {
duration: {
speedUp: 400,
keep: 1000,
slowDown: 400
},
maxSpeed: 5
},
4: {
id: "4",
stem: "今年收成好,今晚打算加个什么菜?",
options: {
"A": "大丰收",
"B": "杂粮饽饽",
"C": "乱炖"
fall: {
speedUp1: {
duration: 400,
value: 10
},
speedUp2: {
duration: 1200,
value: 17
}
}
}
export const goldCoin = {
gravity: 0.4, //掉落阶段受到的重力加速度
bounceCoefficient: 0.5, //弹性系数,即掉落到地面能量损失率,取值区间[0,1]
moveAccelerationX: 0.5, //被脚踩后弹开的加速阶段的水平加速度
moveSlowDownDuration: 100, //离开脚后减速到0所需的时间,单位毫秒
moveVelocityY: 15 //被脚踩之后的垂直速率
}
}
\ No newline at end of file
export namespace MConst {
/**地线的游戏舞台坐标 */
export const GroundLine = 534;
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 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),
4: new egret.Rectangle(44, 466, 208, 68),
5: new egret.Rectangle(53, 466, 231, 68),
6: new egret.Rectangle(48, 477, 196, 64)
}
}
}
import GameMgr from "./GameMgr";
import Leg from "../Game/Leg";
export default class DebugMgr extends egret.DisplayObjectContainer {
private shapeMap = {};
private graphicDebugLayer: egret.DisplayObjectContainer = null;
private uiLayer: eui.UILayer = null;
private log: eui.Label = null;
public onClick = () => { }
public t: any = null;
constructor() {
super();
//创建图形调试层
this.graphicDebugLayer = new egret.DisplayObjectContainer();
this.graphicDebugLayer.touchEnabled = false;
this.addChild(this.graphicDebugLayer);
//创建UI层
this.uiLayer = new eui.UILayer();
this.uiLayer.touchThrough = true;
this.addChild(this.uiLayer);
//创建日志标签
this.log = new eui.Label("Log");
this.log.horizontalCenter = 0;
this.log.top = 50;
this.log.textColor = 0xffffff;
this.log.stroke = 0.5;
this.log.size = 32;
this.uiLayer.addChild(this.log);
//创建调试按钮
let button = new eui.Label("调试");
button.textColor = 0x000000;
button.borderColor = 0x000000;
button.border = true;
button.top = 30;
button.right = 50;
this.uiLayer.addChild(button);
button.onTap(this, () => {
this.onClick();
});
}
public setLog(msg: string) {
this.log.text = msg;
}
public drawCollider(rect: egret.Rectangle, style: GraphicDebug.Style = { color: 0xff0000, lineSize: 1 }) {
let shape = new egret.Shape();
shape.graphics.lineStyle(style.lineSize, style.color);
shape.graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
this.graphicDebugLayer.addChild(shape);
}
public drawLine(line: GraphicDebug.Line, style: GraphicDebug.Style = { color: 0xff0000, lineSize: 1 }) {
let shape = new egret.Shape();
shape.graphics.lineStyle(style.lineSize, style.color);
shape.graphics.moveTo(line.startX, line.startY);
shape.graphics.lineTo(line.endX, line.endY);
this.graphicDebugLayer.addChild(shape);
}
public updateLine(key: string, line: GraphicDebug.Line, style: GraphicDebug.Style = { color: 0xff0000, lineSize: 1 }) {
let shape: egret.Shape = this.shapeMap[key];
if (!shape) {
shape = new egret.Shape();
this.graphicDebugLayer.addChild(shape);
this.shapeMap[key] = shape;
}
shape.graphics.clear();
shape.graphics.lineStyle(style.lineSize, style.color);
shape.graphics.moveTo(line.startX, line.startY);
shape.graphics.lineTo(line.endX, line.endY);
}
public updateCollider(key: string, rect: egret.Rectangle, style: GraphicDebug.Style = { color: 0xff0000, lineSize: 1 }) {
let shape: egret.Shape = this.shapeMap[key];
if (!shape) {
shape = new egret.Shape();
this.graphicDebugLayer.addChild(shape);
this.shapeMap[key] = shape;
}
shape.graphics.clear();
shape.graphics.lineStyle(style.lineSize, style.color);
shape.graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
}
public clearCollider(key: string) {
let shape: egret.Shape = this.shapeMap[key];
if (!shape) {
console.warn("collider is nonexistent");
return;
}
delete this.shapeMap[key];
shape.destroy();
}
private static _instance: DebugMgr = null;
public static get instance(): DebugMgr {
if (!this._instance) {
if (GameMgr.instance.stage) {
this._instance = new DebugMgr();
GameMgr.instance.stage.addChild(this._instance);
} else {
console.error("stage is null,DebugMgr can not instantiate");
}
}
return this._instance;
}
}
export namespace GraphicDebug {
export interface Style {
color: number;
lineSize: number;
}
export interface Line {
startX: number;
startY: number;
endX: number;
endY: number;
}
}
import { MConst } from "../MConst";
import DisplayCollider from "../Game/DisplayCollider";
import Ant from "../Game/Ant";
export default class GameMgr {
private static _instance: GameMgr = null;
public static get instance(): GameMgr {
if (!this._instance) {
this._instance = new GameMgr();
}
return this._instance;
}
public stage: egret.Stage = null;
/**获取地线的世界坐标 */
public get groundLineInWorld() {
return MConst.GroundLine;
}
}
\ No newline at end of file
import Panel from "../views/Panel";
export default class NotWinningPanel extends Panel {
get skinKey() { return "NotWinningPanel" }
get groupName() { return "not_winning_panel" }
}
\ No newline at end of file
import Panel from "../views/Panel"
export default class RankListPanel extends Panel {
get skinKey() { return "RankListPanel" }
get groupName() { return "rank_list_panel" }
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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