(cocos2d-js game) test your response speed----------game optimization (bottom)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.