Cocos2d JS to destroy the Stars (vii) dealing with stars--arranging stars

Source: Internet
Author: User

1 /*2 * This layer has an instantiation of star handling and manipulation of stars3  */4 varGamestarlayout =Ccui. Layout.extend (5 {6SizeNULL,7Stararr:[],//The star resource that holds the clicked and clicked State8Starobjarr:[],//two-bit array to store stars in the game9ctorfunction()Ten     { One          This. _super (); A          This. Zinit (); -          This. Layoutstar (); -     }, the     //The stars are arranged in 10*10 matrix. -Layoutstar:function() -     { -          for(vari = 0; I < 10; i++) +         { -              for(varj = 0; J < 10; J + +) +             { A                 //randomly select one of 5 different color stars at                 varRandomnumber = Math.floor (Math.random () * This. stararr.length); -                 varStarresource = This. Stararr[randomnumber]; -                 varStat {NewGamecreatestar (Starresource.normal, starresource.id,starresource.selected); -                  This. AddChild (Star, 0); -                 //The animated stars appear -                 varMoveTo = Cc.moveto (I/10, CC.P (Star.width*i, star.height*j)); in star.runaction (moveTo); -                 //Put the stars in the array to                  This. starobjarr[i][j] =Star; +             } -         } the     }, *     //Initialize $Zinit:function()Panax Notoginseng     { -          This. Size = Cc.size (480, 500); the         //to set the size of a layer +          This. SetSize ( This. Size); A         //storing star resources in numbers the          This. Stararr = [ +{id:1, Normal:res.star1, Selected:res.star1s}, -{Id:2, Normal:res.star2, selected:res.star2s}, ${Id:3, Normal:res.star3, selected:res.star3s}, ${Id:4, NORMAL:RES.STAR4, selected:res.star4s}, -{Id:5, NORMAL:RES.STAR5, selected:res.star5s} -                         ];
Wu } - }); About //instantiation of $Gamestarlayout.createlayout =function() - { - varStarlayout =Newgamestarlayout (); - returnstarlayout; A};
/********************************effect image**********************************/

Cocos2d JS to destroy the Stars (vii) dealing with stars--arranging stars

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.