《cocos2d-js教學(xué)》javascript_quicksta_第1頁
《cocos2d-js教學(xué)》javascript_quicksta_第2頁
《cocos2d-js教學(xué)》javascript_quicksta_第3頁
《cocos2d-js教學(xué)》javascript_quicksta_第4頁
《cocos2d-js教學(xué)》javascript_quicksta_第5頁
已閱讀5頁,還剩43頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、JAVASCRIPT QUICKSTARTJIANYUN BAO,SENIOR TECHNICAL EVANGELIST, CHUKONGTHE TECHNOLOGY OF MOBILE GAME DEVELOPMENTWhat is JavaScript ?WHAT IS JAVASCRIPT http:/ IS JAVASCRIPT WHAT IS JAVASCRIPT a cross-platform, object-oriented scripting language01inside a host environment (eg. a web browser)03variable d

2、ata types are not declared (dynamic typing)02Why is JavaScript?WHY IS JAVASCRIPT Functional Programming01Simpler code, rapider development 02Close to natural language, easy to understand03Code management easier04Concurrent programming easier 05Code hot updatehttphttpWHY IS JAVASCRIPT Fullstack javas

3、cript framework for web application developmentWHY IS JAVASCRIPT httpJavaScript basic knowledgeDATA TYPE AND VARIABLESDEFINITIONExplicit use var for assignmentImplicit direct assignmentDATA TYPE AND VARIABLESTYPE CONVERSION subtraction (string number) + addition string joint / numbertoString() boole

4、an / number stringDATA TYPE AND VARIABLESTYPE CONVERSIONparseInt() string integerparseFloat() string float non number string NaNDATA TYPE AND VARIABLESVARIABLEScoverage Local override GlobalBASIC DATA TYPEnumber integer / floatboolean true / falsestring must use or “”undefined created but not initia

5、lized variablesnull variables have not dataCOMPOUND TYPESObject object-orientedArray or OBJECTS or new Array()Functiondefinition function functionName(param, ) call functionName(param, );typeof check data typeCOMPOUND TYPESOPERATOR!= / = check value!= / = check value and data type5 = “5” is true (Au

6、tomatic type conversion)null = undefined is true null = undefined is false , (comma) allow Expression place togerther, finally return the rightest value finally a s value is 13OPERATORinstanceof check the variable whether a instance of some data type refer to typeofOPERATORblocks need but dont need

7、; finallySTATEMENTtry catch exception catchingSTATEMENTwith avoid writing object repeatlySTATEMENTIf else if else two branchesFLOW CONTROLBRANCHswitch multi-brancheswhile / do while loop by expressionFLOW CONTROLLOOPfor loop in sectionFLOW CONTROLLOOPendless loop for in kind of foreach loop FLOW CON

8、TROLLOOPtraverse all elements in the array traverse all attributes of JavaScript object continue stop current loop FLOW CONTROLLOOPbreak stop whole loop stop external loop (name: looper) FUNCTIONDEFINITIONNotice do not need declare return type do not need declare parameter type name function FUNCTIO

9、NDEFINITIONanonymous function FUNCTIONDEFINITIONFunction class anonymous function FUNCTIONDEFINITIONthe number of parameters in constructor is unlimited allow a series of string parameters, and the last one is the executive of the function, the statements are separated by “;” (semicolon)Function cla

10、ss anonymous function FUNCTIONDEFINITIONwhen define a function in JavaScript FUNCTIONFUNCTION, OBJECT, METHOD AND CLASSfunction directly call like Java method object also create a object (Function) method append some object as method class also get a Class, has the same name of the functionFUNCTIONC

11、ALLdirect call usually get the last return value non return, get null use new call return this JavaScript objectFUNCTIONTHISthis instance attribute FUNCTIONATTRIBUTElocal variable use var or not declare variable in the functioninstance attribute this prefixclass attribute function name prefixFUNCTIO

12、NCALL METHODdirect call method xxx.foo(para);use call() dynamically call with all parametersuse apply() dynamically call with arguments (array)PARAMETERTYPEempty parameter input as undefined“Duck Type” check type, attribute, method first USE OBJECTOBJECT-ORIENTEDnotice the definition of function doe

13、s not support inheritance syntax inheritance mechanism is not perfectUSE OBJECTOBJECT AND LINKED DATAnotice the object of JavaScript is linked data like Map in Java, “key-value” USE OBJECTINHERITANCE AND PROTOTYPEnotice use “prototype” as pseudo inheritancemechanismevery class has prototype attributewhen extend function and attribute to prototype, as extend the originalclassCocos2d-JS v2.x use thisCREATE OBJECTuse new create CREATE OBJECTuse object create create null object, add function and attribute CREATE OBJECTuse JSON synta

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論