Cocos2d-js controls common creation methods and coordinate conversion list

Source: Internet
Author: User

Cocos2d-js controls common creation methods and coordinate conversion list
Genie

var sprite = new cc.Sprite(res.);sprite.setPosition(, );this.addChild(sprite);


Text tag
var label = new cc.LabelTTF("", "", 30);label.x = ;label.y = ;this.addChild(label);

 

 

Numeric tag
var atlas = new cc.LabelAtlas("", res., , , "");atlas.x = ;atlas.y = ;this.addChild(atlas);


Image menu items
var item = new cc.MenuItemImage(res.,        res.,        this.menuItemCallback,        this);item.x = ;item.y = ;menuItemCallback:function(sender){cc.log("menuItemStartCallback")},


Menu
var menu = new cc.Menu(item);menu.x = ;menu.y = ;this.addChild(menu);


Coordinate Conversion
{Cc. Point} convertToNodeSpace (worldPoint); // convert the world coordinates to the model coordinates. {Cc. Point} convertToNodeSpaceAR (worldPoint); // convert the world coordinates to the model coordinates. AR indicates relative to the anchor. {Cc. Point} convertTouchToNodeSpace (touch); // converts a touch Point from a world coordinate to a model coordinate. {Cc. Point} convertTouchToNodeSpaceAR (touch); // converts a touch Point from a world coordinate to a model coordinate. AR indicates relative to the anchor. {Cc. Point} convertToWorldSpace (nodePoint); // convert the model coordinates to the world coordinates. {Cc. Point} convertToWorldSpaceAR (nodePoint); // convert the model coordinates to the world coordinates. AR indicates relative to the anchor.


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.