The previous article will achieve the approximate logic, play a few of the following found a few shortcomings
1. Random number generation space is 1-10s, this range is a bit large, sometimes cause the wait time is too long or too short, so the generation of random number of space to adjust to 3-6s
Randomtime = Math.floor (Math.random () *3+1) +3;
2. Add animations on the Start Game page and end of game page to make the game more dynamic
This.startanim = cc. Sprite.create (S_clicktostartanim); this.startAnim.setPosition (THIS.SIZE.WIDTH/2,THIS.SIZE.HEIGHT/2); This.addchild (this.startanim,1); var action = cc. Sequence.create (CC. Fadeout.create (1.0), CC. Fadein.create (1.0));//Fade out first, then gradient appears var rep = cc. Repeatforever.create (action);//always cycle the action this.startAnim.runAction (rep);
3. Add share, promote the game
A. Import the class weixinapi.js of the shared interface (this can be found online)
B. Add in the game End Function:
<span style= "FONT-SIZE:24PX;" >document.title = Window.wxData.desc = "My reaction speed is" +time+ "ms! Come and try yours! ";</span>
c. In the index.html:
<script type= "Text/javascript" > //Shared data Window.wxdata = { "appId": "", "Imgurl": "", "link": ' http://iloveyoulhx.sinaapp.com/ReactionTime/', "desc": "Measure your reaction speed, come and try it", " title": "Test reaction speed"};function Share (Result) {}; Weixinapi.ready (function (API) { //share callback var wxcallbacks = { ready:function () { }, cancel: function (RESP) { }, fail:function (resp) {}, confirm:function (resp) { }, all : function (RESP) { } }; Api.sharetofriend (Wxdata, wxcallbacks); Api.sharetotimeline (Wxdata, wxcallbacks); Api.sharetoweibo (Wxdata, wxcallbacks);}); </script>
Effect:
Demo Address: Http://iloveyoulhx.sinaapp.com/ReactionTime
Source Address: Https://github.com/iloster/ReactionTime
(cocos2d-js game) test your response speed----------game optimization (bottom)