COCOS2D-HTML5 OnEnter init ctor constructor----JS-specific features (a bit different from C + +)

Source: Internet
Author: User

ctor constructor, when new an object is called-----coco2d-js, the default ctor, is the constructor of the object, others can also default other functions as constructors.

To be blunt: ctor constructor new object is automatically called, Init in cocos2d-x is the static function create () method creates the object automatically call (because the cocos2d-x provided by the macro, will be automatically called), but JS inside, need to call manually.

The ctor constructor creates an object that differs from the method of passing the ctor function by calling Initialize init.
OnEnter is probably like this. For example, you have a reusable character sprite that addchild into the scene again without the need to call ctor creation, and you can initialize the variable character's properties in OnEnter.

COCOS2D-HTML5 OnEnter init ctor constructor----JS-specific features (a bit different from C + +)

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: 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.