[Cocos2dx-js learning sharing 4], cocos2dx-js sharing

Source: Internet
Author: User

[Cocos2dx-js learning sharing 4], cocos2dx-js sharing

Create a menu word

 

Var startScene = cc. scene. extend ({// determine whether the game has started is_Start: false, // create the constructor: function () {// initialize the constructor in the parent class this. _ super (); // write a laebl menu // var label = new cc. labelTTF ("Start", "Arial", 36); var _ labelMenu = new cc. menuItemFont ("Start", function () {//}, this); var _ winSize = cc. winSize; // set the coordinates of the menu elements (including the actual coordinates and the anchor) _ labelMenu. attr ({// object dictionary x: _ winSize. width/2, y: _ winSize. height/2, anchorX: 0.5, anchorY: 0.5}); // var _ menu = new cc. menu (_ labelMenu); _ menu. x = 0; _ menu. y = 0; this. addChild (_ menu, 2 );},});

Create a menu word element:

Var _ labelMenu = new cc. MenuItemFont ("Start", function () {}, this );

// Set his position in the menu (an attr () method must be called to include an object dictionary in the method)

_ LabelMenu. attr ({

X: _ winSize. width/2,

Y: _ winSize. height/2

// You can also default the anchor.

 

 

});

 

Finally, set the menu position;

Var _ menu = new cc. Menu (_ labelMenu );

 

 


 

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.