Cocos2d-javascript trial note

Source: Internet
Author: User


In the past few days, I have sorted out the 6th EXAMPLES OF THE Zhiyi tutorial,CodeBasically, text is quite difficult. I always think that some of the points are too long-winded, but the meaning is not very clear. So I am thinking about making some dynamic effects on the page. It seems quite troublesome to do GIF animation, and it is easy to be distorted. Use flash. It seems that some browsers cannot see flash, right. Recently HTML5 seems to be quite popular. It is difficult for me to operate canvas and use JavaScript from the very beginning.


Blackbox exporter

Suddenly think of cocos2d there is a web version called cocos2d-javascript, blackbox exporter tcp  if most of the Operation library functions are done,prometheus blackbox exporter  a hundred lines of call is still difficult to me.



Download,blackbox exporter modules  install, and read the tutorial.



According to the first "Creating a New Project", named, as described in the tutorial, a directory selection box pops up, and I created a directory named "cocos2d-javascript.


Blackbox exporter docker

Run "Serve Project. lnk" and open the browser to access "http: // localhost: 4000 /".



Then I saw a big line of "cocos2d JavaScript", followed by a black box with resentment.



Wait for a moment to see it again:



Blackbox exporter tcp example



This time I am sure it is not loading resources.



After reading the script, I finally found the root cause of the problem.


 1   //  Import the cocos2d Module  2  VaR Cocos = require ('cocos2d' ),  3   //  Import the geometry Module  4 GEO = require ('ry ry' );  5   6   //  Create a new layer  7   VaR Cocos2d-javascript = Cocos. nodes. layer. Extend ({  8 Init: Function  (){  9   //  You must always call the super class version of init  10 Cocos2d-javascript.superclass.init.call ( This  );  11   12   //  Get size of canvas  13   VaR S = Cocos. Director. Get ('sharedctor ctor '). Get ('winsize');  14   15   //  Create label  16   VaR Label = Cocos. nodes. Label. Create ({string: 'cocos2d JavaScript ', fontname: 'arial', fontsize: 76 });  17   18   //  Add label to Layer  19   This . Addchild ({Child: Label, Z: 1 }); 20   21   //  Position the label in the center of the View  22 Label. Set ('position', Geo. CCP (S. width/2, S. Height/2 ));  23   }  24   });  25   26 Exports. Main = Function  (){  27  //  Initialise Application  28   29   //  Get director  30   VaR Director = Cocos. Director. Get ('sharedctor ctor' );  31   32   //  Attach director to our <div> element  33 Director. attachinview (document. getelementbyid ('cocos2d _ javascript_app'));  34   35   //  Create a scene  36   VaR Scene = Cocos. nodes. Scene. Create ();  37   38   //  Add our layer to the scene  39 Scene. addchild ({Child: cocos2d- Javascript. Create ()});  40  41   //  Run the scene  42   Director. runwithscene (scene );  43 };


Take note of the 7th rows.Create a projectProgramThe name of my folder is used as the variable name.



Honestly follow the tutorial to create the "Breakout" directory, and the world has finally restored peace...



In other words, cocos2d-html5 released the first version yesterday, hurry to try it, prepare for my next blog.



Cocos2d-html5 Alpha released.



Download link:
Http://cocos2d-x.googlecode.com/files/cocos2d-html5-v0.5.0-alpha.zip



Getting started with Cocos2d-html5


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.