[COCOS2D-HTML5 Development 2] cocos2d-html5 project definition members, local variables, function notes

Source: Internet
Author: User

This article describes how to use JavaScript syntax in the cocos2d-html5 engine. As for the js basics and more in-depth syntax, Please study it on your own!


1. First, we will introduce how to define functions in the following format:

1234 //Function Definitionfunction_test:function(pro1,pro2){},

Definition form: method name colon function (parameter ...) {... },

Note that:

1. When defining a function, the final ending symbol ",", in the form of a comma!

2. To call a function, put it in the declarative function body!

2. Local variables, definition and use of member variables

12345678910111213141516171819 var Helloworld =cc.Layer.extend({ //Member variablesint_prog:10,int_array:[],str_prog:"hello",enum_prog:{tag1:10,tag2:20},//Function Definitionfunction_test:function(pro1,pro2){this.init_prog =20;//Local variablevar int_prog_jb ="Local functions";//Print windowalert(this.init_prog);},});

Definition form of member variables: variable name colon initialization,

Note:

1. Define the member variables with the same comma.

2. Use this to access all member variables.

The definition of local variables is simple. (Note that the semicolon ends ";")


Alert ("content"); The content is displayed in a pop-up window.


This article is from the "Li huaming Himi" blog, please be sure to keep this source http://xiaominghimi.blog.51cto.com/2614927/1284387

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.