JavaScript Intensive Tutorial--COCOSJS scene switch

Source: Internet
Author: User


Scene switch in Main.js, the Startscene as our init run scene, the code is as follows:     CC. Loaderscene.preload (g_resources, function  ()  {         Cc.director.runScene (New playscene ());     }, this); Add the scene switch code to the response function of the Start menu button in Startscene. Click the Start button to toggle the scene into our playscene. The code is as follows:     VAR STARTITEM = NEW CC. Menuitemimage (            res. Start_n_png,            res. start_s_png,            function  ()  {                 cc.log ("menu  is clicked! ");                  Cc.director.replaceScene ( CC. Transitionpageturn (1, new playscene (),  false)  );             }, this); Cc.director is used to get the director Singleton entity, Cc.transitionpageturn creates a scene toggle animation of the page-flipping effect, and of course you can not use transition animations. Direct incoming new secondscene (). The effect of transition jumps is achieved by Transitionscene series classes between scenes in Cocos2d-js. Transitionscene inherits from scene, which is primarily a class of usage related to scene switching effects. such as Transitionfadedown, Transitionpageturn, Transitionjumpzoom and so on. Note: Transition animations require careful browser compatibility. such as page flipping effect is not supported on the browser

This article ish5eduAgency officialHTML5 Trainingtutorials, the main introduction:JavaScript Intensive Tutorials--cocosjs Scene Switching
 

JavaScript Intensive Tutorial--COCOSJS scene switch

Related Article

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.