├── _res.fla ├── _res.html ├── _res.js ├── debug.txt ├── images ├── 16x16.png ├── _res _ 副本_atlas_.json ├── _res _ 副本_atlas_.png ├── _res_atlas_.js ├── _res_atlas_.json └── _res_atlas_.png ├── index.html ├── sounds ├── Camera.mp3 ├── HoeSound.mp3 ├── HorseSound1.mp3 ├── HorseSound2.mp3 ├── Race8.mp3 └── ResultSound.mp3 ├── src ├── Countdown.js ├── GameController.js ├── GameInit.js ├── GetResult.js ├── HorseModel.js ├── HorseNumber.js ├── MessageBar.js ├── MovieclipUtil.js ├── RaceCourse.js ├── ResultPanel.js ├── SoundButton.js ├── SoundManager.js ├── TakePhoto.js ├── Timer.js └── lib │ ├── createjs-2015.11.26.min.js │ └── jquery-1.11.1.min.js ├── 帮助文档.html └── 源文件.fla /_res.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HensonGuo/horserace/55d958b6b25fe21d9b1eee87d0c6fa466debc408/_res.fla -------------------------------------------------------------------------------- /_res.html: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 |
11 | 12 |t |
应用启动后下载各种资源及配置;检测是否有调试文件;如有调试文件,进入调试模式,读取调试文件模拟数据;否则通过cgi接口获取网络数据。上面的流程OK后,构建游戏场景及马匹,收到数据根据下一轮抽奖间隔时间(awardTimeInterval)进行倒计时,倒计时完成,马匹开始跑,同时间隔一段时间请求一次数据,如收到新的数据(及期数改变[periodDate]),抽奖结果也出来了(awardNumbers),模拟结果至结束当前轮;同时再次开启下一轮的模拟。 9 | 10 | 11 |
12 |地址配置:先删除调试文件debug.txt,在GameController.js文件中第11行修改url地址: 15 |
16 | var url = '';
17 | 请求间隔:游戏倒计时完成后,会间隔一段时间请求一次CGI数据,轮询请求,保证能以较小误差及时获得最新结果;这个间隔时间设置的3000ms;此参考的是http://tq50.com/ 上赛马游戏的间隔请求,这个可以根据服务器的承载压力自行修改,GameController.js文件中第9行: 18 |
19 | var requestDataTimer = new Timer(3000);
20 | 数据格式:目前配置的是jsonp格式的,也可以换成json格式的,根据服务端的数据格式修改;在GetResult.js文件中第7行: 21 |
22 | var request = {type:'GET', dataType:'jsonp', jsonp:'callback', success:onSuccess, error:onFail}
23 | {
25 | "current": {
26 | "awardTime": "2016-07-08 20:00:00",
27 | "periodDate": "2016070866",
28 | "awardNumbers": "1,2,3,4,5,6,7,8"
29 | },
30 | "next": {
31 | "awardTimeInterval": "3000",
32 | "awardTime": "2016-07-08 20:10:00",
33 | "periodDate": "2016070867"
34 | }
35 | }
36 | current:当前轮抽奖
38 |next:下一轮抽奖
45 |服务端数据请照此格式发送 53 | 54 | 55 |
56 |在未接入服务端数据的时候可以使用调试文件测试(debug.txt),其测试数据自己可以 58 | 在调试文件中修改,具体修改请参照上面的参数解释;在debug文件当中配置了 59 | 3次模拟数据--seq1、seq2、seq3;模拟数据分别将在一定的间隔时间内触发,其控制 60 | 由游戏内代码控制,请查看GameController.js文件的reloadData()方法: 61 |
62 |function reloadData()
63 | {
64 | if (debugData)
65 | {
66 | date = new Date();
67 | appRunTime = (date.getTime() - appStartTime) / 1000;
68 | if (appRunTime < 10)
69 | {
70 | getResult.data = debugData.seq1;
71 | }
72 | else if(appRunTime < 30)
73 | {
74 | getResult.data = debugData.seq2;
75 | if (! debugData.seq3){excuteAll = true;}
76 | }
77 | else if( appRunTime < 90)
78 | {
79 | getResult.data = debugData.seq3;
80 | if (! debugData.seq4){excuteAll = true;}
81 | }
82 | onNewData(null)
83 | }
84 | else
85 | {
86 | getResult.loadData()
87 | }
88 | }
89 | 自己可以修改上面赋值数据的时间间隔;但不宜修改过小,应为模拟赛马的过程需要一定的时间, 99 | 这个时间不宜小于模拟时间,请设置在30s以上 100 | 101 |
102 |