creator.d.ts 435 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143
  1. /** !#en
  2. The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace.
  3. !#zh
  4. Cocos 引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。 */
  5. declare module cc {
  6. /** !#en Init Debug setting.
  7. !#zh 设置调试模式。
  8. */
  9. export function _initDebugSetting(mode : DebugMode) : void;
  10. /** !#en
  11. Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).<br/>
  12. - In Cocos Creator, error is red.<br/>
  13. - In Chrome, error have a red icon along with red message text.<br/>
  14. !#zh
  15. 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。<br/>
  16. - 在 Cocos Creator 中,错误信息显示是红色的。<br/>
  17. - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。<br/>
  18. @param obj A JavaScript string containing zero or more substitution strings.
  19. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  20. */
  21. export function error(obj : any, subst : any) : void;
  22. /** !#en
  23. Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime).
  24. - In Cocos Creator, warning is yellow.
  25. - In Chrome, warning have a yellow warning icon with the message text.
  26. !#zh
  27. 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。<br/>
  28. - 在 Cocos Creator 中,警告信息显示是黄色的。<br/>
  29. - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。<br/>
  30. @param obj A JavaScript string containing zero or more substitution strings.
  31. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  32. */
  33. export function warn(obj : any, subst : any) : void;
  34. /** !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime).
  35. !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
  36. @param obj A JavaScript string containing zero or more substitution strings.
  37. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  38. */
  39. export function log(obj : any, subst : any) : void;
  40. /** !#en
  41. Outputs an informational message to the Cocos Creator Console (editor) or Web Console (runtime).
  42. - In Cocos Creator, info is blue.
  43. - In Firefox and Chrome, a small "i" icon is displayed next to these items in the Web Console's log.
  44. !#zh
  45. 输出一条信息消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
  46. - 在 Cocos Creator 中,Info 信息显示是蓝色的。<br/>
  47. - 在 Firefox 和 Chrome 中,Info 信息有着小 “i” 图标。
  48. @param obj A JavaScript string containing zero or more substitution strings.
  49. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  50. */
  51. export function info(obj : any, subst : any) : void;
  52. /** !#en
  53. Creates the speed action which changes the speed of an action, making it take longer (speed > 1)
  54. or less (speed < 1) time. <br/>
  55. Useful to simulate 'slow motion' or 'fast forward' effect.
  56. !#zh 修改目标动作的速率。
  57. @example
  58. ```js
  59. // change the target action speed;
  60. var action = cc.scaleTo(0.2, 1, 0.6);
  61. var newAction = cc.speed(action, 0.5);
  62. ```
  63. */
  64. export function speed(action : ActionInterval, speed : number) : Action;
  65. /** !#en Create a follow action which makes its target follows another node.
  66. !#zh 追踪目标节点的位置。
  67. @example
  68. ```js
  69. // example
  70. // creates the action with a set boundary
  71. var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight));
  72. node.runAction(followAction);
  73. // creates the action with no boundary set
  74. var followAction = cc.follow(targetNode);
  75. node.runAction(followAction);
  76. ```
  77. */
  78. export function follow(followedNode : Node, rect : Rect) : Action;
  79. /** Points setter
  80. */
  81. export function setPoints(points : any[]) : void;
  82. /** !#en Creates an action with a Cardinal Spline array of points and tension.
  83. !#zh 按基数样条曲线轨迹移动到目标位置。
  84. @param points array of control points
  85. @example
  86. ```js
  87. //create a cc.CardinalSplineTo
  88. var action1 = cc.cardinalSplineTo(3, array, 0);
  89. ```
  90. */
  91. export function cardinalSplineTo(duration : number, points : any[], tension : number) : ActionInterval;
  92. /** update position of target
  93. */
  94. export function updatePosition(newPos : Vec2) : void;
  95. /** !#en Creates an action with a Cardinal Spline array of points and tension.
  96. !#zh 按基数样条曲线轨迹移动指定的距离。
  97. */
  98. export function cardinalSplineBy(duration : number, points : any[], tension : number) : ActionInterval;
  99. /** !#en Creates an action with a Cardinal Spline array of points and tension.
  100. !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。
  101. @example
  102. ```js
  103. var action1 = cc.catmullRomTo(3, array);
  104. ```
  105. */
  106. export function catmullRomTo(dt : number, points : any[]) : ActionInterval;
  107. /** !#en Creates an action with a Cardinal Spline array of points and tension.
  108. !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。
  109. @example
  110. ```js
  111. var action1 = cc.catmullRomBy(3, array);
  112. ```
  113. */
  114. export function catmullRomBy(dt : number, points : any[]) : ActionInterval;
  115. /** !#en
  116. Creates the action easing object with the rate parameter. <br />
  117. From slow to fast.
  118. !#zh 创建 easeIn 缓动对象,由慢到快。
  119. @example
  120. ```js
  121. // example
  122. action.easing(cc.easeIn(3.0));
  123. ```
  124. */
  125. export function easeIn(rate : number) : any;
  126. /** !#en
  127. Creates the action easing object with the rate parameter. <br />
  128. From fast to slow.
  129. !#zh 创建 easeOut 缓动对象,由快到慢。
  130. @example
  131. ```js
  132. // example
  133. action.easing(cc.easeOut(3.0));
  134. ```
  135. */
  136. export function easeOut(rate : number) : any;
  137. /** !#en
  138. Creates the action easing object with the rate parameter. <br />
  139. Slow to fast then to slow.
  140. !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。
  141. @example
  142. ```js
  143. //The new usage
  144. action.easing(cc.easeInOut(3.0));
  145. ```
  146. */
  147. export function easeInOut(rate : number) : any;
  148. /** !#en
  149. Creates the action easing object with the rate parameter. <br />
  150. Reference easeInExpo: <br />
  151. http://www.zhihu.com/question/21981571/answer/19925418
  152. !#zh
  153. 创建 easeExponentialIn 缓动对象。<br />
  154. EaseExponentialIn 是按指数函数缓动进入的动作。<br />
  155. 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418
  156. @example
  157. ```js
  158. // example
  159. action.easing(cc.easeExponentialIn());
  160. ```
  161. */
  162. export function easeExponentialIn() : any;
  163. /** !#en
  164. Creates the action easing object. <br />
  165. Reference easeOutExpo: <br />
  166. http://www.zhihu.com/question/21981571/answer/19925418
  167. !#zh
  168. 创建 easeExponentialOut 缓动对象。<br />
  169. EaseExponentialOut 是按指数函数缓动退出的动作。<br />
  170. 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
  171. @example
  172. ```js
  173. // example
  174. action.easing(cc.easeExponentialOut());
  175. ```
  176. */
  177. export function easeExponentialOut() : any;
  178. /** !#en
  179. Creates an EaseExponentialInOut action easing object. <br />
  180. Reference easeInOutExpo: <br />
  181. http://www.zhihu.com/question/21981571/answer/19925418
  182. !#zh
  183. 创建 easeExponentialInOut 缓动对象。<br />
  184. EaseExponentialInOut 是按指数函数缓动进入并退出的动作。<br />
  185. 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
  186. @example
  187. ```js
  188. // example
  189. action.easing(cc.easeExponentialInOut());
  190. ```
  191. */
  192. export function easeExponentialInOut() : any;
  193. /** !#en
  194. Creates an EaseSineIn action. <br />
  195. Reference easeInSine: <br />
  196. http://www.zhihu.com/question/21981571/answer/19925418
  197. !#zh
  198. 创建 EaseSineIn 缓动对象。<br />
  199. EaseSineIn 是按正弦函数缓动进入的动作。<br />
  200. 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418
  201. @example
  202. ```js
  203. // example
  204. action.easing(cc.easeSineIn());
  205. ```
  206. */
  207. export function easeSineIn() : any;
  208. /** !#en
  209. Creates an EaseSineOut action easing object. <br />
  210. Reference easeOutSine: <br />
  211. http://www.zhihu.com/question/21981571/answer/19925418
  212. !#zh
  213. 创建 EaseSineOut 缓动对象。<br />
  214. EaseSineIn 是按正弦函数缓动退出的动作。<br />
  215. 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418
  216. @example
  217. ```js
  218. // example
  219. action.easing(cc.easeSineOut());
  220. ```
  221. */
  222. export function easeSineOut() : any;
  223. /** !#en
  224. Creates the action easing object. <br />
  225. Reference easeInOutSine: <br />
  226. http://www.zhihu.com/question/21981571/answer/19925418
  227. !#zh
  228. 创建 easeSineInOut 缓动对象。<br />
  229. EaseSineIn 是按正弦函数缓动进入并退出的动作。<br />
  230. 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418
  231. @example
  232. ```js
  233. // example
  234. action.easing(cc.easeSineInOut());
  235. ```
  236. */
  237. export function easeSineInOut() : any;
  238. /** !#en
  239. Creates the action easing obejct with the period in radians (default is 0.3). <br />
  240. Reference easeInElastic: <br />
  241. http://www.zhihu.com/question/21981571/answer/19925418
  242. !#zh
  243. 创建 easeElasticIn 缓动对象。<br />
  244. EaseElasticIn 是按弹性曲线缓动进入的动作。<br />
  245. 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418
  246. @example
  247. ```js
  248. // example
  249. action.easing(cc.easeElasticIn(3.0));
  250. ```
  251. */
  252. export function easeElasticIn(period : number) : any;
  253. /** !#en
  254. Creates the action easing object with the period in radians (default is 0.3). <br />
  255. Reference easeOutElastic: <br />
  256. http://www.zhihu.com/question/21981571/answer/19925418
  257. !#zh
  258. 创建 easeElasticOut 缓动对象。<br />
  259. EaseElasticOut 是按弹性曲线缓动退出的动作。<br />
  260. 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
  261. @example
  262. ```js
  263. // example
  264. action.easing(cc.easeElasticOut(3.0));
  265. ```
  266. */
  267. export function easeElasticOut(period : number) : any;
  268. /** !#en
  269. Creates the action easing object with the period in radians (default is 0.3). <br />
  270. Reference easeInOutElastic: <br />
  271. http://www.zhihu.com/question/21981571/answer/19925418
  272. !#zh
  273. 创建 easeElasticInOut 缓动对象。<br />
  274. EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。<br />
  275. 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
  276. @example
  277. ```js
  278. // example
  279. action.easing(cc.easeElasticInOut(3.0));
  280. ```
  281. */
  282. export function easeElasticInOut(period : number) : any;
  283. /** !#en
  284. Creates the action easing object. <br />
  285. Eased bounce effect at the beginning.
  286. !#zh
  287. 创建 easeBounceIn 缓动对象。<br />
  288. EaseBounceIn 是按弹跳动作缓动进入的动作。
  289. @example
  290. ```js
  291. // example
  292. action.easing(cc.easeBounceIn());
  293. ```
  294. */
  295. export function easeBounceIn() : any;
  296. /** !#en
  297. Creates the action easing object. <br />
  298. Eased bounce effect at the ending.
  299. !#zh
  300. 创建 easeBounceOut 缓动对象。<br />
  301. EaseBounceOut 是按弹跳动作缓动退出的动作。
  302. @example
  303. ```js
  304. // example
  305. action.easing(cc.easeBounceOut());
  306. ```
  307. */
  308. export function easeBounceOut() : any;
  309. /** !#en
  310. Creates the action easing object. <br />
  311. Eased bounce effect at the begining and ending.
  312. !#zh
  313. 创建 easeBounceInOut 缓动对象。<br />
  314. EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。
  315. @example
  316. ```js
  317. // example
  318. action.easing(cc.easeBounceInOut());
  319. ```
  320. */
  321. export function easeBounceInOut() : any;
  322. /** !#en
  323. Creates the action easing object. <br />
  324. In the opposite direction to move slowly, and then accelerated to the right direction.
  325. !#zh
  326. 创建 easeBackIn 缓动对象。<br />
  327. easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。<br />
  328. @example
  329. ```js
  330. // example
  331. action.easing(cc.easeBackIn());
  332. ```
  333. */
  334. export function easeBackIn() : any;
  335. /** !#en
  336. Creates the action easing object. <br />
  337. Fast moving more than the finish, and then slowly back to the finish.
  338. !#zh
  339. 创建 easeBackOut 缓动对象。<br />
  340. easeBackOut 快速移动超出目标,然后慢慢回到目标点。
  341. @example
  342. ```js
  343. // example
  344. action.easing(cc.easeBackOut());
  345. ```
  346. */
  347. export function easeBackOut() : any;
  348. /** !#en
  349. Creates the action easing object. <br />
  350. Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.
  351. !#zh
  352. 创建 easeBackInOut 缓动对象。<br />
  353. @example
  354. ```js
  355. // example
  356. action.easing(cc.easeBackInOut());
  357. ```
  358. */
  359. export function easeBackInOut() : any;
  360. /** !#en
  361. Creates the action easing object. <br />
  362. Into the 4 reference point. <br />
  363. To calculate the motion curve.
  364. !#zh
  365. 创建 easeBezierAction 缓动对象。<br />
  366. EaseBezierAction 是按贝塞尔曲线缓动的动作。
  367. @param p0 The first bezier parameter
  368. @param p1 The second bezier parameter
  369. @param p2 The third bezier parameter
  370. @param p3 The fourth bezier parameter
  371. @example
  372. ```js
  373. // example
  374. action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
  375. ```
  376. */
  377. export function easeBezierAction(p0 : number, p1 : number, p2 : number, p3 : number) : any;
  378. /** !#en
  379. Creates the action easing object. <br />
  380. Reference easeInQuad: <br />
  381. http://www.zhihu.com/question/21981571/answer/19925418
  382. !#zh
  383. 创建 easeQuadraticActionIn 缓动对象。<br />
  384. EaseQuadraticIn是按二次函数缓动进入的动作。<br />
  385. 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418
  386. @example
  387. ```js
  388. //example
  389. action.easing(cc.easeQuadraticActionIn());
  390. ```
  391. */
  392. export function easeQuadraticActionIn() : any;
  393. /** !#en
  394. Creates the action easing object. <br />
  395. Reference easeOutQuad: <br />
  396. http://www.zhihu.com/question/21981571/answer/19925418
  397. !#zh
  398. 创建 easeQuadraticActionOut 缓动对象。<br />
  399. EaseQuadraticOut 是按二次函数缓动退出的动作。<br />
  400. 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
  401. @example
  402. ```js
  403. //example
  404. action.easing(cc.easeQuadraticActionOut());
  405. ```
  406. */
  407. export function easeQuadraticActionOut() : any;
  408. /** !#en
  409. Creates the action easing object. <br />
  410. Reference easeInOutQuad: <br />
  411. http://www.zhihu.com/question/21981571/answer/19925418
  412. !#zh
  413. 创建 easeQuadraticActionInOut 缓动对象。<br />
  414. EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。<br />
  415. 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
  416. @example
  417. ```js
  418. //example
  419. action.easing(cc.easeQuadraticActionInOut());
  420. ```
  421. */
  422. export function easeQuadraticActionInOut() : any;
  423. /** !#en
  424. Creates the action easing object. <br />
  425. Reference easeIntQuart: <br />
  426. http://www.zhihu.com/question/21981571/answer/19925418
  427. !#zh
  428. 创建 easeQuarticActionIn 缓动对象。<br />
  429. EaseQuarticIn 是按四次函数缓动进入的动作。<br />
  430. 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418
  431. @example
  432. ```js
  433. //example
  434. action.easing(cc.easeQuarticActionIn());
  435. ```
  436. */
  437. export function easeQuarticActionIn() : any;
  438. /** !#en
  439. Creates the action easing object. <br />
  440. Reference easeOutQuart: <br />
  441. http://www.zhihu.com/question/21981571/answer/19925418
  442. !#zh
  443. 创建 easeQuarticActionOut 缓动对象。<br />
  444. EaseQuarticOut 是按四次函数缓动退出的动作。<br />
  445. 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
  446. @example
  447. ```js
  448. //example
  449. action.easing(cc.QuarticActionOut());
  450. ```
  451. */
  452. export function easeQuarticActionOut() : any;
  453. /** !#en
  454. Creates the action easing object. <br />
  455. Reference easeInOutQuart: <br />
  456. http://www.zhihu.com/question/21981571/answer/19925418
  457. !#zh
  458. 创建 easeQuarticActionInOut 缓动对象。<br />
  459. EaseQuarticInOut 是按四次函数缓动进入并退出的动作。<br />
  460. 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
  461. */
  462. export function easeQuarticActionInOut() : any;
  463. /** !#en
  464. Creates the action easing object. <br />
  465. Reference easeInQuint: <br />
  466. http://www.zhihu.com/question/21981571/answer/19925418
  467. !#zh
  468. 创建 easeQuinticActionIn 缓动对象。<br />
  469. EaseQuinticIn 是按五次函数缓动进的动作。<br />
  470. 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418
  471. @example
  472. ```js
  473. //example
  474. action.easing(cc.easeQuinticActionIn());
  475. ```
  476. */
  477. export function easeQuinticActionIn() : any;
  478. /** !#en
  479. Creates the action easing object. <br />
  480. Reference easeOutQuint: <br />
  481. http://www.zhihu.com/question/21981571/answer/19925418
  482. !#zh
  483. 创建 easeQuinticActionOut 缓动对象。<br />
  484. EaseQuinticOut 是按五次函数缓动退出的动作
  485. 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
  486. @example
  487. ```js
  488. //example
  489. action.easing(cc.easeQuadraticActionOut());
  490. ```
  491. */
  492. export function easeQuinticActionOut() : any;
  493. /** !#en
  494. Creates the action easing object. <br />
  495. Reference easeInOutQuint: <br />
  496. http://www.zhihu.com/question/21981571/answer/19925418
  497. !#zh
  498. 创建 easeQuinticActionInOut 缓动对象。<br />
  499. EaseQuinticInOut是按五次函数缓动进入并退出的动作。<br />
  500. 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
  501. @example
  502. ```js
  503. //example
  504. action.easing(cc.easeQuinticActionInOut());
  505. ```
  506. */
  507. export function easeQuinticActionInOut() : any;
  508. /** !#en
  509. Creates the action easing object. <br />
  510. Reference easeInCirc: <br />
  511. http://www.zhihu.com/question/21981571/answer/19925418
  512. !#zh
  513. 创建 easeCircleActionIn 缓动对象。<br />
  514. EaseCircleIn是按圆形曲线缓动进入的动作。<br />
  515. 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418
  516. @example
  517. ```js
  518. //example
  519. action.easing(cc.easeCircleActionIn());
  520. ```
  521. */
  522. export function easeCircleActionIn() : any;
  523. /** !#en
  524. Creates the action easing object. <br />
  525. Reference easeOutCirc: <br />
  526. http://www.zhihu.com/question/21981571/answer/19925418
  527. !#zh
  528. 创建 easeCircleActionOut 缓动对象。<br />
  529. EaseCircleOut是按圆形曲线缓动退出的动作。<br />
  530. 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
  531. */
  532. export function easeCircleActionOut() : any;
  533. /** !#en
  534. Creates the action easing object. <br />
  535. Reference easeInOutCirc: <br />
  536. http://www.zhihu.com/question/21981571/answer/19925418
  537. !#zh
  538. 创建 easeCircleActionInOut 缓动对象。<br />
  539. EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。<br />
  540. 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
  541. @example
  542. ```js
  543. //example
  544. action.easing(cc.easeCircleActionInOut());
  545. ```
  546. */
  547. export function easeCircleActionInOut() : any;
  548. /** !#en
  549. Creates the action easing object. <br />
  550. Reference easeInCubic: <br />
  551. http://www.zhihu.com/question/21981571/answer/19925418
  552. !#zh
  553. 创建 easeCubicActionIn 缓动对象。<br />
  554. EaseCubicIn 是按三次函数缓动进入的动作。<br />
  555. 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418
  556. @example
  557. ```js
  558. //example
  559. action.easing(cc.easeCubicActionIn());
  560. ```
  561. */
  562. export function easeCubicActionIn() : any;
  563. /** !#en
  564. Creates the action easing object. <br />
  565. Reference easeOutCubic: <br />
  566. http://www.zhihu.com/question/21981571/answer/19925418
  567. !#zh
  568. 创建 easeCubicActionOut 缓动对象。<br />
  569. EaseCubicOut 是按三次函数缓动退出的动作。<br />
  570. 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
  571. @example
  572. ```js
  573. //example
  574. action.easing(cc.easeCubicActionOut());
  575. ```
  576. */
  577. export function easeCubicActionOut() : any;
  578. /** !#en
  579. Creates the action easing object. <br />
  580. Reference easeInOutCubic: <br />
  581. http://www.zhihu.com/question/21981571/answer/19925418
  582. !#zh
  583. 创建 easeCubicActionInOut 缓动对象。<br />
  584. EaseCubicInOut是按三次函数缓动进入并退出的动作。<br />
  585. 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
  586. */
  587. export function easeCubicActionInOut() : any;
  588. /** !#en Show the Node.
  589. !#zh 立即显示。
  590. @example
  591. ```js
  592. // example
  593. var showAction = cc.show();
  594. ```
  595. */
  596. export function show() : ActionInstant;
  597. /** !#en Hide the node.
  598. !#zh 立即隐藏。
  599. @example
  600. ```js
  601. // example
  602. var hideAction = cc.hide();
  603. ```
  604. */
  605. export function hide() : ActionInstant;
  606. /** !#en Toggles the visibility of a node.
  607. !#zh 显隐状态切换。
  608. @example
  609. ```js
  610. // example
  611. var toggleVisibilityAction = cc.toggleVisibility();
  612. ```
  613. */
  614. export function toggleVisibility() : ActionInstant;
  615. /** !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.
  616. !#zh 从父节点移除自身。
  617. @example
  618. ```js
  619. // example
  620. var removeSelfAction = cc.removeSelf();
  621. ```
  622. */
  623. export function removeSelf(isNeedCleanUp : boolean) : ActionInstant;
  624. /** !#en Create a FlipX action to flip or unflip the target.
  625. !#zh X轴翻转。
  626. @param flip Indicate whether the target should be flipped or not
  627. @example
  628. ```js
  629. var flipXAction = cc.flipX(true);
  630. ```
  631. */
  632. export function flipX(flip : boolean) : ActionInstant;
  633. /** !#en Create a FlipY action to flip or unflip the target.
  634. !#zh Y轴翻转。
  635. @example
  636. ```js
  637. var flipYAction = cc.flipY(true);
  638. ```
  639. */
  640. export function flipY(flip : boolean) : ActionInstant;
  641. /** !#en Creates a Place action with a position.
  642. !#zh 放置在目标位置。
  643. @example
  644. ```js
  645. // example
  646. var placeAction = cc.place(cc.v2(200, 200));
  647. var placeAction = cc.place(200, 200);
  648. ```
  649. */
  650. export function place(pos : Vec2|number, y? : number) : ActionInstant;
  651. /** !#en Creates the action with the callback.
  652. !#zh 执行回调函数。
  653. @param data data for function, it accepts all data types.
  654. @example
  655. ```js
  656. // example
  657. // CallFunc without data
  658. var finish = cc.callFunc(this.removeSprite, this);
  659. // CallFunc with data
  660. var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true);
  661. ```
  662. */
  663. export function callFunc(selector : Function, selectorTarget? : any|void, data? : any|void) : ActionInstant;
  664. /** !#en
  665. Helper constructor to create an array of sequenceable actions
  666. The created action will run actions sequentially, one after another.
  667. !#zh 顺序执行动作,创建的动作将按顺序依次运行。
  668. @example
  669. ```js
  670. // example
  671. // create sequence with actions
  672. var seq = cc.sequence(act1, act2);
  673. // create sequence with array
  674. var seq = cc.sequence(actArray);
  675. ```
  676. */
  677. export function sequence(tempArray : any[]|FiniteTimeAction) : ActionInterval;
  678. /** !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30)
  679. !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。
  680. @example
  681. ```js
  682. // example
  683. var rep = cc.repeat(cc.sequence(jump2, jump1), 5);
  684. ```
  685. */
  686. export function repeat(action : FiniteTimeAction, times : number) : ActionInterval;
  687. /** !#en Create a acton which repeat forever
  688. !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作。
  689. @example
  690. ```js
  691. // example
  692. var repeat = cc.repeatForever(cc.rotateBy(1.0, 360));
  693. ```
  694. */
  695. export function repeatForever(action : FiniteTimeAction) : ActionInterval;
  696. /** !#en Create a spawn action which runs several actions in parallel.
  697. !#zh 同步执行动作,同步执行一组动作。
  698. @example
  699. ```js
  700. // example
  701. var action = cc.spawn(cc.jumpBy(2, cc.v2(300, 0), 50, 4), cc.rotateBy(2, 720));
  702. todo:It should be the direct use new
  703. ```
  704. */
  705. export function spawn(tempArray : any[]|FiniteTimeAction) : FiniteTimeAction;
  706. /** !#en
  707. Rotates a Node object to a certain angle by modifying its rotation property. <br/>
  708. The direction will be decided by the shortest angle.
  709. !#zh 旋转到目标角度,通过逐帧修改它的 rotation 属性,旋转方向将由最短的角度决定。
  710. @param duration duration in seconds
  711. @param deltaAngleX deltaAngleX in degrees.
  712. @param deltaAngleY deltaAngleY in degrees.
  713. @example
  714. ```js
  715. // example
  716. var rotateTo = cc.rotateTo(2, 61.0);
  717. ```
  718. */
  719. export function rotateTo(duration : number, deltaAngleX : number, deltaAngleY? : number) : ActionInterval;
  720. /** !#en
  721. Rotates a Node object clockwise a number of degrees by modifying its rotation property.
  722. Relative to its properties to modify.
  723. !#zh 旋转指定的角度。
  724. @param duration duration in seconds
  725. @param deltaAngleX deltaAngleX in degrees
  726. @param deltaAngleY deltaAngleY in degrees
  727. @example
  728. ```js
  729. // example
  730. var actionBy = cc.rotateBy(2, 360);
  731. ```
  732. */
  733. export function rotateBy(duration : number, deltaAngleX : number, deltaAngleY? : number) : ActionInterval;
  734. /** !#en
  735. Moves a Node object x,y pixels by modifying its position property. <br/>
  736. x and y are relative to the position of the object. <br/>
  737. Several MoveBy actions can be concurrently called, and the resulting <br/>
  738. movement will be the sum of individual movements.
  739. !#zh 移动指定的距离。
  740. @param duration duration in seconds
  741. @example
  742. ```js
  743. // example
  744. var actionTo = cc.moveBy(2, cc.v2(windowSize.width - 40, windowSize.height - 40));
  745. ```
  746. */
  747. export function moveBy(duration : number, deltaPos : Vec2|number, deltaY : number) : ActionInterval;
  748. /** !#en
  749. Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property. <br/>
  750. Several MoveTo actions can be concurrently called, and the resulting <br/>
  751. movement will be the sum of individual movements.
  752. !#zh 移动到目标位置。
  753. @param duration duration in seconds
  754. @example
  755. ```js
  756. // example
  757. var actionBy = cc.moveTo(2, cc.v2(80, 80));
  758. ```
  759. */
  760. export function moveTo(duration : number, position : Vec2, y : number) : ActionInterval;
  761. /** !#en
  762. Create a action which skews a Node object to given angles by modifying its skewX and skewY properties.
  763. Changes to the specified value.
  764. !#zh 偏斜到目标角度。
  765. @param t time in seconds
  766. @example
  767. ```js
  768. // example
  769. var actionTo = cc.skewTo(2, 37.2, -37.2);
  770. ```
  771. */
  772. export function skewTo(t : number, sx : number, sy : number) : ActionInterval;
  773. /** !#en
  774. Skews a Node object by skewX and skewY degrees. <br />
  775. Relative to its property modification.
  776. !#zh 偏斜指定的角度。
  777. @param t time in seconds
  778. @param sx sx skew in degrees for X axis
  779. @param sy sy skew in degrees for Y axis
  780. @example
  781. ```js
  782. // example
  783. var actionBy = cc.skewBy(2, 0, -90);
  784. ```
  785. */
  786. export function skewBy(t : number, sx : number, sy : number) : ActionInterval;
  787. /** !#en
  788. Moves a Node object simulating a parabolic jump movement by modifying it's position property.
  789. Relative to its movement.
  790. !#zh 用跳跃的方式移动指定的距离。
  791. @example
  792. ```js
  793. // example
  794. var actionBy = cc.jumpBy(2, cc.v2(300, 0), 50, 4);
  795. var actionBy = cc.jumpBy(2, 300, 0, 50, 4);
  796. ```
  797. */
  798. export function jumpBy(duration : number, position : Vec2|number, y? : number, height : number, jumps : number) : ActionInterval;
  799. /** !#en
  800. Moves a Node object to a parabolic position simulating a jump movement by modifying its position property. <br />
  801. Jump to the specified location.
  802. !#zh 用跳跃的方式移动到目标位置。
  803. @example
  804. ```js
  805. // example
  806. var actionTo = cc.jumpTo(2, cc.v2(300, 300), 50, 4);
  807. var actionTo = cc.jumpTo(2, 300, 300, 50, 4);
  808. ```
  809. */
  810. export function jumpTo(duration : number, position : Vec2|number, y? : number, height : number, jumps : number) : ActionInterval;
  811. /** !#en
  812. An action that moves the target with a cubic Bezier curve by a certain distance.
  813. Relative to its movement.
  814. !#zh 按贝赛尔曲线轨迹移动指定的距离。
  815. @param t time in seconds
  816. @param c Array of points
  817. @example
  818. ```js
  819. // example
  820. var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)];
  821. var bezierForward = cc.bezierBy(3, bezier);
  822. ```
  823. */
  824. export function bezierBy(t : number, c : any[]) : ActionInterval;
  825. /** !#en An action that moves the target with a cubic Bezier curve to a destination point.
  826. !#zh 按贝赛尔曲线轨迹移动到目标位置。
  827. @param c array of points
  828. @example
  829. ```js
  830. // example
  831. var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)];
  832. var bezierTo = cc.bezierTo(2, bezier);
  833. ```
  834. */
  835. export function bezierTo(t : number, c : any[]) : ActionInterval;
  836. /** !#en Scales a Node object to a zoom factor by modifying it's scale property.
  837. !#zh 将节点大小缩放到指定的倍数。
  838. @param sx scale parameter in X
  839. @param sy scale parameter in Y, if Null equal to sx
  840. @example
  841. ```js
  842. // example
  843. // It scales to 0.5 in both X and Y.
  844. var actionTo = cc.scaleTo(2, 0.5);
  845. // It scales to 0.5 in x and 2 in Y
  846. var actionTo = cc.scaleTo(2, 0.5, 2);
  847. ```
  848. */
  849. export function scaleTo(duration : number, sx : number, sy? : number) : ActionInterval;
  850. /** !#en
  851. Scales a Node object a zoom factor by modifying it's scale property.
  852. Relative to its changes.
  853. !#zh 按指定的倍数缩放节点大小。
  854. @param duration duration in seconds
  855. @param sx sx scale parameter in X
  856. @param sy sy scale parameter in Y, if Null equal to sx
  857. @example
  858. ```js
  859. // example without sy, it scales by 2 both in X and Y
  860. var actionBy = cc.scaleBy(2, 2);
  861. //example with sy, it scales by 0.25 in X and 4.5 in Y
  862. var actionBy2 = cc.scaleBy(2, 0.25, 4.5);
  863. ```
  864. */
  865. export function scaleBy(duration : number, sx : number, sy? : number|void) : ActionInterval;
  866. /** !#en Blinks a Node object by modifying it's visible property.
  867. !#zh 闪烁(基于透明度)。
  868. @param duration duration in seconds
  869. @param blinks blinks in times
  870. @example
  871. ```js
  872. // example
  873. var action = cc.blink(2, 10);
  874. ```
  875. */
  876. export function blink(duration : number, blinks : number) : ActionInterval;
  877. /** !#en
  878. Fades an object that implements the cc.RGBAProtocol protocol.
  879. It modifies the opacity from the current value to a custom one.
  880. !#zh 修改透明度到指定值。
  881. @param opacity 0-255, 0 is transparent
  882. @example
  883. ```js
  884. // example
  885. var action = cc.fadeTo(1.0, 0);
  886. ```
  887. */
  888. export function fadeTo(duration : number, opacity : number) : ActionInterval;
  889. /** !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.
  890. !#zh 渐显效果。
  891. @param duration duration in seconds
  892. @example
  893. ```js
  894. //example
  895. var action = cc.fadeIn(1.0);
  896. ```
  897. */
  898. export function fadeIn(duration : number) : ActionInterval;
  899. /** !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0.
  900. !#zh 渐隐效果。
  901. @param d duration in seconds
  902. @example
  903. ```js
  904. // example
  905. var action = cc.fadeOut(1.0);
  906. ```
  907. */
  908. export function fadeOut(d : number) : ActionInterval;
  909. /** !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
  910. !#zh 修改颜色到指定值。
  911. @param red 0-255
  912. @param green 0-255
  913. @param blue 0-255
  914. @example
  915. ```js
  916. // example
  917. var action = cc.tintTo(2, 255, 0, 255);
  918. ```
  919. */
  920. export function tintTo(duration : number, red : number, green : number, blue : number) : ActionInterval;
  921. /** !#en
  922. Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
  923. Relative to their own color change.
  924. !#zh 按照指定的增量修改颜色。
  925. @param duration duration in seconds
  926. @example
  927. ```js
  928. // example
  929. var action = cc.tintBy(2, -127, -255, -127);
  930. ```
  931. */
  932. export function tintBy(duration : number, deltaRed : number, deltaGreen : number, deltaBlue : number) : ActionInterval;
  933. /** !#en Delays the action a certain amount of seconds.
  934. !#en 延迟指定的时间量。
  935. @param d duration in seconds
  936. @example
  937. ```js
  938. // example
  939. var delay = cc.delayTime(1);
  940. ```
  941. */
  942. export function delayTime(d : number) : ActionInterval;
  943. /** !#en Executes an action in reverse order, from time=duration to time=0.
  944. !#zh 反转目标动作的时间轴。
  945. @example
  946. ```js
  947. // example
  948. var reverse = cc.reverseTime(this);
  949. ```
  950. */
  951. export function reverseTime(action : FiniteTimeAction) : ActionInterval;
  952. /** !#en Create an action with the specified action and forced target.
  953. !#zh 用已有动作和一个新的目标节点创建动作。
  954. */
  955. export function targetedAction(target : Node, action : FiniteTimeAction) : ActionInterval;
  956. /** Constructor
  957. */
  958. export function HashElement() : void;
  959. /** !#en cc.view is the shared view object.
  960. !#zh cc.view 是全局的视图对象。 */
  961. export var view : View;
  962. /** !#en Director
  963. !#zh 导演类。 */
  964. export var director : Director;
  965. /** !#en cc.winSize is the alias object for the size of the current game window.
  966. !#zh cc.winSize 为当前的游戏窗口的大小。 */
  967. export var winSize : Size;
  968. export var game : Game;
  969. /** Checks whether subclass is child of superclass or equals to superclass
  970. */
  971. export function isChildClassOf(subclass : Function, superclass : Function) : boolean;
  972. /** !#en Defines a CCClass using the given specification, please see [Class](/en/scripting/class/) for details.
  973. !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/zh/scripting/class/)。
  974. @example
  975. ```js
  976. // define base class
  977. var Node = cc.Class();
  978. // define sub class
  979. var Sprite = cc.Class({
  980. name: 'Sprite',
  981. extends: Node,
  982. ctor: function () {
  983. this.url = "";
  984. this.id = 0;
  985. },
  986. properties {
  987. width: {
  988. default: 128,
  989. type: 'Integer',
  990. tooltip: 'The width of sprite'
  991. },
  992. height: 128,
  993. size: {
  994. get: function () {
  995. return cc.v2(this.width, this.height);
  996. }
  997. }
  998. },
  999. load: function () {
  1000. // load this.url
  1001. };
  1002. });
  1003. // instantiate
  1004. var obj = new Sprite();
  1005. obj.url = 'sprite.png';
  1006. obj.load();
  1007. // define static member
  1008. Sprite.count = 0;
  1009. Sprite.getBounds = function (spriteList) {
  1010. // ...
  1011. };
  1012. ```
  1013. */
  1014. export function Class(options : { name?; extends?; ctor?; properties?; statics?; mixins?; editor? : { requireComponent? : Component; disallowMultiple? : Component; menu? : string; executeInEditMode? : boolean; playOnFocus? : boolean; inspector? : string; icon? : string; help? : string; } ; update?; lateUpdate?; onLoad?; start?; onEnable?; onDisable?; onDestroy?; onFocusInEditor?; onLostFocusInEditor?; onRestore?; _getLocalBounds?; }) : Function;
  1015. /** Return all super classes
  1016. */
  1017. export function getInheritanceChain(constructor : Function) : Function[];
  1018. /** whether enable accelerometer event
  1019. */
  1020. export function setAccelerometerEnabled(isEnable : boolean) : void;
  1021. /** set accelerometer interval value
  1022. */
  1023. export function setAccelerometerInterval(interval : number) : void;
  1024. /** !#en Checks whether the object is non-nil and not yet destroyed.
  1025. !#zh 检查该对象是否不为 null 并且尚未销毁。
  1026. @example
  1027. ```js
  1028. cc.log(cc.isValid(target));
  1029. ```
  1030. */
  1031. export function isValid(value : any) : boolean;
  1032. /** Specify that the input value must be integer in Inspector.
  1033. Also used to indicates that the elements in array should be type integer. */
  1034. export var Integer : string;
  1035. /** Indicates that the elements in array should be type double. */
  1036. export var Float : string;
  1037. /** Indicates that the elements in array should be type boolean. */
  1038. export var Boolean : string;
  1039. /** Indicates that the elements in array should be type string. */
  1040. export var String : string;
  1041. /** !#en Deserialize json to cc.Asset
  1042. !#zh 将 JSON 反序列化为对象实例。
  1043. 当指定了 target 选项时,如果 target 引用的其它 asset 的 uuid 不变,则不会改变 target 对 asset 的引用,
  1044. 也不会将 uuid 保存到 result 对象中。
  1045. @param data the serialized cc.Asset json string or json object.
  1046. @param result additional loading result
  1047. */
  1048. export function deserialize(data : string|any, result? : Details, options? : any) : any;
  1049. /** !#en Clones the object original and returns the clone.
  1050. See [Clone exists Entity](/en/scripting/create-destroy-entities/#instantiate)
  1051. !#zh 复制给定的对象
  1052. 详细用法可参考[复制已有Entity](/zh/scripting/create-destroy-entities/#instantiate)
  1053. Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。
  1054. <del>对于 Entity / Component 等 Scene Object,如果对方也会被一起 Instantiate,则重定向到新的引用,否则保留为原来的引用。</del>
  1055. @param original An existing object that you want to make a copy of.
  1056. */
  1057. export function instantiate(original : any) : any;
  1058. /** Finds a node by hierarchy path, the path is case-sensitive.
  1059. It will traverse the hierarchy by splitting the path using '/' character.
  1060. This function will still returns the node even if it is inactive.
  1061. It is recommended to not use this function every frame instead cache the result at startup.
  1062. */
  1063. export function find(path : string, referenceNode? : Node) : Node;
  1064. /** !#en
  1065. The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}}
  1066. Alpha channel is optional. Default value is 255.
  1067. !#zh
  1068. 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。
  1069. Alpha 通道是可选的。默认值是 255。
  1070. @example
  1071. ```js
  1072. -----------------------
  1073. // 1. All channels seperately as parameters
  1074. var color1 = new cc.Color(255, 255, 255, 255);
  1075. // 2. Convert a hex string to a color
  1076. var color2 = new cc.Color("#000000");
  1077. // 3. An color object as parameter
  1078. var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255});
  1079. ```
  1080. */
  1081. export function color(r? : number, g? : number, b? : number, a? : number) : Color;
  1082. /** !#en returns true if both ccColor3B are equal. Otherwise it returns false.
  1083. !#zh 判断两个颜色对象的 RGB 部分是否相等,不比较透明度。
  1084. @example
  1085. ```js
  1086. cc.log(cc.colorEqual(cc.Color.RED, new cc.Color(255, 0, 0))); // true
  1087. ```
  1088. */
  1089. export function colorEqual(color1: (r: number, g: number, b: number, a: number) => void, color2: (r: number, g: number, b: number, a: number) => void) : boolean;
  1090. /** !#en
  1091. convert a string of color for style to Color.
  1092. e.g. "#ff06ff" to : cc.color(255,6,255)。
  1093. !#zh 16 进制转换为 Color
  1094. @example
  1095. ```js
  1096. cc.hexToColor("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
  1097. ```
  1098. */
  1099. export function hexToColor(hex : string) : Color;
  1100. /** !#en
  1101. convert Color to a string of color for style.
  1102. e.g. cc.color(255,6,255) to : "#ff06ff"
  1103. !#zh Color 转换为 16进制。
  1104. @example
  1105. ```js
  1106. var color = new cc.Color(255, 6, 255)
  1107. cc.colorToHex(color); // #ff06ff;
  1108. ```
  1109. */
  1110. export function colorToHex(color: (r: number, g: number, b: number, a: number) => void) : string;
  1111. /** !#en
  1112. Define an enum type. <br/>
  1113. If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.<br/>
  1114. Otherwise it will use the value specified by user who writes the enum definition.
  1115. !#zh
  1116. 定义一个枚举类型。<br/>
  1117. 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。
  1118. @param obj a JavaScript literal object containing enum names and values
  1119. @example
  1120. ```js
  1121. var WrapMode = cc.Enum({
  1122. Repeat: -1,
  1123. Clamp: -1
  1124. });
  1125. // Texture.WrapMode.Repeat == 0
  1126. // Texture.WrapMode.Clamp == 1
  1127. // Texture.WrapMode[0] == "Repeat"
  1128. // Texture.WrapMode[1] == "Clamp"
  1129. var FlagType = cc.Enum({
  1130. Flag1: 1,
  1131. Flag2: 2,
  1132. Flag3: 4,
  1133. Flag4: 8,
  1134. });
  1135. var AtlasSizeList = cc.Enum({
  1136. 128: 128,
  1137. 256: 256,
  1138. 512: 512,
  1139. 1024: 1024,
  1140. });
  1141. ```
  1142. */
  1143. export function Enum(obj : any) : any;
  1144. /** !#en Returns opposite of Vec2.
  1145. !#zh 返回相反的向量。
  1146. @example
  1147. ```js
  1148. cc.pNeg(cc.v2(10, 10));// Vec2 {x: -10, y: -10};
  1149. ```
  1150. */
  1151. export function pNeg(point : Vec2) : Vec2;
  1152. /** !#en Calculates sum of two points.
  1153. !#zh 返回两个向量的和。
  1154. @example
  1155. ```js
  1156. cc.pAdd(cc.v2(1, 1), cc.v2(2, 2));// Vec2 {x: 3, y: 3};
  1157. ```
  1158. */
  1159. export function pAdd(v1 : Vec2, v2 : Vec2) : Vec2;
  1160. /** !#en Calculates difference of two points.
  1161. !#zh 返回两个向量的差。
  1162. @example
  1163. ```js
  1164. cc.pSub(cc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 15, y: 15};
  1165. ```
  1166. */
  1167. export function pSub(v1 : Vec2, v2 : Vec2) : Vec2;
  1168. /** !#en Returns point multiplied by given factor.
  1169. !#zh 向量缩放。
  1170. @example
  1171. ```js
  1172. cc.pMult(cc.v2(5, 5), 4); // Vec2 {x: 20, y: 20};
  1173. ```
  1174. */
  1175. export function pMult(point : Vec2, floatVar : number) : Vec2;
  1176. /** !#en Calculates midpoint between two points.
  1177. !#zh 两个向量之间的中心点。
  1178. @example
  1179. ```js
  1180. cc.pMidpoint(cc.v2(10, 10), cc.v2(5, 5)); // Vec2 {x: 7.5, y: 7.5};
  1181. ```
  1182. */
  1183. export function pMidpoint(v1 : Vec2, v2 : Vec2) : Vec2;
  1184. /** !#en Calculates dot product of two points.
  1185. !#zh 两个向量之间进行点乘。
  1186. @example
  1187. ```js
  1188. cc.pDot(cc.v2(20, 20), cc.v2(5, 5)); // 200;
  1189. ```
  1190. */
  1191. export function pDot(v1 : Vec2, v2 : Vec2) : number;
  1192. /** !#en Calculates cross product of two points.
  1193. !#zh 两个向量之间进行叉乘。
  1194. @example
  1195. ```js
  1196. cc.pCross(cc.v2(20, 20), cc.v2(5, 5)); // 0;
  1197. ```
  1198. */
  1199. export function pCross(v1 : Vec2, v2 : Vec2) : number;
  1200. /** !#en Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) greater than 0.
  1201. !#zh 返回逆时针旋转 90 度后的新向量。
  1202. @example
  1203. ```js
  1204. cc.pPerp(cc.v2(20, 20)); // Vec2 {x: -20, y: 20};
  1205. ```
  1206. */
  1207. export function pPerp(point : Vec2) : Vec2;
  1208. /** !#en Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) smaller than 0.
  1209. !#zh 将指定向量顺时针旋转 90 度并返回。
  1210. @example
  1211. ```js
  1212. cc.pRPerp(cc.v2(20, 20)); // Vec2 {x: 20, y: -20};
  1213. ```
  1214. */
  1215. export function pRPerp(point : Vec2) : Vec2;
  1216. /** !#en Calculates the projection of v1 over v2.
  1217. !#zh 返回 v1 在 v2 上的投影向量。
  1218. @example
  1219. ```js
  1220. var v1 = cc.v2(20, 20);
  1221. var v2 = cc.v2(5, 5);
  1222. cc.pProject(v1, v2); // Vec2 {x: 20, y: 20};
  1223. ```
  1224. */
  1225. export function pProject(v1 : Vec2, v2 : Vec2) : Vec2;
  1226. /** !#en Calculates the square length of a cc.Vec2 (not calling sqrt() ).
  1227. !#zh 返回指定向量长度的平方。
  1228. @example
  1229. ```js
  1230. cc.pLengthSQ(cc.v2(20, 20)); // 800;
  1231. ```
  1232. */
  1233. export function pLengthSQ(v : Vec2) : number;
  1234. /** !#en Calculates the square distance between two points (not calling sqrt() ).
  1235. !#zh 返回两个点之间距离的平方。
  1236. @example
  1237. ```js
  1238. var point1 = cc.v2(20, 20);
  1239. var point2 = cc.v2(5, 5);
  1240. cc.pDistanceSQ(point1, point2); // 450;
  1241. ```
  1242. */
  1243. export function pDistanceSQ(point1 : Vec2, point2 : Vec2) : number;
  1244. /** !#en Calculates distance between point an origin.
  1245. !#zh 返回指定向量的长度.
  1246. @example
  1247. ```js
  1248. cc.pLength(cc.v2(20, 20)); // 28.284271247461902;
  1249. ```
  1250. */
  1251. export function pLength(v : Vec2) : number;
  1252. /** !#en Calculates the distance between two points.
  1253. !#zh 返回指定 2 个向量之间的距离。
  1254. @example
  1255. ```js
  1256. var v1 = cc.v2(20, 20);
  1257. var v2 = cc.v2(5, 5);
  1258. cc.pDistance(v1, v2); // 21.213203435596427;
  1259. ```
  1260. */
  1261. export function pDistance(v1 : Vec2, v2 : Vec2) : number;
  1262. /** !#en Returns this vector with a magnitude of 1.
  1263. !#zh 返回一个长度为 1 的标准化过后的向量。
  1264. @example
  1265. ```js
  1266. cc.pNormalize(cc.v2(20, 20)); // Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
  1267. ```
  1268. */
  1269. export function pNormalize(v : Vec2) : Vec2;
  1270. /** !#en Converts radians to a normalized vector.
  1271. !#zh 将弧度转换为一个标准化后的向量,返回坐标 x = cos(a) , y = sin(a)。
  1272. @example
  1273. ```js
  1274. cc.pForAngle(20); // Vec2 {x: 0.40808206181339196, y: 0.9129452507276277};
  1275. ```
  1276. */
  1277. export function pForAngle(a : number) : Vec2;
  1278. /** !#en Converts a vector to radians.
  1279. !#zh 返回指定向量的弧度。
  1280. @example
  1281. ```js
  1282. cc.pToAngle(cc.v2(20, 20)); // 0.7853981633974483;
  1283. ```
  1284. */
  1285. export function pToAngle(v : Vec2) : number;
  1286. /** !#en Clamp a value between from and to.
  1287. !#zh
  1288. 限定浮点数的最大最小值。<br/>
  1289. 数值大于 max_inclusive 则返回 max_inclusive。<br/>
  1290. 数值小于 min_inclusive 则返回 min_inclusive。<br/>
  1291. 否则返回自身。
  1292. @example
  1293. ```js
  1294. var v1 = cc.clampf(20, 0, 20); // 20;
  1295. var v2 = cc.clampf(-1, 0, 20); // 0;
  1296. var v3 = cc.clampf(10, 0, 20); // 10;
  1297. ```
  1298. */
  1299. export function clampf(value : number, min_inclusive : number, max_inclusive : number) : number;
  1300. /** !#en Clamp a value between 0 and 1.
  1301. !#zh 限定浮点数的取值范围为 0 ~ 1 之间。
  1302. @example
  1303. ```js
  1304. var v1 = cc.clampf(20); // 1;
  1305. var v2 = cc.clampf(-1); // 0;
  1306. var v3 = cc.clampf(0.5); // 0.5;
  1307. ```
  1308. */
  1309. export function clamp01(value : number) : number;
  1310. /** !#en Clamp a point between from and to.
  1311. !#zh
  1312. 返回指定限制区域后的向量。<br/>
  1313. 向量大于 max_inclusive 则返回 max_inclusive。<br/>
  1314. 向量小于 min_inclusive 则返回 min_inclusive。<br/>
  1315. 否则返回自身。
  1316. @example
  1317. ```js
  1318. var min_inclusive = cc.v2(0, 0);
  1319. var max_inclusive = cc.v2(20, 20);
  1320. var v1 = cc.pClamp(cc.v2(20, 20), min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20};
  1321. var v2 = cc.pClamp(cc.v2(0, 0), min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0};
  1322. var v3 = cc.pClamp(cc.v2(10, 10), min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10};
  1323. ```
  1324. */
  1325. export function pClamp(p : Vec2, min_inclusive : Vec2, max_inclusive : Vec2) : Vec2;
  1326. /** !#en Quickly convert cc.Size to a cc.Vec2.
  1327. !#zh 快速转换 cc.Size 为 cc.Vec2。
  1328. @example
  1329. ```js
  1330. cc.pFromSize(new cc.size(20, 20)); // Vec2 {x: 20, y: 20};
  1331. ```
  1332. */
  1333. export function pFromSize(s : Size) : Vec2;
  1334. /** !#en
  1335. Run a math operation function on each point component <br />
  1336. Math.abs, Math.fllor, Math.ceil, Math.round.
  1337. !#zh 通过运行指定的数学运算函数来计算指定的向量。
  1338. @example
  1339. ```js
  1340. cc.pCompOp(cc.v2(-10, -10), Math.abs); // Vec2 {x: 10, y: 10};
  1341. ```
  1342. */
  1343. export function pCompOp(p : Vec2, opFunc : Function) : Vec2;
  1344. /** !#en
  1345. Linear Interpolation between two points a and b.<br />
  1346. alpha == 0 ? a <br />
  1347. alpha == 1 ? b <br />
  1348. otherwise a value between a..b.
  1349. !#zh
  1350. 两个点 A 和 B 之间的线性插值。 <br />
  1351. alpha == 0 ? a <br />
  1352. alpha == 1 ? b <br />
  1353. 否则这个数值在 a ~ b 之间。
  1354. @example
  1355. ```js
  1356. cc.pLerp(cc.v2(20, 20), cc.v2(5, 5), 0.5); // Vec2 {x: 12.5, y: 12.5};
  1357. ```
  1358. */
  1359. export function pLerp(a : Vec2, b : Vec2, alpha : number) : Vec2;
  1360. /** !#en TODO
  1361. !#zh
  1362. 近似判断两个点是否相等。<br/>
  1363. 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。
  1364. @example
  1365. ```js
  1366. var a = cc.v2(20, 20);
  1367. var b = cc.v2(5, 5);
  1368. var b1 = cc.pFuzzyEqual(a, b, 10); // false;
  1369. var b2 = cc.pFuzzyEqual(a, b, 18); // true;
  1370. ```
  1371. */
  1372. export function pFuzzyEqual(a : Vec2, b : Vec2, variance : number) : boolean;
  1373. /** !#en Multiplies a nd b components, a.x*b.x, a.y*b.y.
  1374. !#zh 计算两个向量的每个分量的乘积, a.x * b.x, a.y * b.y。
  1375. @example
  1376. ```js
  1377. cc.pCompMult(acc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 100, y: 100};
  1378. ```
  1379. */
  1380. export function pCompMult(a : Vec2, b : Vec2) : Vec2;
  1381. /** !#en TODO
  1382. !#zh 返回两个向量之间带正负号的弧度。
  1383. */
  1384. export function pAngleSigned(a : Vec2, b : Vec2) : number;
  1385. /** !#en TODO
  1386. !#zh 获取当前向量与指定向量之间的弧度角。
  1387. */
  1388. export function pAngle(a : Vec2, b : Vec2) : number;
  1389. /** !#en Rotates a point counter clockwise by the angle around a pivot.
  1390. !#zh 返回给定向量围绕指定轴心顺时针旋转一定弧度后的结果。
  1391. @param v v is the point to rotate
  1392. @param pivot pivot is the pivot, naturally
  1393. @param angle angle is the angle of rotation cw in radians
  1394. */
  1395. export function pRotateByAngle(v : Vec2, pivot : Vec2, angle : number) : Vec2;
  1396. /** !#en
  1397. A general line-line intersection test
  1398. indicating successful intersection of a line<br />
  1399. note that to truly test intersection for segments we have to make<br />
  1400. sure that s & t lie within [0..1] and for rays, make sure s & t > 0<br />
  1401. the hit point is p3 + t * (p4 - p3);<br />
  1402. the hit point also is p1 + s * (p2 - p1);
  1403. !#zh
  1404. 返回 A 为起点 B 为终点线段 1 所在直线和 C 为起点 D 为终点线段 2 所在的直线是否相交,<br />
  1405. 如果相交返回 true,反之则为 false,参数 retP 是返回交点在线段 1、线段 2 上的比例。
  1406. @param A A is the startpoint for the first line P1 = (p1 - p2).
  1407. @param B B is the endpoint for the first line P1 = (p1 - p2).
  1408. @param C C is the startpoint for the second line P2 = (p3 - p4).
  1409. @param D D is the endpoint for the second line P2 = (p3 - p4).
  1410. @param retP retP.x is the range for a hitpoint in P1 (pa = p1 + s*(p2 - p1)), <br />
  1411. retP.y is the range for a hitpoint in P3 (pa = p2 + t*(p4 - p3)).
  1412. */
  1413. export function pLineIntersect(A : Vec2, B : Vec2, C : Vec2, D : Vec2, retP : Vec2) : boolean;
  1414. /** !#en ccpSegmentIntersect return YES if Segment A-B intersects with segment C-D.
  1415. !#zh 返回线段 A - B 和线段 C - D 是否相交。
  1416. */
  1417. export function pSegmentIntersect(A : Vec2, B : Vec2, C : Vec2, D : Vec2) : boolean;
  1418. /** !#en ccpIntersectPoint return the intersection point of line A-B, C-D.
  1419. !#zh 返回线段 A - B 和线段 C - D 的交点。
  1420. */
  1421. export function pIntersectPoint(A : Vec2, B : Vec2, C : Vec2, D : Vec2) : Vec2;
  1422. /** !#en check to see if both points are equal.
  1423. !#zh 检查指定的 2 个向量是否相等。
  1424. @param A A ccp a
  1425. @param B B ccp b to be compared
  1426. */
  1427. export function pSameAs(A : Vec2, B : Vec2) : boolean;
  1428. /** !#en sets the position of the point to 0.
  1429. !#zh 设置指定向量归 0。
  1430. */
  1431. export function pZeroIn(v : Vec2) : void;
  1432. /** !#en copies the position of one point to another.
  1433. !#zh 令 v1 向量等同于 v2。
  1434. */
  1435. export function pIn(v1 : Vec2, v2 : Vec2) : void;
  1436. /** !#en multiplies the point with the given factor (inplace).
  1437. !#zh 向量缩放,结果保存到第一个向量。
  1438. */
  1439. export function pMultIn(point : Vec2, floatVar : number) : void;
  1440. /** !#en subtracts one point from another (inplace).
  1441. !#zh 向量减法,结果保存到第一个向量。
  1442. */
  1443. export function pSubIn(v1 : Vec2, v2 : Vec2) : void;
  1444. /** !#en adds one point to another (inplace).
  1445. !#zh 向量加法,结果保存到第一个向量。
  1446. */
  1447. export function pAddIn(v1 : Vec2, v2 : Vec2) : void;
  1448. /** !#en normalizes the point (inplace).
  1449. !#zh 规范化 v 向量,设置 v 向量长度为 1。
  1450. */
  1451. export function pNormalizeIn(v : Vec2) : void;
  1452. /** !#en
  1453. The convenience method to create a new Rect.
  1454. see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
  1455. !#zh
  1456. 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
  1457. @example
  1458. ```js
  1459. var a = new cc.rect(0 , 0, 10, 0);
  1460. ```
  1461. */
  1462. export function rect(x? : Number[]|number, y? : number, w? : number, h? : number) : Rect;
  1463. /** !#en Check whether a rect's value equals to another.
  1464. !#zh 判断两个矩形是否相等。
  1465. @param rect1 !#en
  1466. Constructor of cc.Rect class.
  1467. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1468. !#zh
  1469. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1470. @param rect2 !#en
  1471. Constructor of cc.Rect class.
  1472. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1473. !#zh
  1474. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1475. @example
  1476. ```js
  1477. var a = new cc.rect(0, 0, 10, 10);
  1478. var b = new cc.rect(0, 0, 5, 5);
  1479. cc.rectEqualToRect(a, b); // false;
  1480. var c = new cc.rect(0, 0, 5, 5);
  1481. cc.rectEqualToRect(b, c); // true;
  1482. ```
  1483. */
  1484. export function rectEqualToRect(rect1: (x: number, y: number, w: number, h: number) => void, rect2: (x: number, y: number, w: number, h: number) => void) : boolean;
  1485. /** !#en Check whether the rect1 contains rect2.
  1486. !#zh
  1487. 检查 rect1 矩形是否包含 rect2 矩形。 <br/>
  1488. 注意:如果要允许 rect1 和 rect2 的边界重合,应该用 cc.rectOverlapsRect
  1489. @param rect1 !#en
  1490. Constructor of cc.Rect class.
  1491. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1492. !#zh
  1493. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1494. @param rect2 !#en
  1495. Constructor of cc.Rect class.
  1496. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1497. !#zh
  1498. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1499. @example
  1500. ```js
  1501. var a = new cc.rect(0, 0, 20, 20);
  1502. var b = new cc.rect(10, 10, 20, 20);
  1503. cc.rectContainsRect(a, b); // true;
  1504. ```
  1505. */
  1506. export function rectContainsRect(rect1: (x: number, y: number, w: number, h: number) => void, rect2: (x: number, y: number, w: number, h: number) => void) : boolean;
  1507. /** !#en Returns the rightmost x-value of a rect.
  1508. !#zh 返回矩形在 x 轴上的最大值
  1509. @param rect !#en
  1510. Constructor of cc.Rect class.
  1511. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1512. !#zh
  1513. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1514. @example
  1515. ```js
  1516. var a = new cc.rect(10, 0, 20, 20);
  1517. cc.rectGetMaxX(a); // 30;
  1518. ```
  1519. */
  1520. export function rectGetMaxX(rect: (x: number, y: number, w: number, h: number) => void) : number;
  1521. /** !#en Return the midpoint x-value of a rect.
  1522. !#zh 返回矩形在 x 轴上的中点。
  1523. @param rect !#en
  1524. Constructor of cc.Rect class.
  1525. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1526. !#zh
  1527. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1528. @example
  1529. ```js
  1530. var a = new cc.rect(10, 0, 20, 20);
  1531. cc.rectGetMidX(a); // 20;
  1532. ```
  1533. */
  1534. export function rectGetMidX(rect: (x: number, y: number, w: number, h: number) => void) : number;
  1535. /** !#en Returns the leftmost x-value of a rect.
  1536. !#zh 返回矩形在 x 轴上的最小值。
  1537. @param rect !#en
  1538. Constructor of cc.Rect class.
  1539. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1540. !#zh
  1541. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1542. @example
  1543. ```js
  1544. var a = new cc.rect(10, 0, 20, 20);
  1545. cc.rectGetMinX(a); // 10;
  1546. ```
  1547. */
  1548. export function rectGetMinX(rect: (x: number, y: number, w: number, h: number) => void) : number;
  1549. /** !#en Return the topmost y-value of a rect.
  1550. !#zh 返回矩形在 y 轴上的最大值。
  1551. @param rect !#en
  1552. Constructor of cc.Rect class.
  1553. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1554. !#zh
  1555. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1556. @example
  1557. ```js
  1558. var a = new cc.rect(0, 10, 20, 20);
  1559. cc.rectGetMaxY(a); // 30;
  1560. ```
  1561. */
  1562. export function rectGetMaxY(rect: (x: number, y: number, w: number, h: number) => void) : number;
  1563. /** !#en Return the midpoint y-value of `rect'.
  1564. !#zh 返回矩形在 y 轴上的中点。
  1565. @param rect !#en
  1566. Constructor of cc.Rect class.
  1567. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1568. !#zh
  1569. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1570. @example
  1571. ```js
  1572. var a = new cc.rect(0, 10, 20, 20);
  1573. cc.rectGetMidY(a); // 20;
  1574. ```
  1575. */
  1576. export function rectGetMidY(rect: (x: number, y: number, w: number, h: number) => void) : number;
  1577. /** !#en Return the bottommost y-value of a rect.
  1578. !#zh 返回矩形在 y 轴上的最小值。
  1579. @param rect !#en
  1580. Constructor of cc.Rect class.
  1581. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1582. !#zh
  1583. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1584. @example
  1585. ```js
  1586. var a = new cc.rect(0, 10, 20, 20);
  1587. cc.rectGetMinY(a); // 10;
  1588. ```
  1589. */
  1590. export function rectGetMinY(rect: (x: number, y: number, w: number, h: number) => void) : number;
  1591. /** !#en Check whether a rect contains a point.
  1592. !#zh 检查一个矩形是否包含某个坐标点。
  1593. @param rect !#en
  1594. Constructor of cc.Rect class.
  1595. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1596. !#zh
  1597. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1598. @example
  1599. ```js
  1600. var a = new cc.rect(0, 10, 20, 20);
  1601. var b = cc.v2(0, 10, 10, 10);
  1602. cc.rectContainsPoint(a, b); // true;
  1603. ```
  1604. */
  1605. export function rectContainsPoint(rect: (x: number, y: number, w: number, h: number) => void, point : Vec2) : boolean;
  1606. /** !#en Check whether a rect intersect with another.
  1607. !#zh 检查一个矩形是否与另一个相交。
  1608. @param rectA !#en
  1609. Constructor of cc.Rect class.
  1610. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1611. !#zh
  1612. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1613. @param rectB !#en
  1614. Constructor of cc.Rect class.
  1615. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1616. !#zh
  1617. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1618. @example
  1619. ```js
  1620. var a = new cc.rect(0, 10, 20, 20);
  1621. var b = new cc.rect(0, 10, 10, 10);
  1622. cc.rectIntersectsRect(a, b); // true;
  1623. ```
  1624. */
  1625. export function rectIntersectsRect(rectA: (x: number, y: number, w: number, h: number) => void, rectB: (x: number, y: number, w: number, h: number) => void) : boolean;
  1626. /** !#en Check whether a rect overlaps another.
  1627. !#zh 检查一个矩形是否重叠另一个。
  1628. @param rectA !#en
  1629. Constructor of cc.Rect class.
  1630. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1631. !#zh
  1632. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1633. @param rectB !#en
  1634. Constructor of cc.Rect class.
  1635. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1636. !#zh
  1637. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1638. @example
  1639. ```js
  1640. var a = new cc.rect(0, 10, 20, 20);
  1641. var b = new cc.rect(0, 10, 10, 10);
  1642. cc.rectOverlapsRect(a, b); // true;
  1643. ```
  1644. */
  1645. export function rectOverlapsRect(rectA: (x: number, y: number, w: number, h: number) => void, rectB: (x: number, y: number, w: number, h: number) => void) : boolean;
  1646. /** !#en Returns the smallest rectangle that contains the two source rectangles.
  1647. !#zh 返回一个包含两个指定矩形的最小矩形。
  1648. @param rectA !#en
  1649. Constructor of cc.Rect class.
  1650. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1651. !#zh
  1652. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1653. @param rectB !#en
  1654. Constructor of cc.Rect class.
  1655. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1656. !#zh
  1657. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1658. @example
  1659. ```js
  1660. var a = new cc.rect(0, 10, 20, 20);
  1661. var b = new cc.rect(0, 10, 10, 10);
  1662. cc.rectUnion(a, b); // Rect {x: 0, y: 10, width: 20, height: 20};
  1663. ```
  1664. */
  1665. export function rectUnion(rectA: (x: number, y: number, w: number, h: number) => void, rectB: (x: number, y: number, w: number, h: number) => void) : Rect;
  1666. /** !#en Returns the overlapping portion of 2 rectangles.
  1667. !#zh 返回 2 个矩形重叠的部分。
  1668. @param rectA !#en
  1669. Constructor of cc.Rect class.
  1670. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1671. !#zh
  1672. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1673. @param rectB !#en
  1674. Constructor of cc.Rect class.
  1675. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  1676. !#zh
  1677. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  1678. @example
  1679. ```js
  1680. var a = new cc.rect(0, 10, 20, 20);
  1681. var b = new cc.rect(0, 10, 10, 10);
  1682. cc.rectIntersection(a, b); // Rect {x: 0, y: 10, width: 10, height: 10};
  1683. ```
  1684. */
  1685. export function rectIntersection(rectA: (x: number, y: number, w: number, h: number) => void, rectB: (x: number, y: number, w: number, h: number) => void) : Rect;
  1686. export function V3F_C4B_T2F_QuadZero() : V3F_C4B_T2F_Quad;
  1687. /**
  1688. */
  1689. export function V3F_C4B_T2F_QuadCopy(sourceQuad: (tl: V3F_C4B_T2F, bl: V3F_C4B_T2F, tr: V3F_C4B_T2F, br: V3F_C4B_T2F, arrayBuffer: any[], offset: number) => void) : V3F_C4B_T2F_Quad;
  1690. /**
  1691. */
  1692. export function V3F_C4B_T2F_QuadsCopy(sourceQuads : any[]) : any[];
  1693. /** !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}.
  1694. !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。
  1695. @example
  1696. ```js
  1697. var v1 = cc.v2();
  1698. var v2 = cc.v2(0, 0);
  1699. var v3 = cc.v2(v2);
  1700. var v4 = cc.v2({x: 100, y: 100});
  1701. ```
  1702. */
  1703. export function v2(x? : number|any, y? : number) : Vec2;
  1704. /** !#en The convenience method to creates a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}.
  1705. !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。
  1706. @param x a Number or a size object
  1707. @example
  1708. ```js
  1709. var point1 = cc.v2();
  1710. var point2 = cc.v2(100, 100);
  1711. var point3 = cc.v2(point2);
  1712. var point4 = cc.v2({x: 100, y: 100});
  1713. ```
  1714. */
  1715. export function p(x? : number|any, y? : number) : Vec2;
  1716. /** !#en Check whether a point's value equals to another.
  1717. !#zh 判断两个向量是否相等。
  1718. @param point1 !#en
  1719. Constructor
  1720. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  1721. !#zh
  1722. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  1723. @param point2 !#en
  1724. Constructor
  1725. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  1726. !#zh
  1727. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  1728. */
  1729. export function pointEqualToPoint(point1: (x: number, y: number) => void, point2: (x: number, y: number) => void) : boolean;
  1730. /** !#en Enum for debug modes.
  1731. !#zh 调试模式 */
  1732. export enum DebugMode {
  1733. NONE = 0,
  1734. INFO = 0,
  1735. WARN = 0,
  1736. ERROR = 0,
  1737. INFO_FOR_WEB_PAGE = 0,
  1738. WARN_FOR_WEB_PAGE = 0,
  1739. ERROR_FOR_WEB_PAGE = 0,
  1740. }
  1741. /** !#en cc.audioEngine is the singleton object, it provide simple audio APIs.
  1742. !#zh
  1743. cc.audioengine是单例对象。<br/>
  1744. 主要用来播放背景音乐和音效,背景音乐同一时间只能播放一个,而音效则可以同时播放多个。<br/>
  1745. 注意:<br/>
  1746. 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。<br/>
  1747. 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,<br/>
  1748. 有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */
  1749. export class audioEngine {
  1750. /** !#en Play music.
  1751. !#zh
  1752. 播放指定音乐,并可以设置是否循环播放。<br/>
  1753. 注意:音乐播放接口不支持多音轨,同一时间只能播放一个音乐。
  1754. @param url The path of the music file without filename extension.
  1755. @param loop Whether the music loop or not.
  1756. @example
  1757. ```js
  1758. //example
  1759. cc.audioEngine.playMusic(path, false);
  1760. ```
  1761. */
  1762. playMusic(url : string, loop : boolean) : void;
  1763. /** !#en Stop playing music.
  1764. !#zh 停止当前音乐。
  1765. @param releaseData If release the music data or not.As default value is false.
  1766. @example
  1767. ```js
  1768. //example
  1769. cc.audioEngine.stopMusic();
  1770. ```
  1771. */
  1772. stopMusic(releaseData? : boolean) : void;
  1773. /** !#en Pause playing music.
  1774. !#zh 暂停正在播放音乐。
  1775. @example
  1776. ```js
  1777. //example
  1778. cc.audioEngine.pauseMusic();
  1779. ```
  1780. */
  1781. pauseMusic() : void;
  1782. /** !#en Resume playing music.
  1783. !#zh 恢复音乐播放。
  1784. @example
  1785. ```js
  1786. //example
  1787. cc.audioEngine.resumeMusic();
  1788. ```
  1789. */
  1790. resumeMusic() : void;
  1791. /** !#en Rewind playing music.
  1792. !#zh 从头开始重新播放当前音乐。
  1793. @example
  1794. ```js
  1795. //example
  1796. cc.audioEngine.rewindMusic();
  1797. ```
  1798. */
  1799. rewindMusic() : void;
  1800. /** !#en The volume of the music max value is 1.0,the min value is 0.0 .
  1801. !#zh 获取音量(0.0 ~ 1.0)。
  1802. @example
  1803. ```js
  1804. //example
  1805. var volume = cc.audioEngine.getMusicVolume();
  1806. ```
  1807. */
  1808. getMusicVolume() : number;
  1809. /** !#en Set the volume of music.
  1810. !#zh 设置音量(0.0 ~ 1.0)。
  1811. @param volume Volume must be in 0.0~1.0 .
  1812. @example
  1813. ```js
  1814. //example
  1815. cc.audioEngine.setMusicVolume(0.5);
  1816. ```
  1817. */
  1818. setMusicVolume(volume : number) : void;
  1819. /** !#en Whether the music is playing.
  1820. !#zh 音乐是否正在播放。
  1821. @example
  1822. ```js
  1823. //example
  1824. if (cc.audioEngine.isMusicPlaying()) {
  1825. cc.log("music is playing");
  1826. }
  1827. else {
  1828. cc.log("music is not playing");
  1829. }
  1830. ```
  1831. */
  1832. isMusicPlaying() : boolean;
  1833. /** !#en Play sound effect.
  1834. !#zh
  1835. 播放指定音效,并可以设置是否循环播放。<br/>
  1836. 注意:在部分不支持多音轨的浏览器上,这个接口会失效,请使用 playMusic
  1837. @param url The path of the sound effect with filename extension.
  1838. @param loop Whether to loop the effect playing, default value is false
  1839. @example
  1840. ```js
  1841. //example
  1842. var soundId = cc.audioEngine.playEffect(path);
  1843. ```
  1844. */
  1845. playEffect(url : string, loop : boolean, volume : boolean) : number;
  1846. /** !#en Set the volume of sound effects.
  1847. !#zh 设置音效音量(0.0 ~ 1.0)。
  1848. @param volume Volume must be in 0.0~1.0 .
  1849. @example
  1850. ```js
  1851. //example
  1852. cc.audioEngine.setEffectsVolume(0.5);
  1853. ```
  1854. */
  1855. setEffectsVolume(volume : number) : void;
  1856. /** !#en The volume of the effects max value is 1.0,the min value is 0.0 .
  1857. !#zh 获取音效音量(0.0 ~ 1.0)。
  1858. @example
  1859. ```js
  1860. //example
  1861. var effectVolume = cc.audioEngine.getEffectsVolume();
  1862. ```
  1863. */
  1864. getEffectsVolume() : number;
  1865. /** !#en Pause playing sound effect.
  1866. !#zh 暂停指定的音效。
  1867. @param audio The return value of function playEffect.
  1868. @example
  1869. ```js
  1870. //example
  1871. cc.audioEngine.pauseEffect(audioID);
  1872. ```
  1873. */
  1874. pauseEffect(audio : number) : void;
  1875. /** !#en Pause all playing sound effect.
  1876. !#zh 暂停现在正在播放的所有音效。
  1877. @example
  1878. ```js
  1879. //example
  1880. cc.audioEngine.pauseAllEffects();
  1881. ```
  1882. */
  1883. pauseAllEffects() : void;
  1884. /** !#en Resume playing sound effect.
  1885. !#zh 恢复播放指定的音效。
  1886. @param audioID The return value of function playEffect.
  1887. */
  1888. resumeEffect(audioID : number) : void;
  1889. /** !#en Resume all playing sound effect.
  1890. !#zh 恢复播放所有之前暂停的所有音效。
  1891. @example
  1892. ```js
  1893. //example
  1894. cc.audioEngine.resumeAllEffects();
  1895. ```
  1896. */
  1897. resumeAllEffects() : void;
  1898. /** !#en Stop playing sound effect.
  1899. !#zh 停止播放指定音效。
  1900. @param audioID The return value of function playEffect.
  1901. @example
  1902. ```js
  1903. //example
  1904. cc.audioEngine.stopEffect(audioID);
  1905. ```
  1906. */
  1907. stopEffect(audioID : number) : void;
  1908. /** !#en Stop all playing sound effects.
  1909. !#zh 停止正在播放的所有音效。
  1910. @example
  1911. ```js
  1912. //example
  1913. cc.audioEngine.stopAllEffects();
  1914. ```
  1915. */
  1916. stopAllEffects() : void;
  1917. /** !#en Unload the preloaded effect from internal buffer.
  1918. !#zh 卸载预加载的音效。
  1919. @example
  1920. ```js
  1921. //example
  1922. cc.audioEngine.unloadEffect(EFFECT_FILE);
  1923. ```
  1924. */
  1925. unloadEffect(url : string) : void;
  1926. /** !#en End music and effects.
  1927. !#zh 停止所有音乐和音效的播放。
  1928. */
  1929. end() : void;
  1930. }
  1931. /** !#en Class for animation data handling.
  1932. !#zh 动画剪辑,用于存储动画数据。 */
  1933. export class AnimationClip extends Asset {
  1934. constructor();
  1935. /** !#en Duration of this animation.
  1936. !#zh 动画的持续时间。 */
  1937. duration : number;
  1938. /** !#en FrameRate of this animation.
  1939. !#zh 动画的帧速率。 */
  1940. sample : number;
  1941. /** !#en Speed of this animation.
  1942. !#zh 动画的播放速度。 */
  1943. speed : number;
  1944. /** !#en WrapMode of this animation.
  1945. !#zh 动画的循环模式。 */
  1946. wrapMode : WrapMode;
  1947. /** !#en Curve data.
  1948. !#zh 曲线数据。 */
  1949. curveData : any;
  1950. /** !#en Event data.
  1951. !#zh 事件数据。 */
  1952. events : any[];
  1953. /** !#en Crate clip with a set of sprite frames
  1954. !#zh 使用一组序列帧图片来创建动画剪辑
  1955. @example
  1956. ```js
  1957. var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10);
  1958. ```
  1959. */
  1960. createWithSpriteFrames(spriteFrames : [SpriteFrame], sample : number) : AnimationClip;
  1961. }
  1962. /** !#en
  1963. The AnimationState gives full control over animation playback process.
  1964. In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control.
  1965. !#zh
  1966. AnimationState 完全控制动画播放过程。<br/>
  1967. 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */
  1968. export class AnimationState extends AnimationNode {
  1969. constructor();
  1970. /**
  1971. */
  1972. AnimationState(clip : AnimationClip, name? : string) : AnimationState;
  1973. /** !#en The clip that is being played by this animation state.
  1974. !#zh 此动画状态正在播放的剪辑。 */
  1975. clip : AnimationClip;
  1976. /** !#en The name of the playing animation.
  1977. !#zh 动画的名字 */
  1978. name : string;
  1979. }
  1980. /** undefined */
  1981. export class Playable {
  1982. constructor();
  1983. /** !#en Is playing or paused in play mode?
  1984. !#zh 当前是否正在播放。 */
  1985. isPlaying : boolean;
  1986. /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false).
  1987. !#zh 当前是否正在暂停 */
  1988. isPaused : boolean;
  1989. /** !#en Play this animation.
  1990. !#zh 播放动画。
  1991. */
  1992. play() : void;
  1993. /** !#en Stop this animation.
  1994. !#zh 停止动画播放。
  1995. */
  1996. stop() : void;
  1997. /** !#en Pause this animation.
  1998. !#zh 暂停动画。
  1999. */
  2000. pause() : void;
  2001. /** !#en Resume this animation.
  2002. !#zh 重新播放动画。
  2003. */
  2004. resume() : void;
  2005. /** !#en Perform a single frame step.
  2006. !#zh 执行一帧动画。
  2007. */
  2008. step() : void;
  2009. }
  2010. /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation.
  2011. !#zh 动画使用的循环模式。 */
  2012. export enum WrapMode {
  2013. Default = 0,
  2014. Normal = 0,
  2015. Reverse = 0,
  2016. Loop = 0,
  2017. LoopReverse = 0,
  2018. PingPong = 0,
  2019. PingPongReverse = 0,
  2020. }
  2021. /** !#en The abstract interface for all playing animation.
  2022. !#zh 所有播放动画的抽象接口。 */
  2023. export class AnimationNodeBase extends Playable {
  2024. constructor();
  2025. }
  2026. /** !#en The collection and instance of playing animations.
  2027. !#zh 动画曲线的集合,根据当前时间计算出每条曲线的状态。 */
  2028. export class AnimationNode extends AnimationNodeBase {
  2029. /**
  2030. @param timingInput This dictionary is used as a convenience for specifying the timing properties of an Animation in bulk.
  2031. */
  2032. constructor(animator : Animator, curves? : AnimCurve[], timingInput? : any);
  2033. /** !#en The curves list.
  2034. !#zh 曲线列表。 */
  2035. curves : AnimCurve[];
  2036. /** !#en The start delay which represents the number of seconds from an animation's start time to the start of
  2037. the active interval.
  2038. !#zh 延迟多少秒播放。 */
  2039. delay : number;
  2040. /** !#en The animation's iteration count property.
  2041. A real number greater than or equal to zero (including positive infinity) representing the number of times
  2042. to repeat the animation node.
  2043. Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model
  2044. calculations.
  2045. !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */
  2046. repeatCount : number;
  2047. /** !#en The iteration duration of this animation in seconds. (length)
  2048. !#zh 单次动画的持续时间,秒。 */
  2049. duration : number;
  2050. /** !#en The animation's playback speed. 1 is normal playback speed.
  2051. !#zh 播放速率。 */
  2052. speed : number;
  2053. /** !#en
  2054. Wrapping mode of the playing animation.
  2055. Notice : dynamic change wrapMode will reset time and repeatCount property
  2056. !#zh
  2057. 动画循环方式。
  2058. 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */
  2059. wrapMode : WrapMode;
  2060. /** !#en The current time of this animation in seconds.
  2061. !#zh 动画当前的时间,秒。 */
  2062. time : number;
  2063. }
  2064. /** !#en Base class cc.Action for action classes.
  2065. !#zh Action 类是所有动作类型的基类。 */
  2066. export class Action {
  2067. /** !#en
  2068. to copy object with deep copy.
  2069. returns a clone of action.
  2070. !#zh 返回一个克隆的动作。
  2071. */
  2072. clone() : Action;
  2073. /** !#en
  2074. return true if the action has finished.
  2075. !#zh 如果动作已完成就返回 true。
  2076. */
  2077. isDone() : boolean;
  2078. /** !#en get the target.
  2079. !#zh 获取当前目标节点。
  2080. */
  2081. getTarget() : Node;
  2082. /** !#en The action will modify the target properties.
  2083. !#zh 设置目标节点。
  2084. */
  2085. setTarget(target : Node) : void;
  2086. /** !#en get the original target.
  2087. !#zh 获取原始目标节点。
  2088. */
  2089. getOriginalTarget() : Node;
  2090. /** !#en get tag number.
  2091. !#zh 获取用于识别动作的标签。
  2092. */
  2093. getTag() : number;
  2094. /** !#en set tag number.
  2095. !#zh 设置标签,用于识别动作。
  2096. */
  2097. setTag(tag : number) : void;
  2098. /** !#en Default Action tag.
  2099. !#zh 默认动作标签。 */
  2100. TAG_INVALID : number;
  2101. }
  2102. /** !#en
  2103. Base class actions that do have a finite time duration. <br/>
  2104. Possible actions: <br/>
  2105. - An action with a duration of 0 seconds. <br/>
  2106. - An action with a duration of 35.5 seconds.
  2107. Infinite time actions are valid
  2108. !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */
  2109. export class FiniteTimeAction extends Action {
  2110. /** !#en get duration of the action. (seconds).
  2111. !#zh 获取动作以秒为单位的持续时间。
  2112. */
  2113. getDuration() : number;
  2114. /** !#en set duration of the action. (seconds).
  2115. !#zh 设置动作以秒为单位的持续时间。
  2116. */
  2117. setDuration(duration : number) : void;
  2118. /** !#en
  2119. Returns a reversed action. <br />
  2120. For example: <br />
  2121. - The action will be x coordinates of 0 move to 100. <br />
  2122. - The reversed action will be x of 100 move to 0.
  2123. - Will be rewritten
  2124. !#zh 返回一个新的动作,执行与原动作完全相反的动作。
  2125. */
  2126. reverse() : void;
  2127. /** !#en
  2128. to copy object with deep copy.
  2129. returns a clone of action.
  2130. !#zh 返回一个克隆的动作。
  2131. */
  2132. clone() : FiniteTimeAction;
  2133. }
  2134. /** !#en Base class for Easing actions.
  2135. !#zh 所有缓动动作基类,用于修饰 ActionInterval。 */
  2136. export class ActionEase extends ActionInterval {
  2137. }
  2138. /** !#en Base class for Easing actions with rate parameters
  2139. !#zh 拥有速率属性的缓动动作基类。 */
  2140. export class EaseRateAction extends ActionEase {
  2141. }
  2142. /** !#en Ease Elastic abstract class.
  2143. !#zh 弹性缓动动作基类。 */
  2144. export class EaseElastic extends ActionEase {
  2145. }
  2146. /** !#en cc.EaseBounce abstract class.
  2147. !#zh 反弹缓动动作基类。 */
  2148. export class EaseBounce extends ActionEase {
  2149. }
  2150. /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions.
  2151. !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */
  2152. export class ActionInstant extends FiniteTimeAction {
  2153. }
  2154. /** !#en
  2155. <p> An interval action is an action that takes place within a certain period of time. <br/>
  2156. It has an start time, and a finish time. The finish time is the parameter<br/>
  2157. duration plus the start time.</p>
  2158. <p>These CCActionInterval actions have some interesting properties, like:<br/>
  2159. - They can run normally (default) <br/>
  2160. - They can run reversed with the reverse method <br/>
  2161. - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions. </p>
  2162. <p>For example, you can simulate a Ping Pong effect running the action normally and<br/>
  2163. then running it again in Reverse mode. </p>
  2164. !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */
  2165. export class ActionInterval extends FiniteTimeAction {
  2166. /** !#en Implementation of ease motion.
  2167. !#zh 缓动运动。
  2168. @example
  2169. action.easeing(cc.easeIn(3.0));,```js
  2170. action.easeing(cc.easeIn(3.0));
  2171. ```
  2172. */
  2173. easing(easeObj : any) : ActionInterval;
  2174. /** !#en
  2175. Repeats an action a number of times.
  2176. To repeat an action forever use the CCRepeatForever action.
  2177. !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。
  2178. */
  2179. repeat(times : void) : ActionInterval;
  2180. /** !#en
  2181. Repeats an action for ever. <br/>
  2182. To repeat the an action for a limited number of times use the Repeat action. <br/>
  2183. !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。
  2184. */
  2185. repeatForever() : ActionInterval;
  2186. }
  2187. /** !#en
  2188. cc.ActionManager is a class that can manage actions.<br/>
  2189. Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface,
  2190. which uses this class's singleton object.
  2191. But there are some cases where you might need to use this class. <br/>
  2192. Examples:<br/>
  2193. - When you want to run an action where the target is different from a CCNode.<br/>
  2194. - When you want to pause / resume the actions<br/>
  2195. !#zh
  2196. cc.ActionManager 是可以管理动作的单例类。<br/>
  2197. 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。<br/>
  2198. 但也有一些情况下,您可能需要使用这个类。 <br/>
  2199. 例如:
  2200. - 当你想要运行一个动作,但目标不是 CCNode 类型时。 <br/>
  2201. - 当你想要暂停/恢复动作时。 <br/> */
  2202. export class ActionManager {
  2203. /** !#en
  2204. Adds an action with a target.<br/>
  2205. If the target is already present, then the action will be added to the existing target.
  2206. If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target.
  2207. When the target is paused, the queued actions won't be 'ticked'.
  2208. !#zh
  2209. 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。<br/>
  2210. 如果目标已存在,动作将会被直接添加到现有的节点中。<br/>
  2211. 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。<br/>
  2212. 当目标状态的 paused 为 true,动作将不会被执行
  2213. */
  2214. addAction(action : Action, target : Node, paused : boolean) : void;
  2215. /** !#en Removes all actions from all the targets.
  2216. !#zh 移除所有对象的所有动作。
  2217. */
  2218. removeAllActions() : void;
  2219. /** !#en
  2220. Removes all actions from a certain target. <br/>
  2221. All the actions that belongs to the target will be removed.
  2222. !#zh
  2223. 移除指定对象上的所有动作。<br/>
  2224. 属于该目标的所有的动作将被删除。
  2225. */
  2226. removeAllActionsFromTarget(target : any, forceDelete : boolean) : void;
  2227. /** !#en Removes an action given an action reference.
  2228. !#zh 移除指定的动作。
  2229. */
  2230. removeAction(action : Action) : void;
  2231. /** !#en Removes an action given its tag and the target.
  2232. !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。
  2233. */
  2234. removeActionByTag(tag : number, target : any) : void;
  2235. /** !#en Gets an action given its tag an a target.
  2236. !#zh 通过目标对象和标签获取一个动作。
  2237. */
  2238. getActionByTag(tag : number, target : any) : Action;
  2239. /** !#en
  2240. Returns the numbers of actions that are running in a certain target. <br/>
  2241. Composable actions are counted as 1 action. <br/>
  2242. Example: <br/>
  2243. - If you are running 1 Sequence of 7 actions, it will return 1. <br/>
  2244. - If you are running 7 Sequences of 2 actions, it will return 7.
  2245. !#zh
  2246. 返回指定对象下所有正在运行的动作数量。 <br/>
  2247. 组合动作被算作一个动作。<br/>
  2248. 例如:<br/>
  2249. - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。<br/>
  2250. - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。<br/>
  2251. */
  2252. numberOfRunningActionsInTarget(target : any) : number;
  2253. /** !#en Pauses the target: all running actions and newly added actions will be paused.
  2254. !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。
  2255. */
  2256. pauseTarget(target : any) : void;
  2257. /** !#en Resumes the target. All queued actions will be resumed.
  2258. !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。
  2259. */
  2260. resumeTarget(target : any) : void;
  2261. /** !#en Pauses all running actions, returning a list of targets whose actions were paused.
  2262. !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。
  2263. */
  2264. pauseAllRunningActions() : any[];
  2265. /** !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call).
  2266. !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。
  2267. */
  2268. resumeTargets(targetsToResume : any[]) : void;
  2269. /** !#en Pause a set of targets.
  2270. !#zh 暂停一组指定对象。
  2271. */
  2272. pauseTargets(targetsToPause : any[]) : void;
  2273. /** !#en
  2274. purges the shared action manager. It releases the retained instance. <br/>
  2275. because it uses this, so it can not be static.
  2276. !#zh
  2277. 清除共用的动作管理器。它释放了持有的实例。 <br/>
  2278. 因为它使用 this,因此它不能是静态的。
  2279. */
  2280. purgeSharedManager() : void;
  2281. /** !#en The ActionManager update。
  2282. !#zh ActionManager 主循环。
  2283. @param dt delta time in seconds
  2284. */
  2285. update(dt : number) : void;
  2286. }
  2287. /** !#en
  2288. <p>
  2289. ATTENTION: USE cc.director INSTEAD OF cc.Director.<br/>
  2290. cc.director is a singleton object which manage your game's logic flow.<br/>
  2291. Since the cc.director is a singleton, you don't need to call any constructor or create functions,<br/>
  2292. the standard way to use it is by calling:<br/>
  2293. - cc.director.methodName(); <br/>
  2294. It creates and handle the main Window and manages how and when to execute the Scenes.<br/>
  2295. <br/>
  2296. The cc.director is also responsible for:<br/>
  2297. - initializing the OpenGL context<br/>
  2298. - setting the OpenGL pixel format (default on is RGB565)<br/>
  2299. - setting the OpenGL buffer depth (default on is 0-bit)<br/>
  2300. - setting the color for clear screen (default one is BLACK)<br/>
  2301. - setting the projection (default one is 3D)<br/>
  2302. - setting the orientation (default one is Portrait)<br/>
  2303. <br/>
  2304. <br/>
  2305. The cc.director also sets the default OpenGL context:<br/>
  2306. - GL_TEXTURE_2D is enabled<br/>
  2307. - GL_VERTEX_ARRAY is enabled<br/>
  2308. - GL_COLOR_ARRAY is enabled<br/>
  2309. - GL_TEXTURE_COORD_ARRAY is enabled<br/>
  2310. </p>
  2311. <p>
  2312. cc.director also synchronizes timers with the refresh rate of the display.<br/>
  2313. Features and Limitations:<br/>
  2314. - Scheduled timers & drawing are synchronizes with the refresh rate of the display<br/>
  2315. - Only supports animation intervals of 1/60 1/30 & 1/15<br/>
  2316. </p>
  2317. !#zh
  2318. <p>
  2319. 注意:用 cc.director 代替 cc.Director。<br/>
  2320. cc.director 一个管理你的游戏的逻辑流程的单例对象。<br/>
  2321. 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,<br/>
  2322. 使用它的标准方法是通过调用:<br/>
  2323. - cc.director.methodName();
  2324. <br/>
  2325. 它创建和处理主窗口并且管理什么时候执行场景。<br/>
  2326. <br/>
  2327. cc.director 还负责:<br/>
  2328. - 初始化 OpenGL 环境。<br/>
  2329. - 设置OpenGL像素格式。(默认是 RGB565)<br/>
  2330. - 设置OpenGL缓冲区深度 (默认是 0-bit)<br/>
  2331. - 设置空白场景的颜色 (默认是 黑色)<br/>
  2332. - 设置投影 (默认是 3D)<br/>
  2333. - 设置方向 (默认是 Portrait)<br/>
  2334. <br/>
  2335. cc.director 设置了 OpenGL 默认环境 <br/>
  2336. - GL_TEXTURE_2D 启用。<br/>
  2337. - GL_VERTEX_ARRAY 启用。<br/>
  2338. - GL_COLOR_ARRAY 启用。<br/>
  2339. - GL_TEXTURE_COORD_ARRAY 启用。<br/>
  2340. </p>
  2341. <p>
  2342. cc.director 也同步定时器与显示器的刷新速率。
  2343. <br/>
  2344. 特点和局限性: <br/>
  2345. - 将计时器 & 渲染与显示器的刷新频率同步。<br/>
  2346. - 只支持动画的间隔 1/60 1/30 & 1/15。<br/>
  2347. </p> */
  2348. export class Director {
  2349. /** !#en
  2350. Converts an OpenGL coordinate to a view coordinate<br/>
  2351. Useful to convert node points to window points for calls such as glScissor<br/>
  2352. Implementation can be found in CCDirectorWebGL.
  2353. !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。
  2354. */
  2355. convertToUI(glPoint : Vec2) : Vec2;
  2356. /** !#en
  2357. Returns the size of the WebGL view in points.<br/>
  2358. It takes into account any possible rotation (device orientation) of the window.
  2359. !#zh 获取视图的大小,以点为单位。
  2360. */
  2361. getWinSize() : Size;
  2362. /** !#en
  2363. Returns the size of the OpenGL view in pixels.<br/>
  2364. It takes into account any possible rotation (device orientation) of the window.<br/>
  2365. On Mac winSize and winSizeInPixels return the same value.
  2366. !#zh 获取视图大小,以像素为单位。
  2367. */
  2368. getWinSizeInPixels() : Size;
  2369. /** !#en Returns the visible size of the running scene.
  2370. !#zh 获取运行场景的可见大小。
  2371. */
  2372. getVisibleSize() : Size;
  2373. /** !#en Returns the visible origin of the running scene.
  2374. !#zh 获取视图在游戏内容中的坐标原点。
  2375. */
  2376. getVisibleOrigin() : Vec2;
  2377. /** !#en Pause the director's ticker, only involve the game logic execution.
  2378. It won't pause the rendering process nor the event manager.
  2379. If you want to pause the entier game including rendering, audio and event,
  2380. please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}
  2381. !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。
  2382. 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。
  2383. */
  2384. pause() : void;
  2385. /** !#en
  2386. Run a scene. Replaces the running scene with a new one or enter the first scene.<br/>
  2387. The new scene will be launched immediately.
  2388. !#zh 立刻切换指定场景。
  2389. @param scene The need run scene.
  2390. @param onBeforeLoadScene The function invoked at the scene before loading.
  2391. @param onLaunched The function invoked at the scene after launch.
  2392. */
  2393. runSceneImmediate(scene : Scene, onBeforeLoadScene? : Function, onLaunched? : Function) : void;
  2394. /** !#en
  2395. Run a scene. Replaces the running scene with a new one or enter the first scene.
  2396. The new scene will be launched at the end of the current frame.
  2397. !#zh 运行指定场景。
  2398. @param scene The need run scene.
  2399. @param onBeforeLoadScene The function invoked at the scene before loading.
  2400. @param onLaunched The function invoked at the scene after launch.
  2401. */
  2402. runScene(scene : Scene, onBeforeLoadScene? : Function, onLaunched? : Function) : void;
  2403. /** !#en Loads the scene by its name.
  2404. !#zh 通过场景名称进行加载场景。
  2405. @param sceneName The name of the scene to load.
  2406. @param onLaunched callback, will be called after scene launched.
  2407. */
  2408. loadScene(sceneName : string, onLaunched? : Function) : boolean;
  2409. /** !#en
  2410. Preloads the scene to reduces loading time. You can call this method at any time you want.
  2411. After calling this method, you still need to launch the scene by `cc.director.loadScene`.
  2412. It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not
  2413. yet finished, the scene will be launched after loaded automatically.
  2414. !#zh 预加载场景,你可以在任何时候调用这个方法。
  2415. 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。
  2416. 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。
  2417. @param sceneName The name of the scene to preload.
  2418. @param onLoaded callback, will be called after scene loaded.
  2419. */
  2420. preloadScene(sceneName : string, onLoaded: (error: Error) => void) : void;
  2421. /** !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen.
  2422. !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。
  2423. */
  2424. resume() : void;
  2425. /** !#en
  2426. Enables or disables WebGL depth test.<br/>
  2427. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js
  2428. !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。
  2429. */
  2430. setDepthTest(on : boolean) : void;
  2431. /** !#en
  2432. set color for clear screen.<br/>
  2433. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js
  2434. !#zh 设置场景的默认擦除颜色(支持白色全透明,但不支持透明度为中间值)。
  2435. */
  2436. setClearColor(clearColor : Color) : void;
  2437. /** !#en
  2438. Sets an OpenGL projection.<br/>
  2439. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  2440. !#zh 设置 OpenGL 投影。
  2441. */
  2442. setProjection(projection : number) : void;
  2443. /** !#en
  2444. Update the view port.<br/>
  2445. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  2446. !#zh 设置视窗(请不要主动调用这个接口,除非你知道你在做什么)。
  2447. */
  2448. setViewport() : void;
  2449. /** !#en
  2450. Sets an OpenGL projection.<br/>
  2451. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  2452. !#zh 获取 OpenGL 投影。
  2453. */
  2454. getProjection() : number;
  2455. /** !#en
  2456. Enables/disables OpenGL alpha blending.<br/>
  2457. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  2458. !#zh 启用/禁用 透明度融合。
  2459. */
  2460. setAlphaBlending(on : boolean) : void;
  2461. /** !#en
  2462. Returns whether or not the replaced scene will receive the cleanup message.<br/>
  2463. If the new scene is pushed, then the old scene won't receive the "cleanup" message.<br/>
  2464. If the new scene replaces the old one, the it will receive the "cleanup" message.
  2465. !#zh
  2466. 更换场景时是否接收清理消息。<br>
  2467. 如果新场景是采用 push 方式进入的,那么旧的场景将不会接收到 “cleanup” 消息。<br/>
  2468. 如果新场景取代旧的场景,它将会接收到 “cleanup” 消息。</br>
  2469. */
  2470. isSendCleanupToScene() : boolean;
  2471. /** !#en Returns current logic Scene.
  2472. !#zh 获取当前逻辑场景。
  2473. @example
  2474. ```js
  2475. // This will help you to get the Canvas node in scene
  2476. cc.director.getScene().getChildByName('Canvas');
  2477. ```
  2478. */
  2479. getScene() : Scene;
  2480. /** !#en Returns the FPS value.
  2481. !#zh 获取单位帧执行时间。
  2482. */
  2483. getAnimationInterval() : number;
  2484. /** !#en Returns whether or not to display the FPS informations.
  2485. !#zh 获取是否显示 FPS 信息。
  2486. */
  2487. isDisplayStats() : boolean;
  2488. /** !#en Sets whether display the FPS on the bottom-left corner.
  2489. !#zh 设置是否在左下角显示 FPS。
  2490. */
  2491. setDisplayStats(displayStats : boolean) : void;
  2492. /** !#en Returns seconds per frame.
  2493. !#zh 获取实际记录的上一帧执行时间,可能与单位帧执行时间(AnimationInterval)有出入。
  2494. */
  2495. getSecondsPerFrame() : number;
  2496. /** !#en Returns whether next delta time equals to zero.
  2497. !#zh 返回下一个 “delta time” 是否等于零。
  2498. */
  2499. isNextDeltaTimeZero() : boolean;
  2500. /** !#en Returns whether or not the Director is paused.
  2501. !#zh 是否处于暂停状态。
  2502. */
  2503. isPaused() : boolean;
  2504. /** !#en Returns how many frames were called since the director started.
  2505. !#zh 获取 director 启动以来游戏运行的总帧数。
  2506. */
  2507. getTotalFrames() : number;
  2508. /** !#en Returns the cc.Scheduler associated with this director.
  2509. !#zh 获取和 director 相关联的 cc.Scheduler。
  2510. */
  2511. getScheduler() : Scheduler;
  2512. /** !#en Sets the cc.Scheduler associated with this director.
  2513. !#zh 设置和 director 相关联的 cc.Scheduler。
  2514. */
  2515. setScheduler(scheduler : Scheduler) : void;
  2516. /** !#en Returns the cc.ActionManager associated with this director.
  2517. !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。
  2518. */
  2519. getActionManager() : ActionManager;
  2520. /** !#en Sets the cc.ActionManager associated with this director.
  2521. !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。
  2522. */
  2523. setActionManager(actionManager : ActionManager) : void;
  2524. /** Returns the cc.CollisionManager associated with this director.
  2525. */
  2526. getCollisionManager() : CollisionManager;
  2527. /** !#en Returns the delta time since last frame.
  2528. !#zh 获取上一帧的 “delta time”。
  2529. */
  2530. getDeltaTime() : number;
  2531. }
  2532. /** !#en cc.game is the singleton object for game related functions.
  2533. !#zh cc.game 是 Game 的实例,用来驱动整个游戏。 */
  2534. export class Game {
  2535. /** Event triggered when game hide to background.
  2536. Please note that this event is not 100% guaranteed to be fired. */
  2537. EVENT_HIDE : string;
  2538. /** Event triggered when game back to foreground
  2539. Please note that this event is not 100% guaranteed to be fired. */
  2540. EVENT_SHOW : string;
  2541. /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */
  2542. EVENT_GAME_INITED : string;
  2543. /** Event triggered after renderer inited, at this point you will be able to use the render context */
  2544. EVENT_RENDERER_INITED : string;
  2545. /** Key of config */
  2546. CONFIG_KEY : any;
  2547. /** !#en The outer frame of the game canvas, parent of cc.container.
  2548. !#zh 游戏画布的外框,cc.container 的父类。 */
  2549. frame : any;
  2550. /** !#en The container of game canvas, equals to cc.container.
  2551. !#zh 游戏画布的容器。 */
  2552. container : any;
  2553. /** !#en The canvas of the game, equals to cc._canvas.
  2554. !#zh 游戏的画布。 */
  2555. canvas : any;
  2556. /** !#en
  2557. The current game configuration, including:<br/>
  2558. 1. debugMode<br/>
  2559. "debugMode" possible values :<br/>
  2560. 0 - No message will be printed. <br/>
  2561. 1 - cc.error, cc.assert, cc.warn, cc.log will print in console. <br/>
  2562. 2 - cc.error, cc.assert, cc.warn will print in console. <br/>
  2563. 3 - cc.error, cc.assert will print in console. <br/>
  2564. 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.<br/>
  2565. 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. <br/>
  2566. 6 - cc.error, cc.assert will print on canvas, available only on web. <br/>
  2567. 2. showFPS<br/>
  2568. Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.<br/>
  2569. 3. frameRate<br/>
  2570. "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.<br/>
  2571. 4. id<br/>
  2572. "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.<br/>
  2573. 5. renderMode<br/>
  2574. "renderMode" sets the renderer type, only useful on web :<br/>
  2575. 0 - Automatically chosen by engine<br/>
  2576. 1 - Forced to use canvas renderer<br/>
  2577. 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers<br/>
  2578. 6. scenes<br/>
  2579. "scenes" include available scenes in the current bundle.<br/>
  2580. <br/>
  2581. Please DO NOT modify this object directly, it won't have any effect.<br/>
  2582. !#zh
  2583. 当前的游戏配置,包括: <br/>
  2584. 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略) <br/>
  2585. "debugMode" 各种设置选项的意义。 <br/>
  2586. 0 - 没有消息被打印出来。 <br/>
  2587. 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。 <br/>
  2588. 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。 <br/>
  2589. 3 - cc.error,cc.assert 将打印在 console 中。 <br/>
  2590. 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  2591. 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  2592. 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  2593. 2. showFPS(显示 FPS) <br/>
  2594. 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。 <br/>
  2595. 3. frameRate (帧率) <br/>
  2596. “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。 <br/>
  2597. 4. id <br/>
  2598. "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。 <br/>
  2599. 5. renderMode(渲染模式) <br/>
  2600. “renderMode” 设置渲染器类型,仅适用于 web 端: <br/>
  2601. 0 - 通过引擎自动选择。 <br/>
  2602. 1 - 强制使用 canvas 渲染。
  2603. 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。 <br/>
  2604. 6. scenes <br/>
  2605. “scenes” 当前包中可用场景。 <br/>
  2606. <br/>
  2607. 注意:请不要直接修改这个对象,它不会有任何效果。 */
  2608. config : any;
  2609. /** !#en Callback when the scripts of engine have been load.
  2610. !#zh 当引擎完成启动后的回调函数。
  2611. */
  2612. onStart() : void;
  2613. /** !#en Callback when game exits.
  2614. !#zh 当游戏结束后的回调函数。
  2615. */
  2616. onStop() : void;
  2617. /** !#en Set frameRate of game.
  2618. !#zh 设置游戏帧率。
  2619. */
  2620. setFrameRate(frameRate : number) : void;
  2621. /** !#en Run the game frame by frame.
  2622. !#zh 执行一帧游戏循环。
  2623. */
  2624. step() : void;
  2625. /** !#en Pause the game main loop. This will pause:
  2626. game logic execution, rendering process, event manager, background music and all audio effects.
  2627. This is different with cc.director.pause which only pause the game logic execution.
  2628. !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。
  2629. */
  2630. pause() : void;
  2631. /** !#en Resume the game from pause. This will resume:
  2632. game logic execution, rendering process, event manager, background music and all audio effects.
  2633. !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。
  2634. */
  2635. resume() : void;
  2636. /** !#en Check whether the game is paused.
  2637. !#zh 判断游戏是否暂停。
  2638. */
  2639. isPaused() : boolean;
  2640. /** !#en Restart game.
  2641. !#zh 重新开始游戏
  2642. */
  2643. restart() : void;
  2644. /** !#en Prepare game.
  2645. !#zh 准备引擎,请不要直接调用这个函数。
  2646. */
  2647. prepare(cb : Function) : void;
  2648. /** !#en Run game with configuration object and onStart function.
  2649. !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。
  2650. @param config Pass configuration object or onStart function
  2651. @param onStart function to be executed after game initialized
  2652. */
  2653. run(config? : any|Function, onStart? : Function) : void;
  2654. /** !#en
  2655. Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.<br/>
  2656. The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect.
  2657. !#zh
  2658. 声明常驻根节点,该节点不会被在场景切换中被销毁。<br/>
  2659. 目标节点必须位于为层级的根节点,否则无效。
  2660. @param node The node to be made persistent
  2661. */
  2662. addPersistRootNode(node : Node) : void;
  2663. /** !#en Remove a persistent root node.
  2664. !#zh 取消常驻根节点。
  2665. @param node The node to be removed from persistent node list
  2666. */
  2667. removePersistRootNode(node : Node) : void;
  2668. /** !#en Check whether the node is a persistent root node.
  2669. !#zh 检查节点是否是常驻根节点。
  2670. @param node The node to be checked
  2671. */
  2672. isPersistRootNode(node : Node) : boolean;
  2673. }
  2674. /** !#en
  2675. Class of all entities in Cocos Creator scenes.<br/>
  2676. Node also inherits from {{#crossLink "EventTarget"}}Event Target{{/crossLink}}, it permits Node to dispatch events.
  2677. For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}}
  2678. !#zh
  2679. Cocos Creator 场景中的所有节点类。节点也继承了 {{#crossLink "EventTarget"}}EventTarget{{/crossLink}},它允许节点发送事件。<br/>
  2680. 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */
  2681. export class Node extends _BaseNode {
  2682. /** !#en
  2683. The local active state of this node.<br/>
  2684. Note that a Node may be inactive because a parent is not active, even if this returns true.<br/>
  2685. Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene.
  2686. !#zh
  2687. 当前节点的自身激活状态。<br/>
  2688. 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。<br/>
  2689. 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */
  2690. active : boolean;
  2691. /** !#en Indicates whether this node is active in the scene.
  2692. !#zh 表示此节点是否在场景中激活。 */
  2693. activeInHierarchy : boolean;
  2694. /** !#en
  2695. Group index of node.<br/>
  2696. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  2697. !#zh
  2698. 节点的分组索引。<br/>
  2699. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  2700. groupIndex : Integer;
  2701. /** !#en
  2702. Group of node.<br/>
  2703. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  2704. !#zh
  2705. 节点的分组。<br/>
  2706. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  2707. group : string;
  2708. /** !#en
  2709. Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
  2710. You can also get component in the node by passing in the name of the script.
  2711. !#zh
  2712. 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。<br/>
  2713. 传入参数也可以是脚本的名称。
  2714. @example
  2715. ```js
  2716. // get sprite component.
  2717. var sprite = node.getComponent(cc.Sprite);
  2718. // get custom test calss.
  2719. var test = node.getComponent("Test");
  2720. ```
  2721. */
  2722. getComponent(typeOrClassName : Function|string) : Component;
  2723. /** !#en Returns all components of supplied type in the node.
  2724. !#zh 返回节点上指定类型的所有组件。
  2725. @example
  2726. ```js
  2727. var sprites = node.getComponents(cc.Sprite);
  2728. var tests = node.getComponents("Test");
  2729. ```
  2730. */
  2731. getComponents(typeOrClassName : Function|string) : Component[];
  2732. /** !#en Returns the component of supplied type in any of its children using depth first search.
  2733. !#zh 递归查找所有子节点中第一个匹配指定类型的组件。
  2734. @example
  2735. ```js
  2736. var sprite = node.getComponentInChildren(cc.Sprite);
  2737. var Test = node.getComponentInChildren("Test");
  2738. ```
  2739. */
  2740. getComponentInChildren(typeOrClassName : Function|string) : Component;
  2741. /** !#en Returns all components of supplied type in self or any of its children.
  2742. !#zh 递归查找自身或所有子节点中指定类型的组件
  2743. @example
  2744. ```js
  2745. var sprites = node.getComponentsInChildren(cc.Sprite);
  2746. var tests = node.getComponentsInChildren("Test");
  2747. ```
  2748. */
  2749. getComponentsInChildren(typeOrClassName : Function|string) : Component[];
  2750. /** !#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
  2751. !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。
  2752. @param typeOrClassName The constructor or the class name of the component to add
  2753. @example
  2754. ```js
  2755. var sprite = node.addComponent(cc.Sprite);
  2756. var test = node.addComponent("Test");
  2757. ```
  2758. */
  2759. addComponent(typeOrClassName : Function|string) : Component;
  2760. /** !#en
  2761. Removes a component identified by the given name or removes the component object given.
  2762. You can also use component.destroy() if you already have the reference.
  2763. !#zh
  2764. 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。
  2765. 如果你已经获得组件引用,你也可以直接调用 component.destroy()
  2766. @param component The need remove component.
  2767. @example
  2768. ```js
  2769. node.removeComponent(cc.Sprite);
  2770. var Test = require("Test");
  2771. node.removeComponent(Test);
  2772. ```
  2773. */
  2774. removeComponent(component : string|Function|Component) : void;
  2775. /** !#en
  2776. Register a callback of a specific event type on Node.<br/>
  2777. Use this method to register touch or mouse event permit propagation based on scene graph,
  2778. you can propagate the event to the parents or swallow it by calling stopPropagation on the event.<br/>
  2779. It's the recommended way to register touch/mouse event for Node,
  2780. please do not use cc.eventManager directly for Node.
  2781. !#zh
  2782. 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的调用者。<br/>
  2783. 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。<br/>
  2784. 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。
  2785. @param type A string representing the event type to listen for.
  2786. @param callback The callback that will be invoked when the event is dispatched.
  2787. The callback is ignored if it is a duplicate (the callbacks are unique).
  2788. @param target The target to invoke the callback, can be null
  2789. @param useCapture When set to true, the capture argument prevents callback
  2790. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  2791. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  2792. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  2793. @example
  2794. ```js
  2795. // add Node Touch Event
  2796. node.on(cc.Node.EventType.TOUCH_START, callback, this.node);
  2797. node.on(cc.Node.EventType.TOUCH_MOVE, callback, this.node);
  2798. node.on(cc.Node.EventType.TOUCH_END, callback, this.node);
  2799. node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this.node);
  2800. ```
  2801. */
  2802. on(type : string, callback: (param: Event) => void, target? : any, useCapture : boolean) : Function;
  2803. /** !#en
  2804. Removes the callback previously registered with the same type, callback, target and or useCapture.
  2805. This method is merely an alias to removeEventListener.
  2806. !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。
  2807. @param type A string representing the event type being removed.
  2808. @param callback The callback to remove.
  2809. @param target The target to invoke the callback, if it's not given, only callback without target will be removed
  2810. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  2811. If not specified, useCapture defaults to false. If a callback was registered twice,
  2812. one with capture and one without, each must be removed separately. Removal of a capturing callback
  2813. does not affect a non-capturing version of the same listener, and vice versa.
  2814. @example
  2815. ```js
  2816. // remove Node TOUCH_START Event.
  2817. node.on(cc.Node.EventType.TOUCH_START, callback, this.node);
  2818. node.off(cc.Node.EventType.TOUCH_START, callback, this.node);
  2819. ```
  2820. */
  2821. off(type : string, callback : Function, target? : any, useCapture : boolean) : void;
  2822. /** !#en Removes all callbacks previously registered with the same target.
  2823. !#zh 移除目标上的所有注册事件。
  2824. @param target The target to be searched for all related callbacks
  2825. @example
  2826. ```js
  2827. node.targetOff(target);
  2828. ```
  2829. */
  2830. targetOff(target : any) : void;
  2831. /** !#en
  2832. Executes an action, and returns the action that is executed.<br/>
  2833. The node becomes the action's target. Refer to cc.Action's getTarget() <br/>
  2834. Calling runAction while the node is not active won't have any effect. <br/>
  2835. Note:You shouldn't modify the action after runAction, that won't take any effect.<br/>
  2836. if you want to modify, when you define action plus.
  2837. !#zh
  2838. 执行并返回该执行的动作。该节点将会变成动作的目标。<br/>
  2839. 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。<br/>
  2840. 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。
  2841. @example
  2842. ```js
  2843. var action = cc.scaleTo(0.2, 1, 0.6);
  2844. node.runAction(action);
  2845. node.runAction(action).repeatForever(); // fail
  2846. node.runAction(action.repeatForever()); // right
  2847. ```
  2848. */
  2849. runAction(action : Action) : Action;
  2850. /** !#en Stops and removes all actions from the running action list .
  2851. !#zh 停止并且移除所有正在运行的动作列表。
  2852. @example
  2853. ```js
  2854. node.stopAllActions();
  2855. ```
  2856. */
  2857. stopAllActions() : void;
  2858. /** !#en Stops and removes an action from the running action list.
  2859. !#zh 停止并移除指定的动作。
  2860. @param action An action object to be removed.
  2861. @example
  2862. ```js
  2863. var action = cc.scaleTo(0.2, 1, 0.6);
  2864. node.stopAction(action);
  2865. ```
  2866. */
  2867. stopAction(action : Action) : void;
  2868. /** !#en Removes an action from the running action list by its tag.
  2869. !#zh 停止并且移除指定标签的动作。
  2870. @param tag A tag that indicates the action to be removed.
  2871. @example
  2872. ```js
  2873. node.stopAction(1);
  2874. ```
  2875. */
  2876. stopActionByTag(tag : number) : void;
  2877. /** !#en Returns an action from the running action list by its tag.
  2878. !#zh 通过标签获取指定动作。
  2879. @example
  2880. ```js
  2881. var action = node.getActionByTag(1);
  2882. ```
  2883. */
  2884. getActionByTag(tag : number) : Action;
  2885. /** !#en
  2886. Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).<br/>
  2887. Composable actions are counted as 1 action. Example:<br/>
  2888. If you are running 1 Sequence of 7 actions, it will return 1. <br/>
  2889. If you are running 7 Sequences of 2 actions, it will return 7.</p>
  2890. !#zh
  2891. 获取运行着的动作加上正在调度运行的动作的总数。<br/>
  2892. 例如:<br/>
  2893. - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。<br/>
  2894. - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。<br/>
  2895. @example
  2896. ```js
  2897. var count = node.getNumberOfRunningActions();
  2898. cc.log("Running Action Count: " + count);
  2899. ```
  2900. */
  2901. getNumberOfRunningActions() : number;
  2902. }
  2903. /** !#en
  2904. cc.Scene is a subclass of cc.Node that is used only as an abstract concept.<br/>
  2905. cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually.
  2906. !#zh
  2907. cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。<br/>
  2908. cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */
  2909. export class Scene extends _BaseNode {
  2910. /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading.
  2911. !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */
  2912. autoReleaseAssets : boolean;
  2913. }
  2914. /** !#en
  2915. Scheduler is responsible of triggering the scheduled callbacks.<br/>
  2916. You should not use NSTimer. Instead use this class.<br/>
  2917. <br/>
  2918. There are 2 different types of callbacks (selectors):<br/>
  2919. - update callback: the 'update' callback will be called every frame. You can customize the priority.<br/>
  2920. - custom callback: A custom callback will be called every frame, or with a custom interval of time<br/>
  2921. <br/>
  2922. The 'custom selectors' should be avoided when possible. It is faster,
  2923. and consumes less memory to use the 'update callback'. *
  2924. !#zh
  2925. Scheduler 是负责触发回调函数的类。<br/>
  2926. 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。<br/>
  2927. 有两种不同类型的定时器:<br/>
  2928. - update 定时器:每一帧都会触发。您可以自定义优先级。<br/>
  2929. - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。<br/>
  2930. 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */
  2931. export class Scheduler {
  2932. /** !#en
  2933. Modifies the time of all scheduled callbacks.<br/>
  2934. You can use this property to create a 'slow motion' or 'fast forward' effect.<br/>
  2935. Default is 1.0. To create a 'slow motion' effect, use values below 1.0.<br/>
  2936. To create a 'fast forward' effect, use values higher than 1.0.<br/>
  2937. Note:It will affect EVERY scheduled selector / action.
  2938. !#zh
  2939. 设置时间间隔的缩放比例。<br/>
  2940. 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。<br/>
  2941. 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。<br/>
  2942. 要使用 “fast forward(快进)” 效果,使用值大于 1.0。<br/>
  2943. 注意:它影响该 Scheduler 下管理的所有定时器。
  2944. */
  2945. setTimeScale(timeScale : number) : void;
  2946. /** !#en Returns time scale of scheduler.
  2947. !#zh 获取时间间隔的缩放比例。
  2948. */
  2949. getTimeScale() : number;
  2950. /** !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.)
  2951. !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果)
  2952. @param dt delta time
  2953. */
  2954. update(dt : number) : void;
  2955. /** !#en
  2956. <p>
  2957. The scheduled method will be called every 'interval' seconds.</br>
  2958. If paused is YES, then it won't be called until it is resumed.<br/>
  2959. If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.<br/>
  2960. If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.<br/>
  2961. repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously<br/>
  2962. delay is the amount of time the action will wait before it'll start<br/>
  2963. </p>
  2964. !#zh
  2965. 指定回调函数,调用对象等信息来添加一个新的定时器。</br>
  2966. 当时间间隔达到指定值时,设置的回调函数将会被调用。</br>
  2967. 如果 paused 值为 true,那么直到 resume 被调用才开始计时。</br>
  2968. 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样,
  2969. 建议使用 scheduleUpdateForTarget 代替。</br>
  2970. 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。<br/>
  2971. repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER
  2972. 可以让定时器一直循环触发。<br/>
  2973. delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。
  2974. @example
  2975. ```js
  2976. //register a schedule to scheduler
  2977. var scheduler = cc.director.getScheduler();
  2978. scheduler.scheduleCallbackForTarget(this, function, interval, repeat, delay, !this._isRunning);
  2979. ```
  2980. */
  2981. scheduleCallbackForTarget(target : any, callback_fn : Function, interval : number, repeat : number, delay : number, paused : boolean) : void;
  2982. /** !#en The schedule
  2983. !#zh 定时器
  2984. @example
  2985. ```js
  2986. //register a schedule to scheduler
  2987. cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning);
  2988. ```
  2989. */
  2990. schedule(callback : Function, target : any, interval : number, repeat : number, delay : number, paused : boolean) : void;
  2991. /** !#en
  2992. Schedules the update callback for a given target,
  2993. the callback will be invoked every frame after schedule started.
  2994. !#zh
  2995. 使用指定的优先级为指定的对象设置 update 定时器。
  2996. update 定时器每一帧都会被触发。优先级的值越低,定时器被触发的越早。
  2997. */
  2998. scheduleUpdate(target : any, priority : number, paused : boolean, updateFunc : Function) : void;
  2999. /** !#en
  3000. Unschedules a callback for a callback and a given target.
  3001. If you want to unschedule the "update", use `unscheduleUpdate()`
  3002. !#zh
  3003. 根据指定的回调函数和调用对象。
  3004. 如果需要取消 update 定时器,请使用 unscheduleUpdate()。
  3005. @param callback The callback to be unscheduled
  3006. @param target The target bound to the callback.
  3007. */
  3008. unschedule(callback : Function, target : any) : void;
  3009. /** !#en Unschedules the update callback for a given target.
  3010. !#zh 取消指定对象的 update 定时器。
  3011. @param target The target to be unscheduled.
  3012. */
  3013. unscheduleUpdate(target : any) : void;
  3014. /** !#en
  3015. Unschedules all scheduled callbacks for a given target.
  3016. This also includes the "update" callback.
  3017. !#zh 取消指定对象的所有定时器,包括 update 定时器。
  3018. @param target The target to be unscheduled.
  3019. */
  3020. unscheduleAllForTarget(target : any) : void;
  3021. /** !#en
  3022. Unschedules all scheduled callbacks from all targets including the system callbacks.<br/>
  3023. You should NEVER call this method, unless you know what you are doing.
  3024. !#zh
  3025. 取消所有对象的所有定时器,包括系统定时器。<br/>
  3026. 不用调用此函数,除非你确定你在做什么。
  3027. */
  3028. unscheduleAll() : void;
  3029. /** !#en
  3030. Unschedules all callbacks from all targets with a minimum priority.<br/>
  3031. You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher.
  3032. !#zh
  3033. 取消所有优先级的值大于指定优先级的定时器。<br/>
  3034. 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  3035. @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which
  3036. priority is higher than minPriority will be unscheduled.
  3037. */
  3038. unscheduleAllWithMinPriority(minPriority : number) : void;
  3039. /** !#en Checks whether a callback for a given target is scheduled.
  3040. !#zh 检查指定的回调函数和回调对象组合是否存在定时器。
  3041. @param callback The callback to check.
  3042. @param target The target of the callback.
  3043. */
  3044. isScheduled(callback : Function, target : any) : boolean;
  3045. /** !#en
  3046. Pause all selectors from all targets.<br/>
  3047. You should NEVER call this method, unless you know what you are doing.
  3048. !#zh
  3049. 暂停所有对象的所有定时器。<br/>
  3050. 不要调用这个方法,除非你知道你正在做什么。
  3051. */
  3052. pauseAllTargets() : void;
  3053. /** !#en
  3054. Pause all selectors from all targets with a minimum priority. <br/>
  3055. You should only call this with kCCPriorityNonSystemMin or higher.
  3056. !#zh
  3057. 暂停所有优先级的值大于指定优先级的定时器。<br/>
  3058. 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  3059. */
  3060. pauseAllTargetsWithMinPriority(minPriority : number) : void;
  3061. /** !#en
  3062. Resume selectors on a set of targets.<br/>
  3063. This can be useful for undoing a call to pauseAllCallbacks.
  3064. !#zh
  3065. 恢复指定数组中所有对象的定时器。<br/>
  3066. 这个函数是 pauseAllCallbacks 的逆操作。
  3067. */
  3068. resumeTargets(targetsToResume : any[]) : void;
  3069. /** !#en
  3070. Pauses the target.<br/>
  3071. All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.<br/>
  3072. If the target is not present, nothing happens.
  3073. !#zh
  3074. 暂停指定对象的定时器。<br/>
  3075. 指定对象的所有定时器都会被暂停。<br/>
  3076. 如果指定的对象没有定时器,什么也不会发生。
  3077. */
  3078. pauseTarget(target : any) : void;
  3079. /** !#en
  3080. Resumes the target.<br/>
  3081. The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.<br/>
  3082. If the target is not present, nothing happens.
  3083. !#zh
  3084. 恢复指定对象的所有定时器。<br/>
  3085. 指定对象的所有定时器将继续工作。<br/>
  3086. 如果指定的对象没有定时器,什么也不会发生。
  3087. */
  3088. resumeTarget(target : any) : void;
  3089. /** !#en Returns whether or not the target is paused.
  3090. !#zh 返回指定对象的定时器是否暂停了。
  3091. */
  3092. isTargetPaused(target : any) : boolean;
  3093. /** !#en
  3094. Schedules the 'update' callback_fn for a given target with a given priority.<br/>
  3095. The 'update' callback_fn will be called every frame.<br/>
  3096. The lower the priority, the earlier it is called.
  3097. !#zh
  3098. 为指定对象设置 update 定时器。<br/>
  3099. update 定时器每一帧都会被调用。<br/>
  3100. 优先级的值越低,越早被调用。
  3101. @example
  3102. ```js
  3103. //register this object to scheduler
  3104. var scheduler = cc.director.getScheduler();
  3105. scheduler.scheduleUpdateForTarget(this, priority, !this._isRunning );
  3106. ```
  3107. */
  3108. scheduleUpdateForTarget(target : any, priority : number, paused : boolean) : void;
  3109. /** !#en
  3110. Unschedule a callback function for a given target.<br/>
  3111. If you want to unschedule the "update", use unscheduleUpdateForTarget.
  3112. !#zh
  3113. 根据指定的回调函数和调用对象对象取消相应的定时器。<br/>
  3114. 如果需要取消 update 定时器,请使用 unscheduleUpdateForTarget()。
  3115. @param callback callback[Function] or key[String]
  3116. @example
  3117. ```js
  3118. //unschedule a callback of target
  3119. var scheduler = cc.director.getScheduler();
  3120. scheduler.unscheduleCallbackForTarget(this, callback);
  3121. ```
  3122. */
  3123. unscheduleCallbackForTarget(target : any, callback : Function) : void;
  3124. /** !#en Unschedules the update callback function for a given target.
  3125. !#zh 取消指定对象的所有定时器。
  3126. @example
  3127. ```js
  3128. //unschedules the "update" method.
  3129. var scheduler = cc.director.getScheduler();
  3130. scheduler.unscheduleUpdateForTarget(this);
  3131. ```
  3132. */
  3133. unscheduleUpdateForTarget(target : any) : void;
  3134. /** !#en
  3135. Unschedules all function callbacks for a given target.<br/>
  3136. This also includes the "update" callback function.
  3137. !#zh 取消指定对象的所有定时器,包括 update 定时器。
  3138. */
  3139. unscheduleAllCallbacksForTarget(target : any) : void;
  3140. /** !#en
  3141. Unschedules all function callbacks from all targets. <br/>
  3142. You should NEVER call this method, unless you know what you are doing.
  3143. !#zh
  3144. 取消所有对象的所有定时器。<br/>
  3145. 不要调用这个方法,除非你知道你正在做什么。
  3146. */
  3147. unscheduleAllCallbacks() : void;
  3148. /** !#en
  3149. Unschedules all function callbacks from all targets with a minimum priority.<br/>
  3150. You should only call this with kCCPriorityNonSystemMin or higher.
  3151. !#zh
  3152. 取消所有优先级的值大于指定优先级的所有对象的所有定时器。<br/>
  3153. 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  3154. */
  3155. unscheduleAllCallbacksWithMinPriority(minPriority : number) : void;
  3156. /** !#en Priority level reserved for system services.
  3157. !#zh 系统服务的优先级。 */
  3158. PRIORITY_SYSTEM : number;
  3159. /** !#en Minimum priority level for user scheduling.
  3160. !#zh 用户调度最低优先级。 */
  3161. PRIORITY_NON_SYSTEM : number;
  3162. }
  3163. /** !#en
  3164. cc.MotionStreak manages a Ribbon based on it's motion in absolute space. <br/>
  3165. You construct it with a fadeTime, minimum segment size, texture path, texture <br/>
  3166. length and color. The fadeTime controls how long it takes each vertex in <br/>
  3167. the streak to fade out, the minimum segment size it how many pixels the <br/>
  3168. streak will move before adding a new ribbon segment, and the texture <br/>
  3169. length is the how many pixels the texture is stretched across. The texture <br/>
  3170. is vertically aligned along the streak segment.
  3171. !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */
  3172. export class MotionStreak extends Component {
  3173. /** !#en
  3174. !#zh 在编辑器模式下预览拖尾效果。 */
  3175. preview : boolean;
  3176. /** !#en The fade time to fade.
  3177. !#zh 拖尾的渐隐时间,以秒为单位。 */
  3178. fadeTime : number;
  3179. /** !#en The minimum segment size.
  3180. !#zh 拖尾之间最小距离。 */
  3181. minSeg : number;
  3182. /** !#en The stroke's width.
  3183. !#zh 拖尾的宽度。 */
  3184. stroke : number;
  3185. /** !#en The texture of the MotionStreak.
  3186. !#zh 拖尾的贴图。 */
  3187. texture : Texture2D;
  3188. /** !#en The color of the MotionStreak.
  3189. !#zh 拖尾的颜色 */
  3190. color : Color;
  3191. /** !#en The fast Mode.
  3192. !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */
  3193. fastMode : boolean;
  3194. /** !#en Remove all living segments of the ribbon.
  3195. !#zh 删除当前所有的拖尾片段。
  3196. @example
  3197. ```js
  3198. // stop particle system.
  3199. myParticleSystem.stopSystem();
  3200. ```
  3201. */
  3202. reset() : void;
  3203. }
  3204. /** Particle System base class. <br/>
  3205. Attributes of a Particle System:<br/>
  3206. - emmision rate of the particles<br/>
  3207. - Gravity Mode (Mode A): <br/>
  3208. - gravity <br/>
  3209. - direction <br/>
  3210. - speed +- variance <br/>
  3211. - tangential acceleration +- variance<br/>
  3212. - radial acceleration +- variance<br/>
  3213. - Radius Mode (Mode B): <br/>
  3214. - startRadius +- variance <br/>
  3215. - endRadius +- variance <br/>
  3216. - rotate +- variance <br/>
  3217. - Properties common to all modes: <br/>
  3218. - life +- life variance <br/>
  3219. - start spin +- variance <br/>
  3220. - end spin +- variance <br/>
  3221. - start size +- variance <br/>
  3222. - end size +- variance <br/>
  3223. - start color +- variance <br/>
  3224. - end color +- variance <br/>
  3225. - life +- variance <br/>
  3226. - blending function <br/>
  3227. - texture <br/>
  3228. <br/>
  3229. cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).<br/>
  3230. 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, <br/>
  3231. cocos2d uses a another approach, but the results are almost identical.<br/>
  3232. cocos2d supports all the variables used by Particle Designer plus a bit more: <br/>
  3233. - spinning particles (supported when using ParticleSystem) <br/>
  3234. - tangential acceleration (Gravity mode) <br/>
  3235. - radial acceleration (Gravity mode) <br/>
  3236. - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only) <br/>
  3237. It is possible to customize any of the above mentioned properties in runtime. Example: <br/> */
  3238. export class ParticleSystem extends cc._RendererUnderSG {
  3239. /** !#en Play particle in edit mode.
  3240. !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */
  3241. preview : boolean;
  3242. /** !#en
  3243. If set custom to true, then use custom properties insteadof read particle file.
  3244. !#zh 是否自定义粒子属性。 */
  3245. custom : boolean;
  3246. /** !#en The plist file.
  3247. !#zh plist 格式的粒子配置文件。 */
  3248. file : string;
  3249. /** . */
  3250. texture : Texture2D;
  3251. /** !#en Current quantity of particles that are being simulated.
  3252. !#zh 当前播放的粒子数量。 */
  3253. particleCount : number;
  3254. /** !#en Specify the source Blend Factor.
  3255. !#zh 指定原图混合模式。 */
  3256. srcBlendFactor : BlendFactor;
  3257. /** !#en Specify the destination Blend Factor.
  3258. !#zh 指定目标的混合模式。 */
  3259. dstBlendFactor : BlendFactor;
  3260. /** !#en If set to true, the particle system will automatically start playing on onLoad.
  3261. !#zh 如果设置为 true 运行时会自动发射粒子。 */
  3262. playOnLoad : boolean;
  3263. /** !#en Indicate whether the owner node will be auto-removed when it has no particles left.
  3264. !#zh 粒子播放完毕后自动销毁所在的节点。 */
  3265. autoRemoveOnFinish : boolean;
  3266. /** !#en Indicate whether the particle system is activated.
  3267. !#zh 是否激活粒子。 */
  3268. active : boolean;
  3269. /** !#en Maximum particles of the system.
  3270. !#zh 粒子最大数量。 */
  3271. totalParticles : number;
  3272. /** !#en How many seconds the emitter wil run. -1 means 'forever'.
  3273. !#zh 发射器生存时间,单位秒,-1表示持续发射。 */
  3274. duration : number;
  3275. /** !#en Emission rate of the particles.
  3276. !#zh 每秒发射的粒子数目。 */
  3277. emissionRate : number;
  3278. /** !#en Life of each particle setter.
  3279. !#zh 粒子的运行时间。 */
  3280. life : number;
  3281. /** !#en Variation of life.
  3282. !#zh 粒子的运行时间变化范围。 */
  3283. lifeVar : number;
  3284. /** !#en Start color of each particle.
  3285. !#zh 粒子初始颜色。 */
  3286. startColor : Color;
  3287. /** !#en Variation of the start color.
  3288. !#zh 粒子初始颜色变化范围。 */
  3289. startColorVar : Color;
  3290. /** !#en Ending color of each particle.
  3291. !#zh 粒子结束颜色。 */
  3292. endColor : Color;
  3293. /** !#en Variation of the end color.
  3294. !#zh 粒子结束颜色变化范围。 */
  3295. endColorVar : Color;
  3296. /** !#en Angle of each particle setter.
  3297. !#zh 粒子角度。 */
  3298. angle : number;
  3299. /** !#en Variation of angle of each particle setter.
  3300. !#zh 粒子角度变化范围。 */
  3301. angleVar : number;
  3302. /** !#en Start size in pixels of each particle.
  3303. !#zh 粒子的初始大小。 */
  3304. startSize : number;
  3305. /** !#en Variation of start size in pixels.
  3306. !#zh 粒子初始大小的变化范围。 */
  3307. startSizeVar : number;
  3308. /** !#en End size in pixels of each particle.
  3309. !#zh 粒子结束时的大小。 */
  3310. endSize : number;
  3311. /** !#en Variation of end size in pixels.
  3312. !#zh 粒子结束大小的变化范围。 */
  3313. endSizeVar : number;
  3314. /** !#en Start angle of each particle.
  3315. !#zh 粒子开始自旋角度。 */
  3316. startSpin : number;
  3317. /** !#en Variation of start angle.
  3318. !#zh 粒子开始自旋角度变化范围。 */
  3319. startSpinVar : number;
  3320. /** !#en End angle of each particle.
  3321. !#zh 粒子结束自旋角度。 */
  3322. endSpin : number;
  3323. /** !#en Variation of end angle.
  3324. !#zh 粒子结束自旋角度变化范围。 */
  3325. endSpinVar : number;
  3326. /** !#en Source position of the emitter.
  3327. !#zh 发射器位置。 */
  3328. sourcePos : Vec2;
  3329. /** !#en Variation of source position.
  3330. !#zh 发射器位置的变化范围。(横向和纵向) */
  3331. posVar : Vec2;
  3332. /** !#en Particles movement type.
  3333. !#zh 粒子位置类型。 */
  3334. positionType : ParticleSystem.PositionType;
  3335. /** !#en Particles emitter modes.
  3336. !#zh 发射器类型。 */
  3337. emitterMode : ParticleSystem.EmitterMode;
  3338. /** !#en Gravity of the emitter.
  3339. !#zh 重力。 */
  3340. gravity : Vec2;
  3341. /** !#en Speed of the emitter.
  3342. !#zh 速度。 */
  3343. speed : number;
  3344. /** !#en Variation of the speed.
  3345. !#zh 速度变化范围。 */
  3346. speedVar : number;
  3347. /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode.
  3348. !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */
  3349. tangentialAccel : number;
  3350. /** !#en Variation of the tangential acceleration.
  3351. !#zh 每个粒子的切向加速度变化范围。 */
  3352. tangentialAccelVar : number;
  3353. /** !#en Acceleration of each particle. Only available in 'Gravity' mode.
  3354. !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */
  3355. radialAccel : number;
  3356. /** !#en Variation of the radial acceleration.
  3357. !#zh 粒子径向加速度变化范围。 */
  3358. radialAccelVar : number;
  3359. /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode.
  3360. !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */
  3361. rotationIsDir : boolean;
  3362. /** !#en Starting radius of the particles. Only available in 'Radius' mode.
  3363. !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */
  3364. startRadius : number;
  3365. /** !#en Variation of the starting radius.
  3366. !#zh 初始半径变化范围。 */
  3367. startRadiusVar : number;
  3368. /** !#en Ending radius of the particles. Only available in 'Radius' mode.
  3369. !#zh 结束半径,只有在半径模式下可用。 */
  3370. endRadius : number;
  3371. /** !#en Variation of the ending radius.
  3372. !#zh 结束半径变化范围。 */
  3373. endRadiusVar : number;
  3374. /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
  3375. !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */
  3376. rotatePerS : number;
  3377. /** !#en Variation of the degress to rotate a particle around the source pos per second.
  3378. !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */
  3379. rotatePerSVar : number;
  3380. /** !#en The Particle emitter lives forever.
  3381. !#zh 表示发射器永久存在 */
  3382. DURATION_INFINITY : number;
  3383. /** !#en The starting size of the particle is equal to the ending size.
  3384. !#zh 表示粒子的起始大小等于结束大小。 */
  3385. START_SIZE_EQUAL_TO_END_SIZE : number;
  3386. /** !#en The starting radius of the particle is equal to the ending radius.
  3387. !#zh 表示粒子的起始半径等于结束半径。 */
  3388. START_RADIUS_EQUAL_TO_END_RADIUS : number;
  3389. /** !#en Add a particle to the emitter.
  3390. !#zh 添加一个粒子到发射器中。
  3391. */
  3392. addParticle() : boolean;
  3393. /** !#en Stop emitting particles. Running particles will continue to run until they die.
  3394. !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。
  3395. @example
  3396. ```js
  3397. // stop particle system.
  3398. myParticleSystem.stopSystem();
  3399. ```
  3400. */
  3401. stopSystem() : void;
  3402. /** !#en Kill all living particles.
  3403. !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。
  3404. @example
  3405. ```js
  3406. // play particle system.
  3407. myParticleSystem.resetSystem();
  3408. ```
  3409. */
  3410. resetSystem() : void;
  3411. /** !#en Whether or not the system is full.
  3412. !#zh 发射器中粒子是否大于等于设置的总粒子数量。
  3413. */
  3414. isFull() : boolean;
  3415. /** !#en
  3416. <p> Sets a new CCSpriteFrame as particle.</br>
  3417. WARNING: this method is experimental. Use setTextureWithRect instead.
  3418. </p>
  3419. !#zh
  3420. <p> 设置一个新的精灵帧为粒子。</br>
  3421. 警告:这个函数只是试验,请使用 setTextureWithRect 实现。
  3422. </p>
  3423. */
  3424. setDisplayFrame(spriteFrame : SpriteFrame) : void;
  3425. /** !#en Sets a new texture with a rect. The rect is in texture position and size.
  3426. !#zh 设置一张新贴图和关联的矩形。
  3427. */
  3428. setTextureWithRect(texture : Texture2D, rect : Rect) : void;
  3429. }
  3430. /** !#en cc.TMXObjectGroup represents the TMX object group.
  3431. !#zh TMXObjectGroup 用来表示 TMX 对象组。 */
  3432. export class TMXObjectGroup extends cc._Class {
  3433. /** Properties from the group. They can be added using tilemap editors. */
  3434. properties : any[];
  3435. /** Name of the group */
  3436. groupName : string;
  3437. /** <p>The cc.TMXObjectGroup's constructor. <br/>
  3438. This function will automatically be invoked when you create a node using new construction: "var node = new cc.TMXObjectGroup()".<br/>
  3439. Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
  3440. */
  3441. ctor() : void;
  3442. /** !#en Offset position of child objects.
  3443. !#zh 获取子对象的偏移位置。
  3444. @example
  3445. ```js
  3446. var offset = tMXObjectGroup.getPositionOffset();
  3447. ```
  3448. */
  3449. getPositionOffset() : Vec2;
  3450. /** !#en Offset position of child objects.
  3451. !#zh 设置子对象的偏移位置。
  3452. @example
  3453. ```js
  3454. tMXObjectGroup.setPositionOffset(cc.v2(5, 5));
  3455. ```
  3456. */
  3457. setPositionOffset(offset : Vec2) : void;
  3458. /** !#en List of properties stored in a dictionary.
  3459. !#zh 以映射的形式获取属性列表。
  3460. @example
  3461. ```js
  3462. var offset = tMXObjectGroup.getProperties();
  3463. ```
  3464. */
  3465. getProperties() : any[];
  3466. /** !#en List of properties stored in a dictionary.
  3467. !#zh 设置属性列表。
  3468. @example
  3469. ```js
  3470. tMXObjectGroup.setProperties(obj);
  3471. ```
  3472. */
  3473. setProperties(Var : any) : void;
  3474. /** !#en Gets the Group name.
  3475. !#zh 获取组名称。
  3476. @example
  3477. ```js
  3478. var groupName = tMXObjectGroup.getGroupName;
  3479. ```
  3480. */
  3481. getGroupName() : string;
  3482. /** !#en Set the Group name.
  3483. !#zh 设置组名称。
  3484. @example
  3485. ```js
  3486. tMXObjectGroup.setGroupName("New Group");
  3487. ```
  3488. */
  3489. setGroupName(groupName : string) : void;
  3490. /** !#en
  3491. Return the object for the specific object name. <br />
  3492. It will return the 1st object found on the array for the given name.
  3493. !#zh 获取指定的对象。
  3494. @example
  3495. ```js
  3496. var object = tMXObjectGroup.getObject("Group");
  3497. ```
  3498. */
  3499. getObject(objectName : string) : any;
  3500. /** !#en Gets the objects.
  3501. !#zh 获取对象数组。
  3502. @example
  3503. ```js
  3504. var objects = tMXObjectGroup.getObjects();
  3505. ```
  3506. */
  3507. getObjects() : any[];
  3508. /** !#en Set the objects.
  3509. !#zh 设置对象数组。
  3510. @example
  3511. ```js
  3512. tMXObjectGroup.setObjects(objects);
  3513. ```
  3514. */
  3515. setObjects(objects : any) : void;
  3516. }
  3517. /** !#en Render the TMX layer.
  3518. !#zh 渲染 TMX layer。 */
  3519. export class TiledLayer extends _SGComponent {
  3520. /** !#en Gets the layer name.
  3521. !#zh 获取层的名称。
  3522. @example
  3523. ```js
  3524. var layerName = tiledLayer.getLayerName();
  3525. cc.log(layerName);
  3526. ```
  3527. */
  3528. getLayerName() : string;
  3529. /** !#en Set the layer name.
  3530. !#zh 设置层的名称
  3531. @example
  3532. ```js
  3533. tiledLayer.setLayerName("New Layer");
  3534. ```
  3535. */
  3536. SetLayerName(layerName : string) : void;
  3537. /** !#en Return the value for the specific property name.
  3538. !#zh 获取指定属性名的值。
  3539. @example
  3540. ```js
  3541. var property = tiledLayer.getProperty("info");
  3542. cc.log(property);
  3543. ```
  3544. */
  3545. getProperty(propertyName : string) : any;
  3546. /** !#en Returns the position in pixels of a given tile coordinate.
  3547. !#zh 获取指定 tile 的像素坐标。
  3548. @param pos position or x
  3549. @example
  3550. ```js
  3551. var pos = tiledLayer.getPositionAt(cc.v2(0, 0));
  3552. cc.log("Pos: " + pos);
  3553. var pos = tiledLayer.getPositionAt(0, 0);
  3554. cc.log("Pos: " + pos);
  3555. ```
  3556. */
  3557. getPositionAt(pos : Vec2|number, y? : number) : Vec2;
  3558. /** !#en Removes a tile at given tile coordinate.
  3559. !#zh 删除指定坐标上的 tile。
  3560. @param pos position or x
  3561. @example
  3562. ```js
  3563. tiledLayer.removeTileAt(cc.v2(0, 0));
  3564. tiledLayer.removeTileAt(0, 0);
  3565. ```
  3566. */
  3567. removeTileAt(pos : Vec2|number, y? : number) : void;
  3568. /** !#en
  3569. Sets the tile gid (gid = tile global id) at a given tile coordinate.<br />
  3570. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.<br />
  3571. If a tile is already placed at that position, then it will be removed.
  3572. !#zh
  3573. 设置给定坐标的 tile 的 gid (gid = tile 全局 id),
  3574. tile 的 GID 可以使用方法 “tileGIDAt” 来获得。<br />
  3575. 如果一个 tile 已经放在那个位置,那么它将被删除。
  3576. @param posOrX position or x
  3577. @param flagsOrY flags or y
  3578. @example
  3579. ```js
  3580. tiledLayer.setTileGID(1001, 10, 10, 1)
  3581. ```
  3582. */
  3583. setTileGID(gid : number, posOrX : Vec2|number, flagsOrY : number, flags? : number) : void;
  3584. /** !#en
  3585. Returns the tile gid at a given tile coordinate. <br />
  3586. if it returns 0, it means that the tile is empty. <br />
  3587. This method requires the the tile map has not been previously released (eg. don't call layer.releaseMap())<br />
  3588. !#zh
  3589. 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID. <br />
  3590. 如果它返回 0,则表示该 tile 为空。<br />
  3591. 该方法要求 tile 地图之前没有被释放过(如:没有调用过layer.releaseMap()).
  3592. @param pos or x
  3593. @example
  3594. ```js
  3595. var tileGid = tiledLayer.getTileGIDAt(0, 0);
  3596. ```
  3597. */
  3598. getTileGIDAt(pos : Vec2|number, y? : number) : number;
  3599. /** !#en
  3600. Returns the tile (_ccsg.Sprite) at a given a tile coordinate. <br/>
  3601. The returned _ccsg.Sprite will be already added to the _ccsg.TMXLayer. Don't add it again.<br/>
  3602. The _ccsg.Sprite can be treated like any other _ccsg.Sprite: rotated, scaled, translated, opacity, color, etc. <br/>
  3603. You can remove either by calling: <br/>
  3604. - layer.removeChild(sprite, cleanup); <br/>
  3605. - or layer.removeTileAt(ccp(x,y));
  3606. !#zh
  3607. 通过指定的 tile 坐标获取对应的 tile(Sprite)。 返回的 tile(Sprite) 应是已经添加到 TMXLayer,请不要重复添加。<br/>
  3608. 这个 tile(Sprite) 如同其他的 Sprite 一样,可以旋转、缩放、翻转、透明化、设置颜色等。<br/>
  3609. 你可以通过调用以下方法来对它进行删除:<br/>
  3610. 1. layer.removeChild(sprite, cleanup);<br/>
  3611. 2. 或 layer.removeTileAt(cc.v2(x,y));
  3612. @param pos or x
  3613. @example
  3614. ```js
  3615. var title = tiledLayer.getTileAt(100, 100);
  3616. cc.log(title);
  3617. ```
  3618. */
  3619. getTileAt(pos : Vec2|number, y? : number) : _ccsg.Sprite;
  3620. /** !#en
  3621. Dealloc the map that contains the tile position from memory. <br />
  3622. Unless you want to know at runtime the tiles positions, you can safely call this method. <br />
  3623. If you are going to call layer.getTileGIDAt() then, don't release the map.
  3624. !#zh
  3625. 从内存中释放包含 tile 位置信息的地图。<br />
  3626. 除了在运行时想要知道 tiles 的位置信息外,你都可安全的调用此方法。<br />
  3627. 如果你之后还要调用 layer.tileGIDAt(), 请不要释放地图.
  3628. @example
  3629. ```js
  3630. tiledLayer.releaseMap();
  3631. ```
  3632. */
  3633. releaseMap() : void;
  3634. /** !#en Sets the untransformed size of the _ccsg.TMXLayer.
  3635. !#zh 设置未转换的 layer 大小。
  3636. @param size The untransformed size of the _ccsg.TMXLayer or The untransformed size's width of the TMXLayer.
  3637. @param height The untransformed size's height of the _ccsg.TMXLayer.
  3638. @example
  3639. ```js
  3640. tiledLayer.setContentSize(100, 100);
  3641. ```
  3642. */
  3643. setContentSize(size : Size|number, height? : number) : void;
  3644. /** !#en Return texture of cc.SpriteBatchNode.
  3645. !#zh 获取纹理。
  3646. @example
  3647. ```js
  3648. var texture = tiledLayer.getTexture();
  3649. cc.log("Texture: " + texture);
  3650. ```
  3651. */
  3652. getTexture() : Texture2D;
  3653. /** !#en Set the texture of cc.SpriteBatchNode.
  3654. !#zh 设置纹理。
  3655. @example
  3656. ```js
  3657. tiledLayer.setTexture(texture);
  3658. ```
  3659. */
  3660. setTexture(texture : Texture2D) : void;
  3661. /** !#en Set the opacity of all tiles
  3662. !#zh 设置所有 Tile 的透明度
  3663. @example
  3664. ```js
  3665. tiledLayer.setTileOpacity(128);
  3666. ```
  3667. */
  3668. setTileOpacity(opacity : number) : void;
  3669. /** !#en Gets layer size.
  3670. !#zh 获得层大小。
  3671. @example
  3672. ```js
  3673. var size = tiledLayer.getLayerSize();
  3674. cc.log("layer size: " + size);
  3675. ```
  3676. */
  3677. getLayerSize() : Size;
  3678. /** !#en Set layer size.
  3679. !#zh 设置层大小。
  3680. @example
  3681. ```js
  3682. tiledLayer.setLayerSize(new cc.size(5, 5));
  3683. ```
  3684. */
  3685. setLayerSize(layerSize : Size) : void;
  3686. /** !#en Size of the map's tile (could be different from the tile's size).
  3687. !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。
  3688. @example
  3689. ```js
  3690. var mapTileSize = tiledLayer.getMapTileSize();
  3691. cc.log("MapTile size: " + mapTileSize);
  3692. ```
  3693. */
  3694. getMapTileSize() : Size;
  3695. /** !#en Set the map tile size.
  3696. !#zh 设置 tile 的大小。
  3697. @example
  3698. ```js
  3699. tiledLayer.setMapTileSize(new cc.size(10, 10));
  3700. ```
  3701. */
  3702. setMapTileSize(tileSize : Size) : void;
  3703. /** !#en Pointer to the map of tiles.
  3704. !#zh 获取地图 tiles。
  3705. @example
  3706. ```js
  3707. var tiles = tiledLayer.getTiles();
  3708. ```
  3709. */
  3710. getTiles() : any[];
  3711. /** !#en Pointer to the map of tiles.
  3712. !#zh 设置地图 tiles
  3713. @example
  3714. ```js
  3715. tiledLayer.setTiles(tiles);
  3716. ```
  3717. */
  3718. setTiles(tiles : any[]) : void;
  3719. /** !#en Tile set information for the layer.
  3720. !#zh 获取 layer 的 Tileset 信息。
  3721. @example
  3722. ```js
  3723. var tileset = tiledLayer.getTileSet();
  3724. ```
  3725. */
  3726. getTileSet() : TMXTilesetInfo;
  3727. /** !#en Tile set information for the layer.
  3728. !#zh 设置 layer 的 Tileset 信息。
  3729. @example
  3730. ```js
  3731. tiledLayer.setTileSet(tileset);
  3732. ```
  3733. */
  3734. setTileSet(tileset : TMXTilesetInfo) : void;
  3735. /** !#en Layer orientation, which is the same as the map orientation.
  3736. !#zh 获取 Layer 方向(同地图方向)。
  3737. @example
  3738. ```js
  3739. var orientation = tiledLayer.getLayerOrientation();
  3740. cc.log("Layer Orientation: " + orientation);
  3741. ```
  3742. */
  3743. getLayerOrientation() : number;
  3744. /** !#en Layer orientation, which is the same as the map orientation.
  3745. !#zh 设置 Layer 方向(同地图方向)。
  3746. @example
  3747. ```js
  3748. tiledLayer.setLayerOrientation(TiledMap.Orientation.ORTHO);
  3749. ```
  3750. */
  3751. setLayerOrientation(orientation : TiledMap.Orientation) : void;
  3752. /** !#en properties from the layer. They can be added using Tiled.
  3753. !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。
  3754. @example
  3755. ```js
  3756. var properties = tiledLayer.getProperties();
  3757. cc.log("Properties: " + properties);
  3758. ```
  3759. */
  3760. getProperties() : any[];
  3761. /** !#en properties from the layer. They can be added using Tiled.
  3762. !#zh 设置层属性。
  3763. @example
  3764. ```js
  3765. tiledLayer.setLayerOrientation(properties);
  3766. ```
  3767. */
  3768. setProperties(properties : any[]) : void;
  3769. }
  3770. /** !#en Renders a TMX Tile Map in the scene.
  3771. !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */
  3772. export class TiledMap extends Component {
  3773. /** !#en The TiledMap Asset.
  3774. !#zh TiledMap 资源。 */
  3775. tmxAsset : cc.TiledMapAsset;
  3776. /** !#en Gets the map size.
  3777. !#zh 获取地图大小。
  3778. @example
  3779. ```js
  3780. var mapSize = tiledMap.getMapSize();
  3781. cc.log("Map Size: " + mapSize);
  3782. ```
  3783. */
  3784. getMapSize() : Size;
  3785. /** !#en Set the map size.
  3786. !#zh 设置地图大小。
  3787. @example
  3788. ```js
  3789. tiledMap.setMapSize(new cc.size(960, 640));
  3790. ```
  3791. */
  3792. setMapSize(mapSize : Size) : void;
  3793. /** !#en Gets the tile size.
  3794. !#zh 获取地图背景中 tile 元素的大小。
  3795. @example
  3796. ```js
  3797. var tileSize = tiledMap.getTileSize();
  3798. cc.log("Tile Size: " + tileSize);
  3799. ```
  3800. */
  3801. getTileSize() : Size;
  3802. /** !#en Set the tile size.
  3803. !#zh 设置地图背景中 tile 元素的大小。
  3804. @example
  3805. ```js
  3806. tiledMap.setTileSize(new cc.size(10, 10));
  3807. ```
  3808. */
  3809. setTileSize(tileSize : Size) : void;
  3810. /** !#en map orientation.
  3811. !#zh 获取地图方向。
  3812. @example
  3813. ```js
  3814. var mapOrientation = tiledMap.getMapOrientation();
  3815. cc.log("Map Orientation: " + mapOrientation);
  3816. ```
  3817. */
  3818. getMapOrientation() : number;
  3819. /** !#en map orientation.
  3820. !#zh 设置地图方向。
  3821. @example
  3822. ```js
  3823. tiledMap.setMapOrientation(TiledMap.Orientation.ORTHO);
  3824. ```
  3825. */
  3826. setMapOrientation(orientation : TiledMap.Orientation) : void;
  3827. /** !#en object groups.
  3828. !#zh 获取所有的对象层。
  3829. @example
  3830. ```js
  3831. var objGroups = titledMap.getObjectGroups();
  3832. for (var i = 0; i < objGroups.length; ++i) {
  3833. cc.log("obj: " + objGroups[i]);
  3834. }
  3835. ```
  3836. */
  3837. getObjectGroups() : any[];
  3838. /** !#en object groups.
  3839. !#zh 设置所有的对象层。
  3840. @example
  3841. ```js
  3842. titledMap.setObjectGroups(groups);
  3843. ```
  3844. */
  3845. setObjectGroups(groups : any[]) : void;
  3846. /** !#en Gets the map properties.
  3847. !#zh 获取地图的属性。
  3848. @example
  3849. ```js
  3850. var properties = titledMap.getProperties();
  3851. for (var i = 0; i < properties.length; ++i) {
  3852. cc.log("Properties: " + properties[i]);
  3853. }
  3854. ```
  3855. */
  3856. getProperties() : any[];
  3857. /** !#en Set the map properties.
  3858. !#zh 设置地图的属性。
  3859. @example
  3860. ```js
  3861. titledMap.setProperties(properties);
  3862. ```
  3863. */
  3864. setProperties(properties : any[]) : void;
  3865. /** !#en Return All layers array.
  3866. !#zh 返回包含所有 layer 的数组。
  3867. @example
  3868. ```js
  3869. var layers = titledMap.allLayers();
  3870. for (var i = 0; i < layers.length; ++i) {
  3871. cc.log("Layers: " + layers[i]);
  3872. }
  3873. ```
  3874. */
  3875. allLayers() : Node[];
  3876. /** !#en return the cc.TiledLayer for the specific layer.
  3877. !#zh 获取指定名称的 layer。
  3878. @example
  3879. ```js
  3880. var layer = titledMap.getLayer("Player");
  3881. cc.log(layer);
  3882. ```
  3883. */
  3884. getLayer(layerName : string) : TiledLayer;
  3885. /** !#en Return the TMXObjectGroup for the specific group.
  3886. !#zh 获取指定的 TMXObjectGroup。
  3887. @example
  3888. ```js
  3889. var group = titledMap.getObjectGroup("Players");
  3890. cc.log("ObjectGroup: " + group);
  3891. ```
  3892. */
  3893. getObjectGroup(groupName : string) : TMXObjectGroup;
  3894. /** !#en Return the value for the specific property name.
  3895. !#zh 通过属性名称,获取指定的属性。
  3896. @example
  3897. ```js
  3898. var property = titledMap.getProperty("info");
  3899. cc.log("Property: " + property);
  3900. ```
  3901. */
  3902. getProperty(propertyName : string) : string;
  3903. /** !#en Return properties dictionary for tile GID.
  3904. !#zh 通过 GID ,获取指定的属性。
  3905. @example
  3906. ```js
  3907. var properties = titledMap.getPropertiesForGID(GID);
  3908. cc.log("Properties: " + properties);
  3909. ```
  3910. */
  3911. getPropertiesForGID(GID : number) : any;
  3912. }
  3913. /** Class for tiled map asset handling. */
  3914. export class TiledMapAsset extends Asset {
  3915. constructor();
  3916. }
  3917. /** !#en
  3918. cc.NodePool is the cache pool designed for node type.<br/>
  3919. It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  3920. It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class,
  3921. for example, a prefab is a specific node type. <br/>
  3922. When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.<br/>
  3923. Some common use case is :<br/>
  3924. 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)<br/>
  3925. 2. Blocks in candy crash (massive creation and recreation)<br/>
  3926. etc...
  3927. !#zh
  3928. cc.NodePool 是用于管理节点对象的对象缓存池。<br/>
  3929. 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁<br/>
  3930. 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。
  3931. 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。<br/>
  3932. 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。<br/>
  3933. 一些常见的用例是:<br/>
  3934. 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)<br/>
  3935. 2.糖果粉碎传奇中的木块(频繁创建)。
  3936. 等等.... */
  3937. export class NodePool {
  3938. /** !#en
  3939. Constructor for creating a pool for a specific node template (usually a prefab). You can pass a component (type or name) argument for handling event for reusing and recycling node.
  3940. !#zh
  3941. 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。
  3942. @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。
  3943. @example
  3944. ```js
  3945. properties: {
  3946. template: cc.Prefab
  3947. },
  3948. onLoad () {
  3949. // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled.
  3950. this.myPool = new cc.NodePool('MyTemplateHandler');
  3951. }
  3952. ```
  3953. */
  3954. NodePool(poolHandlerComp : [Function|String]) : void;
  3955. /** !#en The pool handler component, it could be the class name or the constructor.
  3956. !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */
  3957. poolHandlerComp : Function|string;
  3958. /** !#en The current available size in the pool
  3959. !#zh 获取当前缓冲池的可用对象数量
  3960. */
  3961. size() : void;
  3962. /** !#en Destroy all cached nodes in the pool
  3963. !#zh 销毁对象池中缓存的所有节点
  3964. */
  3965. clear() : void;
  3966. /** !#en Put a new Node into the pool.
  3967. It will automatically remove the node from its parent without cleanup.
  3968. It will also invoke unuse method of the poolHandlerComp if exist.
  3969. !#zh 向缓冲池中存入一个不再需要的节点对象。
  3970. 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。
  3971. 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。
  3972. @example
  3973. ```js
  3974. let myNode = cc.instantiate(this.template);
  3975. this.myPool.put(myNode);
  3976. ```
  3977. */
  3978. put() : void;
  3979. /** !#en Get a obj from pool, if no available object in pool, null will be returned.
  3980. This function will invoke the reuse function of poolHandlerComp if exist.
  3981. !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。
  3982. 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。
  3983. @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数
  3984. @example
  3985. ```js
  3986. let newNode = this.myPool.get();
  3987. ```
  3988. */
  3989. get(params : any) : any;
  3990. }
  3991. /** !#en
  3992. Attention: In creator, it's strongly not recommended to use cc.pool to manager cc.Node.
  3993. We provided {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} instead.
  3994. cc.pool is a singleton object serves as an object cache pool.<br/>
  3995. It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  3996. !#zh
  3997. 首先请注意,在 Creator 中我们强烈不建议使用 cc.pool 来管理 cc.Node 节点对象,请使用 {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} 代替
  3998. 因为 cc.pool 是面向类来设计的,而 cc.Node 中使用 Component 来进行组合,它的类永远都一样,实际却千差万别。
  3999. cc.pool 是一个单例对象,用作为对象缓存池。<br/>
  4000. 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁<br/> */
  4001. export class pool {
  4002. /** !#en Put the obj in pool.
  4003. !#zh 加入对象到对象池中。
  4004. @param obj The need put in pool object.
  4005. @example
  4006. ```js
  4007. ---------------------------------
  4008. var sp = new _ccsg.Sprite("a.png");
  4009. this.addChild(sp);
  4010. cc.pool.putInPool(sp);
  4011. cc.pool.getFromPool(_ccsg.Sprite, "a.png");
  4012. ```
  4013. */
  4014. putInPool(obj : any) : void;
  4015. /** !#en Check if this kind of obj has already in pool.
  4016. !#zh 检查对象池中是否有指定对象的存在。
  4017. @param objClass The check object class.
  4018. */
  4019. hasObject(objClass : any) : boolean;
  4020. /** !#en Remove the obj if you want to delete it.
  4021. !#zh 移除在对象池中指定的对象。
  4022. */
  4023. removeObject() : void;
  4024. /** !#en Get the obj from pool.
  4025. !#zh 获取对象池中的指定对象。
  4026. */
  4027. getFromPool() : any;
  4028. /** !#en Remove all objs in pool and reset the pool.
  4029. !#zh 移除对象池中的所有对象,并且重置对象池。
  4030. */
  4031. drainAllPools() : void;
  4032. }
  4033. /** !#en Box Collider.
  4034. !#zh 包围盒碰撞组件 */
  4035. export class BoxCollider extends Component {
  4036. /** !#en Position offset
  4037. !#zh 位置偏移量 */
  4038. offset : Vec2;
  4039. /** !#en Box size
  4040. !#zh 包围盒大小 */
  4041. size : Size;
  4042. }
  4043. /** !#en Circle Collider.
  4044. !#zh 圆形碰撞组件 */
  4045. export class CircleCollider extends Component {
  4046. /** !#en Position offset
  4047. !#zh 位置偏移量 */
  4048. offset : Vec2;
  4049. /** !#en Circle radius
  4050. !#zh 圆形半径 */
  4051. radius : number;
  4052. }
  4053. /** !#en Collider component base class.
  4054. !#zh 碰撞组件基类 */
  4055. export class Collider extends Component {
  4056. /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag.
  4057. !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */
  4058. tag : Integer;
  4059. }
  4060. /** !#en
  4061. A simple collision manager class.
  4062. It will calculate whether the collider collides other colliders, if collides then call the callbacks.
  4063. !#zh
  4064. 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */
  4065. export class CollisionManager {
  4066. /** !#en
  4067. !#zh
  4068. 是否开启碰撞管理,默认为不开启 */
  4069. enabled : boolean;
  4070. /** !#en
  4071. !#zh
  4072. 是否绘制碰撞组件的包围盒,默认为不绘制 */
  4073. enabledDrawBoundingBox : boolean;
  4074. /** !#en
  4075. !#zh
  4076. 是否绘制碰撞组件的形状,默认为不绘制 */
  4077. enabledDebugDraw : boolean;
  4078. }
  4079. /** !#en Intersection helper class
  4080. !#zh 辅助类,用于测试形状与形状是否相交 */
  4081. export class Intersection {
  4082. /** !#en Test line and line
  4083. !#zh 测试线段与线段是否相交
  4084. @param a1 The start point of the first line
  4085. @param a2 The end point of the first line
  4086. @param b1 The start point of the second line
  4087. @param b2 The end point of the second line
  4088. */
  4089. lineLine(a1 : Vec2, a2 : Vec2, b1 : Vec2, b2 : Vec2) : boolean;
  4090. /** !#en Test line and rect
  4091. !#zh 测试线段与矩形是否相交
  4092. @param a1 The start point of the line
  4093. @param a2 The end point of the line
  4094. @param b The rect
  4095. */
  4096. lineRect(a1 : Vec2, a2 : Vec2, b : Rect) : boolean;
  4097. /** !#en Test line and polygon
  4098. !#zh 测试线段与多边形是否相交
  4099. @param a1 The start point of the line
  4100. @param a2 The end point of the line
  4101. @param b The polygon, a set of points
  4102. */
  4103. linePolygon(a1 : Vec2, a2 : Vec2, b : [Vec2]) : boolean;
  4104. /** !#en Test rect and rect
  4105. !#zh 测试矩形与矩形是否相交
  4106. @param a The first rect
  4107. @param b The second rect
  4108. */
  4109. rectRect(a : Rect, b : Rect) : boolean;
  4110. /** !#en Test rect and polygon
  4111. !#zh 测试矩形与多边形是否相交
  4112. @param a The rect
  4113. @param b The polygon, a set of points
  4114. */
  4115. rectPolygon(a : Rect, b : [Vec2]) : boolean;
  4116. /** !#en Test polygon and polygon
  4117. !#zh 测试多边形与多边形是否相交
  4118. @param a The first polygon, a set of points
  4119. @param b The second polygon, a set of points
  4120. */
  4121. polygonPolygon(a : [Vec2], b : [Vec2]) : boolean;
  4122. /** !#en Test circle and circle
  4123. !#zh 测试圆形与圆形是否相交
  4124. @param a Object contains position and radius
  4125. @param b Object contains position and radius
  4126. */
  4127. circleCircle(a : any, b : any) : boolean;
  4128. /** !#en Test polygon and circle
  4129. !#zh 测试矩形与圆形是否相交
  4130. @param polygon The Polygon, a set of points
  4131. @param circle Object contains position and radius
  4132. */
  4133. polygonCircle(polygon : [Vec2], circle : any) : boolean;
  4134. /** !#en Test whether the point is in the polygon
  4135. !#zh 测试一个点是否在一个多边形中
  4136. @param point The point
  4137. @param polygon The polygon, a set of points
  4138. */
  4139. pointInPolygon(point : Vec2, polygon : [Vec2]) : boolean;
  4140. /** !#en Calculate the distance of point to line.
  4141. !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。
  4142. @param point The point
  4143. @param start The start point of line
  4144. @param end The end point of line
  4145. @param isSegment whether this line is a segment
  4146. */
  4147. pointLineDistance(point : Vec2, start : Vec2, end : Vec2, isSegment : boolean) : boolean;
  4148. }
  4149. /** !#en Polygon Collider.
  4150. !#zh 多边形碰撞组件 */
  4151. export class PolygonCollider extends Component {
  4152. /** !#en Position offset
  4153. !#zh 位置偏移量 */
  4154. offset : Vec2;
  4155. /** !#en Polygon points
  4156. !#zh 多边形顶点数组 */
  4157. points : [Vec2];
  4158. }
  4159. /** !#en
  4160. Base class for handling assets used in Fireball. This class can be instantiate.
  4161. You may want to override:<br/>
  4162. - createNode<br/>
  4163. - cc.Object._serialize<br/>
  4164. - cc.Object._deserialize<br/>
  4165. !#zh
  4166. 资源基类,该类可以被实例化。<br/>
  4167. 您可能需要重写:<br/>
  4168. - createNode <br/>
  4169. - cc.Object._serialize<br/>
  4170. - cc.Object._deserialize<br/> */
  4171. export class Asset extends RawAsset {
  4172. constructor();
  4173. /** !#en
  4174. Returns the url of this asset's first raw file, if none of rawFile exists,
  4175. it will returns an empty string.
  4176. !#zh 返回该资源的原始文件的 URL,如果不支持 RAW 文件,它将返回一个空字符串。 */
  4177. rawUrl : string;
  4178. /** !#en
  4179. Returns the url of this asset's raw files, if none of rawFile exists,
  4180. it will returns an empty array.
  4181. !#zh 返回该资源的原文件的 URL 数组,如果不支持 RAW 文件,它将返回一个空数组。 */
  4182. rawUrls : String[];
  4183. /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene is marked as `asyncLoadAssets`.
  4184. !#zh 当场景被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它 RawAsset。 */
  4185. preventDeferredLoadDependents : boolean;
  4186. /** !#en
  4187. Create a new node using this asset in the scene.<br/>
  4188. If this type of asset dont have its corresponding node type, this method should be null.
  4189. !#zh
  4190. 使用该资产在场景中创建一个新节点。<br/>
  4191. 如果这类资产没有相应的节点类型,该方法应该是空的。
  4192. */
  4193. createNode(callback: (error: string, node: any) => void) : void;
  4194. }
  4195. /** !#en Class for audio data handling.
  4196. !#zh 音频资源类。 */
  4197. export class AudioClip extends RawAsset {
  4198. constructor();
  4199. }
  4200. /** !#en Class for BitmapFont handling.
  4201. !#zh 位图字体资源类。 */
  4202. export class BitmapFont extends RawAsset {
  4203. constructor();
  4204. }
  4205. /** !#en Class for Font handling.
  4206. !#zh 字体资源类。 */
  4207. export class Font extends RawAsset {
  4208. constructor();
  4209. }
  4210. /** !#en Class for prefab handling.
  4211. !#zh 预制资源类。 */
  4212. export class Prefab extends Asset {
  4213. constructor();
  4214. }
  4215. /** !#en
  4216. The base class for registering asset types.
  4217. You may want to override:
  4218. - createNode (static)
  4219. !#zh
  4220. 注册用的资源基类。<br/>
  4221. 你可能要重写:<br/>
  4222. - createNode (static) */
  4223. export class RawAsset extends CCObject {
  4224. /** !#en
  4225. Create a new node in the scene.<br/>
  4226. If this type of asset dont have its corresponding node type, this method should be null.
  4227. !#zh
  4228. 在场景中创建一个新节点。<br/>
  4229. 如果这类资源没有相应的节点类型,该方法应该是空的。
  4230. */
  4231. createNodeByInfo(Info : any, callback: (error: string, node: any) => void) : void;
  4232. }
  4233. /** !#en Class for scene handling.
  4234. !#zh 场景资源类。 */
  4235. export class SceneAsset extends Asset {
  4236. constructor();
  4237. scene : cc.Scene;
  4238. /** !#en Indicates the raw assets of this scene can be load after scene launched.
  4239. !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */
  4240. asyncLoadAssets : boolean;
  4241. }
  4242. /** !#en Class for script handling.
  4243. !#zh Script 资源类。 */
  4244. export class _Script extends Asset {
  4245. constructor();
  4246. }
  4247. /** !#en Class for JavaScript handling.
  4248. !#zh JavaScript 资源类。 */
  4249. export class _JavaScript extends Asset {
  4250. constructor();
  4251. }
  4252. /** !#en Class for coffee script handling.
  4253. !#zh CoffeeScript 资源类。 */
  4254. export class CoffeeScript extends Asset {
  4255. constructor();
  4256. }
  4257. /** !#en Class for sprite atlas handling.
  4258. !#zh 精灵图集资源类。 */
  4259. export class SpriteAtlas extends RawAsset {
  4260. constructor();
  4261. /** Returns the texture of the sprite atlas
  4262. */
  4263. getTexture() : cc.Texture2D;
  4264. /** Returns the sprite frame correspond to the given key in sprite atlas.
  4265. */
  4266. getSpriteFrame(key : string) : SpriteFrame;
  4267. /** Returns the sprite frames in sprite atlas.
  4268. */
  4269. getSpriteFrames() : [SpriteFrame];
  4270. }
  4271. /** !#en Class for TTFFont handling.
  4272. !#zh TTF 字体资源类。 */
  4273. export class TTFFont extends Asset {
  4274. constructor();
  4275. }
  4276. /** !#en Class for text file.
  4277. !#zh 文本资源类。 */
  4278. export class TextAsset extends Asset {
  4279. constructor();
  4280. }
  4281. /** !#en The animation component is used to play back animations.
  4282. Animation provide several events to register:
  4283. - play : Emit when egine playing animation
  4284. - stop : Emit when stop playing animation
  4285. - pause : Emit when pause animation
  4286. - resume : Emit when resume animation
  4287. - lastframe : If animation repeat coutn is larger than 1, emit when animation play to the last frame
  4288. - finished : Emit when finish playing animation
  4289. !#zh Animation 组件用于播放动画。你能指定动画剪辑到动画组件并从脚本控制播放。
  4290. Animation 提供了一系列可注册的事件:
  4291. - play : 开始播放时
  4292. - stop : 停止播放时
  4293. - pause : 暂停播放时
  4294. - resume : 恢复播放时
  4295. - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时
  4296. - finished : 动画播放完成时 */
  4297. export class Animation extends CCComponent {
  4298. /** !#en Animation will play the default clip when start game.
  4299. !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */
  4300. defaultClip : AnimationClip;
  4301. /** !#en Current played clip.
  4302. !#zh 当前播放的动画剪辑。 */
  4303. currentClip : AnimationClip;
  4304. /** !#en Whether the animation should auto play the default clip when start game.
  4305. !#zh 是否在运行游戏后自动播放默认动画剪辑。 */
  4306. playOnLoad : boolean;
  4307. /** !#en Get all the clips used in this animation.
  4308. !#zh 获取动画组件上的所有动画剪辑。
  4309. */
  4310. getClips() : AnimationClip[];
  4311. /** !#en Plays an animation and stop other animations.
  4312. !#zh 播放当前或者指定的动画,并且停止当前正在播放动画。
  4313. @param name The name of animation to play. If no name is supplied then the default animation will be played.
  4314. @param startTime play an animation from startTime
  4315. @example
  4316. ```js
  4317. var animCtrl = this.node.getComponent(cc.Animation);
  4318. animCtrl.play("linear");
  4319. ```
  4320. */
  4321. play(name? : string, startTime? : number) : AnimationState;
  4322. /** !#en
  4323. Plays an additive animation, it will not stop other animations.
  4324. If there are other animations playing, then will play several animations at the same time.
  4325. !#zh 播放当前或者指定的动画(将不会停止当前播放的动画)。
  4326. @param name The name of animation to play. If no name is supplied then the default animation will be played.
  4327. @param startTime play an animation from startTime
  4328. @example
  4329. ```js
  4330. // linear_1 and linear_2 at the same time playing.
  4331. var animCtrl = this.node.getComponent(cc.Animation);
  4332. animCtrl.playAdditive("linear_1");
  4333. animCtrl.playAdditive("linear_2");
  4334. ```
  4335. */
  4336. playAdditive(name? : string, startTime? : number) : AnimationState;
  4337. /** !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation. <br/>
  4338. Stopping an animation also Rewinds it to the Start.
  4339. !#zh 停止当前或者指定的动画。如果没有指定名字,则停止所有动画。
  4340. @param name The animation to stop, if not supplied then stops all playing animations.
  4341. */
  4342. stop(name? : string) : void;
  4343. /** !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation.
  4344. !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。
  4345. @param name The animation to pauses, if not supplied then pauses all playing animations.
  4346. */
  4347. pause(name? : string) : void;
  4348. /** !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation.
  4349. !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。
  4350. @param name The animation to resumes, if not supplied then resumes all paused animations.
  4351. */
  4352. resume(name? : string) : void;
  4353. /** !#en Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time.
  4354. !#zh 设置指定动画的播放时间。如果没有指定名字,则设置所有动画的播放时间。
  4355. @param time The time to go to
  4356. @param name Specified animation name, if not supplied then make all animations go to the time.
  4357. */
  4358. setCurrentTime(time? : number, name? : string) : void;
  4359. /** !#en Returns the animation state named name. If no animation with the specified name, the function will return null.
  4360. !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。
  4361. */
  4362. getAnimationState(name : string) : AnimationState;
  4363. /** !#en Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip.
  4364. !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。
  4365. @param clip the clip to add
  4366. */
  4367. addClip(clip : AnimationClip, newName? : string) : AnimationState;
  4368. /** !#en
  4369. Remove clip from the animation list. This will remove the clip and any animation states based on it.
  4370. If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip.
  4371. But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null
  4372. !#zh
  4373. 从动画列表中移除指定的动画剪辑,<br/>
  4374. 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。
  4375. 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。
  4376. @param force If force is true, then will always remove the clip and any animation states based on it.
  4377. */
  4378. removeClip(clip : AnimationClip, force : boolean) : void;
  4379. /** !#en
  4380. Samples animations at the current state.<br/>
  4381. This is useful when you explicitly want to set up some animation state, and sample it once.
  4382. !#zh 对当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。
  4383. */
  4384. sample() : void;
  4385. /** !#en
  4386. Register animation event callback.
  4387. The event argumetns will provide the AnimationState which emit the event.
  4388. When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped.
  4389. !#zh
  4390. 注册动画事件回调。
  4391. 回调的事件里将会附上发送事件的 AnimationState。
  4392. 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。
  4393. @param type A string representing the event type to listen for.
  4394. @param callback The callback that will be invoked when the event is dispatched.
  4395. The callback is ignored if it is a duplicate (the callbacks are unique).
  4396. @param target The target to invoke the callback, can be null
  4397. @param useCapture When set to true, the capture argument prevents callback
  4398. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  4399. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  4400. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  4401. @example
  4402. ```js
  4403. onPlay: function (event) {
  4404. var state = event.detail; // state instanceof cc.AnimationState
  4405. var type = event.type; // type === 'play';
  4406. }
  4407. // register event to all animation
  4408. animation.on('', 'play', this.onPlay, this);
  4409. ```
  4410. */
  4411. on(type : string, callback: (param: Event) => void, target : any, useCapture : boolean) : void;
  4412. /** !#en
  4413. Unregister animation event callback.
  4414. !#zh
  4415. 取消注册动画事件回调。
  4416. @param type A string representing the event type being removed.
  4417. @param callback The callback to remove.
  4418. @param target The target to invoke the callback, if it's not given, only callback without target will be removed
  4419. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  4420. If not specified, useCapture defaults to false. If a callback was registered twice,
  4421. one with capture and one without, each must be removed separately. Removal of a capturing callback
  4422. does not affect a non-capturing version of the same listener, and vice versa.
  4423. @example
  4424. ```js
  4425. // unregister event to all animation
  4426. animation.off('', 'play', this.onPlay, this);
  4427. ```
  4428. */
  4429. off(type : string, callback : Function, target : any, useCapture : boolean) : void;
  4430. }
  4431. /** !#en Audio Source.
  4432. !#zh 音频源组件,能对音频剪辑。 */
  4433. export class AudioSource extends Component {
  4434. /** !#en
  4435. Is the audio source playing (Read Only). <br/>
  4436. Note: isPlaying is not supported for Native platforms.
  4437. !#zh
  4438. 该音频剪辑是否正播放(只读)。<br/>
  4439. 注意:Native 平台暂时不支持 isPlaying。 */
  4440. isPlaying : boolean;
  4441. /** !#en The clip of the audio source.
  4442. !#zh 默认要播放的音频剪辑。 */
  4443. clip : AudioClip;
  4444. /** !#en The volume of the audio source.
  4445. !#zh 音频源的音量(0.0 ~ 1.0)。 */
  4446. volume : number;
  4447. /** !#en Is the audio source mute?
  4448. !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */
  4449. mute : boolean;
  4450. /** !#en Is the audio source looping?
  4451. !#zh 音频源是否循环播放? */
  4452. loop : boolean;
  4453. /** !#en If set to true, the audio source will automatically start playing on onLoad.
  4454. !#zh 如果设置为true,音频源将在 onLoad 时自动播放。 */
  4455. playOnLoad : boolean;
  4456. /** !#en Plays the clip.
  4457. !#zh 播放音频剪辑。
  4458. */
  4459. play() : void;
  4460. /** !#en Stops the clip.
  4461. !#zh 停止当前音频剪辑。
  4462. */
  4463. stop() : void;
  4464. /** !#en Pause the clip.
  4465. !#zh 暂停当前音频剪辑。
  4466. */
  4467. pause() : void;
  4468. /** !#en Resume the clip.
  4469. !#zh 恢复播放。
  4470. */
  4471. resume() : void;
  4472. /** !#en Rewind playing music.
  4473. !#zh 从头开始播放。
  4474. */
  4475. rewind() : void;
  4476. }
  4477. /** !#en
  4478. Button has 3 Transition types
  4479. When Button state changed:
  4480. If Transition type is Button.Transition.NONE, Button will do nothing
  4481. If Transition type is Button.Transition.COLOR, Button will change target's color
  4482. If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
  4483. Button will trigger 5 events:
  4484. Button.EVENT_TOUCH_DOWN
  4485. Button.EVENT_TOUCH_UP
  4486. Button.EVENT_HOVER_IN
  4487. Button.EVENT_HOVER_MOVE
  4488. Button.EVENT_HOVER_OUT
  4489. !#zh
  4490. 按钮组件。可以被按下,或者点击。</br>
  4491. 按钮可以通过修改 Transition 来设置按钮状态过渡的方式:</br>
  4492. -Button.Transition.NONE // 不做任何过渡</br>
  4493. -Button.Transition.COLOR // 进行颜色之间过渡</br>
  4494. -Button.Transition.SPRITE // 进行精灵之间过渡</br>
  4495. 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):</br>
  4496. // 以下事件可以在全平台上都触发</br>
  4497. -cc.Node.EventType.TOUCH_START // 按下时事件</br>
  4498. -cc.Node.EventType.TOUCH_Move // 按住移动后事件</br>
  4499. -cc.Node.EventType.TOUCH_END // 按下后松开后事件</br>
  4500. -cc.Node.EventType.TOUCH_CANCEL // 按下取消事件</br>
  4501. // 以下事件只在 PC 平台上触发</br>
  4502. -cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件</br>
  4503. -cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件</br>
  4504. -cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件</br>
  4505. -cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件</br>
  4506. -cc.Node.EventType.MOUSE_UP // 鼠标松开事件</br>
  4507. -cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件</br> */
  4508. export class Button extends Component {
  4509. /** !#en
  4510. Whether the Button is disabled.
  4511. If true, the Button will trigger event and do transition.
  4512. !#zh
  4513. 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */
  4514. interactable : boolean;
  4515. /** !#en Transition type
  4516. !#zh 按钮状态改变时过渡方式。 */
  4517. transition : Button.Transition;
  4518. /** !#en Normal state color.
  4519. !#zh 普通状态下按钮所显示的颜色。 */
  4520. normalColor : Color;
  4521. /** !#en Pressed state color
  4522. !#zh 按下状态时按钮所显示的颜色。 */
  4523. pressedColor : Color;
  4524. /** !#en Hover state color
  4525. !#zh 悬停状态下按钮所显示的颜色。 */
  4526. hoverColor : Color;
  4527. /** !#en Disabled state color
  4528. !#zh 禁用状态下按钮所显示的颜色。 */
  4529. disabledColor : Color;
  4530. /** !#en Color transition duration
  4531. !#zh 颜色过渡时所需时间 */
  4532. duration : number;
  4533. /** !#en Normal state sprite
  4534. !#zh 普通状态下按钮所显示的 Sprite 。 */
  4535. normalSprite : SpriteFrame;
  4536. /** !#en Pressed state sprite
  4537. !#zh 按下状态时按钮所显示的 Sprite 。 */
  4538. pressedSprite : SpriteFrame;
  4539. /** !#en Hover state sprite
  4540. !#zh 悬停状态下按钮所显示的 Sprite 。 */
  4541. hoverSprite : SpriteFrame;
  4542. /** !#en Disabled state sprite
  4543. !#zh 禁用状态下按钮所显示的 Sprite 。 */
  4544. disabledSprite : SpriteFrame;
  4545. /** !#en
  4546. Transition target.
  4547. When Button state changed:
  4548. If Transition type is Button.Transition.NONE, Button will do nothing
  4549. If Transition type is Button.Transition.COLOR, Button will change target's color
  4550. If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
  4551. !#zh
  4552. 需要过渡的目标。
  4553. 当前按钮状态改变有:
  4554. -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。
  4555. -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。
  4556. -如果 Transition type 选择 Button.Transition.NONE,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */
  4557. target : Node;
  4558. /** !#en If Button is clicked, it will trigger event's handler
  4559. !#zh 按钮的点击事件列表。 */
  4560. clickEvents : Component.EventHandler[];
  4561. }
  4562. /** !#zh: 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。
  4563. 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */
  4564. export class Canvas extends Component {
  4565. /** !#en Current active canvas, the scene should only have one active canvas at the same time.
  4566. !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */
  4567. instance : Canvas;
  4568. /** !#en The desigin resolution for current scene.
  4569. !#zh 当前场景设计分辨率。 */
  4570. designResolution : cc.Size;
  4571. /** !#en TODO
  4572. !#zh: 是否优先将设计分辨率高度撑满视图高度。 */
  4573. fitHeight : boolean;
  4574. /** !#en TODO
  4575. !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */
  4576. fitWidth : boolean;
  4577. }
  4578. /** !#en
  4579. Base class for everything attached to Node(Entity).<br/>
  4580. <br/>
  4581. NOTE: Not allowed to use construction parameters for Component's subclasses,
  4582. because Component is created by the engine.
  4583. !#zh
  4584. 所有附加到节点的基类。<br/>
  4585. <br/>
  4586. 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */
  4587. export class Component extends Object {
  4588. constructor();
  4589. /** !#en The node this component is attached to. A component is always attached to a node.
  4590. !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */
  4591. node : Node;
  4592. /** !#en The uuid for editor.
  4593. !#zh 组件的 uuid,用于编辑器。 */
  4594. uuid : string;
  4595. /** !#en indicates whether this component is enabled or not.
  4596. !#zh 表示该组件自身是否启用。 */
  4597. enabled : boolean;
  4598. /** !#en indicates whether this component is enabled and its node is also active in the hierarchy.
  4599. !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。。 */
  4600. enabledInHierarchy : boolean;
  4601. /** !#en TODO
  4602. !#zh onLoad 是否被调用。 */
  4603. _isOnLoadCalled : boolean;
  4604. /** !#en Update is called every frame, if the Component is enabled.
  4605. !#zh 如果该组件启用,则每帧调用 update。
  4606. */
  4607. update() : void;
  4608. /** !#en LateUpdate is called every frame, if the Component is enabled.
  4609. !#zh 如果该组件启用,则每帧调用 LateUpdate。
  4610. */
  4611. lateUpdate() : void;
  4612. /** !#en When attaching to an active node or its node first activated.
  4613. !#zh 当附加到一个激活的节点上或者其节点第一次激活时候调用。
  4614. */
  4615. onLoad() : void;
  4616. /** !#en Called before all scripts' update if the Component is enabled the first time.
  4617. !#zh 如果该组件第一次启用,则在所有组件的 update 之前调用。
  4618. */
  4619. start() : void;
  4620. /** !#en Called when this component becomes enabled and its node is active.
  4621. !#zh 当该组件被启用,并且它的节点也激活时。
  4622. */
  4623. onEnable() : void;
  4624. /** !#en Called when this component becomes disabled or its node becomes inactive.
  4625. !#zh 当该组件被禁用或节点变为无效时调用。
  4626. */
  4627. onDisable() : void;
  4628. /** !#en Called when this component will be destroyed.
  4629. !#zh 当该组件被销毁时调用
  4630. */
  4631. onDestroy() : void;
  4632. onFocusInEditor() : void;
  4633. onLostFocusInEditor() : void;
  4634. /** !#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
  4635. !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。
  4636. @param typeOrTypename the constructor or the class name of the component to add
  4637. @example
  4638. ```js
  4639. var sprite = node.addComponent(cc.Sprite);
  4640. var test = node.addComponent("Test");
  4641. ```
  4642. */
  4643. addComponent(typeOrTypename : Function|string) : Component;
  4644. /** !#en
  4645. Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
  4646. You can also get component in the node by passing in the name of the script.
  4647. !#zh
  4648. 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。<br/>
  4649. 传入参数也可以是脚本的名称。
  4650. @example
  4651. ```js
  4652. // get sprite component.
  4653. var sprite = node.getComponent(cc.Sprite);
  4654. // get custom test calss.
  4655. var test = node.getComponent("Test");
  4656. ```
  4657. */
  4658. getComponent(typeOrClassName : Function|string) : Component;
  4659. /** !#en Returns all components of supplied Type in the node.
  4660. !#zh 返回节点上指定类型的所有组件。
  4661. @example
  4662. ```js
  4663. var sprites = node.getComponents(cc.Sprite);
  4664. var tests = node.getComponents("Test");
  4665. ```
  4666. */
  4667. getComponents(typeOrClassName : Function|string) : Component[];
  4668. /** !#en Returns the component of supplied type in any of its children using depth first search.
  4669. !#zh 递归查找所有子节点中第一个匹配指定类型的组件。
  4670. @example
  4671. ```js
  4672. var sprite = node.getComponentInChildren(cc.Sprite);
  4673. var Test = node.getComponentInChildren("Test");
  4674. ```
  4675. */
  4676. getComponentInChildren(typeOrClassName : Function|string) : Component;
  4677. /** !#en Returns the components of supplied type in self or any of its children using depth first search.
  4678. !#zh 递归查找自身或所有子节点中指定类型的组件
  4679. @example
  4680. ```js
  4681. var sprites = node.getComponentsInChildren(cc.Sprite);
  4682. var tests = node.getComponentsInChildren("Test");
  4683. ```
  4684. */
  4685. getComponentsInChildren(typeOrClassName : Function|string) : Component[];
  4686. /** !#en
  4687. If the component's bounding box is different from the node's, you can implement this method to supply
  4688. a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly.
  4689. !#zh
  4690. 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB),
  4691. 以便编辑器的场景视图可以正确地执行点选测试。
  4692. @param out_rect the Rect to receive the bounding box
  4693. */
  4694. _getLocalBounds(out_rect : Rect) : void;
  4695. /** !#en
  4696. onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs
  4697. an undo operation on this component.<br/>
  4698. <br/>
  4699. If the component contains the "internal state", short for "temporary member variables which not included<br/>
  4700. in its CCClass properties", then you may need to implement this function.<br/>
  4701. <br/>
  4702. The editor will call the getset accessors of your component to record/restore the component's state<br/>
  4703. for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement<br/>
  4704. this function to manually synchronize your component's "internal states" with its public properties.<br/>
  4705. Once you implement this function, all the getset accessors of your component will not be called when<br/>
  4706. the user performs an undo/redo operation. Which means that only the properties with default value<br/>
  4707. will be recorded or restored by editor.<br/>
  4708. <br/>
  4709. Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need<br/>
  4710. to support the reset menu, you should manually synchronize your component's "internal states" with its<br/>
  4711. properties in this function. Once you implement this function, all the getset accessors of your component<br/>
  4712. will not be called during reset operation. Which means that only the properties with default value<br/>
  4713. will be reset by editor.
  4714. This function is only called in editor mode.
  4715. !#zh
  4716. onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。<br/>
  4717. <br/>
  4718. 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。<br/>
  4719. <br/>
  4720. 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。
  4721. 然而,在极端的情况下,它可能无法良好运作。<br/>
  4722. 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。
  4723. 一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。
  4724. 这意味着仅仅指定了默认值的属性将被编辑器记录和还原。<br/>
  4725. <br/>
  4726. 同样的,编辑可能无法在极端情况下正确地重置您的组件。<br/>
  4727. 于是如果你需要支持组件重置菜单,你需要在该方法中手工同步组件属性到“内部状态”。<br/>
  4728. 一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。
  4729. 这意味着仅仅指定了默认值的属性将被编辑器重置。
  4730. <br/>
  4731. 此方法仅在编辑器下会被调用。
  4732. */
  4733. onRestore() : void;
  4734. /** !#en
  4735. Schedules a custom selector.<br/>
  4736. If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.
  4737. !#zh
  4738. 调度一个自定义的回调函数。<br/>
  4739. 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。
  4740. @param callback The callback function
  4741. @param interval Tick interval in seconds. 0 means tick every frame. If interval = 0, it's recommended to use scheduleUpdate() instead.
  4742. @param repeat The selector will be executed (repeat + 1) times, you can use kCCRepeatForever for tick infinitely.
  4743. @param delay The amount of time that the first tick will wait before execution.
  4744. @example
  4745. ```js
  4746. var timeCallback = function (dt) {
  4747. cc.log("time: " + dt);
  4748. }
  4749. this.schedule(timeCallback, 1);
  4750. ```
  4751. */
  4752. schedule(callback : Function, interval? : number, repeat? : number, delay? : number) : void;
  4753. /** !#en Schedules a callback function that runs only once, with a delay of 0 or larger.
  4754. !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。
  4755. @param callback A function wrapped as a selector
  4756. @param delay The amount of time that the first tick will wait before execution.
  4757. @example
  4758. ```js
  4759. var timeCallback = function (dt) {
  4760. cc.log("time: " + dt);
  4761. }
  4762. this.scheduleOnce(timeCallback, 2);
  4763. ```
  4764. */
  4765. scheduleOnce(callback : Function, delay? : number) : void;
  4766. /** !#en Unschedules a custom callback function.
  4767. !#zh 取消调度一个自定义的回调函数。
  4768. @param callback_fn A function wrapped as a selector
  4769. @example
  4770. ```js
  4771. this.unschedule(_callback);
  4772. ```
  4773. */
  4774. unschedule(callback_fn : Function) : void;
  4775. /** !#en
  4776. unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.<br/>
  4777. Actions are not affected by this method.
  4778. !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 'update' 回调函数。动作不受此方法影响。
  4779. @example
  4780. ```js
  4781. this.unscheduleAllCallbacks();
  4782. ```
  4783. */
  4784. unscheduleAllCallbacks() : void;
  4785. }
  4786. /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users.
  4787. !#zh EditBox 组件,用于获取用户的输入文本。 */
  4788. export class EditBox extends _RendererUnderSG {
  4789. /** !#en Input string of EditBox.
  4790. !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */
  4791. string : string;
  4792. /** !#en The background image of EditBox.
  4793. !#zh 输入框的背景图片 */
  4794. backGroundImage : SpriteFrame;
  4795. /** !#en
  4796. The return key type of EditBox.
  4797. Note: it is meaningless for web platforms and desktop platforms.
  4798. !#zh
  4799. 指定移动设备上面回车按钮的样式。
  4800. 注意:这个选项对 web 平台与 desktop 平台无效。 */
  4801. returnType : EditBox.KeyboardReturnType;
  4802. /** !#en Set the input flags that are to be applied to the EditBox.
  4803. !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */
  4804. inputFlag : EditBox.InputFlag;
  4805. /** !#en
  4806. Set the input mode of the edit box.
  4807. If you pass ANY, it will create a multiline EditBox.
  4808. !#zh
  4809. 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */
  4810. inputMode : EditBox.InputMode;
  4811. /** !#en Font size of the input text.
  4812. !#zh 输入框文本的字体大小 */
  4813. fontSize : number;
  4814. /** !#en Change the lineHeight of displayed text.
  4815. !#zh 输入框文本的行高。 */
  4816. lineHeight : number;
  4817. /** !#en Font color of the input text.
  4818. !#zh 输入框文本的颜色。 */
  4819. fontColor : Color;
  4820. /** !#en The display text of placeholder.
  4821. !#zh 输入框占位符的文本内容。 */
  4822. placeholder : string;
  4823. /** !#en The font size of placeholder.
  4824. !#zh 输入框占位符的字体大小。 */
  4825. placeholderFontSize : number;
  4826. /** !#en The font color of placeholder.
  4827. !#zh 输入框最大允许输入的字符个数。 */
  4828. placeholderFontColor : Color;
  4829. /** !#en The maximize input length of EditBox.
  4830. !#zh 输入框最大允许输入的字符个数。 */
  4831. maxLength : number;
  4832. /** !#en The event handler to be called when EditBox began to edit text.
  4833. !#zh 开始编辑文本输入框触发的事件回调。 */
  4834. editingDidBegin : Component.EventHandler;
  4835. /** !#en The event handler to be called when EditBox text changes.
  4836. !#zh 编辑文本输入框时触发的事件回调。 */
  4837. textChanged : Component.EventHandler;
  4838. /** !#en The event handler to be called when EditBox edit ends.
  4839. !#zh 结束编辑文本输入框时触发的事件回调。 */
  4840. editingDidEnded : Component.EventHandler;
  4841. /** !#en The event handler to be called when return key is pressed. Windows is not supported.
  4842. !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */
  4843. editingReturn : Component.EventHandler;
  4844. }
  4845. /** !#en The Label Component.
  4846. !#zh 文字标签组件 */
  4847. export class Label extends _RendererUnderSG {
  4848. /** !#en Content string of label.
  4849. !#zh 标签显示的文本内容。 */
  4850. string : string;
  4851. /** !#en Horizontal Alignment of label.
  4852. !#zh 文本内容的水平对齐方式。 */
  4853. horizontalAlign : Label.HorizontalAlign;
  4854. /** !#en Vertical Alignment of label.
  4855. !#zh 文本内容的垂直对齐方式。 */
  4856. verticalAlign : Label.VerticalAlign;
  4857. /** !#en The actual rendering font size in shrink mode
  4858. !#zh SHRINK 模式下面文本实际渲染的字体大小 */
  4859. actualFontSize : number;
  4860. /** !#en Font size of label.
  4861. !#zh 文本字体大小。 */
  4862. fontSize : number;
  4863. /** !#en Line Height of label.
  4864. !#zh 文本行高。 */
  4865. lineHeight : number;
  4866. /** !#en Overflow of label.
  4867. !#zh 文字显示超出范围时的处理方式。 */
  4868. overflow : Label.Overflow;
  4869. /** !#en Whether auto wrap label when string width is large than label width.
  4870. !#zh 是否自动换行。 */
  4871. enableWrapText : boolean;
  4872. /** !#en The font of label.
  4873. !#zh 文本字体。 */
  4874. font : cc.Font;
  4875. /** !#en Whether use system font name or not.
  4876. !#zh 是否使用系统字体。 */
  4877. isSystemFontUsed : boolean;
  4878. }
  4879. /** !#en Outline effect used to change the display, only used for TTF font
  4880. !#zh 描边效果组件,用于字体描边,只能用于系统字体 */
  4881. export class LabelOutline extends Component {
  4882. /** !#en Change the outline color
  4883. !#zh 改变描边的颜色 */
  4884. color : Color;
  4885. /** !#en Change the outline width
  4886. !#zh 改变描边的宽度 */
  4887. width : number;
  4888. }
  4889. /** !#en The Layout is a container component, use it to arrange child elements easily.
  4890. !#zh Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。 */
  4891. export class Layout extends Component {
  4892. /** !#en The layout type.
  4893. !#zh 布局类型 */
  4894. type : Layout.Type;
  4895. /** !#en
  4896. The are three resize modes for Layout.
  4897. None, resize Container and resize children.
  4898. !#zh 缩放模式 */
  4899. resizeMode : Layout.ResizeMode;
  4900. /** !#en The cell size for grid layout.
  4901. !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */
  4902. cellSize : Size;
  4903. /** !#en
  4904. The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first,
  4905. and then break line on demand. Choose vertical if you want to layout vertically at first .
  4906. !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */
  4907. startAxis : Layout.AxisDirection;
  4908. /** !#en The padding of layout, it only effect the layout in one direction.
  4909. !#zh 容器内边距,只会在布局方向上生效。 */
  4910. padding : number;
  4911. /** !#en The distance in x-axis between each element in layout.
  4912. !#zh 子节点之间的水平间距。 */
  4913. spacingX : number;
  4914. /** !#en The distance in y-axis between each element in layout.
  4915. !#zh 子节点之间的垂直间距。 */
  4916. spacingY : number;
  4917. /** !#en
  4918. Only take effect in Vertical layout mode.
  4919. This option changes the start element's positioning.
  4920. !#zh 垂直排列子节点的方向。 */
  4921. verticalDirection : Layout.VerticalDirection;
  4922. /** !#en
  4923. Only take effect in Horizontal layout mode.
  4924. This option changes the start element's positioning.
  4925. !#zh 水平排列子节点的方向。 */
  4926. horizontalDirection : Layout.HorizontalDirection;
  4927. }
  4928. /** undefined */
  4929. export class Mask extends _RendererInSG {
  4930. }
  4931. /** !#en
  4932. Visual indicator of progress in some operation.
  4933. Displays a bar to the user representing how far the operation has progressed.
  4934. !#zh
  4935. 进度条组件,可用于显示加载资源时的进度。 */
  4936. export class ProgressBar extends Component {
  4937. /** !#en The targeted Sprite which will be changed progressively.
  4938. !#zh 用来显示进度条比例的 Sprite 对象。 */
  4939. barSprite : Sprite;
  4940. /** !#en The progress mode, there are two modes supported now: horizontal and vertical.
  4941. !#zh 进度条的模式 */
  4942. mode : ProgressBar.Mode;
  4943. /** !#en The total width or height of the bar sprite.
  4944. !#zh 进度条实际的总长度 */
  4945. totalLength : number;
  4946. /** !#en The current progress of the bar sprite. The valid value is between 0-1.
  4947. !#zh 当前进度值,该数值的区间是 0-1 之间。 */
  4948. progress : number;
  4949. /** !#en Whether reverse the progress direction of the bar sprite.
  4950. !#zh 进度条是否进行反方向变化。 */
  4951. reverse : boolean;
  4952. }
  4953. /** Rendering component in scene graph.
  4954. Maintains a node which will be the scene graph of component's Node. */
  4955. export class _RendererInSG extends _SGComponent {
  4956. }
  4957. /** The base rendering component which will attach a leaf node to the cocos2d scene graph. */
  4958. export class _RendererUnderSG extends _SGComponent {
  4959. }
  4960. /** The base class for all rendering component in scene graph.
  4961. You should override:
  4962. - _createSgNode
  4963. - _initSgNode */
  4964. export class _SGComponent extends Component {
  4965. }
  4966. /** !#en
  4967. The Scrollbar control allows the user to scroll an image or other view that is too large to see completely
  4968. !#zh 滚动条组件 */
  4969. export class Scrollbar extends Component {
  4970. /** !#en The "handle" part of the scrollbar.
  4971. !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */
  4972. handle : cc.Sprite;
  4973. /** !#en The direction of scrollbar.
  4974. !#zh ScrollBar 的滚动方向。 */
  4975. direction : Scrollbar.Direction;
  4976. /** !#en Whehter enable auto hide or not.
  4977. !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */
  4978. enableAutoHide : boolean;
  4979. /** !#en
  4980. The time to hide scrollbar when scroll finished.
  4981. Note: This value is only useful when enableAutoHide is true.
  4982. !#zh
  4983. 没有滚动动作后经过多久会自动隐藏。
  4984. 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */
  4985. autoHideTime : number;
  4986. }
  4987. /** !#en
  4988. Layout container for a view hierarchy that can be scrolled by the user,
  4989. allowing it to be larger than the physical display.
  4990. !#zh
  4991. 滚动视图组件 */
  4992. export class ScrollView extends Component {
  4993. /** !#en This is a reference to the UI element to be scrolled.
  4994. !#zh 可滚动展示内容的节点。 */
  4995. content : Node;
  4996. /** !#en Enable horizontal scroll.
  4997. !#zh 是否开启水平滚动。 */
  4998. horizontal : boolean;
  4999. /** !#en Enable vertical scroll.
  5000. !#zh 是否开启垂直滚动。 */
  5001. vertical : boolean;
  5002. /** !#en When inertia is set, the content will continue to move when touch ended.
  5003. !#zh 是否开启滚动惯性。 */
  5004. inertia : boolean;
  5005. /** !#en
  5006. It determines how quickly the content stop moving. A value of 1 will stop the movement immediately.
  5007. A value of 0 will never stop the movement until it reaches to the boundary of scrollview.
  5008. !#zh
  5009. 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */
  5010. brake : number;
  5011. /** !#en When elastic is set, the content will be bounce back when move out of boundary.
  5012. !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */
  5013. elastic : boolean;
  5014. /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately.
  5015. !#zh 回弹持续的时间,0 表示将立即反弹。 */
  5016. bounceDuration : number;
  5017. /** !#en The horizontal scrollbar reference.
  5018. !#zh 水平滚动的 ScrollBar。 */
  5019. horizontalScrollBar : Scrollbar;
  5020. /** !#en The vertical scrollbar reference.
  5021. !#zh 垂直滚动的 ScrollBar。 */
  5022. verticalScrollBar : Scrollbar;
  5023. /** !#en Scrollview events callback
  5024. !#zh 滚动视图的事件回调函数 */
  5025. scrollEvents : Component.EventHandler[];
  5026. /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes of the scroll view
  5027. It's set to true by default.
  5028. !#zh 如果这个属性被设置为 true,那么滚动行为会取消 ScrollView 的子节点上注册的触摸事件,默认被设置为 true。
  5029. 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */
  5030. cancelInnerEvents : boolean;
  5031. /** !#en Scroll the content to the bottom boundary of ScrollView.
  5032. !#zh 视图内容将在规定时间内滚动到视图底部。
  5033. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  5034. the content will jump to the bottom boundary immediately.
  5035. @param attenuated Whether the scroll acceleration attenuated, default is true.
  5036. @example
  5037. ```js
  5038. // Scroll to the bottom of the view.
  5039. scrollView.scrollToBottom(0.1);
  5040. ```
  5041. */
  5042. scrollToBottom(timeInSecond? : number, attenuated? : boolean) : void;
  5043. /** !#en Scroll the content to the top boundary of ScrollView.
  5044. !#zh 视图内容将在规定时间内滚动到视图顶部。
  5045. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  5046. the content will jump to the top boundary immediately.
  5047. @param attenuated Whether the scroll acceleration attenuated, default is true.
  5048. @example
  5049. ```js
  5050. // Scroll to the top of the view.
  5051. scrollView.scrollToTop(0.1);
  5052. ```
  5053. */
  5054. scrollToTop(timeInSecond? : number, attenuated? : boolean) : void;
  5055. /** !#en Scroll the content to the left boundary of ScrollView.
  5056. !#zh 视图内容将在规定时间内滚动到视图左边。
  5057. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  5058. the content will jump to the left boundary immediately.
  5059. @param attenuated Whether the scroll acceleration attenuated, default is true.
  5060. @example
  5061. ```js
  5062. // Scroll to the left of the view.
  5063. scrollView.scrollToLeft(0.1);
  5064. ```
  5065. */
  5066. scrollToLeft(timeInSecond? : number, attenuated? : boolean) : void;
  5067. /** !#en Scroll the content to the right boundary of ScrollView.
  5068. !#zh 视图内容将在规定时间内滚动到视图右边。
  5069. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  5070. the content will jump to the right boundary immediately.
  5071. @param attenuated Whether the scroll acceleration attenuated, default is true.
  5072. @example
  5073. ```js
  5074. // Scroll to the right of the view.
  5075. scrollView.scrollToRight(0.1);
  5076. ```
  5077. */
  5078. scrollToRight(timeInSecond? : number, attenuated? : boolean) : void;
  5079. /** !#en Scroll the content to the top left boundary of ScrollView.
  5080. !#zh 视图内容将在规定时间内滚动到视图左上角。
  5081. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  5082. the content will jump to the top left boundary immediately.
  5083. @param attenuated Whether the scroll acceleration attenuated, default is true.
  5084. @example
  5085. ```js
  5086. // Scroll to the upper left corner of the view.
  5087. scrollView.scrollToTopLeft(0.1);
  5088. ```
  5089. */
  5090. scrollToTopLeft(timeInSecond? : number, attenuated? : boolean) : void;
  5091. /** !#en Scroll the content to the top right boundary of ScrollView.
  5092. !#zh 视图内容将在规定时间内滚动到视图右上角。
  5093. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  5094. the content will jump to the top right boundary immediately.
  5095. @param attenuated Whether the scroll acceleration attenuated, default is true.
  5096. @example
  5097. ```js
  5098. // Scroll to the top right corner of the view.
  5099. scrollView.scrollToTopRight(0.1);
  5100. ```
  5101. */
  5102. scrollToTopRight(timeInSecond? : number, attenuated? : boolean) : void;
  5103. /** !#en Scroll the content to the bottom left boundary of ScrollView.
  5104. !#zh 视图内容将在规定时间内滚动到视图左下角。
  5105. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  5106. the content will jump to the bottom left boundary immediately.
  5107. @param attenuated Whether the scroll acceleration attenuated, default is true.
  5108. @example
  5109. ```js
  5110. // Scroll to the lower left corner of the view.
  5111. scrollView.scrollToBottomLeft(0.1);
  5112. ```
  5113. */
  5114. scrollToBottomLeft(timeInSecond? : number, attenuated? : boolean) : void;
  5115. /** !#en Scroll the content to the bottom right boundary of ScrollView.
  5116. !#zh 视图内容将在规定时间内滚动到视图右下角。
  5117. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  5118. the content will jump to the bottom right boundary immediately.
  5119. @param attenuated Whether the scroll acceleration attenuated, default is true.
  5120. @example
  5121. ```js
  5122. // Scroll to the lower right corner of the view.
  5123. scrollView.scrollToBottomRight(0.1);
  5124. ```
  5125. */
  5126. scrollToBottomRight(timeInSecond? : number, attenuated? : boolean) : void;
  5127. /** !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the
  5128. specific offset immediately.
  5129. !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。
  5130. @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset
  5131. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  5132. the content will jump to the specific offset of ScrollView immediately.
  5133. @param attenuated Whether the scroll acceleration attenuated, default is true.
  5134. @example
  5135. ```js
  5136. // Scroll to middle position in 0.1 second in x-axis
  5137. var maxScrollOffset = this.getMaxScrollOffset();
  5138. scrollView.scrollToOffset(cc.v2(maxScrollOffset.x / 2, 0), 0.1);
  5139. ```
  5140. */
  5141. scrollToOffset(offset : Vec2, timeInSecond? : number, attenuated? : boolean) : void;
  5142. /** !#en Get the positive offset value corresponds to the content's top left boundary.
  5143. !#zh 获取滚动视图相对于左上角原点的当前滚动偏移
  5144. */
  5145. getScrollOffset() : Vec2;
  5146. /** !#en Get the maximize available scroll offset
  5147. !#zh 获取滚动视图最大可以滚动的偏移量
  5148. */
  5149. getMaxScrollOffset() : Vec2;
  5150. /** !#en Scroll the content to the horizontal percent position of ScrollView.
  5151. !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。
  5152. @param percent A value between 0 and 1.
  5153. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  5154. the content will jump to the horizontal percent position of ScrollView immediately.
  5155. @param attenuated Whether the scroll acceleration attenuated, default is true.
  5156. @example
  5157. ```js
  5158. // Scroll to middle position.
  5159. scrollView.scrollToBottomRight(0.5, 0.1);
  5160. ```
  5161. */
  5162. scrollToPercentHorizontal(percent : number, timeInSecond? : number, attenuated? : boolean) : void;
  5163. /** !#en Scroll the content to the percent position of ScrollView in any direction.
  5164. !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。
  5165. @param anchor A point which will be clamp between cc.v2(0,0) and cc.v2(1,1).
  5166. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  5167. the content will jump to the percent position of ScrollView immediately.
  5168. @param attenuated Whether the scroll acceleration attenuated, default is true.
  5169. @example
  5170. ```js
  5171. // Vertical scroll to the bottom of the view.
  5172. scrollView.scrollTo(cc.v2(0, 1), 0.1);
  5173. // Horizontal scroll to view right.
  5174. scrollView.scrollTo(cc.v2(1, 0), 0.1);
  5175. ```
  5176. */
  5177. scrollTo(anchor : Vec2, timeInSecond? : number, attenuated? : boolean) : void;
  5178. /** !#en Scroll the content to the vertical percent position of ScrollView.
  5179. !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。
  5180. @param percent A value between 0 and 1.
  5181. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  5182. the content will jump to the vertical percent position of ScrollView immediately.
  5183. @param attenuated Whether the scroll acceleration attenuated, default is true.
  5184. // Scroll to middle position.
  5185. scrollView.scrollToPercentVertical(0.5, 0.1);
  5186. */
  5187. scrollToPercentVertical(percent : number, timeInSecond? : number, attenuated? : boolean) : void;
  5188. /** !#en Stop auto scroll immediately
  5189. !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动
  5190. */
  5191. stopAutoScroll() : void;
  5192. /** !#en Modify the content position.
  5193. !#zh 设置当前视图内容的坐标点。
  5194. @param position The position in content's parent space.
  5195. */
  5196. setContentPosition(position : Vec2) : void;
  5197. /** !#en Query the content's position in its parent space.
  5198. !#zh 获取当前视图内容的坐标点。
  5199. */
  5200. getContentPosition() : Position;
  5201. }
  5202. /** !#en Renders a sprite in the scene.
  5203. !#zh 该组件用于在场景中渲染精灵。 */
  5204. export class Sprite extends _RendererUnderSG {
  5205. /** !#en The sprite frame of the sprite.
  5206. !#zh 精灵的精灵帧 */
  5207. spriteFrame : SpriteFrame;
  5208. /** !#en The sprite render type.
  5209. !#zh 精灵渲染类型 */
  5210. type : Sprite.SpriteType;
  5211. /** !#en
  5212. The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  5213. !#zh
  5214. 精灵填充类型,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  5215. fillType : Sprite.FillType;
  5216. /** !#en
  5217. The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  5218. !#zh
  5219. 填充中心点,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  5220. fillCenter : Vec2;
  5221. /** !#en
  5222. The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  5223. !#zh
  5224. 填充起始点,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  5225. fillStart : number;
  5226. /** !#en
  5227. The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  5228. !#zh
  5229. 填充范围,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  5230. fillRange : number;
  5231. /** !#en specify the frame is trimmed or not.
  5232. !#zh 是否使用裁剪模式 */
  5233. trim : boolean;
  5234. /** !#en specify the source Blend Factor.
  5235. !#zh 指定原图的混合模式 */
  5236. srcBlendFactor : BlendFactor;
  5237. /** !#en specify the destination Blend Factor.
  5238. !#zh 指定目标的混合模式 */
  5239. dstBlendFactor : BlendFactor;
  5240. /** !#en specify the size tracing mode.
  5241. !#zh 精灵尺寸调整模式 */
  5242. sizeMode : Sprite.SizeMode;
  5243. /** !#en Change the left sprite's cap inset.
  5244. !#zh 设置精灵左边框-用于九宫格。
  5245. @param insetLeft The values to use for the cap inset.
  5246. @example
  5247. ```js
  5248. sprite.setInsetLeft(5);
  5249. ```
  5250. */
  5251. setInsetLeft(insetLeft : number) : void;
  5252. /** !#en Query the left sprite's cap inset.
  5253. !#zh 获取精灵左边框
  5254. @example
  5255. ```js
  5256. var insetLeft = sprite.getInsetLeft();
  5257. cc.log("Inset Left:" + insetLeft);
  5258. ```
  5259. */
  5260. getInsetLeft() : number;
  5261. /** !#en Change the top sprite's cap inset.
  5262. !#zh 设置精灵上边框-用于九宫格。
  5263. @param insetTop The values to use for the cap inset.
  5264. @example
  5265. ```js
  5266. sprite.setInsetTop(5);
  5267. ```
  5268. */
  5269. setInsetTop(insetTop : number) : void;
  5270. /** !#en Query the top sprite's cap inset.
  5271. !#zh 获取精灵上边框。
  5272. @example
  5273. ```js
  5274. var insetTop = sprite.getInsetTop();
  5275. cc.log("Inset Top:" + insetTop);
  5276. ```
  5277. */
  5278. getInsetTop() : number;
  5279. /** !#en Change the right sprite's cap inset.
  5280. !#zh 设置精灵右边框-用于九宫格。
  5281. @param insetRight The values to use for the cap inset.
  5282. @example
  5283. ```js
  5284. sprite.setInsetRight(5);
  5285. ```
  5286. */
  5287. setInsetRight(insetRight : number) : void;
  5288. /** !#en Query the right sprite's cap inset.
  5289. !#zh 获取精灵右边框。
  5290. @example
  5291. ```js
  5292. var insetRight = sprite.getInsetRight();
  5293. cc.log("Inset Right:" + insetRight);
  5294. ```
  5295. */
  5296. getInsetRight() : number;
  5297. /** !#en Change the bottom sprite's cap inset.
  5298. !#zh 设置精灵下边框-用于九宫格。
  5299. @param bottomInset The values to use for the cap inset.
  5300. @example
  5301. ```js
  5302. sprite.setInsetBottom(5);
  5303. ```
  5304. */
  5305. setInsetBottom(bottomInset : number) : void;
  5306. /** !#en Query the bottom sprite's cap inset.
  5307. !#zh 获取精灵下边框。
  5308. @example
  5309. ```js
  5310. var insetBottom = sprite.getInsetBottom();
  5311. cc.log("Inset Bottom:" + insetBottom);
  5312. ```
  5313. */
  5314. getInsetBottom() : number;
  5315. }
  5316. /** !#en A distortion used to change the rendering of simple sprite.If will take effect after sprite component is added.
  5317. !#zh 扭曲效果组件,用于改变SIMPLE类型sprite的渲染,只有当sprite组件已经添加后,才能起作用. */
  5318. export class SpriteDistortion extends Component {
  5319. /** !#en Change the UV offset for distortion rendering.
  5320. !#zh 在渲染时改变UV的整体偏移. */
  5321. offset : Vec2;
  5322. /** !#en Change the UV scale for distortion rendering.
  5323. !#zh 在渲染时改变UV的寻址系数 */
  5324. tiling : Vec2;
  5325. }
  5326. /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game.
  5327. !#zh Video 组件,用于在游戏中播放视频 */
  5328. export class VideoPlayer extends _RendererUnderSG {
  5329. /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path.
  5330. !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */
  5331. resourceType : VideoPlayer.ResourceType;
  5332. /** !#en The remote URL of video.
  5333. !#zh 远程视频的 URL */
  5334. remoteURL : string;
  5335. /** !#en The local video full path.
  5336. !#zh 本地视频的 URL */
  5337. video : string;
  5338. /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time.
  5339. !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */
  5340. currentTime : number;
  5341. /** !#en Whether keep the aspect ration of the original video.
  5342. !#zh 是否保持视频原来的宽高比 */
  5343. keepAspectRatio : boolean;
  5344. /** !#en Whether play video in fullscreen mode.
  5345. !#zh 是否全屏播放视频 */
  5346. isFullscreen : boolean;
  5347. /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed.
  5348. !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */
  5349. videoPlayerEvent : cc.Component.EventHandler[];
  5350. /** !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch.
  5351. !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。
  5352. */
  5353. play() : void;
  5354. /** !#en If a video is paused, call this method to resume playing.
  5355. !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。
  5356. */
  5357. resume() : void;
  5358. /** !#en If a video is playing, call this method to pause playing.
  5359. !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。
  5360. */
  5361. pause() : void;
  5362. /** !#en If a video is playing, call this method to stop playing immediately.
  5363. !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。
  5364. */
  5365. stop() : void;
  5366. }
  5367. /** !#en cc.WebView is a component for display web pages in the game
  5368. !#zh WebView 组件,用于在游戏中显示网页 */
  5369. export class WebView extends _RendererUnderSG {
  5370. /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix.
  5371. !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */
  5372. url : string;
  5373. /** !#en The webview's event callback , it will be triggered when certain webview event occurs.
  5374. !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */
  5375. webviewLoadedEvents : cc.Component.EventHandler[];
  5376. }
  5377. /** !#en
  5378. Stores and manipulate the anchoring based on its parent.
  5379. Widget are used for GUI but can also be used for other things.
  5380. Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame.
  5381. !#zh
  5382. Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。
  5383. Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到。 */
  5384. export class Widget extends Component {
  5385. /** !#en Whether to align the top.
  5386. !#zh 是否对齐上边。 */
  5387. isAlignTop : boolean;
  5388. /** !#en
  5389. Vertically aligns the midpoint, This will open the other vertical alignment options cancel.
  5390. !#zh
  5391. 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */
  5392. isAlignVerticalCenter : boolean;
  5393. /** !#en Whether to align the bottom.
  5394. !#zh 是否对齐下边。 */
  5395. isAlignBottom : boolean;
  5396. /** !#en Whether to align the left.
  5397. !#zh 是否对齐左边 */
  5398. isAlignLeft : boolean;
  5399. /** !#en
  5400. Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled.
  5401. !#zh
  5402. 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */
  5403. isAlignHorizontalCenter : boolean;
  5404. /** !#en Whether to align the right.
  5405. !#zh 是否对齐右边。 */
  5406. isAlignRight : boolean;
  5407. /** !#en
  5408. Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally,
  5409. the width setting is invalid (read only).
  5410. !#zh
  5411. 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */
  5412. isStretchWidth : boolean;
  5413. /** !#en
  5414. Whether the stretched vertically, when enable the left and right alignment will be stretched vertically,
  5415. then height setting is invalid (read only)
  5416. !#zh
  5417. 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */
  5418. isStretchHeight : boolean;
  5419. /** !#en
  5420. The margins between the top of this node and the top of parent node,
  5421. the value can be negative, Only available in 'isAlignTop' open.
  5422. !#zh
  5423. 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */
  5424. top : number;
  5425. /** !#en
  5426. The margins between the bottom of this node and the bottom of parent node,
  5427. the value can be negative, Only available in 'isAlignBottom' open.
  5428. !#zh
  5429. 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */
  5430. bottom : number;
  5431. /** !#en
  5432. The margins between the left of this node and the left of parent node,
  5433. the value can be negative, Only available in 'isAlignLeft' open.
  5434. !#zh
  5435. 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */
  5436. left : number;
  5437. /** !#en
  5438. The margins between the right of this node and the right of parent node,
  5439. the value can be negative, Only available in 'isAlignRight' open.
  5440. !#zh
  5441. 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */
  5442. right : number;
  5443. /** !#en
  5444. Horizontal aligns the midpoint offset value,
  5445. the value can be negative, Only available in 'isAlignHorizontalCenter' open.
  5446. !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */
  5447. horizontalCenter : number;
  5448. /** !#en
  5449. Vertical aligns the midpoint offset value,
  5450. the value can be negative, Only available in 'isAlignVerticalCenter' open.
  5451. !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */
  5452. verticalCenter : number;
  5453. /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
  5454. !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
  5455. isAbsoluteHorizontalCenter : boolean;
  5456. /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
  5457. !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
  5458. isAbsoluteVerticalCenter : boolean;
  5459. /** !#en
  5460. If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
  5461. !#zh
  5462. 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
  5463. isAbsoluteTop : boolean;
  5464. /** !#en
  5465. If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
  5466. !#zh
  5467. 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
  5468. isAbsoluteBottom : boolean;
  5469. /** !#en
  5470. If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
  5471. !#zh
  5472. 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
  5473. isAbsoluteLeft : boolean;
  5474. /** !#en
  5475. If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
  5476. !#zh
  5477. 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
  5478. isAbsoluteRight : boolean;
  5479. /** !#en TODO
  5480. !#zh
  5481. 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。
  5482. 这样便于脚本或动画继续控制当前节点。
  5483. 注意:onEnable 时所在的那一帧仍然会进行对齐。 */
  5484. isAlignOnce : boolean;
  5485. }
  5486. /** !#en
  5487. EventTarget is an object to which an event is dispatched when something has occurred.
  5488. Entity are the most common event targets, but other objects can be event targets too.
  5489. Event targets are an important part of the Fireball event model.
  5490. The event target serves as the focal point for how events flow through the scene graph.
  5491. When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object
  5492. into the event flow from the root of the hierarchy. The event object then makes its way through
  5493. the scene graph until it reaches the event target, at which point it begins its return trip through
  5494. the scene graph. This round-trip journey to the event target is conceptually divided into three phases:
  5495. - The capture phase comprises the journey from the root to the last node before the event target's node
  5496. - The target phase comprises only the event target node
  5497. - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree
  5498. See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  5499. Event targets can implement the following methods:
  5500. - _getCapturingTargets
  5501. - _getBubblingTargets
  5502. !#zh
  5503. 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标,
  5504. 但是其他对象也可以是事件目标。<br/> */
  5505. export class EventTarget {
  5506. /** !#en
  5507. Register an callback of a specific event type on the EventTarget.
  5508. This method is merely an alias to addEventListener.
  5509. !#zh
  5510. 注册事件目标的特定事件类型回调,仅仅是 addEventListener 的别名。
  5511. @param type A string representing the event type to listen for.
  5512. @param callback The callback that will be invoked when the event is dispatched.
  5513. The callback is ignored if it is a duplicate (the callbacks are unique).
  5514. @param target The target to invoke the callback, can be null
  5515. @param useCapture When set to true, the capture argument prevents callback
  5516. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5517. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5518. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5519. @example
  5520. ```js
  5521. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  5522. cc.log("this is callback");
  5523. }, node);
  5524. ```
  5525. */
  5526. on(type : string, callback: (param: Event) => void, target : any, useCapture : boolean) : Function;
  5527. /** !#en
  5528. Removes the callback previously registered with the same type, callback, target and or useCapture.
  5529. This method is merely an alias to removeEventListener.
  5530. !#zh
  5531. 删除之前与同类型,回调,目标或 useCapture 注册的回调,仅仅是 removeEventListener 的别名。
  5532. @param type A string representing the event type being removed.
  5533. @param callback The callback to remove.
  5534. @param target The target to invoke the callback, if it's not given, only callback without target will be removed
  5535. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  5536. If not specified, useCapture defaults to false. If a callback was registered twice,
  5537. one with capture and one without, each must be removed separately. Removal of a capturing callback
  5538. does not affect a non-capturing version of the same listener, and vice versa.
  5539. @example
  5540. ```js
  5541. // register touchEnd eventListener
  5542. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  5543. cc.log("this is callback");
  5544. }, node);
  5545. // remove touchEnd eventListener
  5546. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  5547. ```
  5548. */
  5549. off(type : string, callback : Function, target : any, useCapture : boolean) : void;
  5550. /** !#en Removes all callbacks previously registered with the same target.
  5551. !#zh 删除指定目标上的所有注册回调。
  5552. @param target The target to be searched for all related callbacks
  5553. */
  5554. targetOff(target : any) : void;
  5555. /** !#en
  5556. Register an callback of a specific event type on the EventTarget,
  5557. the callback will remove itself after the first time it is triggered.
  5558. !#zh
  5559. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  5560. @param type A string representing the event type to listen for.
  5561. @param callback The callback that will be invoked when the event is dispatched.
  5562. The callback is ignored if it is a duplicate (the callbacks are unique).
  5563. @param target The target to invoke the callback, can be null
  5564. @param useCapture When set to true, the capture argument prevents callback
  5565. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5566. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5567. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5568. @example
  5569. ```js
  5570. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  5571. cc.log("this is callback");
  5572. }, node);
  5573. ```
  5574. */
  5575. once(type : string, callback: (param: Event) => void, target : any, useCapture : boolean) : void;
  5576. /** !#en
  5577. Dispatches an event into the event flow.
  5578. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  5579. !#zh 分发事件到事件流中。
  5580. @param event The Event object that is dispatched into the event flow
  5581. */
  5582. dispatchEvent(event : Event) : void;
  5583. /** !#en
  5584. Send an event to this object directly, this method will not propagate the event to any other objects.
  5585. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  5586. !#zh
  5587. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  5588. @param message the message to send
  5589. @param detail whatever argument the message needs
  5590. */
  5591. emit(message : string, detail? : any) : void;
  5592. }
  5593. /** !#en Base class of all kinds of events.
  5594. !#zh 包含事件相关信息的对象。 */
  5595. export class Event {
  5596. constructor();
  5597. /**
  5598. @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
  5599. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  5600. */
  5601. Event(type : string, bubbles : boolean) : Event;
  5602. /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit".
  5603. !#zh 事件类型。 */
  5604. type : string;
  5605. /** !#en Indicate whether the event bubbles up through the tree or not.
  5606. !#zh 表示该事件是否进行冒泡。 */
  5607. bubbles : boolean;
  5608. /** !#en A reference to the target to which the event was originally dispatched.
  5609. !#zh 最初事件触发的目标 */
  5610. target : any;
  5611. /** !#en A reference to the currently registered target for the event.
  5612. !#zh 当前目标 */
  5613. currentTarget : any;
  5614. /** !#en
  5615. Indicates which phase of the event flow is currently being evaluated.
  5616. Returns an integer value represented by 4 constants:
  5617. - Event.NONE = 0
  5618. - Event.CAPTURING_PHASE = 1
  5619. - Event.AT_TARGET = 2
  5620. - Event.BUBBLING_PHASE = 3
  5621. The phases are explained in the [section 3.1, Event dispatch and DOM event flow]
  5622. (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification.
  5623. !#zh 事件阶段 */
  5624. eventPhase : number;
  5625. /** !#en Reset the event for being stored in the object pool.
  5626. !#zh 重置对象池中存储的事件。
  5627. */
  5628. unuse() : string;
  5629. /** !#en Reuse the event for being used again by the object pool.
  5630. !#zh 用于对象池再次使用的事件。
  5631. */
  5632. reuse() : string;
  5633. /** !#en Stops propagation for current event.
  5634. !#zh 停止传递当前事件。
  5635. */
  5636. stopPropagation() : void;
  5637. /** !#en Stops propagation for current event immediately,
  5638. the event won't even be dispatched to the listeners attached in the current target.
  5639. !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。
  5640. */
  5641. stopPropagationImmediate() : void;
  5642. /** !#en Checks whether the event has been stopped.
  5643. !#zh 检查该事件是否已经停止传递.
  5644. */
  5645. isStopped() : boolean;
  5646. /** !#en
  5647. <p>
  5648. Gets current target of the event <br/>
  5649. note: It only be available when the event listener is associated with node. <br/>
  5650. It returns 0 when the listener is associated with fixed priority.
  5651. </p>
  5652. !#zh 获取当前目标节点
  5653. */
  5654. getCurrentTarget() : Node;
  5655. /** !#en Gets the event type.
  5656. !#zh 获取事件类型
  5657. */
  5658. getType() : string;
  5659. /** !#en Code for event without type.
  5660. !#zh 没有类型的事件 */
  5661. NO_TYPE : string;
  5662. /** !#en Events not currently dispatched are in this phase
  5663. !#zh 尚未派发事件阶段 */
  5664. NONE : number;
  5665. /** !#en
  5666. The capturing phase comprises the journey from the root to the last node before the event target's node
  5667. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  5668. !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */
  5669. CAPTURING_PHASE : number;
  5670. /** !#en
  5671. The target phase comprises only the event target node
  5672. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  5673. !#zh 目标阶段仅包括事件目标节点。 */
  5674. AT_TARGET : number;
  5675. /** !#en
  5676. The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy
  5677. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  5678. !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */
  5679. BUBBLING_PHASE : number;
  5680. }
  5681. /** !#en
  5682. <p>
  5683. The base class of event listener. <br/>
  5684. If you need custom listener which with different callback, you need to inherit this class. <br/>
  5685. For instance, you could refer to EventListenerAcceleration, EventListenerKeyboard, <br/>
  5686. EventListenerTouchOneByOne, EventListenerCustom.
  5687. </p>
  5688. !#zh
  5689. 封装用户的事件处理逻辑。
  5690. 注意:这是一个抽象类,开发者不应该直接实例化这个类,请参考 {{#crossLink "EventListener/create:method"}}cc.EventListener.create{{/crossLink}}。 */
  5691. export class EventListener {
  5692. /** Constructor
  5693. */
  5694. EventListener(type : number, listenerID : number, callback : number) : EventListener;
  5695. /** !#en Checks whether the listener is available.
  5696. !#zh 检测监听器是否有效
  5697. */
  5698. checkAvailable() : boolean;
  5699. /** !#en Clones the listener, its subclasses have to override this method.
  5700. !#zh 克隆监听器,它的子类必须重写此方法。
  5701. */
  5702. clone() : EventListener;
  5703. /** !#en Enables or disables the listener
  5704. !#zh 启用或禁用监听器。
  5705. */
  5706. setEnabled(enabled : boolean) : void;
  5707. /** !#en Checks whether the listener is enabled
  5708. !#zh 检查监听器是否可用。
  5709. */
  5710. isEnabled() : boolean;
  5711. /** !#en The type code of unknown event listener.
  5712. !#zh 未知的事件监听器类型 */
  5713. UNKNOWN : number;
  5714. /** !#en The type code of keyboard event listener.
  5715. !#zh 键盘事件监听器类型 */
  5716. KEYBOARD : number;
  5717. /** !#en The type code of focus event listener.
  5718. !#zh 加速器事件监听器类型 */
  5719. ACCELERATION : number;
  5720. /** !#en
  5721. Create a EventListener object with configuration including the event type, handlers and other parameters.
  5722. In handlers, this refer to the event listener object itself.
  5723. You can also pass custom parameters in the configuration object,
  5724. all custom parameters will be polyfilled into the event listener object and can be accessed in handlers.
  5725. !#zh 通过指定不同的 Event 对象来设置想要创建的事件监听器。
  5726. @param argObj a json object
  5727. @example
  5728. ```js
  5729. // Create KEYBOARD EventListener.
  5730. cc.EventListener.create({
  5731. event: cc.EventListener.KEYBOARD,
  5732. onKeyPressed: function (keyCode, event) {
  5733. cc.log('pressed key: ' + keyCode);
  5734. },
  5735. onKeyReleased: function (keyCode, event) {
  5736. cc.log('released key: ' + keyCode);
  5737. }
  5738. });
  5739. // Create ACCELERATION EventListener.
  5740. cc.EventListener.create({
  5741. event: cc.EventListener.ACCELERATION,
  5742. callback: function (acc, event) {
  5743. cc.log('acc: ' + keyCode);
  5744. }
  5745. });
  5746. ```
  5747. */
  5748. create(argObj : any) : EventListener;
  5749. }
  5750. /** !#en
  5751. <p>
  5752. cc.eventManager is a singleton object which manages event listener subscriptions and event dispatching. <br/>
  5753. <br/>
  5754. The EventListener list is managed in such way so that event listeners can be added and removed <br/>
  5755. while events are being dispatched.
  5756. </p>
  5757. !#zh
  5758. 事件管理器,它主要管理事件监听器注册和派发系统事件。
  5759. 原始设计中,它支持鼠标,触摸,键盘,陀螺仪和自定义事件。
  5760. 在 Creator 的设计中,鼠标,触摸和自定义事件的监听和派发请参考 http://cocos.com/docs/creator/scripting/events.html。 */
  5761. export class eventManager {
  5762. /** !#en Pauses all listeners which are associated the specified target.
  5763. !#zh 暂停传入的 node 相关的所有监听器的事件响应。
  5764. */
  5765. pauseTarget(node : Node, recursive : boolean) : void;
  5766. /** !#en Resumes all listeners which are associated the specified target.
  5767. !#zh 恢复传入的 node 相关的所有监听器的事件响应。
  5768. */
  5769. resumeTarget(node : Node, recursive : boolean) : void;
  5770. /** !#en
  5771. <p>
  5772. Adds a event listener for a specified event.<br/>
  5773. if the parameter "nodeOrPriority" is a node,
  5774. it means to add a event listener for a specified event with the priority of scene graph.<br/>
  5775. if the parameter "nodeOrPriority" is a Number,
  5776. it means to add a event listener for a specified event with the fixed priority.<br/>
  5777. </p>
  5778. !#zh
  5779. 将事件监听器添加到事件管理器中。<br/>
  5780. 如果参数 “nodeOrPriority” 是节点,优先级由 node 的渲染顺序决定,显示在上层的节点将优先收到事件。<br/>
  5781. 如果参数 “nodeOrPriority” 是数字,优先级则固定为该参数的数值,数字越小,优先级越高。<br/>
  5782. @param listener The listener of a specified event or a object of some event parameters.
  5783. @param nodeOrPriority The priority of the listener is based on the draw order of this node or fixedPriority The fixed priority of the listener.
  5784. */
  5785. addListener(listener : EventListener|any, nodeOrPriority : Node|number) : EventListener;
  5786. /** !#en Remove a listener.
  5787. !#zh 移除一个已添加的监听器。
  5788. @param listener an event listener or a registered node target
  5789. @example
  5790. ```js
  5791. // 1. remove eventManager add Listener;
  5792. var mouseListener1 = cc.eventManager.addListener({
  5793. event: cc.EventListener.MOUSE,
  5794. onMouseDown: function(keyCode, event){ },
  5795. onMouseUp: function(keyCode, event){ },
  5796. onMouseMove: function () { },
  5797. onMouseScroll: function () { }
  5798. }, node);
  5799. cc.eventManager.removeListener(mouseListener1);
  5800. // 2. remove eventListener create Listener;
  5801. var mouseListener2 = cc.EventListener.create({
  5802. event: cc.EventListener.MOUSE,
  5803. onMouseDown: function(keyCode, event){ },
  5804. onMouseUp: function(keyCode, event){ },
  5805. onMouseMove: function () { },
  5806. onMouseScroll: function () { }
  5807. });
  5808. cc.eventManager.removeListener(mouseListener2);
  5809. ```
  5810. */
  5811. removeListener(listener: (type: number, listenerID: number, callback: number) => void) : void;
  5812. /** !#en Removes all listeners with the same event listener type or removes all listeners of a node.
  5813. !#zh
  5814. 移除注册到 eventManager 中指定类型的所有事件监听器。<br/>
  5815. 1. 如果传入的第一个参数类型是 Node,那么事件管理器将移除与该对象相关的所有事件监听器。
  5816. (如果第二参数 recursive 是 true 的话,就会连同该对象的子控件上所有的事件监听器也一并移除)<br/>
  5817. 2. 如果传入的第一个参数类型是 Number(该类型 EventListener 中定义的事件类型),
  5818. 那么事件管理器将移除该类型的所有事件监听器。<br/>
  5819. 下列是目前存在监听器类型: <br/>
  5820. cc.EventListener.UNKNOWN <br/>
  5821. cc.EventListener.KEYBOARD <br/>
  5822. cc.EventListener.ACCELERATION,<br/>
  5823. @param listenerType listenerType or a node
  5824. */
  5825. removeListeners(listenerType : number|Node, recursive : boolean) : void;
  5826. /** !#en Removes all listeners
  5827. !#zh 移除所有事件监听器。
  5828. */
  5829. removeAllListeners() : void;
  5830. /** !#en Sets listener's priority with fixed value.
  5831. !#zh 设置 FixedPriority 类型监听器的优先级。
  5832. @param listener Constructor
  5833. */
  5834. setPriority(listener: (type: number, listenerID: number, callback: number) => void, fixedPriority : number) : void;
  5835. /** !#en Whether to enable dispatching events
  5836. !#zh 启用或禁用事件管理器,禁用后不会分发任何事件。
  5837. */
  5838. setEnabled(enabled : boolean) : void;
  5839. /** !#en Checks whether dispatching events is enabled
  5840. !#zh 检测事件管理器是否启用。
  5841. */
  5842. isEnabled() : boolean;
  5843. }
  5844. /** !#en The touch event class
  5845. !#zh 封装了触摸相关的信息。 */
  5846. export class Touch {
  5847. /** !#en Returns the current touch location in OpenGL coordinates.、
  5848. !#zh 获取当前触点位置。
  5849. */
  5850. getLocation() : Vec2;
  5851. /** !#en Returns X axis location value.
  5852. !#zh 获取当前触点 X 轴位置。
  5853. */
  5854. getLocationX() : number;
  5855. /** !#en Returns Y axis location value.
  5856. !#zh 获取当前触点 Y 轴位置。
  5857. */
  5858. getLocationY() : number;
  5859. /** !#en Returns the previous touch location in OpenGL coordinates.
  5860. !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
  5861. */
  5862. getPreviousLocation() : Vec2;
  5863. /** !#en Returns the start touch location in OpenGL coordinates.
  5864. !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。
  5865. */
  5866. getStartLocation() : Vec2;
  5867. /** !#en Returns the delta distance from the previous touche to the current one in screen coordinates.
  5868. !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  5869. */
  5870. getDelta() : Vec2;
  5871. /** !#en Returns the current touch location in screen coordinates.
  5872. !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
  5873. */
  5874. getLocationInView() : Vec2;
  5875. /** !#en Returns the previous touch location in screen coordinates.
  5876. !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
  5877. */
  5878. getPreviousLocationInView() : Vec2;
  5879. /** !#en Returns the start touch location in screen coordinates.
  5880. !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
  5881. */
  5882. getStartLocationInView() : Vec2;
  5883. /** !#en Returns the id of cc.Touch.
  5884. !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
  5885. */
  5886. getID() : number;
  5887. /** !#en Sets information to touch.
  5888. !#zh 设置触摸相关的信息。用于监控触摸事件。
  5889. */
  5890. setTouchInfo(id : number, x : number, y : number) : void;
  5891. }
  5892. /** undefined */
  5893. export class Graphics extends _RendererUnderSG {
  5894. /** !#en
  5895. Current line width.
  5896. !#zh
  5897. 当前线条宽度 */
  5898. lineWidth : number;
  5899. /** !#en
  5900. lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together.
  5901. !#zh
  5902. lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */
  5903. lineJoin : Graphics.LineJoin;
  5904. /** !#en
  5905. lineCap determines how the end points of every line are drawn.
  5906. !#zh
  5907. lineCap 指定如何绘制每一条线段末端。 */
  5908. lineCap : Graphics.LineCap;
  5909. /** !#en
  5910. stroke color
  5911. !#zh
  5912. 线段颜色 */
  5913. strokeColor : Color;
  5914. /** !#en
  5915. fill color
  5916. !#zh
  5917. 填充颜色 */
  5918. fillColor : Color;
  5919. /** !#en
  5920. Sets the miter limit ratio
  5921. !#zh
  5922. 设置斜接面限制比例 */
  5923. miterLimit : number;
  5924. /** !#en Move path start point to (x,y).
  5925. !#zh 移动路径起点到坐标(x, y)
  5926. @param x The x axis of the coordinate for the end point.
  5927. @param y The y axis of the coordinate for the end point.
  5928. */
  5929. moveTo(x? : number, y? : number) : void;
  5930. /** !#en Adds a straight line to the path
  5931. !#zh 绘制直线路径
  5932. @param x The x axis of the coordinate for the end point.
  5933. @param y The y axis of the coordinate for the end point.
  5934. */
  5935. lineTo(x? : number, y? : number) : void;
  5936. /** !#en Adds a cubic Bézier curve to the path
  5937. !#zh 绘制三次贝赛尔曲线路径
  5938. @param c1x The x axis of the coordinate for the first control point.
  5939. @param c1y The y axis of the coordinate for first control point.
  5940. @param c2x The x axis of the coordinate for the second control point.
  5941. @param c2y The y axis of the coordinate for the second control point.
  5942. @param x The x axis of the coordinate for the end point.
  5943. @param y The y axis of the coordinate for the end point.
  5944. */
  5945. bezierCurveTo(c1x? : number, c1y? : number, c2x? : number, c2y? : number, x? : number, y? : number) : void;
  5946. /** !#en Adds a quadratic Bézier curve to the path
  5947. !#zh 绘制二次贝赛尔曲线路径
  5948. @param cx The x axis of the coordinate for the control point.
  5949. @param cy The y axis of the coordinate for the control point.
  5950. @param x The x axis of the coordinate for the end point.
  5951. @param y The y axis of the coordinate for the end point.
  5952. */
  5953. quadraticCurveTo(cx? : number, cy? : number, x? : number, y? : number) : void;
  5954. /** !#en Adds an arc to the path which is centered at (cx, cy) position with radius r starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to false).
  5955. !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。
  5956. @param cx The x axis of the coordinate for the center point.
  5957. @param cy The y axis of the coordinate for the center point.
  5958. @param r The arc's radius.
  5959. @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.
  5960. @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.
  5961. @param counterclockwise An optional Boolean which, if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise.
  5962. */
  5963. arc(cx? : number, cy? : number, r? : number, startAngle? : number, endAngle? : number, counterclockwise? : number) : void;
  5964. /** !#en Adds an ellipse to the path.
  5965. !#zh 绘制椭圆路径。
  5966. @param cx The x axis of the coordinate for the center point.
  5967. @param cy The y axis of the coordinate for the center point.
  5968. @param rx The ellipse's x-axis radius.
  5969. @param ry The ellipse's y-axis radius.
  5970. */
  5971. ellipse(cx? : number, cy? : number, rx? : number, ry? : number) : void;
  5972. /** !#en Adds an circle to the path.
  5973. !#zh 绘制圆形路径。
  5974. @param cx The x axis of the coordinate for the center point.
  5975. @param cy The y axis of the coordinate for the center point.
  5976. @param r The circle's radius.
  5977. */
  5978. circle(cx? : number, cy? : number, r? : number) : void;
  5979. /** !#en Adds an rectangle to the path.
  5980. !#zh 绘制矩形路径。
  5981. @param x The x axis of the coordinate for the rectangle starting point.
  5982. @param y The y axis of the coordinate for the rectangle starting point.
  5983. @param w The rectangle's width.
  5984. @param h The rectangle's height.
  5985. */
  5986. rect(x? : number, y? : number, w? : number, h? : number) : void;
  5987. /** !#en Adds an round corner rectangle to the path.
  5988. !#zh 绘制圆角矩形路径。
  5989. @param x The x axis of the coordinate for the rectangle starting point.
  5990. @param y The y axis of the coordinate for the rectangle starting point.
  5991. @param w The rectangles width.
  5992. @param h The rectangle's height.
  5993. @param r The radius of the rectangle.
  5994. */
  5995. roundRect(x? : number, y? : number, w? : number, h? : number, r? : number) : void;
  5996. /** !#en Draws a filled rectangle.
  5997. !#zh 绘制填充矩形。
  5998. @param x The x axis of the coordinate for the rectangle starting point.
  5999. @param y The y axis of the coordinate for the rectangle starting point.
  6000. @param w The rectangle's width.
  6001. @param h The rectangle's height.
  6002. */
  6003. fillRect(x? : number, y? : number, w? : number, h? : number) : void;
  6004. /** !#en Erasing any previously drawn content.
  6005. !#zh 擦除之前绘制的所有内容的方法。
  6006. */
  6007. clear() : void;
  6008. /** !#en Causes the point of the pen to move back to the start of the current path. It tries to add a straight line from the current point to the start.
  6009. !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。
  6010. */
  6011. close() : void;
  6012. /** !#en Strokes the current or given path with the current stroke style.
  6013. !#zh 根据当前的画线样式,绘制当前或已经存在的路径。
  6014. */
  6015. stroke() : void;
  6016. /** !#en Fills the current or given path with the current fill style.
  6017. !#zh 根据当前的画线样式,填充当前或已经存在的路径。
  6018. */
  6019. stroke() : void;
  6020. }
  6021. /** Loader for resource loading process. It's a singleton object. */
  6022. export class loader extends Pipeline {
  6023. /** The downloader in cc.loader's pipeline, it's by default the first pipe.
  6024. It's used to download files with several handlers: pure text, image, script, audio, font, uuid.
  6025. You can add your own download function with addDownloadHandlers */
  6026. downloader : any;
  6027. /** The downloader in cc.loader's pipeline, it's by default the second pipe.
  6028. It's used to parse downloaded content with several handlers: JSON, image, plist, fnt, uuid.
  6029. You can add your own download function with addLoadHandlers */
  6030. loader : any;
  6031. /** Add custom supported types handler or modify existing type handler for download process.
  6032. @param extMap Custom supported types with corresponded handler
  6033. @example
  6034. ```js
  6035. cc.loader.addDownloadHandlers({
  6036. // This will match all url with `.scene` extension or all url with `scene` type
  6037. 'scene' : function (url, callback) {}
  6038. });
  6039. ```
  6040. */
  6041. addDownloadHandlers(extMap : any) : void;
  6042. /** Add custom supported types handler or modify existing type handler for load process.
  6043. @param extMap Custom supported types with corresponded handler
  6044. @example
  6045. ```js
  6046. cc.loader.addLoadHandlers({
  6047. // This will match all url with `.scene` extension or all url with `scene` type
  6048. 'scene' : function (url, callback) {}
  6049. });
  6050. ```
  6051. */
  6052. addLoadHandlers(extMap : any) : void;
  6053. /** Load resources with a progression callback and a complete callback.
  6054. The progression callback is the same as Pipeline's {{#crossLink "Pipeline/onProgress:method"}}onProgress{{/crossLink}}
  6055. The complete callback is almost the same as Pipeline's {{#crossLink "Pipeline/onComplete:method"}}onComplete{{/crossLink}}
  6056. The only difference is when user pass a single url as resources, the complete callback will set its result directly as the second parameter.
  6057. @param resources Url list in an array
  6058. @param progressCallback Callback invoked when progression change
  6059. @param completeCallback Callback invoked when all resources loaded
  6060. @example
  6061. ```js
  6062. cc.loader.load('a.png', function (err, tex) {
  6063. cc.log('Result should be a texture: ' + (tex instanceof cc.Texture2D));
  6064. });
  6065. cc.loader.load('http://example.com/a.png', function (err, tex) {
  6066. cc.log('Should load a texture from external url: ' + (tex instanceof cc.Texture2D));
  6067. });
  6068. cc.loader.load({id: 'http://example.com/getImageREST?file=a.png', type: 'png'}, function (err, tex) {
  6069. cc.log('Should load a texture from RESTful API by specify the type: ' + (tex instanceof cc.Texture2D));
  6070. });
  6071. cc.loader.load(['a.png', 'b.json'], function (errors, results) {
  6072. if (errors) {
  6073. for (var i = 0; i < errors.length; i++) {
  6074. cc.log('Error url [' + errors[i] + ']: ' + results.getError(errors[i]));
  6075. }
  6076. }
  6077. var aTex = results.getContent('a.png');
  6078. var bJsonObj = results.getContent('b.json');
  6079. });
  6080. ```
  6081. */
  6082. load(resources : string|any[], progressCallback? : Function, completeCallback : Function) : void;
  6083. /** Load resources from the "resources" folder inside the "assets" folder of your project.<br>
  6084. <br>
  6085. Note: All asset urls in Creator use forward slashes, urls using backslashes will not work.
  6086. @param url Url of the target resource.
  6087. The url is relative to the "resources" folder, extensions must be omitted.
  6088. @param type Only asset of type will be loaded if this argument is supplied.
  6089. @param completeCallback Callback invoked when the resource loaded.
  6090. @example
  6091. ```js
  6092. // load the prefab (project/assets/resources/misc/character/cocos) from resources folder
  6093. cc.loader.loadRes('misc/character/cocos', function (err, prefab) {
  6094. if (err) {
  6095. cc.error(err.message || err);
  6096. return;
  6097. }
  6098. cc.log('Result should be a prefab: ' + (prefab instanceof cc.Prefab));
  6099. });
  6100. // load the sprite frame (project/assets/resources/imgs/cocos.png/cocos) from resources folder
  6101. cc.loader.loadRes('imgs/cocos', cc.SpriteFrame, function (err, spriteFrame) {
  6102. if (err) {
  6103. cc.error(err.message || err);
  6104. return;
  6105. }
  6106. cc.log('Result should be a sprite frame: ' + (spriteFrame instanceof cc.SpriteFrame));
  6107. });
  6108. ```
  6109. */
  6110. loadRes(url : string, type? : Function, completeCallback: (error: Error, resource: any) => void) : void;
  6111. /** Load all assets in a folder inside the "assets/resources" folder of your project.<br>
  6112. <br>
  6113. Note: All asset urls in Creator use forward slashes, urls using backslashes will not work.
  6114. @param url Url of the target folder.
  6115. The url is relative to the "resources" folder, extensions must be omitted.
  6116. @param type Only asset of type will be loaded if this argument is supplied.
  6117. @param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
  6118. @example
  6119. ```js
  6120. // load the texture (resources/imgs/cocos.png) and sprite frame (resources/imgs/cocos.png/cocos)
  6121. cc.loader.loadResAll('imgs/cocos', function (err, assets) {
  6122. if (err) {
  6123. cc.error(err);
  6124. return;
  6125. }
  6126. var texture = assets[0];
  6127. var spriteFrame = assets[1];
  6128. });
  6129. // load all textures in "resources/imgs/"
  6130. cc.loader.loadResAll('imgs', cc.Texture2D, function (err, textures) {
  6131. if (err) {
  6132. cc.error(err);
  6133. return;
  6134. }
  6135. var texture1 = textures[0];
  6136. var texture2 = textures[1];
  6137. });
  6138. ```
  6139. */
  6140. loadResAll(url : string, type? : Function, completeCallback: (error: Error, assets: any[]) => void) : void;
  6141. /** Get resource data by id. <br>
  6142. When you load resources with {{#crossLink "loader/load:method"}}{{/crossLink}} or {{#crossLink "loader/loadRes:method"}}{{/crossLink}},
  6143. the url will be the unique identity of the resource.
  6144. After loaded, you can acquire them by passing the url to this API.
  6145. */
  6146. getRes(url : string) : any;
  6147. /** Returns an item in pipeline.
  6148. */
  6149. getItem() : any;
  6150. /** Release the cache of resource by url.
  6151. */
  6152. release(url : string) : void;
  6153. /** Release the loaded cache of asset.
  6154. */
  6155. releaseAsset(asset : Asset) : void;
  6156. /** Release the cache of resource which loaded by {{#crossLink "loader/loadRes:method"}}{{/crossLink}}.
  6157. */
  6158. releaseRes(url : string) : void;
  6159. /** Resource cache of all resources.
  6160. */
  6161. releaseAll() : void;
  6162. /** !#en
  6163. Indicates whether to release the asset when loading a new scene.<br>
  6164. By default, when loading a new scene, all assets in the previous scene will be released or preserved
  6165. according to whether the previous scene checked the "Auto Release Assets" option.
  6166. On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResAll`
  6167. will not be affected by that option, remain not released by default.<br>
  6168. Use this API to change the default behavior on a single asset, to force preserve or release specified asset when scene switching.<br>
  6169. <br>
  6170. See: {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  6171. !#zh
  6172. 设置当场景切换时是否自动释放资源。<br>
  6173. 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。
  6174. 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResAll` 动态加载的资源,则不受场景设置的影响,默认不自动释放。<br>
  6175. 使用这个 API 可以在单个资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。<br>
  6176. <br>
  6177. 参考:{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  6178. @param assetOrUrl asset object or the raw asset's url
  6179. @param autoRelease indicates whether should release automatically
  6180. @example
  6181. ```js
  6182. // auto release the texture event if "Auto Release Assets" disabled in current scene
  6183. cc.loader.setAutoRelease(texture2d, true);
  6184. // don't release the texture even if "Auto Release Assets" enabled in current scene
  6185. cc.loader.setAutoRelease(texture2d, false);
  6186. // first parameter can be url
  6187. cc.loader.setAutoRelease(audioUrl, false);
  6188. ```
  6189. */
  6190. setAutoRelease(assetOrUrl : Asset|string, autoRelease : boolean) : void;
  6191. /** !#en
  6192. Indicates whether to release the asset and its referenced other assets when loading a new scene.<br>
  6193. By default, when loading a new scene, all assets in the previous scene will be released or preserved
  6194. according to whether the previous scene checked the "Auto Release Assets" option.
  6195. On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResAll`
  6196. will not be affected by that option, remain not released by default.<br>
  6197. Use this API to change the default behavior on the specified asset and its recursively referenced assets, to force preserve or release specified asset when scene switching.<br>
  6198. <br>
  6199. See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  6200. !#zh
  6201. 设置当场景切换时是否自动释放资源及资源引用的其它资源。<br>
  6202. 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。
  6203. 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResAll` 动态加载的资源,则不受场景设置的影响,默认不自动释放。<br>
  6204. 使用这个 API 可以在指定资源及资源递归引用到的所有资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。<br>
  6205. <br>
  6206. 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  6207. @param assetOrUrl asset object or the raw asset's url
  6208. @param autoRelease indicates whether should release automatically
  6209. @example
  6210. ```js
  6211. // auto release the SpriteFrame and its Texture event if "Auto Release Assets" disabled in current scene
  6212. cc.loader.setAutoReleaseRecursively(spriteFrame, true);
  6213. // don't release the SpriteFrame and its Texture even if "Auto Release Assets" enabled in current scene
  6214. cc.loader.setAutoReleaseRecursively(spriteFrame, false);
  6215. // don't release the Prefab and all the referenced assets
  6216. cc.loader.setAutoReleaseRecursively(prefab, false);
  6217. ```
  6218. */
  6219. setAutoReleaseRecursively(assetOrUrl : Asset|string, autoRelease : boolean) : void;
  6220. /** !#en
  6221. Returns whether the asset is configured as auto released, despite how "Auto Release Assets" property is set on scene asset.<br>
  6222. <br>
  6223. See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}
  6224. !#zh
  6225. 返回指定的资源是否有被设置为自动释放,不论场景的“Auto Release Assets”如何设置。<br>
  6226. <br>
  6227. 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}
  6228. @param assetOrUrl asset object or the raw asset's url
  6229. */
  6230. isAutoRelease(assetOrUrl : Asset|string) : boolean;
  6231. }
  6232. /** !#en
  6233. LoadingItems is the manager of items in pipeline.</br>
  6234. It hold a map of items, each entry in the map is a url to object key value pair.</br>
  6235. Each item always contains the following property:</br>
  6236. - id: The identification of the item, usually it's identical to url</br>
  6237. - url: The url </br>
  6238. - type: The type, it's the extension name of the url by default, could be specified manually too.</br>
  6239. - error: The error happened in pipeline will be stored in this property.</br>
  6240. - content: The content processed by the pipeline, the final result will also be stored in this property.</br>
  6241. - complete: The flag indicate whether the item is completed by the pipeline.</br>
  6242. - states: An object stores the states of each pipe the item go through, the state can be: Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE</br>
  6243. </br>
  6244. Item can hold other custom properties.
  6245. !#zh
  6246. LoadingItems 负责管理 pipeline 中的对象</br>
  6247. 它有一个 map 属性用来存放加载项,在 map 对象中已 url 为 key 值。</br>
  6248. 每个对象都会包含下列属性:</br>
  6249. - id:该对象的标识,通常与 url 相同。</br>
  6250. - url:路径 </br>
  6251. - type: 类型,它这是默认的 URL 的扩展名,可以手动指定赋值。</br>
  6252. - error:pipeline 中发生的错误将被保存在这个属性中。</br>
  6253. - content: pipeline 中处理的内容时,最终的结果也将被存储在这个属性中。</br>
  6254. - complete:该标志表明该对象是否通过 pipeline 完成。</br>
  6255. - states:该对象存储每个管道中对象经历的状态,状态可以是 Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE</br>
  6256. </br>
  6257. 对象可容纳其他自定义属性。 */
  6258. export class LoadingItems extends CallbacksInvoker {
  6259. /** !#en The map of all items.
  6260. !#zh 存储所有加载项的对象。 */
  6261. map : any;
  6262. /** !#en The map of completed items.
  6263. !#zh 存储已经完成的加载项。 */
  6264. completed : any;
  6265. /** !#en Total count of all items.
  6266. !#zh 所有加载项的总数。 */
  6267. totalCount : number;
  6268. /** !#en Total count of completed items.
  6269. !#zh 所有完成加载项的总数。 */
  6270. completedCount : number;
  6271. /** !#en Check whether all items are completed.
  6272. !#zh 检查是否所有加载项都已经完成。
  6273. */
  6274. isCompleted() : boolean;
  6275. /** !#en Check whether an item is completed.
  6276. !#zh 通过 id 检查指定加载项是否已经加载完成。
  6277. @param id The item's id.
  6278. */
  6279. isItemCompleted(id : string) : boolean;
  6280. /** !#en Check whether an item exists.
  6281. !#zh 通过 id 检查加载项是否存在。
  6282. @param id The item's id.
  6283. */
  6284. exists(id : string) : boolean;
  6285. /** !#en Returns the content of an internal item.
  6286. !#zh 通过 id 获取指定对象的内容。
  6287. @param id The item's id.
  6288. */
  6289. getContent(id : string) : any;
  6290. /** !#en Returns the error of an internal item.
  6291. !#zh 通过 id 获取指定对象的错误信息。
  6292. @param id The item's id.
  6293. */
  6294. getError(id : string) : any;
  6295. /** !#en Add a listener for an item, the callback will be invoked when the item is completed.
  6296. !#zh 监听加载项(通过 key 指定)的完成事件。
  6297. @param callback can be null
  6298. @param target can be null
  6299. */
  6300. addListener(key : string, callback : Function, target : any) : boolean;
  6301. /** !#en
  6302. Check if the specified key has any registered callback. </br>
  6303. If a callback is also specified, it will only return true if the callback is registered.
  6304. !#zh
  6305. 检查指定的加载项是否有完成事件监听器。</br>
  6306. 如果同时还指定了一个回调方法,并且回调有注册,它只会返回 true。
  6307. */
  6308. hasListener(key : string, callback? : Function, target? : any) : boolean;
  6309. /** !#en
  6310. Removes a listener. </br>
  6311. It will only remove when key, callback, target all match correctly.
  6312. !#zh
  6313. 移除指定加载项已经注册的完成事件监听器。</br>
  6314. 只会删除 key, callback, target 均匹配的监听器。
  6315. */
  6316. remove(key : string, callback : Function, target : any) : boolean;
  6317. /** !#en
  6318. Removes all callbacks registered in a certain event
  6319. type or all callbacks registered with a certain target.
  6320. !#zh 删除指定目标的所有完成事件监听器。
  6321. @param key The event key to be removed or the target to be removed
  6322. */
  6323. removeAllListeners(key : string|any) : void;
  6324. }
  6325. /** !#en
  6326. A pipeline describes a sequence of manipulations, each manipulation is called a pipe.</br>
  6327. It's designed for loading process. so items should be urls, and the url will be the identity of each item during the process.</br>
  6328. A list of items can flow in the pipeline and it will output the results of all pipes.</br>
  6329. They flow in the pipeline like water in tubes, they go through pipe by pipe separately.</br>
  6330. Finally all items will flow out the pipeline and the process is finished.
  6331. !#zh
  6332. pipeline 描述了一系列的操作,每个操作都被称为 pipe。</br>
  6333. 它被设计来做加载过程的流程管理。所以 item 应该是 url,并且该 url 将是在处理中的每个 item 的身份标识。</br>
  6334. 一个 item 列表可以在 pipeline 中流动,它将输出加载项经过所有 pipe 之后的结果。</br>
  6335. 它们穿过 pipeline 就像水在管子里流动,将会按顺序流过每个 pipe。</br>
  6336. 最后当所有加载项都流出 pipeline 时,整个加载流程就结束了。 */
  6337. export class Pipeline {
  6338. /** !#en
  6339. Constructor, pass an array of pipes to construct a new Pipeline,
  6340. the pipes will be chained in the given order.</br>
  6341. A pipe is an object which must contain an `id` in string and a `handle` function,
  6342. the id must be unique in the pipeline.</br>
  6343. It can also include `async` property to identify whether it's an asynchronous process.
  6344. !#zh
  6345. 构造函数,通过一系列的 pipe 来构造一个新的 pipeline,pipes 将会在给定的顺序中被锁定。</br>
  6346. 一个 pipe 就是一个对象,它包含了字符串类型的 ‘id’ 和 ‘handle’ 函数,在 pipeline 中 id 必须是唯一的。</br>
  6347. 它还可以包括 ‘async’ 属性以确定它是否是一个异步过程。
  6348. @example
  6349. ```js
  6350. var pipeline = new Pipeline([
  6351. {
  6352. id: 'Downloader',
  6353. handle: function (item, callback) {},
  6354. async: true
  6355. },
  6356. {id: 'Parser', handle: function (item) {}, async: false}
  6357. ]);
  6358. ```
  6359. */
  6360. Pipeline(pipes : any[]) : void;
  6361. /** !#en
  6362. Insert a new pipe at the given index of the pipeline. </br>
  6363. A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline.
  6364. !#zh
  6365. 在给定的索引位置插入一个新的 pipe。</br>
  6366. 一个 pipe 必须包含一个字符串类型的 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。
  6367. @param pipe The pipe to be inserted
  6368. @param index The index to insert
  6369. */
  6370. insertPipe(pipe : any, index : number) : void;
  6371. /** !#en
  6372. Add a new pipe at the end of the pipeline. </br>
  6373. A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline.
  6374. !#zh
  6375. 添加一个新的 pipe 到 pipeline 尾部。 </br>
  6376. 该 pipe 必须包含一个字符串类型 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。
  6377. @param pipe The pipe to be appended
  6378. */
  6379. appendPipe(pipe : any) : void;
  6380. /** !#en
  6381. Let new items flow into the pipeline. </br>
  6382. Each item can be a simple url string or an object,
  6383. if it's an object, it must contain `id` property. </br>
  6384. You can specify its type by `type` property, by default, the type is the extension name in url. </br>
  6385. By adding a `skips` property including pipe ids, you can skip these pipe. </br>
  6386. The object can contain any supplementary property as you want. </br>
  6387. !#zh
  6388. 让新的 item 流入 pipeline 中。</br>
  6389. 这里的每个 item 可以是一个简单字符串类型的 url 或者是一个对象,
  6390. 如果它是一个对象的话,他必须要包含 ‘id’ 属性。</br>
  6391. 你也可以指定它的 ‘type’ 属性类型,默认情况下,该类型是 ‘url’ 的后缀名。</br>
  6392. 也通过添加一个 包含 ‘skips’ 属性的 item 对象,你就可以跳过 skips 中包含的 pipe。</br>
  6393. 该对象可以包含任何附加属性。
  6394. @example
  6395. ```js
  6396. pipeline.flowIn([
  6397. 'res/Background.png',
  6398. {
  6399. id: 'res/scene.json',
  6400. type: 'scene',
  6401. name: 'scene',
  6402. skips: ['Downloader']
  6403. }
  6404. ]);
  6405. ```
  6406. */
  6407. flowIn(urlList : any[]) : any[];
  6408. /** !#en
  6409. Let new items flow into the pipeline and give a callback when the list of items are all completed. </br>
  6410. This is for loading dependencies for an existing item in flow, usually used in a pipe logic. </br>
  6411. For example, we have a loader for scene configuration file in JSON, the scene will only be fully loaded </br>
  6412. after all its dependencies are loaded, then you will need to use function to flow in all dependencies </br>
  6413. found in the configuration file, and finish the loader pipe only after all dependencies are loaded (in the callback).
  6414. !#zh
  6415. 让新 items 流入 pipeline 并且当 item 列表完成时进行回调函数。</br>
  6416. 这个 API 的使用通常是为了加载依赖项。</br>
  6417. 例如:</br>
  6418. 我们需要加载一个场景配置的 JSON 文件,该场景会将所有的依赖项全部都加载完毕以后,进行回调表示加载完毕。
  6419. */
  6420. flowInDeps(urlList : any[], callback : Function) : any[];
  6421. /** !#en
  6422. Copy the item states from one source item to all destination items. </br>
  6423. It's quite useful when a pipe generate new items from one source item,</br>
  6424. then you should flowIn these generated items into pipeline, </br>
  6425. but you probably want them to skip all pipes the source item already go through,</br>
  6426. you can achieve it with this API. </br>
  6427. </br>
  6428. For example, an unzip pipe will generate more items, but you won't want them to pass unzip or download pipe again.
  6429. !#zh
  6430. 从一个源 item 向所有目标 item 复制它的 pipe 状态,用于避免重复通过部分 pipe。</br>
  6431. 当一个源 item 生成了一系列新的 items 时很有用,</br>
  6432. 你希望让这些新的依赖项进入 pipeline,但是又不希望它们通过源 item 已经经过的 pipe,</br>
  6433. 但是你可能希望他们源 item 已经通过并跳过所有 pipes,</br>
  6434. 这个时候就可以使用这个 API。
  6435. @param srcItem The source item
  6436. @param dstItems A single destination item or an array of destination items
  6437. */
  6438. copyItemStates(srcItem : any, dstItems : any[]|any) : void;
  6439. /** !#en Returns whether the pipeline is flowing (contains item) currently.
  6440. !#zh 获取 pipeline 当前是否正在处理中。
  6441. */
  6442. isFlowing() : boolean;
  6443. /** !#en Returns all items in pipeline.
  6444. !#zh 获取 pipeline 中的所有 items。
  6445. */
  6446. getItems() : LoadingItems;
  6447. /** !#en Returns an item in pipeline.
  6448. !#zh 获取指定 item。
  6449. */
  6450. getItem() : LoadingItems;
  6451. /** !#en Removes an item in pipeline, no matter it's in progress or completed.
  6452. !#zh 移除指定 item,无论是进行时还是已完成。
  6453. */
  6454. removeItem() : boolean;
  6455. /** !#en Clear the current pipeline, this function will clean up the items.
  6456. !#zh 清空当前 pipeline,该函数将清理 items。
  6457. */
  6458. clear() : void;
  6459. /** !#en This is a callback which will be invoked while an item flow out the pipeline, you should overwrite this function.
  6460. !#zh 这个回调函数将在 item 流出 pipeline 时被调用,你应该重写该函数。
  6461. @param completedCount The number of the items that are already completed.
  6462. @param totalCount The total number of the items.
  6463. @param item The latest item which flow out the pipeline.
  6464. @example
  6465. ```js
  6466. pipeline.onProgress = function (completedCount, totalCount, item) {
  6467. var progress = (100 * completedCount / totalCount).toFixed(2);
  6468. cc.log(progress + '%');
  6469. }
  6470. ```
  6471. */
  6472. onProgress(completedCount : number, totalCount : number, item : any) : void;
  6473. /** !#en This is a callback which will be invoked while all items flow out the pipeline,
  6474. you should overwirte this function.
  6475. !#zh 该函数将在所有 item 流出 pipeline 时被调用,你应该重写该函数。
  6476. @param error All errored urls will be stored in this array, if no error happened, then it will be null
  6477. @param items All items.
  6478. @example
  6479. ```js
  6480. pipeline.onComplete = function (error, items) {
  6481. if (error)
  6482. cc.log('Completed with ' + error.length + ' errors');
  6483. else
  6484. cc.log('Completed ' + items.totalCount + ' items');
  6485. }
  6486. ```
  6487. */
  6488. onComplete(error : any[], items : LoadingItems) : void;
  6489. }
  6490. /** <p>
  6491. This class manages all events of input. include: touch, mouse, accelerometer, keyboard <br/>
  6492. </p> */
  6493. export class inputManager {
  6494. /**
  6495. */
  6496. handleTouchesBegin(touches : any[]) : void;
  6497. /**
  6498. */
  6499. handleTouchesMove(touches : any[]) : void;
  6500. /**
  6501. */
  6502. handleTouchesEnd(touches : any[]) : void;
  6503. /**
  6504. */
  6505. handleTouchesCancel(touches : any[]) : void;
  6506. /**
  6507. */
  6508. getSetOfTouchesEndOrCancel(touches : any[]) : any[];
  6509. /**
  6510. */
  6511. getHTMLElementPosition(element : HTMLElement) : any;
  6512. /**
  6513. */
  6514. getPreTouch(touch : Touch) : Touch;
  6515. /**
  6516. */
  6517. setPreTouch(touch : Touch) : void;
  6518. /**
  6519. */
  6520. getTouchByXY(tx : number, ty : number, pos : Vec2) : Touch;
  6521. /**
  6522. */
  6523. getTouchByXY(location : Vec2, pos : Vec2, eventType : number) : Event.EventMouse;
  6524. /**
  6525. */
  6526. getPointByEvent(event : Touch, pos : Vec2) : Vec2;
  6527. /**
  6528. */
  6529. getTouchesByEvent(event : Touch, pos : Vec2) : any[];
  6530. /**
  6531. */
  6532. registerSystemEvent(element : HTMLElement) : void;
  6533. /**
  6534. */
  6535. update(dt : number) : void;
  6536. }
  6537. /** Key map for keyboard event */
  6538. export enum KEY {
  6539. none = 0,
  6540. back = 0,
  6541. menu = 0,
  6542. backspace = 0,
  6543. tab = 0,
  6544. enter = 0,
  6545. shift = 0,
  6546. ctrl = 0,
  6547. alt = 0,
  6548. pause = 0,
  6549. capslock = 0,
  6550. escape = 0,
  6551. space = 0,
  6552. pageup = 0,
  6553. pagedown = 0,
  6554. end = 0,
  6555. home = 0,
  6556. left = 0,
  6557. up = 0,
  6558. right = 0,
  6559. down = 0,
  6560. select = 0,
  6561. insert = 0,
  6562. Delete = 0,
  6563. a = 0,
  6564. b = 0,
  6565. c = 0,
  6566. d = 0,
  6567. e = 0,
  6568. f = 0,
  6569. g = 0,
  6570. h = 0,
  6571. i = 0,
  6572. j = 0,
  6573. k = 0,
  6574. l = 0,
  6575. m = 0,
  6576. n = 0,
  6577. o = 0,
  6578. p = 0,
  6579. q = 0,
  6580. r = 0,
  6581. s = 0,
  6582. t = 0,
  6583. u = 0,
  6584. v = 0,
  6585. w = 0,
  6586. x = 0,
  6587. y = 0,
  6588. z = 0,
  6589. num0 = 0,
  6590. num1 = 0,
  6591. num2 = 0,
  6592. num3 = 0,
  6593. num4 = 0,
  6594. num5 = 0,
  6595. num6 = 0,
  6596. num7 = 0,
  6597. num8 = 0,
  6598. num9 = 0,
  6599. '*' = 0,
  6600. '+' = 0,
  6601. '-' = 0,
  6602. numdel = 0,
  6603. '/' = 0,
  6604. f1 = 0,
  6605. f2 = 0,
  6606. f3 = 0,
  6607. f4 = 0,
  6608. f5 = 0,
  6609. f6 = 0,
  6610. f7 = 0,
  6611. f8 = 0,
  6612. f9 = 0,
  6613. f10 = 0,
  6614. f11 = 0,
  6615. f12 = 0,
  6616. numlock = 0,
  6617. scrolllock = 0,
  6618. ';' = 0,
  6619. semicolon = 0,
  6620. equal = 0,
  6621. '=' = 0,
  6622. ',' = 0,
  6623. comma = 0,
  6624. dash = 0,
  6625. '.' = 0,
  6626. period = 0,
  6627. forwardslash = 0,
  6628. grave = 0,
  6629. '[' = 0,
  6630. openbracket = 0,
  6631. backslash = 0,
  6632. ']' = 0,
  6633. closebracket = 0,
  6634. quote = 0,
  6635. dpadLeft = 0,
  6636. dpadRight = 0,
  6637. dpadUp = 0,
  6638. dpadDown = 0,
  6639. dpadCenter = 0,
  6640. }
  6641. /** Image formats */
  6642. export enum ImageFormat {
  6643. JPG = 0,
  6644. PNG = 0,
  6645. TIFF = 0,
  6646. WEBP = 0,
  6647. PVR = 0,
  6648. ETC = 0,
  6649. S3TC = 0,
  6650. ATITC = 0,
  6651. TGA = 0,
  6652. RAWDATA = 0,
  6653. UNKNOWN = 0,
  6654. getImageFormatByData = 0,
  6655. }
  6656. /** Predefined constants */
  6657. export enum Macro {
  6658. INVALID_INDEX = 0,
  6659. NODE_TAG_INVALID = 0,
  6660. PI = 0,
  6661. PI2 = 0,
  6662. FLT_MAX = 0,
  6663. FLT_MIN = 0,
  6664. RAD = 0,
  6665. DEG = 0,
  6666. UINT_MAX = 0,
  6667. REPEAT_FOREVER = 0,
  6668. FLT_EPSILON = 0,
  6669. ONE = 0,
  6670. ZERO = 0,
  6671. SRC_ALPHA = 0,
  6672. SRC_ALPHA_SATURATE = 0,
  6673. SRC_COLOR = 0,
  6674. DST_ALPHA = 0,
  6675. DST_COLOR = 0,
  6676. ONE_MINUS_SRC_ALPHA = 0,
  6677. ONE_MINUS_SRC_COLOR = 0,
  6678. ONE_MINUS_DST_ALPHA = 0,
  6679. ONE_MINUS_DST_COLOR = 0,
  6680. ONE_MINUS_CONSTANT_ALPHA = 0,
  6681. ONE_MINUS_CONSTANT_COLOR = 0,
  6682. LINEAR = 0,
  6683. BLEND_DST = 0,
  6684. WEB_ORIENTATION_PORTRAIT = 0,
  6685. WEB_ORIENTATION_LANDSCAPE_LEFT = 0,
  6686. WEB_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 0,
  6687. WEB_ORIENTATION_LANDSCAPE_RIGHT = 0,
  6688. ORIENTATION_PORTRAIT = 0,
  6689. ORIENTATION_LANDSCAPE = 0,
  6690. ORIENTATION_AUTO = 0,
  6691. VERTEX_ATTRIB_FLAG_NONE = 0,
  6692. VERTEX_ATTRIB_FLAG_POSITION = 0,
  6693. VERTEX_ATTRIB_FLAG_COLOR = 0,
  6694. VERTEX_ATTRIB_FLAG_TEX_COORDS = 0,
  6695. VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0,
  6696. GL_ALL = 0,
  6697. VERTEX_ATTRIB_POSITION = 0,
  6698. VERTEX_ATTRIB_COLOR = 0,
  6699. VERTEX_ATTRIB_TEX_COORDS = 0,
  6700. VERTEX_ATTRIB_MAX = 0,
  6701. UNIFORM_PMATRIX = 0,
  6702. UNIFORM_MVMATRIX = 0,
  6703. UNIFORM_MVPMATRIX = 0,
  6704. UNIFORM_TIME = 0,
  6705. UNIFORM_SINTIME = 0,
  6706. UNIFORM_COSTIME = 0,
  6707. UNIFORM_RANDOM01 = 0,
  6708. UNIFORM_SAMPLER = 0,
  6709. UNIFORM_MAX = 0,
  6710. SHADER_POSITION_TEXTURECOLOR = 0,
  6711. SHADER_SPRITE_POSITION_TEXTURECOLOR = 0,
  6712. SHADER_POSITION_TEXTURECOLORALPHATEST = 0,
  6713. SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST = 0,
  6714. SHADER_POSITION_COLOR = 0,
  6715. SHADER_SPRITE_POSITION_COLOR = 0,
  6716. SHADER_POSITION_TEXTURE = 0,
  6717. SHADER_POSITION_TEXTURE_UCOLOR = 0,
  6718. SHADER_POSITION_TEXTUREA8COLOR = 0,
  6719. SHADER_POSITION_UCOLOR = 0,
  6720. SHADER_POSITION_LENGTHTEXTURECOLOR = 0,
  6721. UNIFORM_PMATRIX_S = 0,
  6722. UNIFORM_MVMATRIX_S = 0,
  6723. UNIFORM_MVPMATRIX_S = 0,
  6724. UNIFORM_TIME_S = 0,
  6725. UNIFORM_SINTIME_S = 0,
  6726. UNIFORM_COSTIME_S = 0,
  6727. UNIFORM_RANDOM01_S = 0,
  6728. UNIFORM_SAMPLER_S = 0,
  6729. UNIFORM_ALPHA_TEST_VALUE_S = 0,
  6730. ATTRIBUTE_NAME_COLOR = 0,
  6731. ATTRIBUTE_NAME_POSITION = 0,
  6732. ATTRIBUTE_NAME_TEX_COORD = 0,
  6733. ITEM_SIZE = 0,
  6734. CURRENT_ITEM = 0,
  6735. ZOOM_ACTION_TAG = 0,
  6736. NORMAL_TAG = 0,
  6737. SELECTED_TAG = 0,
  6738. DISABLE_TAG = 0,
  6739. FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0,
  6740. DIRECTOR_STATS_POSITION = 0,
  6741. DIRECTOR_FPS_INTERVAL = 0,
  6742. COCOSNODE_RENDER_SUBPIXEL = 0,
  6743. SPRITEBATCHNODE_RENDER_SUBPIXEL = 0,
  6744. AUTO_PREMULTIPLIED_ALPHA_FOR_PNG = 0,
  6745. OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0,
  6746. TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0,
  6747. TEXTURE_ATLAS_USE_VAO = 0,
  6748. USE_LA88_LABELS = 0,
  6749. SPRITE_DEBUG_DRAW = 0,
  6750. LABELBMFONT_DEBUG_DRAW = 0,
  6751. LABELATLAS_DEBUG_DRAW = 0,
  6752. ENABLE_STACKABLE_ACTIONS = 0,
  6753. ENABLE_GL_STATE_CACHE = 0,
  6754. BLEND_SRC = 0,
  6755. lerp = 0,
  6756. rand = 0,
  6757. randomMinus1To1 = 0,
  6758. random0To1 = 0,
  6759. degreesToRadians = 0,
  6760. radiansToDegrees = 0,
  6761. nodeDrawSetup = 0,
  6762. incrementGLDraws = 0,
  6763. checkGLErrorDebug = 0,
  6764. }
  6765. /** The base class of most of all the objects in Fireball. */
  6766. export class Object {
  6767. constructor();
  6768. /** !#en The name of the object.
  6769. !#zh 该对象的名称。 */
  6770. name : string;
  6771. /** !#en Indicates whether the object is not yet destroyed.
  6772. !#zh 表示该对象是否可用(被销毁后将不可用)。 */
  6773. isValid : boolean;
  6774. /** !#en
  6775. Destroy this Object, and release all its own references to other objects.<br/>
  6776. Actual object destruction will delayed until before rendering.
  6777. <br/>
  6778. After destroy, this CCObject is not usable any more.
  6779. You can use cc.isValid(obj) to check whether the object is destroyed before accessing it.
  6780. !#zh
  6781. 销毁该对象,并释放所有它对其它对象的引用。<br/>
  6782. 销毁后,CCObject 不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
  6783. 实际销毁操作会延迟到当前帧渲染前执行。
  6784. @example
  6785. ```js
  6786. obj.destroy();
  6787. ```
  6788. */
  6789. destroy() : boolean;
  6790. }
  6791. /** Bit mask that controls object states. */
  6792. export class Flags {
  6793. /** !#en The object will not be saved.
  6794. !#zh 该对象将不会被保存。 */
  6795. DontSave : number;
  6796. /** !#en The object will not be saved when building a player.
  6797. !#zh 构建项目时,该对象将不会被保存。 */
  6798. EditorOnly : number;
  6799. }
  6800. /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen.
  6801. It's invalid on safari, QQbrowser and android browser */
  6802. export class screen {
  6803. /** initialize
  6804. */
  6805. init() : void;
  6806. /** return true if it's full now.
  6807. */
  6808. fullScreen() : boolean;
  6809. /** change the screen to full mode.
  6810. */
  6811. requestFullScreen(element : Element, onFullScreenChange : Function) : void;
  6812. /** exit the full mode.
  6813. */
  6814. exitFullScreen() : boolean;
  6815. /** Automatically request full screen with a touch/click event
  6816. */
  6817. autoFullScreen(element : Element, onFullScreenChange : Function) : void;
  6818. }
  6819. /** System variables */
  6820. export class sys {
  6821. /** English language code */
  6822. LANGUAGE_ENGLISH : string;
  6823. /** Chinese language code */
  6824. LANGUAGE_CHINESE : string;
  6825. /** French language code */
  6826. LANGUAGE_FRENCH : string;
  6827. /** Italian language code */
  6828. LANGUAGE_ITALIAN : string;
  6829. /** German language code */
  6830. LANGUAGE_GERMAN : string;
  6831. /** Spanish language code */
  6832. LANGUAGE_SPANISH : string;
  6833. /** Spanish language code */
  6834. LANGUAGE_DUTCH : string;
  6835. /** Russian language code */
  6836. LANGUAGE_RUSSIAN : string;
  6837. /** Korean language code */
  6838. LANGUAGE_KOREAN : string;
  6839. /** Japanese language code */
  6840. LANGUAGE_JAPANESE : string;
  6841. /** Hungarian language code */
  6842. LANGUAGE_HUNGARIAN : string;
  6843. /** Portuguese language code */
  6844. LANGUAGE_PORTUGUESE : string;
  6845. /** Arabic language code */
  6846. LANGUAGE_ARABIC : string;
  6847. /** Norwegian language code */
  6848. LANGUAGE_NORWEGIAN : string;
  6849. /** Polish language code */
  6850. LANGUAGE_POLISH : string;
  6851. /** Unknown language code */
  6852. LANGUAGE_UNKNOWN : string;
  6853. OS_IOS : string;
  6854. OS_ANDROID : string;
  6855. OS_WINDOWS : string;
  6856. OS_MARMALADE : string;
  6857. OS_LINUX : string;
  6858. OS_BADA : string;
  6859. OS_BLACKBERRY : string;
  6860. OS_OSX : string;
  6861. OS_WP8 : string;
  6862. OS_WINRT : string;
  6863. OS_UNKNOWN : string;
  6864. UNKNOWN : number;
  6865. WIN32 : number;
  6866. LINUX : number;
  6867. MACOS : number;
  6868. ANDROID : number;
  6869. IPHONE : number;
  6870. IPAD : number;
  6871. BLACKBERRY : number;
  6872. NACL : number;
  6873. EMSCRIPTEN : number;
  6874. TIZEN : number;
  6875. WINRT : number;
  6876. WP8 : number;
  6877. MOBILE_BROWSER : number;
  6878. DESKTOP_BROWSER : number;
  6879. /** Indicates whether executes in editor's window process (Electron's renderer context) */
  6880. EDITOR_PAGE : number;
  6881. /** Indicates whether executes in editor's main process (Electron's browser context) */
  6882. EDITOR_CORE : number;
  6883. /** BROWSER_TYPE_WECHAT */
  6884. BROWSER_TYPE_WECHAT : string;
  6885. BROWSER_TYPE_ANDROID : string;
  6886. BROWSER_TYPE_IE : string;
  6887. BROWSER_TYPE_QQ : string;
  6888. BROWSER_TYPE_MOBILE_QQ : string;
  6889. BROWSER_TYPE_UC : string;
  6890. BROWSER_TYPE_360 : string;
  6891. BROWSER_TYPE_BAIDU_APP : string;
  6892. BROWSER_TYPE_BAIDU : string;
  6893. BROWSER_TYPE_MAXTHON : string;
  6894. BROWSER_TYPE_OPERA : string;
  6895. BROWSER_TYPE_OUPENG : string;
  6896. BROWSER_TYPE_MIUI : string;
  6897. BROWSER_TYPE_FIREFOX : string;
  6898. BROWSER_TYPE_SAFARI : string;
  6899. BROWSER_TYPE_CHROME : string;
  6900. BROWSER_TYPE_LIEBAO : string;
  6901. BROWSER_TYPE_QZONE : string;
  6902. BROWSER_TYPE_SOUGOU : string;
  6903. BROWSER_TYPE_UNKNOWN : string;
  6904. /** Is native ? This is set to be true in jsb auto. */
  6905. isNative : boolean;
  6906. /** Is web browser ? */
  6907. isBrowser : boolean;
  6908. /** Indicate whether system is mobile system */
  6909. isMobile : boolean;
  6910. /** Indicate the running platform */
  6911. platform : number;
  6912. /** Indicate the current language of the running system */
  6913. language : string;
  6914. /** Indicate the running os name */
  6915. os : string;
  6916. /** Indicate the running os version */
  6917. osVersion : string;
  6918. /** Indicate the running os main version */
  6919. osMainVersion : number;
  6920. /** Indicate the running browser type */
  6921. browserType : string;
  6922. /** Indicate the running browser version */
  6923. browserVersion : number;
  6924. /** Indicate the real pixel resolution of the whole game window */
  6925. windowPixelResolution : number;
  6926. /** cc.sys.localStorage is a local storage component. */
  6927. localStorage : any;
  6928. /** The capabilities of the current platform */
  6929. capabilities : any;
  6930. /** Forces the garbage collection, only available in JSB
  6931. */
  6932. garbageCollect() : void;
  6933. /** Dumps rooted objects, only available in JSB
  6934. */
  6935. dumpRoot() : void;
  6936. /** Restart the JS VM, only available in JSB
  6937. */
  6938. restartVM() : void;
  6939. /** Clean a script in the JS VM, only available in JSB
  6940. */
  6941. cleanScript(jsfile : string) : void;
  6942. /** Check whether an object is valid,
  6943. In web engine, it will return true if the object exist
  6944. In native engine, it will return true if the JS object and the correspond native object are both valid
  6945. */
  6946. isObjectValid(obj : any) : boolean;
  6947. /** Dump system informations
  6948. */
  6949. dump() : void;
  6950. /** Open a url in browser
  6951. */
  6952. openURL(url : string) : void;
  6953. }
  6954. /** cc.view is the singleton object which represents the game window.<br/>
  6955. It's main task include: <br/>
  6956. - Apply the design resolution policy<br/>
  6957. - Provide interaction with the window, like resize event on web, retina display support, etc...<br/>
  6958. - Manage the game view port which can be different with the window<br/>
  6959. - Manage the content scale and translation<br/>
  6960. <br/>
  6961. Since the cc.view is a singleton, you don't need to call any constructor or create functions,<br/>
  6962. the standard way to use it is by calling:<br/>
  6963. - cc.view.methodName(); <br/> */
  6964. export class View {
  6965. /** <p>
  6966. Sets view's target-densitydpi for android mobile browser. it can be set to: <br/>
  6967. 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi" <br/>
  6968. 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value) <br/>
  6969. 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value) <br/>
  6970. 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi" <br/>
  6971. 5. Custom value, e.g: "480" <br/>
  6972. </p>
  6973. */
  6974. setTargetDensityDPI(densityDPI : string) : void;
  6975. /** Returns the current target-densitydpi value of cc.view.
  6976. */
  6977. getTargetDensityDPI() : string;
  6978. /** Sets whether resize canvas automatically when browser's size changed.<br/>
  6979. Useful only on web.
  6980. @param enabled Whether enable automatic resize with browser's resize event
  6981. */
  6982. resizeWithBrowserSize(enabled : boolean) : void;
  6983. /** Sets the callback function for cc.view's resize action,<br/>
  6984. this callback will be invoked before applying resolution policy, <br/>
  6985. so you can do any additional modifications within the callback.<br/>
  6986. Useful only on web.
  6987. @param callback The callback function
  6988. */
  6989. setResizeCallback(callback : Function|void) : void;
  6990. /** Sets the orientation of the game, it can be landscape, portrait or auto.
  6991. When set it to landscape or portrait, and screen w/h ratio doesn't fit,
  6992. cc.view will automatically rotate the game canvas using CSS.
  6993. Note that this function doesn't have any effect in native,
  6994. in native, you need to set the application orientation in native project settings
  6995. @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO
  6996. */
  6997. setOrientation(orientation : number) : void;
  6998. /** Sets whether the engine modify the "viewport" meta in your web page.<br/>
  6999. It's enabled by default, we strongly suggest you not to disable it.<br/>
  7000. And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden<br/>
  7001. Only useful on web
  7002. @param enabled Enable automatic modification to "viewport" meta
  7003. */
  7004. adjustViewPort(enabled : boolean) : void;
  7005. /** Retina support is enabled by default for Apple device but disabled for other devices,<br/>
  7006. it takes effect only when you called setDesignResolutionPolicy<br/>
  7007. Only useful on web
  7008. @param enabled Enable or disable retina display
  7009. */
  7010. enableRetina(enabled : boolean) : void;
  7011. /** Check whether retina display is enabled.<br/>
  7012. Only useful on web
  7013. */
  7014. isRetinaEnabled() : boolean;
  7015. /** If enabled, the application will try automatically to enter full screen mode on mobile devices<br/>
  7016. You can pass true as parameter to enable it and disable it by passing false.<br/>
  7017. Only useful on web
  7018. @param enabled Enable or disable auto full screen on mobile devices
  7019. */
  7020. enableAutoFullScreen(enabled : boolean) : void;
  7021. /** Check whether auto full screen is enabled.<br/>
  7022. Only useful on web
  7023. */
  7024. isAutoFullScreenEnabled() : boolean;
  7025. /** Get whether render system is ready(no matter opengl or canvas),<br/>
  7026. this name is for the compatibility with cocos2d-x, subclass must implement this method.
  7027. */
  7028. isViewReady() : boolean;
  7029. /** Sets the resolution translate on View.
  7030. */
  7031. setContentTranslateLeftTop(offsetLeft : number, offsetTop : number) : void;
  7032. /** Returns the resolution translate on View
  7033. */
  7034. getContentTranslateLeftTop() : Size;
  7035. /** Returns the frame size of the view.<br/>
  7036. On native platforms, it returns the screen size since the view is a fullscreen view.<br/>
  7037. On web, it returns the size of the canvas's outer DOM element.
  7038. */
  7039. getFrameSize() : Size;
  7040. /** On native, it sets the frame size of view.<br/>
  7041. On web, it sets the size of the canvas's outer DOM element.
  7042. */
  7043. setFrameSize(width : number, height : number) : void;
  7044. /** Returns the visible area size of the view port.
  7045. */
  7046. getVisibleSize() : Size;
  7047. /** Returns the visible area size of the view port.
  7048. */
  7049. getVisibleSizeInPixel() : Size;
  7050. /** Returns the visible origin of the view port.
  7051. */
  7052. getVisibleOrigin() : Vec2;
  7053. /** Returns the visible origin of the view port.
  7054. */
  7055. getVisibleOriginInPixel() : Vec2;
  7056. /** Returns whether developer can set content's scale factor.
  7057. */
  7058. canSetContentScaleFactor() : boolean;
  7059. /** Returns the current resolution policy
  7060. */
  7061. getResolutionPolicy() : ResolutionPolicy;
  7062. /** Sets the current resolution policy
  7063. */
  7064. setResolutionPolicy(resolutionPolicy : ResolutionPolicy|number) : void;
  7065. /** Sets the resolution policy with designed view size in points.<br/>
  7066. The resolution policy include: <br/>
  7067. [1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.<br/>
  7068. [2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.<br/>
  7069. [3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.<br/>
  7070. [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width<br/>
  7071. [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height<br/>
  7072. [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy<br/>
  7073. @param width Design resolution width.
  7074. @param height Design resolution height.
  7075. @param resolutionPolicy The resolution policy desired
  7076. */
  7077. setDesignResolutionSize(width : number, height : number, resolutionPolicy : ResolutionPolicy|number) : void;
  7078. /** Returns the designed size for the view.
  7079. Default resolution size is the same as 'getFrameSize'.
  7080. */
  7081. getDesignResolutionSize() : Size;
  7082. /** Sets the container to desired pixel resolution and fit the game content to it.
  7083. This function is very useful for adaptation in mobile browsers.
  7084. In some HD android devices, the resolution is very high, but its browser performance may not be very good.
  7085. In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry.
  7086. But this API can be helpful to set a desired pixel resolution which is in between.
  7087. This API will do the following:
  7088. 1. Set viewport's width to the desired width in pixel
  7089. 2. Set body width to the exact pixel resolution
  7090. 3. The resolution policy will be reset with designed view size in points.
  7091. @param width Design resolution width.
  7092. @param height Design resolution height.
  7093. @param resolutionPolicy The resolution policy desired
  7094. */
  7095. setRealPixelResolution(width : number, height : number, resolutionPolicy : ResolutionPolicy|number) : void;
  7096. /** Sets view port rectangle with points.
  7097. @param w width
  7098. @param h height
  7099. */
  7100. setViewPortInPoints(x : number, y : number, w : number, h : number) : void;
  7101. /** Sets Scissor rectangle with points.
  7102. */
  7103. setScissorInPoints(x : number, y : number, w : number, h : number) : void;
  7104. /** Returns whether GL_SCISSOR_TEST is enable
  7105. */
  7106. isScissorEnabled() : boolean;
  7107. /** Returns the current scissor rectangle
  7108. */
  7109. getScissorRect() : Rect;
  7110. /** Sets the name of the view
  7111. */
  7112. setViewName(viewName : string) : void;
  7113. /** Returns the name of the view
  7114. */
  7115. getViewName() : string;
  7116. /** Returns the view port rectangle.
  7117. */
  7118. getViewPortRect() : Rect;
  7119. /** Returns scale factor of the horizontal direction (X axis).
  7120. */
  7121. getScaleX() : number;
  7122. /** Returns scale factor of the vertical direction (Y axis).
  7123. */
  7124. getScaleY() : number;
  7125. /** Returns device pixel ratio for retina display.
  7126. */
  7127. getDevicePixelRatio() : number;
  7128. /** Returns the real location in view for a translation based on a related position
  7129. @param tx The X axis translation
  7130. @param ty The Y axis translation
  7131. @param relatedPos The related position object including "left", "top", "width", "height" informations
  7132. */
  7133. convertToLocationInView(tx : number, ty : number, relatedPos : any) : Vec2;
  7134. }
  7135. /** <p>cc.ContainerStrategy class is the root strategy class of container's scale strategy,
  7136. it controls the behavior of how to scale the cc.container and cc.game.canvas object</p> */
  7137. export class ContainerStrategy {
  7138. /** Manipulation before appling the strategy
  7139. @param view The target view
  7140. */
  7141. preApply(view : View) : void;
  7142. /** Function to apply this strategy
  7143. */
  7144. apply(view : View, designedResolution : Size) : void;
  7145. /** Manipulation after applying the strategy
  7146. @param view The target view
  7147. */
  7148. postApply(view : View) : void;
  7149. }
  7150. /** <p>cc.ContentStrategy class is the root strategy class of content's scale strategy,
  7151. it controls the behavior of how to scale the scene and setup the viewport for the game</p> */
  7152. export class ContentStrategy {
  7153. /** Manipulation before applying the strategy
  7154. @param view The target view
  7155. */
  7156. preApply(view : View) : void;
  7157. /** Function to apply this strategy
  7158. The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
  7159. The target view can then apply these value to itself, it's preferred not to modify directly its private variables
  7160. */
  7161. apply(view : View, designedResolution : Size) : any;
  7162. /** Manipulation after applying the strategy
  7163. @param view The target view
  7164. */
  7165. postApply(view : View) : void;
  7166. }
  7167. /** undefined */
  7168. export class EqualToFrame extends ContainerStrategy {
  7169. }
  7170. /** undefined */
  7171. export class ProportionalToFrame extends ContainerStrategy {
  7172. }
  7173. /** undefined */
  7174. export class EqualToWindow extends EqualToFrame {
  7175. }
  7176. /** undefined */
  7177. export class ProportionalToWindow extends ProportionalToFrame {
  7178. }
  7179. /** undefined */
  7180. export class OriginalContainer extends ContainerStrategy {
  7181. }
  7182. /** <p>cc.ResolutionPolicy class is the root strategy class of scale strategy,
  7183. its main task is to maintain the compatibility with Cocos2d-x</p> */
  7184. export class ResolutionPolicy {
  7185. /**
  7186. @param containerStg The container strategy
  7187. @param contentStg The content strategy
  7188. */
  7189. ResolutionPolicy(containerStg : ContainerStrategy, contentStg : ContentStrategy) : void;
  7190. /** Manipulation before applying the resolution policy
  7191. @param view The target view
  7192. */
  7193. preApply(view : View) : void;
  7194. /** Function to apply this resolution policy
  7195. The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
  7196. The target view can then apply these value to itself, it's preferred not to modify directly its private variables
  7197. @param view The target view
  7198. @param designedResolution The user defined design resolution
  7199. */
  7200. apply(view : View, designedResolution : Size) : any;
  7201. /** Manipulation after appyling the strategy
  7202. @param view The target view
  7203. */
  7204. postApply(view : View) : void;
  7205. /** Setup the container's scale strategy
  7206. */
  7207. setContainerStrategy(containerStg : ContainerStrategy) : void;
  7208. /** Setup the content's scale strategy
  7209. */
  7210. setContentStrategy(contentStg : ContentStrategy) : void;
  7211. /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.<br/>
  7212. Distortion can occur, and the application may appear stretched or compressed. */
  7213. EXACT_FIT : number;
  7214. /** The entire application fills the specified area, without distortion but possibly with some cropping,<br/>
  7215. while maintaining the original aspect ratio of the application. */
  7216. NO_BORDER : number;
  7217. /** The entire application is visible in the specified area without distortion while maintaining the original<br/>
  7218. aspect ratio of the application. Borders can appear on two sides of the application. */
  7219. SHOW_ALL : number;
  7220. /** The application takes the height of the design resolution size and modifies the width of the internal<br/>
  7221. canvas so that it fits the aspect ratio of the device<br/>
  7222. no distortion will occur however you must make sure your application works on different<br/>
  7223. aspect ratios */
  7224. FIXED_HEIGHT : number;
  7225. /** The application takes the width of the design resolution size and modifies the height of the internal<br/>
  7226. canvas so that it fits the aspect ratio of the device<br/>
  7227. no distortion will occur however you must make sure your application works on different<br/>
  7228. aspect ratios */
  7229. FIXED_WIDTH : number;
  7230. /** Unknow policy */
  7231. UNKNOWN : number;
  7232. }
  7233. /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view,
  7234. it should represent the same rect as cc.view.getViewportRect() */
  7235. export class visibleRect {
  7236. /** initialize
  7237. */
  7238. init(visibleRect : Rect) : void;
  7239. /** Top left coordinate of the screen related to the game scene. */
  7240. topLeft : Vec2;
  7241. /** Top right coordinate of the screen related to the game scene. */
  7242. topRight : Vec2;
  7243. /** Top center coordinate of the screen related to the game scene. */
  7244. top : Vec2;
  7245. /** Bottom left coordinate of the screen related to the game scene. */
  7246. bottomLeft : Vec2;
  7247. /** Bottom right coordinate of the screen related to the game scene. */
  7248. bottomRight : Vec2;
  7249. /** Bottom center coordinate of the screen related to the game scene. */
  7250. bottom : Vec2;
  7251. /** Center coordinate of the screen related to the game scene. */
  7252. center : Vec2;
  7253. /** Left center coordinate of the screen related to the game scene. */
  7254. left : Vec2;
  7255. /** Right center coordinate of the screen related to the game scene. */
  7256. right : Vec2;
  7257. /** Width of the screen. */
  7258. width : number;
  7259. /** Height of the screen. */
  7260. height : number;
  7261. }
  7262. /** The CallbacksHandler is an abstract class that can register and unregister callbacks by key.
  7263. Subclasses should implement their own methods about how to invoke the callbacks. */
  7264. export class _CallbacksHandler {
  7265. constructor();
  7266. /**
  7267. @param target can be null
  7268. */
  7269. add(key : string, callback : Function, target? : any) : boolean;
  7270. /** Check if the specified key has any registered callback. If a callback is also specified,
  7271. it will only return true if the callback is registered.
  7272. */
  7273. has(key : string, callback? : Function, target? : any) : boolean;
  7274. /** Removes all callbacks registered in a certain event type or all callbacks registered with a certain target
  7275. @param key The event key to be removed or the target to be removed
  7276. */
  7277. removeAll(key : string|any) : void;
  7278. /**
  7279. */
  7280. remove(key : string, callback : Function, target : any) : boolean;
  7281. }
  7282. /** !#en The callbacks invoker to handle and invoke callbacks by key.
  7283. !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */
  7284. export class CallbacksInvoker extends _CallbacksHandler {
  7285. constructor();
  7286. /**
  7287. */
  7288. invoke(key : string, p1? : any, p2? : any, p3? : any, p4? : any, p5? : any) : void;
  7289. /**
  7290. */
  7291. invokeAndRemove(key : string, p1? : any, p2? : any, p3? : any, p4? : any, p5? : any) : void;
  7292. /**
  7293. @param remove remove callbacks after invoked
  7294. */
  7295. bindKey(key : string, remove? : boolean) : Function;
  7296. }
  7297. /** !#en Contains information collected during deserialization
  7298. !#zh 包含反序列化时的一些信息 */
  7299. export class Details {
  7300. constructor();
  7301. /** list of the depends assets' uuid */
  7302. uuidList : String[];
  7303. /** the obj list whose field needs to load asset by uuid */
  7304. uuidObjList : any[];
  7305. /** the corresponding field name which referenced to the asset */
  7306. uuidPropList : String[];
  7307. /** the corresponding field name which referenced to the raw object */
  7308. rawProp : string;
  7309. reset() : void;
  7310. /**
  7311. */
  7312. getUuidOf(obj : any, propName : string) : string;
  7313. /**
  7314. */
  7315. push(obj : any, propName : string, uuid : string) : void;
  7316. }
  7317. /** undefined */
  7318. export class url {
  7319. /** Returns the url of raw assets, you will only need this if the raw asset is inside the "resources" folder.
  7320. @example
  7321. ```js
  7322. ---
  7323. var url = cc.url.raw("textures/myTexture.png");
  7324. console.log(url); // "resources/raw/textures/myTexture.png"
  7325. ```
  7326. */
  7327. raw(url : string) : string;
  7328. /** Returns the url of builtin raw assets. This method can only used in editor.
  7329. @example
  7330. ```js
  7331. ---
  7332. var url = cc.url.builtinRaw("textures/myTexture.png");
  7333. console.log(url); // "resources/default-raw/textures/myTexture.png"
  7334. ```
  7335. */
  7336. builtinRaw(url : string) : string;
  7337. }
  7338. /** !#en
  7339. A cc.SpriteFrame has:<br/>
  7340. - texture: A cc.Texture2D that will be used by the _ccsg.Sprite<br/>
  7341. - rectangle: A rectangle of the texture<br/>
  7342. <br/>
  7343. You can modify the frame of a _ccsg.Sprite by doing:<br/>
  7344. Note: It's not recommended to use SpriteFrame constructor (new SpriteFrame)
  7345. because its memory usage can't be tracked in native environment, <br/>
  7346. if you know what you are doing, you may need to manually retain it after creation then
  7347. release it when you no longer need it.
  7348. !#zh
  7349. 一个 SpriteFrame 包含:<br/>
  7350. - 纹理:会被 Sprite 使用的 Texture2D 对象。<br/>
  7351. - 矩形:在纹理中的矩形区域。<br/>
  7352. 注意:<br/>
  7353. 不建议用户使用构造函数进行创建,因为其内存使用情况,不能在本地环境中进行跟踪,需要用户手动管理内存,不然会导致严重错误。<br/>
  7354. 如果你知道你在做什么,你可能需要手动将其保留在创建之后,然后释放它。 */
  7355. export class SpriteFrame extends Asset {
  7356. constructor();
  7357. /** !#en
  7358. Constructor of SpriteFrame class. <br/>
  7359. Note: It's not recommended to use SpriteFrame constructor (new SpriteFrame)
  7360. because its memory usage can't be tracked in native environment, <br/>
  7361. if you know what you are doing, you may need to manually retain it after creation then
  7362. release it when you no longer need it.
  7363. !#zh
  7364. SpriteFrame 类的构造函数。<br/>
  7365. 注意:<br/>
  7366. 不建议用户使用构造函数进行创建,因为其内存使用情况,不能在本地环境中进行跟踪,
  7367. 需要用户手动管理内存,不然会导致严重错误。<br/>
  7368. 如果你知道你在做什么,你可能需要手动将其保留在创建之后,然后释放它。
  7369. @param rotated Whether the frame is rotated in the texture
  7370. @param offset The offset of the frame in the texture
  7371. @param originalSize The size of the frame in the texture
  7372. */
  7373. SpriteFrame(filename? : string|Texture2D, rect? : Rect, rotated? : boolean, offset? : Vec2, originalSize? : Size) : void;
  7374. /** !#en Top border of the sprite
  7375. !#zh sprite 的顶部边框 */
  7376. insetTop : number;
  7377. /** !#en Bottom border of the sprite
  7378. !#zh sprite 的底部边框 */
  7379. insetBottom : number;
  7380. /** !#en Left border of the sprite
  7381. !#zh sprite 的左边边框 */
  7382. insetLeft : number;
  7383. /** !#en Right border of the sprite
  7384. !#zh sprite 的左边边框 */
  7385. insetRight : number;
  7386. /** !#en Returns whether the texture have been loaded
  7387. !#zh 返回是否已加载纹理
  7388. */
  7389. textureLoaded() : boolean;
  7390. /** Add a event listener for texture loaded event.
  7391. */
  7392. addLoadedEventListener(callback : Function, target : any) : void;
  7393. /** !#en Returns whether the sprite frame is rotated in the texture.
  7394. !#zh 获取 SpriteFrame 是否旋转
  7395. */
  7396. isRotated() : boolean;
  7397. /** !#en Set whether the sprite frame is rotated in the texture.
  7398. !#zh 设置 SpriteFrame 是否旋转
  7399. */
  7400. setRotated(bRotated : boolean) : void;
  7401. /** !#en Returns the rect of the sprite frame in the texture.
  7402. !#zh 获取 SpriteFrame 的纹理矩形区域
  7403. */
  7404. getRect() : Rect;
  7405. /** !#en Sets the rect of the sprite frame in the texture.
  7406. !#zh 设置 SpriteFrame 的纹理矩形区域
  7407. */
  7408. setRect(rect : Rect) : void;
  7409. /** !#en Returns the original size of the trimmed image.
  7410. !#zh 获取修剪前的原始大小
  7411. */
  7412. getOriginalSize() : Size;
  7413. /** !#en Sets the original size of the trimmed image.
  7414. !#zh 设置修剪前的原始大小
  7415. */
  7416. setOriginalSize(size : Size) : void;
  7417. /** !#en Returns the texture of the frame.
  7418. !#zh 获取使用的纹理实例
  7419. */
  7420. getTexture() : Texture2D;
  7421. /** !#en Sets the texture of the frame, the texture is retained automatically.
  7422. !#zh 设置使用的纹理实例,会被 retain。
  7423. */
  7424. _refreshTexture(texture : Texture2D) : void;
  7425. /** !#en Returns the offset of the frame in the texture.
  7426. !#zh 获取偏移量
  7427. */
  7428. getOffset() : Vec2;
  7429. /** !#en Sets the offset of the frame in the texture.
  7430. !#zh 设置偏移量
  7431. */
  7432. setOffset(offsets : Vec2) : void;
  7433. /** !#en Clone the sprite frame.
  7434. !#zh 克隆 SpriteFrame
  7435. */
  7436. clone() : SpriteFrame;
  7437. /** !#en If a loading scene is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which
  7438. associated by user's custom Components in the scene, will not preload automatically.
  7439. These textures will be load when Sprite component is going to render the SpriteFrames.
  7440. You can call this method if you want to load the texture early.
  7441. !#zh 当加载中的场景被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。
  7442. 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。
  7443. @example
  7444. ```js
  7445. if (spriteFrame.textureLoaded()) {
  7446. this._onSpriteFrameLoaded();
  7447. }
  7448. else {
  7449. spriteFrame.once('load', this._onSpriteFrameLoaded, this);
  7450. spriteFrame.ensureLoadTexture();
  7451. }
  7452. ```
  7453. */
  7454. ensureLoadTexture() : void;
  7455. }
  7456. /** <p>
  7457. This class allows to easily create OpenGL or Canvas 2D textures from images, text or raw data. <br/>
  7458. The created cc.Texture2D object will always have power-of-two dimensions. <br/>
  7459. Depending on how you create the cc.Texture2D object, the actual image area of the texture might be smaller than the texture dimensions <br/>
  7460. i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0). <br/>
  7461. Be aware that the content of the generated textures will be upside-down! </p> */
  7462. export class Texture2D extends RawAsset {
  7463. /** Get width in pixels.
  7464. */
  7465. getPixelWidth() : number;
  7466. /** Get height of in pixels.
  7467. */
  7468. getPixelHeight() : number;
  7469. /** Get content size.
  7470. */
  7471. getContentSize() : Size;
  7472. /** Get content size in pixels.
  7473. */
  7474. getContentSizeInPixels() : Size;
  7475. /** Init with HTML element.
  7476. @example
  7477. ```js
  7478. var img = new Image();
  7479. img.src = dataURL;
  7480. texture.initWithElement(img);
  7481. texture.handleLoadedTexture();
  7482. ```
  7483. */
  7484. initWithElement(element : HTMLImageElement|HTMLCanvasElement) : void;
  7485. /** Intializes with a texture2d with data.
  7486. */
  7487. initWithData(data : any[], pixelFormat : number, pixelsWide : number, pixelsHigh : number, contentSize : Size) : boolean;
  7488. /** Initializes a texture from a UIImage object.
  7489. Extensions to make it easy to create a CCTexture2D object from an image file.
  7490. Note that RGBA type textures will have their alpha premultiplied - use the blending mode (gl.ONE, gl.ONE_MINUS_SRC_ALPHA).
  7491. */
  7492. initWithImage(uiImage : HTMLImageElement) : boolean;
  7493. /** HTMLElement Object getter.
  7494. */
  7495. getHtmlElementObj() : HTMLImageElement;
  7496. /** Check whether texture is loaded.
  7497. */
  7498. isLoaded() : boolean;
  7499. /** Handler of texture loaded event.
  7500. */
  7501. handleLoadedTexture(premultiplied? : boolean) : void;
  7502. /** Description of cc.Texture2D.
  7503. */
  7504. description() : string;
  7505. /** Release texture.
  7506. */
  7507. releaseTexture() : void;
  7508. /** Pixel format of the texture.
  7509. */
  7510. getPixelFormat() : number;
  7511. /** Whether or not the texture has their Alpha premultiplied,
  7512. support only in WebGl rendering mode.
  7513. */
  7514. hasPremultipliedAlpha() : boolean;
  7515. /** Whether or not use mipmap, support only in WebGl rendering mode.
  7516. */
  7517. hasMipmaps() : boolean;
  7518. /** Sets the min filter, mag filter, wrap s and wrap t texture parameters. <br/>
  7519. If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}.
  7520. @param texParams texParams object or minFilter
  7521. */
  7522. setTexParameters(texParams : any|number, magFilter? : number, wrapS? : Texture2D.WrapMode, wrapT? : Texture2D.WrapMode) : void;
  7523. /** WebGLTexture Object. */
  7524. name : WebGLTexture;
  7525. /** Pixel format of the texture. */
  7526. pixelFormat : number;
  7527. /** Width in pixels. */
  7528. pixelWidth : number;
  7529. /** Height in pixels. */
  7530. pixelHeight : number;
  7531. /** Content width in points. */
  7532. width : number;
  7533. /** Content height in points. */
  7534. height : number;
  7535. }
  7536. /** <p>A class that implements a Texture Atlas. <br />
  7537. Supported features: <br />
  7538. The atlas file can be a PNG, JPG. <br />
  7539. Quads can be updated in runtime <br />
  7540. Quads can be added in runtime <br />
  7541. Quads can be removed in runtime <br />
  7542. Quads can be re-ordered in runtime <br />
  7543. The TextureAtlas capacity can be increased or decreased in runtime.</p> */
  7544. export class TextureAtlas {
  7545. constructor();
  7546. /** <p>Creates a TextureAtlas with an filename and with an initial capacity for Quads. <br />
  7547. The TextureAtlas capacity can be increased in runtime. </p>
  7548. Constructor of cc.TextureAtlas
  7549. @example
  7550. ```js
  7551. --------------------------
  7552. 1. //creates a TextureAtlas with filename
  7553. var textureAtlas = new cc.TextureAtlas("res/hello.png", 3);
  7554. 2. //creates a TextureAtlas with texture
  7555. var texture = cc.textureCache.addImage("hello.png");
  7556. var textureAtlas = new cc.TextureAtlas(texture, 3);
  7557. ```
  7558. */
  7559. TextureAtlas(fileName : string|Texture2D, capacity : number) : void;
  7560. /** Quantity of quads that are going to be drawn.
  7561. */
  7562. getTotalQuads() : number;
  7563. /** Quantity of quads that can be stored with the current texture atlas size.
  7564. */
  7565. getCapacity() : number;
  7566. /** Texture of the texture atlas.
  7567. */
  7568. getTexture() : Image;
  7569. /** Set texture for texture atlas.
  7570. */
  7571. setTexture(texture : Image) : void;
  7572. /** specify if the array buffer of the VBO needs to be updated.
  7573. */
  7574. setDirty(dirty : boolean) : void;
  7575. /** whether or not the array buffer of the VBO needs to be updated.
  7576. */
  7577. isDirty() : boolean;
  7578. /** Quads that are going to be rendered.
  7579. */
  7580. getQuads() : any[];
  7581. /**
  7582. */
  7583. setQuads(quads : any[]) : void;
  7584. /** <p>Initializes a TextureAtlas with a filename and with a certain capacity for Quads.<br />
  7585. The TextureAtlas capacity can be increased in runtime.<br />
  7586. WARNING: Do not reinitialize the TextureAtlas because it will leak memory. </p>
  7587. @example
  7588. ```js
  7589. --------------------------------------------------
  7590. var textureAtlas = new cc.TextureAtlas();
  7591. textureAtlas.initWithTexture("hello.png", 3);
  7592. ```
  7593. */
  7594. initWithFile(file : string, capacity : number) : boolean;
  7595. /** <p>Initializes a TextureAtlas with a previously initialized Texture2D object, and<br />
  7596. with an initial capacity for Quads.<br />
  7597. The TextureAtlas capacity can be increased in runtime.<br />
  7598. WARNING: Do not reinitialize the TextureAtlas because it will leak memory</p>
  7599. @example
  7600. ```js
  7601. ---------------------------
  7602. var texture = cc.textureCache.addImage("hello.png");
  7603. var textureAtlas = new cc.TextureAtlas();
  7604. textureAtlas.initWithTexture(texture, 3);
  7605. ```
  7606. */
  7607. initWithTexture(texture : Image, capacity : number) : boolean;
  7608. /** <p>Updates a Quad (texture, vertex and color) at a certain index <br />
  7609. index must be between 0 and the atlas capacity - 1 </p>
  7610. */
  7611. updateQuad(quad : V3F_C4B_T2F_Quad, index : number) : void;
  7612. /** <p>Inserts a Quad (texture, vertex and color) at a certain index<br />
  7613. index must be between 0 and the atlas capacity - 1 </p>
  7614. */
  7615. insertQuad(quad : V3F_C4B_T2F_Quad, index : number) : void;
  7616. /** <p>
  7617. Inserts a c array of quads at a given index <br />
  7618. index must be between 0 and the atlas capacity - 1 <br />
  7619. this method doesn't enlarge the array when amount + index > totalQuads <br />
  7620. </p>
  7621. */
  7622. insertQuads(quads : any[], index : number, amount : number) : void;
  7623. /** <p>Removes the quad that is located at a certain index and inserts it at a new index <br />
  7624. This operation is faster than removing and inserting in a quad in 2 different steps</p>
  7625. */
  7626. insertQuadFromIndex(fromIndex : number, newIndex : number) : void;
  7627. /** <p>Removes a quad at a given index number.<br />
  7628. The capacity remains the same, but the total number of quads to be drawn is reduced in 1 </p>
  7629. */
  7630. removeQuadAtIndex(index : number) : void;
  7631. /** Removes a given number of quads at a given index.
  7632. */
  7633. removeQuadsAtIndex(index : number, amount : number) : void;
  7634. /** <p>Removes all Quads. <br />
  7635. The TextureAtlas capacity remains untouched. No memory is freed.<br />
  7636. The total number of quads to be drawn will be 0</p>
  7637. */
  7638. removeAllQuads() : void;
  7639. /** <p>Resize the capacity of the CCTextureAtlas.<br />
  7640. The new capacity can be lower or higher than the current one<br />
  7641. It returns YES if the resize was successful. <br />
  7642. If it fails to resize the capacity it will return NO with a new capacity of 0. <br />
  7643. no used for js</p>
  7644. */
  7645. resizeCapacity(newCapacity : number) : boolean;
  7646. /** Used internally by CCParticleBatchNode <br/>
  7647. don't use this unless you know what you're doing.
  7648. */
  7649. increaseTotalQuadsWith(amount : number) : void;
  7650. /** Moves an amount of quads from oldIndex at newIndex.
  7651. */
  7652. moveQuadsFromIndex(oldIndex : number, amount : number, newIndex : number) : void;
  7653. /** Ensures that after a realloc quads are still empty <br/>
  7654. Used internally by CCParticleBatchNode.
  7655. */
  7656. fillWithEmptyQuadsFromIndex(index : number, amount : number) : void;
  7657. /** <p>Draws n quads from an index (offset). <br />
  7658. n + start can't be greater than the capacity of the atlas</p>
  7659. */
  7660. drawNumberOfQuads(n : number, start : number) : void;
  7661. /** Indicates whether or not the array buffer of the VBO needs to be updated. */
  7662. dirty : boolean;
  7663. /** Image texture for cc.TextureAtlas. */
  7664. texture : Image;
  7665. /** Quantity of quads that can be stored with the current texture atlas size. */
  7666. capacity : number;
  7667. /** Quantity of quads that are going to be drawn. */
  7668. totalQuads : number;
  7669. /** Quads that are going to be rendered. */
  7670. quads : any[];
  7671. }
  7672. /** cc.textureCache is a singleton object, it's the global cache for cc.Texture2D */
  7673. export class textureCache {
  7674. /** Description
  7675. */
  7676. description() : string;
  7677. /** Returns an already created texture. Returns null if the texture doesn't exist.
  7678. @example
  7679. ```js
  7680. ------------------
  7681. var key = cc.textureCache.textureForKey("hello.png");
  7682. ```
  7683. */
  7684. textureForKey(textureKeyName : string) : Texture2D;
  7685. /** Returns an already created texture. Returns null if the texture doesn't exist.
  7686. @example
  7687. ```js
  7688. ------------------
  7689. var key = cc.textureCache.getTextureForKey("hello.png");
  7690. ```
  7691. */
  7692. getTextureForKey(textureKeyName : string) : Texture2D;
  7693. /**
  7694. @example
  7695. ```js
  7696. ---------------
  7697. var cacheTextureForColor = cc.textureCache.getTextureColors(texture);
  7698. ```
  7699. */
  7700. getTextureColors(texture : Image) : any[];
  7701. /** <p>Purges the dictionary of loaded textures. <br />
  7702. Call this method if you receive the "Memory Warning" <br />
  7703. In the short term: it will free some resources preventing your app from being killed <br />
  7704. In the medium term: it will allocate more resources <br />
  7705. In the long term: it will be the same</p>
  7706. @example
  7707. ```js
  7708. --------
  7709. cc.textureCache.removeAllTextures();
  7710. ```
  7711. */
  7712. removeAllTextures() : void;
  7713. /** Deletes a texture from the cache given a texture.
  7714. @example
  7715. ```js
  7716. -----
  7717. cc.textureCache.removeTexture(texture);
  7718. ```
  7719. */
  7720. removeTexture(texture : Image) : void;
  7721. /** Deletes a texture from the cache given a its key name.
  7722. @example
  7723. ```js
  7724. ------
  7725. cc.textureCache.removeTexture("hello.png");
  7726. ```
  7727. */
  7728. removeTextureForKey(textureKeyName : string) : void;
  7729. /** <p>Returns a Texture2D object given an file image <br />
  7730. If the file image was not previously loaded, it will create a new Texture2D <br />
  7731. object and it will return it. It will use the filename as a key.<br />
  7732. Otherwise it will return a reference of a previously loaded image. <br />
  7733. Supported image extensions: .png, .jpg, .gif</p>
  7734. @example
  7735. ```js
  7736. ----
  7737. cc.textureCache.addImage("hello.png");
  7738. ```
  7739. */
  7740. addImage(url : string, cb : Function, target : any) : Texture2D;
  7741. /** Cache the image data.
  7742. */
  7743. cacheImage(path : string, texture : Image|HTMLImageElement|HTMLCanvasElement) : void;
  7744. /** <p>Returns a Texture2D object given an UIImage image<br />
  7745. If the image was not previously loaded, it will create a new Texture2D object and it will return it.<br />
  7746. Otherwise it will return a reference of a previously loaded image<br />
  7747. The "key" parameter will be used as the "key" for the cache.<br />
  7748. If "key" is null, then a new texture will be created each time.</p>
  7749. */
  7750. addUIImage(image : HTMLImageElement|HTMLCanvasElement, key : string) : Texture2D;
  7751. }
  7752. /** A base node for CCNode and CCEScene, it will:
  7753. - provide the same api with origin cocos2d rendering node (SGNode)
  7754. - maintains properties of the internal SGNode
  7755. - retain and release the SGNode
  7756. - serialize datas for SGNode (but SGNode itself will not being serialized)
  7757. - notifications if some properties changed
  7758. - define some interfaces shares between CCNode and CCEScene */
  7759. export class _BaseNode extends Object {
  7760. /** !#en Name of node.
  7761. !#zh 该节点名称。 */
  7762. name : string;
  7763. /** !#en The parent of the node.
  7764. !#zh 该节点的父节点。 */
  7765. parent : Node;
  7766. /** !#en The uuid for editor, will be stripped before building project.
  7767. !#zh 用于编辑器使用的 uuid,在构建项目之前将会被剔除。 */
  7768. uuid : string;
  7769. /** !#en Skew x
  7770. !#zh 该节点 Y 轴倾斜角度。 */
  7771. skewX : number;
  7772. /** !#en Skew y
  7773. !#zh 该节点 X 轴倾斜角度。 */
  7774. skewY : number;
  7775. /** !#en Z order in depth which stands for the drawing order.
  7776. !#zh 该节点渲染排序的 Z 轴深度。 */
  7777. zIndex : number;
  7778. /** !#en Rotation of node.
  7779. !#zh 该节点旋转角度。 */
  7780. rotation : number;
  7781. /** !#en Rotation on x axis.
  7782. !#zh 该节点 X 轴旋转角度。 */
  7783. rotationX : number;
  7784. /** !#en Rotation on y axis.
  7785. !#zh 该节点 Y 轴旋转角度。 */
  7786. rotationY : number;
  7787. /** !#en Scale on x axis.
  7788. !#zh 节点 X 轴缩放。 */
  7789. scaleX : number;
  7790. /** !#en Scale on y axis.
  7791. !#zh 节点 Y 轴缩放。 */
  7792. scaleY : number;
  7793. /** !#en x axis position of node.
  7794. !#zh 节点 X 轴坐标。 */
  7795. x : number;
  7796. /** !#en y axis position of node.
  7797. !#zh 节点 Y 轴坐标。 */
  7798. y : number;
  7799. /** !#en All children nodes.
  7800. !#zh 节点的所有子节点。 */
  7801. children : Node[];
  7802. /** !#en All children nodes.
  7803. !#zh 节点的子节点数量。 */
  7804. childrenCount : number;
  7805. /** !#en Anchor point's position on x axis.
  7806. !#zh 节点 X 轴锚点位置。 */
  7807. anchorX : number;
  7808. /** !#en Anchor point's position on y axis.
  7809. !#zh 节点 Y 轴锚点位置。 */
  7810. anchorY : number;
  7811. /** !#en Width of node.
  7812. !#zh 节点宽度。 */
  7813. width : number;
  7814. /** !#en Height of node.
  7815. !#zh 节点高度。 */
  7816. height : number;
  7817. /** !#en Tag of node.
  7818. !#zh 节点标签。 */
  7819. tag : number;
  7820. /** !#en Opacity of node, default value is 255.
  7821. !#zh 节点透明度,默认值为 255。 */
  7822. opacity : number;
  7823. /** !#en Indicate whether node's opacity value affect its child nodes, default value is false.
  7824. !#zh 节点的不透明度值是否影响其子节点,默认值为 false。 */
  7825. cascadeOpacity : boolean;
  7826. /** !#en Color of node, default value is white: (255, 255, 255).
  7827. !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */
  7828. color : Color;
  7829. /** !#en
  7830. Properties configuration function </br>
  7831. All properties in attrs will be set to the node, </br>
  7832. when the setter of the node is available, </br>
  7833. the property will be set via setter function.</br>
  7834. !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。
  7835. @param attrs Properties to be set to node
  7836. @example
  7837. ```js
  7838. var attrs = { key: 0, num: 100 };
  7839. node.attr(attrs);
  7840. ```
  7841. */
  7842. attr(attrs : any) : void;
  7843. /** !#en
  7844. Returns the scale factor of the node.
  7845. Assertion will fail when _scaleX != _scaleY.
  7846. !#zh 获取节点的缩放。当 X 轴和 Y 轴有相同的缩放数值时。
  7847. @example
  7848. ```js
  7849. cc.log("Node Scale: " + node.getScale());
  7850. ```
  7851. */
  7852. getScale() : number;
  7853. /** !#en Sets the scale factor of the node. 1.0 is the default scale factor. This function can modify the X and Y scale at the same time.
  7854. !#zh 设置节点的缩放比例,默认值为 1.0。这个函数可以在同一时间修改 X 和 Y 缩放。
  7855. @param scaleX scaleX or scale
  7856. @example
  7857. ```js
  7858. node.setScale(cc.v2(1, 1));
  7859. node.setScale(1, 1);
  7860. ```
  7861. */
  7862. setScale(scaleX : number|Vec2, scaleY? : number) : void;
  7863. /** !#en Returns a copy of the position (x,y) of the node in cocos2d coordinates. (0,0) is the left-bottom corner.
  7864. !#zh 获取在父节点坐标系中节点的位置( x , y )。
  7865. @example
  7866. ```js
  7867. cc.log("Node Position: " + node.getPosition());
  7868. ```
  7869. */
  7870. getPosition() : Vec2;
  7871. /** !#en
  7872. Changes the position (x,y) of the node in cocos2d coordinates.<br/>
  7873. The original point (0,0) is at the left-bottom corner of screen.<br/>
  7874. Usually we use cc.v2(x,y) to compose CCVec2 object.<br/>
  7875. and Passing two numbers (x,y) is more efficient than passing CCPoint object.
  7876. !#zh
  7877. 设置节点在父坐标系中的位置。<br/>
  7878. 可以通过 2 种方式设置坐标点:<br/>
  7879. 1.传入 cc.v2(x, y) 类型为 cc.Vec2 的对象。<br/>
  7880. 2.传入 2 个数值 x 和 y。
  7881. @param newPosOrxValue The position (x,y) of the node in coordinates or the X coordinate for position
  7882. @param yValue Y coordinate for position
  7883. @example
  7884. ```js
  7885. node.setPosition(cc.v2(0, 0));
  7886. node.setPosition(0, 0);
  7887. ```
  7888. */
  7889. setPosition(newPosOrxValue : Vec2|number, yValue? : number) : void;
  7890. /** !#en
  7891. Returns a copy of the anchor point.<br/>
  7892. Anchor point is the point around which all transformations and positioning manipulations take place.<br/>
  7893. It's like a pin in the node where it is "attached" to its parent. <br/>
  7894. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. <br/>
  7895. But you can use values higher than (1,1) and lower than (0,0) too. <br/>
  7896. The default anchor point is (0.5,0.5), so it starts at the center of the node.
  7897. !#zh
  7898. 获取节点锚点,用百分比表示。<br/>
  7899. 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
  7900. 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
  7901. 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
  7902. 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
  7903. 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
  7904. @example
  7905. ```js
  7906. cc.log("Node AnchorPoint: " + node.getAnchorPoint());
  7907. ```
  7908. */
  7909. getAnchorPoint() : Vec2;
  7910. /** !#en
  7911. Sets the anchor point in percent. <br/>
  7912. anchor point is the point around which all transformations and positioning manipulations take place. <br/>
  7913. It's like a pin in the node where it is "attached" to its parent. <br/>
  7914. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.<br/>
  7915. But you can use values higher than (1,1) and lower than (0,0) too.<br/>
  7916. The default anchor point is (0.5,0.5), so it starts at the center of the node.
  7917. !#zh
  7918. 设置锚点的百分比。<br/>
  7919. 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
  7920. 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
  7921. 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
  7922. 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
  7923. 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
  7924. @param point The anchor point of node or The x axis anchor of node.
  7925. @param y The y axis anchor of node.
  7926. @example
  7927. ```js
  7928. node.setAnchorPoint(cc.v2(1, 1));
  7929. node.setAnchorPoint(1, 1);
  7930. ```
  7931. */
  7932. setAnchorPoint(point : Vec2|number, y? : number) : void;
  7933. /** !#en
  7934. Returns a copy of the anchor point in absolute pixels. <br/>
  7935. you can only read it. If you wish to modify it, use setAnchorPoint.
  7936. !#zh
  7937. 返回锚点的绝对像素位置。<br/>
  7938. 你只能读它。如果您要修改它,使用 setAnchorPoint。
  7939. @example
  7940. ```js
  7941. cc.log("AnchorPointInPoints: " + node.getAnchorPointInPoints());
  7942. ```
  7943. */
  7944. getAnchorPointInPoints() : Vec2;
  7945. /** !#en
  7946. Returns a copy the untransformed size of the node. <br/>
  7947. The contentSize remains the same no matter the node is scaled or rotated.<br/>
  7948. All nodes has a size. Layer and Scene has the same size of the screen by default. <br/>
  7949. !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。
  7950. @param ignoreSizeProvider true if you need to get the original size of the node
  7951. @example
  7952. ```js
  7953. cc.log("Content Size: " + node.getContentSize());
  7954. ```
  7955. */
  7956. getContentSize(ignoreSizeProvider? : boolean) : Size;
  7957. /** !#en
  7958. Sets the untransformed size of the node.<br/>
  7959. The contentSize remains the same no matter the node is scaled or rotated.<br/>
  7960. All nodes has a size. Layer and Scene has the same size of the screen.
  7961. !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。
  7962. @param size The untransformed size of the node or The untransformed size's width of the node.
  7963. @param height The untransformed size's height of the node.
  7964. @example
  7965. ```js
  7966. node.setContentSize(cc.size(100, 100));
  7967. node.setContentSize(100, 100);
  7968. ```
  7969. */
  7970. setContentSize(size : Size|number, height? : number) : void;
  7971. /** !#en
  7972. Returns a "local" axis aligned bounding box of the node. <br/>
  7973. The returned box is relative only to its parent.
  7974. !#zh 返回父节坐标系下的轴向对齐的包围盒。
  7975. @example
  7976. ```js
  7977. var boundingBox = node.getBoundingBox();
  7978. ```
  7979. */
  7980. getBoundingBox() : Rect;
  7981. /** !#en Stops all running actions and schedulers.
  7982. !#zh 停止所有正在播放的动作和计时器。
  7983. @example
  7984. ```js
  7985. node.cleanup();
  7986. ```
  7987. */
  7988. cleanup() : void;
  7989. /** !#en Returns a child from the container given its tag.
  7990. !#zh 通过标签获取节点的子节点。
  7991. @param aTag An identifier to find the child node.
  7992. @example
  7993. ```js
  7994. var child = node.getChildByTag(1001);
  7995. ```
  7996. */
  7997. getChildByTag(aTag : number) : Node;
  7998. /** !#en Returns a child from the container given its uuid.
  7999. !#zh 通过 uuid 获取节点的子节点。
  8000. @param uuid The uuid to find the child node.
  8001. @example
  8002. ```js
  8003. var child = node.getChildByUuid(uuid);
  8004. ```
  8005. */
  8006. getChildByUuid(uuid : string) : Node;
  8007. /** !#en Returns a child from the container given its name.
  8008. !#zh 通过名称获取节点的子节点。
  8009. @param name A name to find the child node.
  8010. @example
  8011. ```js
  8012. var child = node.getChildByName("Test Node");
  8013. ```
  8014. */
  8015. getChildByName(name : string) : Node;
  8016. /** !#en
  8017. "add" logic MUST only be in this method <br/>
  8018. !#zh
  8019. 添加子节点,并且可以修改该节点的 局部 Z 顺序和标签。
  8020. @param child A child node
  8021. @param localZOrder Z order for drawing priority. Please refer to setZOrder(int)
  8022. @param tag An integer or a name to identify the node easily. Please refer to setTag(int) and setName(string)
  8023. @example
  8024. ```js
  8025. node.addChild(newNode, 1, 1001);
  8026. ```
  8027. */
  8028. addChild(child : Node, localZOrder? : number, tag? : number|string) : void;
  8029. /** !#en
  8030. Remove itself from its parent node. If cleanup is true, then also remove all actions and callbacks. <br/>
  8031. If the cleanup parameter is not passed, it will force a cleanup. <br/>
  8032. If the node orphan, then nothing happens.
  8033. !#zh
  8034. 从父节点中删除一个节点。cleanup 参数为 true,那么在这个节点上所有的动作和回调都会被删除,反之则不会。<br/>
  8035. 如果不传入 cleanup 参数,默认是 true 的。<br/>
  8036. 如果这个节点是一个孤节点,那么什么都不会发生。
  8037. @param cleanup true if all actions and callbacks on this node should be removed, false otherwise.
  8038. @example
  8039. ```js
  8040. node.removeFromParent();
  8041. node.removeFromParent(false);
  8042. ```
  8043. */
  8044. removeFromParent(cleanup? : boolean) : void;
  8045. /** !#en
  8046. Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. </p>
  8047. If the cleanup parameter is not passed, it will force a cleanup. <br/>
  8048. "remove" logic MUST only be on this method <br/>
  8049. If a class wants to extend the 'removeChild' behavior it only needs <br/>
  8050. to override this method.
  8051. !#zh
  8052. 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  8053. 如果 cleanup 参数不传入,默认为 true 表示清理。<br/>
  8054. @param child The child node which will be removed.
  8055. @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
  8056. @example
  8057. ```js
  8058. node.removeChild(newNode);
  8059. node.removeChild(newNode, false);
  8060. ```
  8061. */
  8062. removeChild(child : Node, cleanup? : boolean) : void;
  8063. /** !#en
  8064. Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter.
  8065. If the cleanup parameter is not passed, it will force a cleanup. <br/>
  8066. !#zh
  8067. 通过标签移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  8068. 如果 cleanup 参数不传入,默认为 true 表示清理。
  8069. @param tag An integer number that identifies a child node
  8070. @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
  8071. @example
  8072. ```js
  8073. node.removeChildByTag(1001);
  8074. node.removeChildByTag(1001, false);
  8075. ```
  8076. */
  8077. removeChildByTag(tag : number, cleanup? : boolean) : void;
  8078. /** !#en
  8079. Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. <br/>
  8080. If the cleanup parameter is not passed, it will force a cleanup.
  8081. !#zh
  8082. 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  8083. 如果 cleanup 参数不传入,默认为 true 表示清理。
  8084. @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise.
  8085. @example
  8086. ```js
  8087. node.removeAllChildren();
  8088. node.removeAllChildren(false);
  8089. ```
  8090. */
  8091. removeAllChildren(cleanup? : boolean) : void;
  8092. /** !#en
  8093. Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.<br/>
  8094. The matrix is in Pixels. The returned transform is readonly and cannot be changed.
  8095. !#zh
  8096. 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。<br/>
  8097. 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。
  8098. @example
  8099. ```js
  8100. var affineTransform = node.getParentToNodeTransform();
  8101. ```
  8102. */
  8103. getParentToNodeTransform() : AffineTransform;
  8104. /** !#en Returns the world affine transform matrix. The matrix is in Pixels.
  8105. !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。
  8106. @example
  8107. ```js
  8108. var affineTransform = node.getNodeToWorldTransform();
  8109. ```
  8110. */
  8111. getNodeToWorldTransform() : AffineTransform;
  8112. /** !#en
  8113. Returns the world affine transform matrix. The matrix is in Pixels.<br/>
  8114. This method is AR (Anchor Relative).
  8115. !#zh
  8116. 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。<br/>
  8117. 该方法基于节点坐标。
  8118. @example
  8119. ```js
  8120. var mat = node.getNodeToWorldTransformAR();
  8121. ```
  8122. */
  8123. getNodeToWorldTransformAR() : AffineTransform;
  8124. /** !#en Returns the inverse world affine transform matrix. The matrix is in Pixels.
  8125. !#en 返回世界坐标系到节点坐标系的逆矩阵。
  8126. @example
  8127. ```js
  8128. var affineTransform = node.getWorldToNodeTransform();
  8129. ```
  8130. */
  8131. getWorldToNodeTransform() : AffineTransform;
  8132. /** !#en Converts a Point to node (local) space coordinates. The result is in Vec2.
  8133. !#zh 将一个点转换到节点 (局部) 坐标系。结果以 Vec2 为单位。
  8134. @example
  8135. ```js
  8136. var newVec2 = node.convertToNodeSpace(cc.v2(100, 100));
  8137. ```
  8138. */
  8139. convertToNodeSpace(worldPoint : Vec2) : Vec2;
  8140. /** !#en Converts a Point to world space coordinates. The result is in Points.
  8141. !#zh 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。
  8142. @example
  8143. ```js
  8144. var newVec2 = node.convertToWorldSpace(cc.v2(100, 100));
  8145. ```
  8146. */
  8147. convertToWorldSpace(nodePoint : Vec2) : Vec2;
  8148. /** !#en
  8149. Converts a Point to node (local) space coordinates. The result is in Points.<br/>
  8150. treating the returned/received node point as anchor relative.
  8151. !#zh
  8152. 将一个点转换到节点 (局部) 空间坐标系。结果以 Vec2 为单位。<br/>
  8153. 返回值将基于节点坐标。
  8154. @example
  8155. ```js
  8156. var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100));
  8157. ```
  8158. */
  8159. convertToNodeSpaceAR(worldPoint : Vec2) : Vec2;
  8160. /** !#en
  8161. Converts a local Point to world space coordinates.The result is in Points.<br/>
  8162. treating the returned/received node point as anchor relative.
  8163. !#zh
  8164. 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。<br/>
  8165. 返回值将基于世界坐标。
  8166. @example
  8167. ```js
  8168. var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100));
  8169. ```
  8170. */
  8171. convertToWorldSpaceAR(nodePoint : Vec2) : Vec2;
  8172. /** !#en convenience methods which take a cc.Touch instead of cc.Vec2.
  8173. !#zh 将触摸点转换成本地坐标系中位置。
  8174. @param touch The touch object
  8175. @example
  8176. ```js
  8177. var newVec2 = node.convertTouchToNodeSpace(touch);
  8178. ```
  8179. */
  8180. convertTouchToNodeSpace(touch : Touch) : Vec2;
  8181. /** !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative).
  8182. !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。
  8183. @param touch The touch object
  8184. @example
  8185. ```js
  8186. var newVec2 = node.convertTouchToNodeSpaceAR(touch);
  8187. ```
  8188. */
  8189. convertTouchToNodeSpaceAR(touch : Touch) : Vec2;
  8190. /** !#en
  8191. Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
  8192. The matrix is in Pixels.
  8193. !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。
  8194. @example
  8195. ```js
  8196. var affineTransform = node.getNodeToParentTransform();
  8197. ```
  8198. */
  8199. getNodeToParentTransform() : AffineTransform;
  8200. /** !#en
  8201. Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
  8202. The matrix is in Pixels.<br/>
  8203. This method is AR (Anchor Relative).
  8204. !#zh
  8205. 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。<br/>
  8206. 这个矩阵以像素为单位。<br/>
  8207. 该方法基于节点坐标。
  8208. @example
  8209. ```js
  8210. var affineTransform = node.getNodeToParentTransformAR();
  8211. ```
  8212. */
  8213. getNodeToParentTransformAR() : AffineTransform;
  8214. /** !#en
  8215. Returns a "world" axis aligned bounding box of the node.<br/>
  8216. The bounding box contains self and active children's world bounding box.
  8217. !#zh
  8218. 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。<br/>
  8219. 该边框包含自身和已激活的子节点的世界边框。
  8220. @example
  8221. ```js
  8222. var newRect = node.getBoundingBoxToWorld();
  8223. ```
  8224. */
  8225. getBoundingBoxToWorld() : Rect;
  8226. /** !#en
  8227. Returns the displayed opacity of Node,
  8228. the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled.
  8229. !#zh
  8230. 获取节点显示透明度,
  8231. 显示透明度和透明度之间的不同之处在于当启用级连透明度时,
  8232. 显示透明度是基于自身透明度和父节点透明度计算的。
  8233. @example
  8234. ```js
  8235. var displayOpacity = node.getDisplayedOpacity();
  8236. ```
  8237. */
  8238. getDisplayedOpacity() : number;
  8239. /** !#en
  8240. Returns the displayed color of Node,
  8241. the difference between displayed color and color is that displayed color is calculated based on color and parent node's color when cascade color enabled.
  8242. !#zh
  8243. 获取节点的显示透明度,
  8244. 显示透明度和透明度之间的不同之处在于显示透明度是基于透明度和父节点透明度启用级连透明度时计算的。
  8245. @example
  8246. ```js
  8247. var displayColor = node.getDisplayedColor();
  8248. ```
  8249. */
  8250. getDisplayedColor() : Color;
  8251. /** !#en
  8252. Set whether color should be changed with the opacity value,
  8253. useless in ccsg.Node, but this function is override in some class to have such behavior.
  8254. !#zh 设置更改透明度时是否修改RGB值,
  8255. @example
  8256. ```js
  8257. node.setOpacityModifyRGB(true);
  8258. ```
  8259. */
  8260. setOpacityModifyRGB(opacityValue : boolean) : void;
  8261. /** !#en Get whether color should be changed with the opacity value.
  8262. !#zh 更改透明度时是否修改RGB值。
  8263. @example
  8264. ```js
  8265. var hasChange = node.isOpacityModifyRGB();
  8266. ```
  8267. */
  8268. isOpacityModifyRGB() : boolean;
  8269. /** !#en Get the sibling index.
  8270. !#zh 获取同级索引。
  8271. @example
  8272. ```js
  8273. var index = node.getSiblingIndex();
  8274. ```
  8275. */
  8276. getSiblingIndex() : number;
  8277. /** !#en Set the sibling index of this node.
  8278. !#zh 设置节点同级索引。
  8279. @example
  8280. ```js
  8281. node.setSiblingIndex(1);
  8282. ```
  8283. */
  8284. setSiblingIndex(index : number) : void;
  8285. /** !#en Is this node a child of the given node?
  8286. !#zh 是否是指定节点的子节点?
  8287. @example
  8288. ```js
  8289. node.isChildOf(newNode);
  8290. ```
  8291. */
  8292. isChildOf(parent : Node) : boolean;
  8293. /** !#en Sorts the children array depends on children's zIndex and arrivalOrder,
  8294. normally you won't need to invoke this function.
  8295. !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。
  8296. */
  8297. sortAllChildren() : void;
  8298. /** !#en The local scale relative to the parent.
  8299. !#zh 节点相对父节点的缩放。 */
  8300. scale : number;
  8301. /** !#en Returns the x axis position of the node in cocos2d coordinates.
  8302. !#zh 获取节点 X 轴坐标。
  8303. @example
  8304. ```js
  8305. var posX = node.getPositionX();
  8306. ```
  8307. */
  8308. getPositionX() : number;
  8309. /** !#en Sets the x axis position of the node in cocos2d coordinates.
  8310. !#zh 设置节点 X 轴坐标。
  8311. @example
  8312. ```js
  8313. node.setPositionX(1);
  8314. ```
  8315. */
  8316. setPositionX(x : number) : void;
  8317. /** !#en Returns the y axis position of the node in cocos2d coordinates.
  8318. !#zh 获取节点 Y 轴坐标。
  8319. @example
  8320. ```js
  8321. var posY = node.getPositionY();
  8322. ```
  8323. */
  8324. getPositionY() : number;
  8325. /** !#en Sets the y axis position of the node in cocos2d coordinates.
  8326. !#zh 设置节点 Y 轴坐标。
  8327. @param y The new position in y axis
  8328. @example
  8329. ```js
  8330. node.setPositionY(100);
  8331. ```
  8332. */
  8333. setPositionY(y : number) : void;
  8334. /** !#en Returns the local Z order of this node.
  8335. !#zh 获取节点局部 Z 轴顺序。
  8336. @example
  8337. ```js
  8338. var localZorder = node.getLocalZOrder();
  8339. ```
  8340. */
  8341. getLocalZOrder() : number;
  8342. /** !#en
  8343. LocalZOrder is the 'key' used to sort the node relative to its siblings. <br/>
  8344. <br/>
  8345. The Node's parent will sort all its children based ont the LocalZOrder value. <br/>
  8346. If two nodes have the same LocalZOrder, then the node that was added first to the children's array <br/>
  8347. will be in front of the other node in the array. <br/>
  8348. Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) <br/>
  8349. And Nodes that have LocalZOder values smaller than 0 are the "left" subtree <br/>
  8350. While Nodes with LocalZOder greater than 0 are the "right" subtree.
  8351. !#zh
  8352. LocalZOrder 是 “key” (关键)来分辨节点和它兄弟节点的相关性。
  8353. 父节点将会通过 LocalZOrder 的值来分辨所有的子节点。
  8354. 如果两个节点有同样的 LocalZOrder,那么先加入子节点数组的节点将会显示在后加入的节点的前面。
  8355. 同样的,场景图使用 “In-Order(按顺序)” 遍历数算法来遍历
  8356. ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) 并且拥有小于 0 的 LocalZOrder 的值的节点是 “ left ” 子树(左子树)
  8357. 所以拥有大于 0 的 LocalZOrder 的值得节点是 “ right ”子树(右子树)。
  8358. @example
  8359. ```js
  8360. node.setLocalZOrder(1);
  8361. ```
  8362. */
  8363. setLocalZOrder(localZOrder : number) : void;
  8364. /** !#en Returns whether node's opacity value affect its child nodes.
  8365. !#zh 返回节点的不透明度值是否影响其子节点。
  8366. @example
  8367. ```js
  8368. cc.log(node.isCascadeOpacityEnabled());
  8369. ```
  8370. */
  8371. isCascadeOpacityEnabled() : boolean;
  8372. /** !#en Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity.
  8373. !#zh 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。
  8374. @example
  8375. ```js
  8376. node.setCascadeOpacityEnabled(true);
  8377. ```
  8378. */
  8379. setCascadeOpacityEnabled(cascadeOpacityEnabled : boolean) : void;
  8380. /** !#en Enable or disable cascade color, if cascade enabled, child nodes' opacity will be the cascade value of parent color and its own color.
  8381. !#zh 启用或禁用级连颜色,如果级连启用,子节点的颜色将是父颜色和它自己的颜色的级连值。
  8382. @example
  8383. ```js
  8384. node.setCascadeColorEnabled(true);
  8385. ```
  8386. */
  8387. setCascadeColorEnabled(cascadeColorEnabled : boolean) : void;
  8388. }
  8389. /** !#en
  8390. cc.AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.<br/>
  8391. Please do not use its constructor directly, use cc.affineTransformMake alias function instead.
  8392. !#zh
  8393. cc.AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。<br/>
  8394. 请不要直接使用它的构造,请使用 cc.affineTransformMake 函数代替。 */
  8395. export class AffineTransform {
  8396. /** !#en Create a cc.AffineTransform object with all contents in the matrix.
  8397. !#zh 用在矩阵中的所有内容创建一个 cc.AffineTransform 对象。
  8398. */
  8399. affineTransformMake(a : number, b : number, c : number, d : number, tx : number, ty : number) : AffineTransform;
  8400. /** !#en Clone a cc.AffineTransform object from the specified transform.
  8401. !#zh 克隆指定的 cc.AffineTransform 对象。
  8402. */
  8403. affineTransformClone(t : AffineTransform) : AffineTransform;
  8404. /** !#en Apply the affine transformation on a point.
  8405. !#zh 对一个点应用矩阵变换。
  8406. @param point or x.
  8407. @param transOrY transform matrix or y.
  8408. @param t transform matrix or y.
  8409. */
  8410. pointApplyAffineTransform(point : Vec2|number, transOrY : AffineTransform|number, t : AffineTransform) : Vec2;
  8411. /** !#en Apply the affine transformation on a size.
  8412. !#zh 应用 Size 到仿射变换矩阵上。
  8413. */
  8414. sizeApplyAffineTransform(size : Size, t : AffineTransform) : Size;
  8415. /** !#en
  8416. Create a identity transformation matrix: <br/>
  8417. [ 1, 0, 0, <br/>
  8418. 0, 1, 0 ]
  8419. !#zh
  8420. 单位矩阵:<br/>
  8421. [ 1, 0, 0, <br/>
  8422. 0, 1, 0 ]
  8423. */
  8424. affineTransformMakeIdentity() : AffineTransform;
  8425. /** !#en Apply the affine transformation on a rect.
  8426. !#zh 应用 Rect 到仿射变换矩阵上。
  8427. */
  8428. rectApplyAffineTransform(rect : Rect, anAffineTransform : AffineTransform) : Rect;
  8429. /** !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box.
  8430. !#zh 应用 Rect 到仿射变换矩阵上, 并转换为有向包围盒
  8431. */
  8432. obbApplyAffineTransform(rect : Rect, anAffineTransform : AffineTransform, out_bl : Vec2, out_tl : Vec2, out_tr : Vec2, out_br : Vec2) : void;
  8433. /** !#en Create a new affine transformation with a base transformation matrix and a translation based on it.
  8434. !#zh 基于一个基础矩阵加上一个平移操作来创建一个新的矩阵。
  8435. @param t The base affine transform object.
  8436. @param tx The translation on x axis.
  8437. @param ty The translation on y axis.
  8438. */
  8439. affineTransformTranslate(t : AffineTransform, tx : number, ty : number) : AffineTransform;
  8440. /** !#en Create a new affine transformation with a base transformation matrix and a scale based on it.
  8441. !#zh 创建一个基础变换矩阵,并在此基础上进行了 Scale 仿射变换。
  8442. @param t The base affine transform object.
  8443. @param sx The scale on x axis.
  8444. @param sy The scale on y axis.
  8445. */
  8446. affineTransformScale(t : AffineTransform, sx : number, sy : number) : AffineTransform;
  8447. /** !#en Create a new affine transformation with a base transformation matrix and a rotation based on it.
  8448. !#zh 创建一个基础变换矩阵,并在此基础上进行了 Rotation 仿射变换。
  8449. @param aTransform The base affine transform object.
  8450. @param anAngle The angle to rotate.
  8451. */
  8452. affineTransformRotate(aTransform : AffineTransform, anAngle : number) : AffineTransform;
  8453. /** !#en
  8454. Concatenate a transform matrix to another and return the result:<br/>
  8455. t' = t1 * t2
  8456. !#zh 拼接两个矩阵,并返回结果:<br/>
  8457. t' = t1 * t2
  8458. @param t1 The first transform object.
  8459. @param t2 The transform object to concatenate.
  8460. */
  8461. affineTransformConcat(t1 : AffineTransform, t2 : AffineTransform) : AffineTransform;
  8462. /** !#en
  8463. Concatenate a transform matrix to another<br/>
  8464. The results are reflected in the first matrix.<br/>
  8465. t' = t1 * t2
  8466. !#zh
  8467. 拼接两个矩阵,将结果保存到第一个矩阵。<br/>
  8468. t' = t1 * t2
  8469. @param t1 The first transform object.
  8470. @param t2 The transform object to concatenate.
  8471. */
  8472. affineTransformConcatIn(t1 : AffineTransform, t2 : AffineTransform) : AffineTransform;
  8473. /** !#en Return true if an affine transform equals to another, false otherwise.
  8474. !#zh 判断两个矩阵是否相等。
  8475. */
  8476. affineTransformEqualToTransform(t1 : AffineTransform, t2 : AffineTransform) : boolean;
  8477. /** !#en Get the invert transform of an AffineTransform object.
  8478. !#zh 求逆矩阵。
  8479. */
  8480. affineTransformInvert(t : AffineTransform) : AffineTransform;
  8481. }
  8482. /** !#en
  8483. Representation of RGBA colors.
  8484. Each color component is a floating point value with a range from 0 to 255.
  8485. You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color.
  8486. !#zh
  8487. cc.Color 用于表示颜色。
  8488. 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。
  8489. 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */
  8490. export class Color extends ValueType {
  8491. /**
  8492. @param r red component of the color, default value is 0.
  8493. @param g green component of the color, defualt value is 0.
  8494. @param b blue component of the color, default value is 0.
  8495. @param a alpha component of the color, default value is 255.
  8496. */
  8497. Color(r? : number, g? : number, b? : number, a? : number) : Color;
  8498. /** !#en Solid white, RGBA is [255, 255, 255, 255].
  8499. !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */
  8500. WHITE : Color;
  8501. /** !#en Solid black, RGBA is [0, 0, 0, 255].
  8502. !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */
  8503. BLACK : Color;
  8504. /** !#en Transparent, RGBA is [0, 0, 0, 0].
  8505. !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */
  8506. TRANSPARENT : Color;
  8507. /** !#en Grey, RGBA is [127.5, 127.5, 127.5].
  8508. !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */
  8509. GRAY : Color;
  8510. /** !#en Solid red, RGBA is [255, 0, 0].
  8511. !#zh 纯红色,RGBA 是 [255, 0, 0]。 */
  8512. RED : Color;
  8513. /** !#en Solid green, RGBA is [0, 255, 0].
  8514. !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */
  8515. GREEN : Color;
  8516. /** !#en Solid blue, RGBA is [0, 0, 255].
  8517. !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */
  8518. BLUE : Color;
  8519. /** !#en Yellow, RGBA is [255, 235, 4].
  8520. !#zh 黄色,RGBA 是 [255, 235, 4]。 */
  8521. YELLOW : Color;
  8522. /** !#en Orange, RGBA is [255, 127, 0].
  8523. !#zh 橙色,RGBA 是 [255, 127, 0]。 */
  8524. ORANGE : Color;
  8525. /** !#en Cyan, RGBA is [0, 255, 255].
  8526. !#zh 青色,RGBA 是 [0, 255, 255]。 */
  8527. CYAN : Color;
  8528. /** !#en Magenta, RGBA is [255, 0, 255].
  8529. !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */
  8530. MAGENTA : Color;
  8531. /** !#en Clone a new color from the current color.
  8532. !#zh 克隆当前颜色。
  8533. @example
  8534. ```js
  8535. var color = new cc.Color();
  8536. var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255}
  8537. ```
  8538. */
  8539. clone() : Color;
  8540. /** !#en TODO
  8541. !#zh 判断两个颜色是否相等。
  8542. @example
  8543. ```js
  8544. var color1 = cc.Color.WHITE;
  8545. var color2 = new cc.Color(255, 255, 255);
  8546. cc.log(color1.equals(color2)); // true;
  8547. color2 = cc.Color.RED;
  8548. cc.log(color2.equals(color1)); // false;
  8549. ```
  8550. */
  8551. equals(other: (r: number, g: number, b: number, a: number) => void) : boolean;
  8552. /** !#en TODO
  8553. !#zh 线性插值
  8554. @param ratio the interpolation coefficient.
  8555. @param out optional, the receiving vector.
  8556. @example
  8557. ```js
  8558. // Converts a white color to a black one trough time.
  8559. update: function (dt) {
  8560. var color = this.node.color;
  8561. if (color.equals(cc.Color.BLACK)) {
  8562. return;
  8563. }
  8564. this.ratio += dt * 0.1;
  8565. this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio);
  8566. }
  8567. ```
  8568. */
  8569. lerp(to: (r: number, g: number, b: number, a: number) => void, ratio : number, out: (r: number, g: number, b: number, a: number) => void) : Color;
  8570. /** !#en TODO
  8571. !#zh 转换为方便阅读的字符串。
  8572. @example
  8573. ```js
  8574. var color = cc.Color.WHITE;
  8575. color.toString(); // "rgba(255, 255, 255, 255)"
  8576. ```
  8577. */
  8578. toString() : string;
  8579. /** !#en TODO
  8580. !#zh 设置当前的红色值,并返回当前对象。
  8581. @param red the new Red component.
  8582. @example
  8583. ```js
  8584. var color = new cc.Color();
  8585. color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255}
  8586. ```
  8587. */
  8588. setR(red : number) : Color;
  8589. /** !#en TODO
  8590. !#zh 设置当前的绿色值,并返回当前对象。
  8591. @param green the new Green component.
  8592. @example
  8593. ```js
  8594. var color = new cc.Color();
  8595. color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255}
  8596. ```
  8597. */
  8598. setG(green : number) : Color;
  8599. /** !#en TODO
  8600. !#zh 设置当前的蓝色值,并返回当前对象。
  8601. @param blue the new Blue component.
  8602. @example
  8603. ```js
  8604. var color = new cc.Color();
  8605. color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255}
  8606. ```
  8607. */
  8608. setB(blue : number) : Color;
  8609. /** !#en TODO
  8610. !#zh 设置当前的透明度,并返回当前对象。
  8611. @param alpha the new Alpha component.
  8612. @example
  8613. ```js
  8614. var color = new cc.Color();
  8615. color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0}
  8616. ```
  8617. */
  8618. setA(alpha : number) : Color;
  8619. /** !#en TODO
  8620. !#zh 转换为 CSS 格式。
  8621. @param opt "rgba", "rgb", "#rgb" or "#rrggbb".
  8622. @example
  8623. ```js
  8624. var color = cc.Color.BLACK;
  8625. color.toCSS(); // "#000";
  8626. color.toCSS("rgba"); // "rgba(0,0,0,1.00)";
  8627. color.toCSS("rgb"); // "rgba(0,0,0)";
  8628. color.toCSS("#rgb"); // "#000";
  8629. color.toCSS("#rrggbb"); // "#000000";
  8630. ```
  8631. */
  8632. toCSS(opt : string) : string;
  8633. /** !#en Clamp this color to make all components between 0 to 255。
  8634. !#zh 限制颜色数值,在 0 到 255 之间。
  8635. @example
  8636. ```js
  8637. var color = new cc.Color(1000, 0, 0, 255);
  8638. color.clamp();
  8639. cc.log(color); // (255, 0, 0, 255)
  8640. ```
  8641. */
  8642. clamp() : void;
  8643. /** !#en TODO
  8644. !#zh 读取 16 进制。
  8645. @example
  8646. ```js
  8647. var color = cc.Color.BLACK;
  8648. color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
  8649. ```
  8650. */
  8651. fromHEX(hexString : string) : Color;
  8652. /** !#en TODO
  8653. !#zh 转换为 16 进制。
  8654. @param fmt "#rgb" or "#rrggbb".
  8655. @example
  8656. ```js
  8657. var color = cc.Color.BLACK;
  8658. color.toHEX("#rgb"); // "000";
  8659. color.toHEX("#rrggbb"); // "000000";
  8660. ```
  8661. */
  8662. toHEX(fmt : string) : string;
  8663. /** !#en Convert to 24bit rgb value.
  8664. !#zh 转换为 24bit 的 RGB 值。
  8665. @example
  8666. ```js
  8667. var color = cc.Color.YELLOW;
  8668. color.toRGBValue(); // 16771844;
  8669. ```
  8670. */
  8671. toRGBValue() : number;
  8672. /** !#en TODO
  8673. !#zh 读取 HSV(色彩模型)格式。
  8674. @example
  8675. ```js
  8676. var color = cc.Color.YELLOW;
  8677. color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255};
  8678. ```
  8679. */
  8680. fromHSV(h : number, s : number, v : number) : Color;
  8681. /** !#en TODO
  8682. !#zh 转换为 HSV(色彩模型)格式。
  8683. @example
  8684. ```js
  8685. var color = cc.Color.YELLOW;
  8686. color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1};
  8687. ```
  8688. */
  8689. toHSV() : any;
  8690. /** !#en TODO
  8691. !#zh RGB 转换为 HSV。
  8692. @param r red, must be [0, 255].
  8693. @param g red, must be [0, 255].
  8694. @param b red, must be [0, 255].
  8695. @example
  8696. ```js
  8697. cc.Color.rgb2hsv(255, 255, 255); // Object {h: 0, s: 0, v: 1};
  8698. ```
  8699. */
  8700. rgb2hsv(r : number, g : number, b : number) : any;
  8701. /** !#en TODO
  8702. !#zh HSV 转换为 RGB。
  8703. @example
  8704. ```js
  8705. cc.Color.hsv2rgb(0, 0, 1); // Object {r: 255, g: 255, b: 255};
  8706. ```
  8707. */
  8708. hsv2rgb(h : number, s : number, v : number) : any;
  8709. }
  8710. /** !#en A 2D rectangle defined by x, y position and width, height.
  8711. !#zh 通过位置和宽高定义的 2D 矩形。 */
  8712. export class Rect extends ValueType {
  8713. /** !#en
  8714. Constructor of cc.Rect class.
  8715. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  8716. !#zh
  8717. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  8718. */
  8719. Rect(x? : number, y? : number, w? : number, h? : number) : Rect;
  8720. /** !#en Creates a rectangle from two coordinate values.
  8721. !#zh 根据指定 2 个坐标创建出一个矩形区域。
  8722. @example
  8723. ```js
  8724. cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10};
  8725. ```
  8726. */
  8727. fromMinMax(v1 : Vec2, v2 : Vec2) : Rect;
  8728. /** !#en Checks if rect contains.
  8729. !#zh
  8730. 判断 2 个矩形是否有包含。<br/>
  8731. 返回 1 为 a 包含 b,如果 -1 为 b 包含 a,
  8732. 0 这则都不包含。
  8733. @param a Rect a
  8734. @param b Rect b
  8735. @example
  8736. ```js
  8737. var a = new cc.rect(0, 0, 10, 10);
  8738. var b = new cc.rect(5, 5, 5, 5);
  8739. var c = new cc.rect(20, 20, 10, 10);
  8740. cc.Rect.contain(a, b); // 1;
  8741. cc.Rect.contain(b, a); // -1;
  8742. cc.Rect.contain(a, c); // 0;
  8743. ```
  8744. */
  8745. contain(a: (x: number, y: number, w: number, h: number) => void, b: (x: number, y: number, w: number, h: number) => void) : number;
  8746. /** !#en TODO
  8747. !#zh 克隆一个新的 Rect。
  8748. @example
  8749. ```js
  8750. var a = new cc.rect(0, 0, 10, 10);
  8751. a.clone();// Rect {x: 0, y: 0, width: 10, height: 10}
  8752. ```
  8753. */
  8754. clone() : Rect;
  8755. /** !#en TODO
  8756. !#zh 是否等于指定的矩形。
  8757. @param other !#en
  8758. Constructor of cc.Rect class.
  8759. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  8760. !#zh
  8761. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  8762. @example
  8763. ```js
  8764. var a = new cc.rect(0, 0, 10, 10);
  8765. var b = new cc.rect(0, 0, 10, 10);
  8766. a.equals(b);// true;
  8767. ```
  8768. */
  8769. equals(other: (x: number, y: number, w: number, h: number) => void) : boolean;
  8770. /** !#en TODO
  8771. !#zh 线性插值
  8772. @param to !#en
  8773. Constructor of cc.Rect class.
  8774. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  8775. !#zh
  8776. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  8777. @param ratio the interpolation coefficient.
  8778. @param out optional, the receiving vector.
  8779. @example
  8780. ```js
  8781. var a = new cc.rect(0, 0, 10, 10);
  8782. var b = new cc.rect(50, 50, 100, 100);
  8783. update (dt) {
  8784. // method 1;
  8785. var c = a.lerp(b, dt * 0.1);
  8786. // method 2;
  8787. a.lerp(b, dt * 0.1, c);
  8788. }
  8789. ```
  8790. */
  8791. lerp(to: (x: number, y: number, w: number, h: number) => void, ratio : number, out: (x: number, y: number, w: number, h: number) => void) : Rect;
  8792. /** !#en TODO
  8793. !#zh 转换为方便阅读的字符串
  8794. @example
  8795. ```js
  8796. var a = new cc.rect(0, 0, 10, 10);
  8797. a.toString();// "(0.00, 0.00, 10.00, 10.00)";
  8798. ```
  8799. */
  8800. toString() : string;
  8801. /** !#en TODO
  8802. !#zh 矩形 x 轴上的最小值。 */
  8803. xMin : number;
  8804. /** !#en TODO
  8805. !#zh 矩形 y 轴上的最小值。 */
  8806. yMin : number;
  8807. /** !#en TODO
  8808. !#zh 矩形 x 轴上的最大值。 */
  8809. xMax : number;
  8810. /** !#en TODO
  8811. !#zh 矩形 y 轴上的最大值。 */
  8812. yMax : number;
  8813. /** !#en TODO
  8814. !#zh 矩形的中心点。 */
  8815. center : number;
  8816. /** !#en TODO
  8817. !#zh 矩形的大小。 */
  8818. size : Size;
  8819. /** !#en TODO
  8820. !#zh 当前矩形与指定矩形是否相交。
  8821. @param rect !#en
  8822. Constructor of cc.Rect class.
  8823. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  8824. !#zh
  8825. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  8826. @example
  8827. ```js
  8828. var a = new cc.rect(0, 0, 10, 10);
  8829. var b = new cc.rect(0, 0, 20, 20);
  8830. a.intersects(b);// true
  8831. ```
  8832. */
  8833. intersects(rect: (x: number, y: number, w: number, h: number) => void) : void;
  8834. /** !#en TODO
  8835. !#zh 当前矩形是否包含指定坐标点。
  8836. Returns true if the point inside this rectangle.
  8837. @example
  8838. ```js
  8839. var a = new cc.rect(0, 0, 10, 10);
  8840. var b = new cc.v2(0, 5);
  8841. a.contains(b);// true
  8842. ```
  8843. */
  8844. contains(point : Vec2) : void;
  8845. /** !#en Returns true if the other rect totally inside this rectangle.
  8846. !#zh 当前矩形是否包含指定矩形。
  8847. @param rect !#en
  8848. Constructor of cc.Rect class.
  8849. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  8850. !#zh
  8851. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  8852. @example
  8853. ```js
  8854. var a = new cc.rect(0, 0, 10, 10);
  8855. var b = new cc.rect(0, 0, 20, 20);
  8856. a.containsRect(b);// true
  8857. ```
  8858. */
  8859. containsRect(rect: (x: number, y: number, w: number, h: number) => void) : void;
  8860. }
  8861. /** !#en
  8862. cc.Size is the class for size object,<br/>
  8863. please do not use its constructor to create sizes,<br/>
  8864. use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.<br/>
  8865. It will be deprecated soon, please use cc.Vec2 instead.
  8866. !#zh
  8867. cc.Size 是 size 对象的类。<br/>
  8868. 请不要使用它的构造函数创建的 size,<br/>
  8869. 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。<br/>
  8870. 它不久将被取消,请使用cc.Vec2代替。 */
  8871. export class Size {
  8872. /**
  8873. */
  8874. Size(width : number, height : number) : Size;
  8875. /** !#en return a Size object with width = 0 and height = 0.
  8876. !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */
  8877. ZERO : Size;
  8878. /** !#en TODO
  8879. !#zh 克隆 size 对象。
  8880. @example
  8881. ```js
  8882. var a = new cc.size(10, 10);
  8883. a.clone();// return Size {width: 0, height: 0};
  8884. ```
  8885. */
  8886. clone() : Size;
  8887. /** !#en TODO
  8888. !#zh 当前 Size 对象是否等于指定 Size 对象。
  8889. @example
  8890. ```js
  8891. var a = new cc.size(10, 10);
  8892. a.equals(new cc.size(10, 10));// return true;
  8893. ```
  8894. */
  8895. equals(other: (width: number, height: number) => void) : boolean;
  8896. /** !#en TODO
  8897. !#zh 线性插值。
  8898. @param to !#en
  8899. Constructor of cc.Rect class.
  8900. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  8901. !#zh
  8902. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  8903. @param ratio the interpolation coefficient.
  8904. @param out optional, the receiving vector.
  8905. @example
  8906. ```js
  8907. var a = new cc.size(10, 10);
  8908. var b = new cc.rect(50, 50, 100, 100);
  8909. update (dt) {
  8910. // method 1;
  8911. var c = a.lerp(b, dt * 0.1);
  8912. // method 2;
  8913. a.lerp(b, dt * 0.1, c);
  8914. }
  8915. ```
  8916. */
  8917. lerp(to: (x: number, y: number, w: number, h: number) => void, ratio : number, out: (width: number, height: number) => void) : Size;
  8918. /** !#en TODO
  8919. !#zh 转换为方便阅读的字符串。
  8920. @example
  8921. ```js
  8922. var a = new cc.size(10, 10);
  8923. a.toString();// return "(10.00, 10.00)";
  8924. ```
  8925. */
  8926. toString() : string;
  8927. /** !#en
  8928. Helper function that creates a cc.Size.<br/>
  8929. Please use cc.p or cc.v2 instead, it will soon replace cc.Size.
  8930. !#zh
  8931. 创建一个 cc.Size 对象的帮助函数。<br/>
  8932. 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。
  8933. @param w width or a size object
  8934. @param h height
  8935. @example
  8936. ```js
  8937. var size1 = cc.size();
  8938. var size2 = cc.size(100,100);
  8939. var size3 = cc.size(size2);
  8940. var size4 = cc.size({width: 100, height: 100});
  8941. ```
  8942. */
  8943. size(w : number|Size, h : number) : Size;
  8944. /** !#en Check whether a point's value equals to another.
  8945. !#zh 检查 Size 对象是否等于另一个。
  8946. @example
  8947. ```js
  8948. var a = new cc.size(10, 10);
  8949. var b = new cc.size(10, 10);
  8950. cc.sizeEqualToSize(a, b);// return true;
  8951. var b = new cc.size(5, 10);
  8952. cc.sizeEqualToSize(a, b);// return false;
  8953. ```
  8954. */
  8955. sizeEqualToSize(size1: (width: number, height: number) => void, size2: (width: number, height: number) => void) : boolean;
  8956. }
  8957. /** !#en the device accelerometer reports values for each axis in units of g-force.
  8958. !#zh 设备重力传感器传递的各个轴的数据。 */
  8959. export class Acceleration {
  8960. constructor();
  8961. /**
  8962. */
  8963. Acceleration(x : number, y : number, z : number, timestamp : number) : Acceleration;
  8964. }
  8965. /** !#en Blend Function used for textures.
  8966. !#zh 图像的混合方式。 */
  8967. export class BlendFunc {
  8968. constructor();
  8969. /**
  8970. @param src1 source blend function
  8971. @param dst1 destination blend function
  8972. */
  8973. BlendFunc(src1 : number, dst1 : number) : BlendFunc;
  8974. }
  8975. /** !#en
  8976. Enum for blend factor
  8977. Refer to: http://www.andersriggelsen.dk/glblendfunc.php
  8978. !#zh
  8979. 混合因子
  8980. 可参考: http://www.andersriggelsen.dk/glblendfunc.php */
  8981. export enum BlendFactor {
  8982. ONE = 0,
  8983. ZERO = 0,
  8984. SRC_ALPHA = 0,
  8985. SRC_COLOR = 0,
  8986. DST_ALPHA = 0,
  8987. DST_COLOR = 0,
  8988. ONE_MINUS_SRC_ALPHA = 0,
  8989. ONE_MINUS_SRC_COLOR = 0,
  8990. ONE_MINUS_DST_ALPHA = 0,
  8991. ONE_MINUS_DST_COLOR = 0,
  8992. blendFuncDisable = 0,
  8993. }
  8994. /** undefined */
  8995. export class WebGLColor {
  8996. constructor();
  8997. /**
  8998. */
  8999. WebGLColor(r : number, g : number, b : number, a : number, arrayBuffer : any[], offset : number) : WebGLColor;
  9000. BYTES_PER_ELEMENT : number;
  9001. }
  9002. /** undefined */
  9003. export class Vertex2F {
  9004. /**
  9005. */
  9006. Vertex2F(x : number, y : number, arrayBuffer : any[], offset : number) : Vertex2F;
  9007. BYTES_PER_ELEMENT : number;
  9008. }
  9009. /** undefined */
  9010. export class Vertex3F {
  9011. constructor();
  9012. /**
  9013. */
  9014. Vertex3F(x : number, y : number, z : number, arrayBuffer : any[], offset : number) : Vertex3F;
  9015. BYTES_PER_ELEMENT : number;
  9016. }
  9017. /** undefined */
  9018. export class Tex2F {
  9019. constructor();
  9020. /**
  9021. */
  9022. Tex2F(u : number, v : number, arrayBuffer : any[], offset : number) : Tex2F;
  9023. BYTES_PER_ELEMENT : number;
  9024. }
  9025. /** undefined */
  9026. export class Quad2 {
  9027. constructor();
  9028. /**
  9029. */
  9030. Quad2(tl: (x: number, y: number, arrayBuffer: any[], offset: number) => void, tr: (x: number, y: number, arrayBuffer: any[], offset: number) => void, bl: (x: number, y: number, arrayBuffer: any[], offset: number) => void, br: (x: number, y: number, arrayBuffer: any[], offset: number) => void, arrayBuffer : any[], offset : number) : Quad2;
  9031. BYTES_PER_ELEMENT : number;
  9032. }
  9033. /** A 3D Quad. 4 * 3 floats */
  9034. export class Quad3 {
  9035. /**
  9036. */
  9037. Quad3(bl1: (x: number, y: number, z: number, arrayBuffer: any[], offset: number) => void, br1: (x: number, y: number, z: number, arrayBuffer: any[], offset: number) => void, tl1: (x: number, y: number, z: number, arrayBuffer: any[], offset: number) => void, tr1: (x: number, y: number, z: number, arrayBuffer: any[], offset: number) => void, arrayBuffer : any[], offset : number) : Quad3;
  9038. }
  9039. /** undefined */
  9040. export class V3F_C4B_T2F {
  9041. constructor();
  9042. /**
  9043. */
  9044. V3F_C4B_T2F(vertices: (x: number, y: number, z: number, arrayBuffer: any[], offset: number) => void, colors: (r: number, g: number, b: number, a: number) => void, texCoords: (u: number, v: number, arrayBuffer: any[], offset: number) => void, arrayBuffer : any[], offset : number) : V3F_C4B_T2F;
  9045. BYTES_PER_ELEMENT() : void;
  9046. }
  9047. /** undefined */
  9048. export class V3F_C4B_T2F_Quad {
  9049. constructor();
  9050. /**
  9051. */
  9052. V3F_C4B_T2F_Quad(tl: (vertices: Vertex3F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number) => void, bl: (vertices: Vertex3F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number) => void, tr: (vertices: Vertex3F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number) => void, br: (vertices: Vertex3F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number) => void, arrayBuffer : any[], offset : number) : V3F_C4B_T2F_Quad;
  9053. BYTES_PER_ELEMENT : number;
  9054. }
  9055. /** undefined */
  9056. export class V2F_C4B_T2F {
  9057. constructor();
  9058. /**
  9059. */
  9060. V2F_C4B_T2F(vertices: (x: number, y: number, arrayBuffer: any[], offset: number) => void, colors: (r: number, g: number, b: number, a: number) => void, texCoords: (u: number, v: number, arrayBuffer: any[], offset: number) => void, arrayBuffer : any[], offset : number) : V2F_C4B_T2F;
  9061. BYTES_PER_ELEMENT : number;
  9062. }
  9063. /** undefined */
  9064. export class V2F_C4B_T2F_Triangle {
  9065. constructor();
  9066. /**
  9067. */
  9068. V2F_C4B_T2F_Triangle(a: (vertices: Vertex2F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number) => void, b: (vertices: Vertex2F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number) => void, c: (vertices: Vertex2F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number) => void, arrayBuffer : any[], offset : number) : V2F_C4B_T2F_Triangle;
  9069. }
  9070. /** !#en The base class of all value types.
  9071. !#zh 所有值类型的基类。 */
  9072. export class ValueType {
  9073. constructor();
  9074. /** !#en This method returns an exact copy of current value.
  9075. !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。
  9076. */
  9077. clone() : ValueType;
  9078. /** !#en Compares this object with the other one.
  9079. !#zh 当前对象是否等于指定对象。
  9080. */
  9081. equals(other : ValueType) : boolean;
  9082. /** !#en TODO
  9083. !#zh 转换为方便阅读的字符串。
  9084. */
  9085. toString() : string;
  9086. /** !#en
  9087. Linearly interpolates between this value to to value by ratio which is in the range [0, 1].
  9088. When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to.
  9089. !#zh
  9090. 线性插值。<br/>
  9091. 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。
  9092. @param to the to value
  9093. @param ratio the interpolation coefficient
  9094. */
  9095. lerp(to : ValueType, ratio : number) : ValueType;
  9096. }
  9097. /** !#en Representation of 2D vectors and points.
  9098. !#zh 表示 2D 向量和坐标 */
  9099. export class Vec2 extends ValueType {
  9100. constructor();
  9101. /** !#en
  9102. Constructor
  9103. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9104. !#zh
  9105. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9106. */
  9107. Vec2(x? : number, y? : number) : Vec2;
  9108. /** !#en clone a Vec2 value
  9109. !#zh 克隆一个 Vec2 值
  9110. */
  9111. clone() : Vec2;
  9112. /** !#en TODO
  9113. !#zh 设置向量值。
  9114. @param newValue !#en new value to set. !#zh 要设置的新值
  9115. */
  9116. set(newValue: (x: number, y: number) => void) : Vec2;
  9117. /** !#en TODO
  9118. !#zh 当前的向量是否与指定的向量相等。
  9119. @param other !#en
  9120. Constructor
  9121. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9122. !#zh
  9123. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9124. */
  9125. equals(other: (x: number, y: number) => void) : boolean;
  9126. /** !#en TODO
  9127. !#zh 转换为方便阅读的字符串。
  9128. */
  9129. toString() : string;
  9130. /** !#en TODO
  9131. !#zh 线性插值。
  9132. @param to !#en
  9133. Constructor
  9134. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9135. !#zh
  9136. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9137. @param ratio the interpolation coefficient
  9138. @param out optional, the receiving vector
  9139. */
  9140. lerp(to: (x: number, y: number) => void, ratio : number, out: (x: number, y: number) => void) : Vec2;
  9141. /** !#en Adds this vector. If you want to save result to another vector, use add() instead.
  9142. !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。
  9143. @param vector !#en
  9144. Constructor
  9145. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9146. !#zh
  9147. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9148. @example
  9149. ```js
  9150. var v = cc.v2(10, 10);
  9151. v.addSelf(cc.v2(5, 5));// return Vec2 {x: 15, y: 15};
  9152. ```
  9153. */
  9154. addSelf(vector: (x: number, y: number) => void) : Vec2;
  9155. /** !#en Adds two vectors, and returns the new result.
  9156. !#zh 向量加法,并返回新结果。
  9157. @param vector !#en
  9158. Constructor
  9159. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9160. !#zh
  9161. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9162. @param out optional, the receiving vector
  9163. @example
  9164. ```js
  9165. var v = cc.v2(10, 10);
  9166. v.add(cc.v2(5, 5)); // return Vec2 {x: 15, y: 15};
  9167. var v1;
  9168. v.add(cc.v2(5, 5), v1); // return Vec2 {x: 15, y: 15};
  9169. ```
  9170. */
  9171. add(vector: (x: number, y: number) => void, out: (x: number, y: number) => void) : Vec2;
  9172. /** !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead.
  9173. !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。
  9174. @param vector !#en
  9175. Constructor
  9176. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9177. !#zh
  9178. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9179. @example
  9180. ```js
  9181. var v = cc.v2(10, 10);
  9182. v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5};
  9183. ```
  9184. */
  9185. subSelf(vector: (x: number, y: number) => void) : Vec2;
  9186. /** !#en Subtracts one vector from this, and returns the new result.
  9187. !#zh 向量减法,并返回新结果。
  9188. @param vector !#en
  9189. Constructor
  9190. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9191. !#zh
  9192. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9193. @param out optional, the receiving vector
  9194. @example
  9195. ```js
  9196. var v = cc.v2(10, 10);
  9197. v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5};
  9198. var v1;
  9199. v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5};
  9200. ```
  9201. */
  9202. sub(vector: (x: number, y: number) => void, out: (x: number, y: number) => void) : Vec2;
  9203. /** !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead.
  9204. !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。
  9205. @example
  9206. ```js
  9207. var v = cc.v2(10, 10);
  9208. v.mulSelf(5);// return Vec2 {x: 50, y: 50};
  9209. ```
  9210. */
  9211. mulSelf(num : number) : Vec2;
  9212. /** !#en Multiplies by a number, and returns the new result.
  9213. !#zh 缩放当前向量,并返回新结果。
  9214. @param out optional, the receiving vector
  9215. @example
  9216. ```js
  9217. var v = cc.v2(10, 10);
  9218. v.mul(5); // return Vec2 {x: 50, y: 50};
  9219. var v1;
  9220. v.mul(5, v1); // return Vec2 {x: 50, y: 50};
  9221. ```
  9222. */
  9223. mul(num : number, out: (x: number, y: number) => void) : Vec2;
  9224. /** !#en Multiplies two vectors.
  9225. !#zh 分量相乘。
  9226. @param vector !#en
  9227. Constructor
  9228. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9229. !#zh
  9230. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9231. @example
  9232. ```js
  9233. var v = cc.v2(10, 10);
  9234. v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50};
  9235. ```
  9236. */
  9237. scaleSelf(vector: (x: number, y: number) => void) : Vec2;
  9238. /** !#en Multiplies two vectors, and returns the new result.
  9239. !#zh 分量相乘,并返回新的结果。
  9240. @param vector !#en
  9241. Constructor
  9242. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9243. !#zh
  9244. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9245. @param out optional, the receiving vector
  9246. @example
  9247. ```js
  9248. var v = cc.v2(10, 10);
  9249. v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50};
  9250. var v1;
  9251. v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50};
  9252. ```
  9253. */
  9254. scale(vector: (x: number, y: number) => void, out: (x: number, y: number) => void) : Vec2;
  9255. /** !#en Divides by a number. If you want to save result to another vector, use div() instead.
  9256. !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。
  9257. @param vector !#en
  9258. Constructor
  9259. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9260. !#zh
  9261. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9262. @example
  9263. ```js
  9264. var v = cc.v2(10, 10);
  9265. v.divSelf(5); // return Vec2 {x: 2, y: 2};
  9266. ```
  9267. */
  9268. divSelf(vector: (x: number, y: number) => void) : Vec2;
  9269. /** !#en Divides by a number, and returns the new result.
  9270. !#zh 向量除法,并返回新的结果。
  9271. @param vector !#en
  9272. Constructor
  9273. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9274. !#zh
  9275. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9276. @param out optional, the receiving vector
  9277. @example
  9278. ```js
  9279. var v = cc.v2(10, 10);
  9280. v.div(5); // return Vec2 {x: 2, y: 2};
  9281. var v1;
  9282. v.div(5, v1); // return Vec2 {x: 2, y: 2};
  9283. ```
  9284. */
  9285. div(vector: (x: number, y: number) => void, out: (x: number, y: number) => void) : Vec2;
  9286. /** !#en Negates the components. If you want to save result to another vector, use neg() instead.
  9287. !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。
  9288. @example
  9289. ```js
  9290. var v = cc.v2(10, 10);
  9291. v.negSelf(); // return Vec2 {x: -10, y: -10};
  9292. ```
  9293. */
  9294. negSelf() : Vec2;
  9295. /** !#en Negates the components, and returns the new result.
  9296. !#zh 返回取反后的新向量。
  9297. @param out optional, the receiving vector
  9298. @example
  9299. ```js
  9300. var v = cc.v2(10, 10);
  9301. var v1;
  9302. v.neg(v1); // return Vec2 {x: -10, y: -10};
  9303. ```
  9304. */
  9305. neg(out: (x: number, y: number) => void) : Vec2;
  9306. /** !#en Dot product
  9307. !#zh 当前向量与指定向量进行点乘。
  9308. @param vector !#en
  9309. Constructor
  9310. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9311. !#zh
  9312. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9313. @example
  9314. ```js
  9315. var v = cc.v2(10, 10);
  9316. v.dot(cc.v2(5, 5)); // return 100;
  9317. ```
  9318. */
  9319. dot(vector: (x: number, y: number) => void) : number;
  9320. /** !#en Cross product
  9321. !#zh 当前向量与指定向量进行叉乘。
  9322. @param vector !#en
  9323. Constructor
  9324. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9325. !#zh
  9326. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9327. @example
  9328. ```js
  9329. var v = cc.v2(10, 10);
  9330. v.cross(cc.v2(5, 5)); // return 0;
  9331. ```
  9332. */
  9333. cross(vector: (x: number, y: number) => void) : number;
  9334. /** !#en Returns the length of this vector.
  9335. !#zh 返回该向量的长度。
  9336. @example
  9337. ```js
  9338. var v = cc.v2(10, 10);
  9339. v.mag(); // return 14.142135623730951;
  9340. ```
  9341. */
  9342. mag() : number;
  9343. /** !#en Returns the squared length of this vector.
  9344. !#zh 返回该向量的长度平方。
  9345. @example
  9346. ```js
  9347. var v = cc.v2(10, 10);
  9348. v.magSqr(); // return 200;
  9349. ```
  9350. */
  9351. magSqr() : number;
  9352. /** !#en Make the length of this vector to 1.
  9353. !#zh 向量归一化,让这个向量的长度为 1。
  9354. @example
  9355. ```js
  9356. var v = cc.v2(10, 10);
  9357. v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
  9358. ```
  9359. */
  9360. normalizeSelf() : Vec2;
  9361. /** !#en
  9362. Returns this vector with a magnitude of 1.<br/>
  9363. <br/>
  9364. Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function.
  9365. !#zh
  9366. 返回归一化后的向量。<br/>
  9367. <br/>
  9368. 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。
  9369. @param out optional, the receiving vector
  9370. */
  9371. normalize(out: (x: number, y: number) => void) : Vec2;
  9372. /** !#en Get angle in radian between this and vector.
  9373. !#zh 夹角的弧度。
  9374. @param vector !#en
  9375. Constructor
  9376. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9377. !#zh
  9378. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9379. */
  9380. angle(vector: (x: number, y: number) => void) : number;
  9381. /** !#en Get angle in radian between this and vector with direction.
  9382. !#zh 带方向的夹角的弧度。
  9383. @param vector !#en
  9384. Constructor
  9385. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9386. !#zh
  9387. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  9388. */
  9389. signAngle(vector: (x: number, y: number) => void) : number;
  9390. /** !#en rotate
  9391. !#zh 返回旋转给定弧度后的新向量。
  9392. @param out optional, the receiving vector
  9393. */
  9394. rotate(radians : number, out: (x: number, y: number) => void) : Vec2;
  9395. /** !#en rotate self
  9396. !#zh 按指定弧度旋转向量。
  9397. */
  9398. rotateSelf(radians : number) : Vec2;
  9399. /** !#en return a Vec2 object with x = 1 and y = 1.
  9400. !#zh 新 Vec2 对象。 */
  9401. ONE : Vec2;
  9402. /** !#en return a Vec2 object with x = 0 and y = 0.
  9403. !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */
  9404. ZERO : Vec2;
  9405. /** !#en return a Vec2 object with x = 0 and y = 1.
  9406. !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */
  9407. up : Vec2;
  9408. /** !#en return a Vec2 object with x = 1 and y = 0.
  9409. !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */
  9410. RIGHT : Vec2;
  9411. }
  9412. /****************************************************
  9413. * Node
  9414. *****************************************************/
  9415. export module Node {
  9416. /** !#en The event type supported by Node
  9417. !#zh Node 支持的事件类型 */
  9418. export enum EventType {
  9419. TOUCH_START = 0,
  9420. TOUCH_MOVE = 0,
  9421. TOUCH_END = 0,
  9422. TOUCH_CANCEL = 0,
  9423. MOUSE_DOWN = 0,
  9424. MOUSE_MOVE = 0,
  9425. MOUSE_ENTER = 0,
  9426. MOUSE_LEAVE = 0,
  9427. MOUSE_UP = 0,
  9428. MOUSE_WHEEL = 0,
  9429. }
  9430. }
  9431. /****************************************************
  9432. * ParticleSystem
  9433. *****************************************************/
  9434. export module ParticleSystem {
  9435. /** !#en Enum for emitter modes
  9436. !#zh 发射模式 */
  9437. export enum EmitterMode {
  9438. GRAVITY = 0,
  9439. RADIUS = 0,
  9440. }
  9441. }
  9442. /****************************************************
  9443. * ParticleSystem
  9444. *****************************************************/
  9445. export module ParticleSystem {
  9446. /** !#en Enum for particles movement type.
  9447. !#zh 粒子位置类型 */
  9448. export enum PositionType {
  9449. FREE = 0,
  9450. RELATIVE = 0,
  9451. GROUPED = 0,
  9452. }
  9453. }
  9454. /****************************************************
  9455. * TiledMap
  9456. *****************************************************/
  9457. export module TiledMap {
  9458. /** !#en The orientation of tiled map.
  9459. !#zh Tiled Map 地图方向。 */
  9460. export enum Orientation {
  9461. ORTHO = 0,
  9462. HEX = 0,
  9463. ISO = 0,
  9464. NONE = 0,
  9465. MAP = 0,
  9466. LAYER = 0,
  9467. OBJECTGROUP = 0,
  9468. OBJECT = 0,
  9469. TILE = 0,
  9470. HORIZONTAL = 0,
  9471. VERTICAL = 0,
  9472. DIAGONAL = 0,
  9473. FLIPPED_ALL = 0,
  9474. FLIPPED_MASK = 0,
  9475. STAGGERAXIS_X = 0,
  9476. STAGGERAXIS_Y = 0,
  9477. STAGGERINDEX_ODD = 0,
  9478. STAGGERINDEX_EVEN = 0,
  9479. }
  9480. }
  9481. /****************************************************
  9482. * Button
  9483. *****************************************************/
  9484. export module Button {
  9485. /** !#en Enum for transition type.
  9486. !#zh 过渡类型 */
  9487. export enum Transition {
  9488. NONE = 0,
  9489. COLOR = 0,
  9490. SPRITE = 0,
  9491. }
  9492. }
  9493. /****************************************************
  9494. * Component
  9495. *****************************************************/
  9496. export module Component {
  9497. /** !#en
  9498. Component will register a event to target component's handler.
  9499. And it will trigger the handler when a certain event occurs.
  9500. !@zh
  9501. “EventHandler” 类用来设置场景中的事件回调,
  9502. 该类允许用户设置回调目标节点,目标组件名,组件方法名,
  9503. 并可通过 emit 方法调用目标函数。 */
  9504. export class EventHandler {
  9505. /** !#en Event target
  9506. !#zh 目标节点 */
  9507. target : Node;
  9508. /** !#en Component name
  9509. !#zh 目标组件名 */
  9510. component : string;
  9511. /** !#en Event handler
  9512. !#zh 响应事件函数名 */
  9513. handler : string;
  9514. /**
  9515. */
  9516. emitEvents(events : Component.EventHandler[], params : any) : void;
  9517. /** !#en Emit event with params
  9518. !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。
  9519. @example
  9520. ```js
  9521. // Call Function
  9522. var eventHandler = new cc.Component.EventHandler();
  9523. eventHandler.target = newTarget;
  9524. eventHandler.component = "MainMenu";
  9525. eventHandler.handler = "OnClick"
  9526. eventHandler.emit(["param1", "param2", ....]);
  9527. ```
  9528. */
  9529. emit(params : any[]) : void;
  9530. }
  9531. }
  9532. /****************************************************
  9533. * EditBox
  9534. *****************************************************/
  9535. export module EditBox {
  9536. /** !#en Enum for keyboard return types
  9537. !#zh 键盘的返回键类型 */
  9538. export enum KeyboardReturnType {
  9539. DEFAULT = 0,
  9540. DONE = 0,
  9541. SEND = 0,
  9542. SEARCH = 0,
  9543. GO = 0,
  9544. }
  9545. }
  9546. /****************************************************
  9547. * EditBox
  9548. *****************************************************/
  9549. export module EditBox {
  9550. /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter.
  9551. !#zh 输入模式 */
  9552. export enum InputMode {
  9553. ANY = 0,
  9554. EMAIL_ADDR = 0,
  9555. NUMERIC = 0,
  9556. PHONE_NUMBER = 0,
  9557. URL = 0,
  9558. DECIMAL = 0,
  9559. SINGLE_LINE = 0,
  9560. }
  9561. }
  9562. /****************************************************
  9563. * EditBox
  9564. *****************************************************/
  9565. export module EditBox {
  9566. /** !#en Enum for the EditBox's input flags
  9567. !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */
  9568. export enum InputFlag {
  9569. PASSWORD = 0,
  9570. SENSITIVE = 0,
  9571. INITIAL_CAPS_WORD = 0,
  9572. INITIAL_CAPS_SENTENCE = 0,
  9573. INITIAL_CAPS_ALL_CHARACTERS = 0,
  9574. }
  9575. }
  9576. /****************************************************
  9577. * Label
  9578. *****************************************************/
  9579. export module Label {
  9580. /** !#en Enum for text alignment.
  9581. !#zh 文本横向对齐类型 */
  9582. export enum HorizontalAlign {
  9583. LEFT = 0,
  9584. CENTER = 0,
  9585. RIGHT = 0,
  9586. }
  9587. }
  9588. /****************************************************
  9589. * Label
  9590. *****************************************************/
  9591. export module Label {
  9592. /** !#en Enum for vertical text alignment.
  9593. !#zh 文本垂直对齐类型 */
  9594. export enum VerticalAlign {
  9595. TOP = 0,
  9596. CENTER = 0,
  9597. BOTTOM = 0,
  9598. }
  9599. }
  9600. /****************************************************
  9601. * Label
  9602. *****************************************************/
  9603. export module Label {
  9604. /** !#en Enum for Overflow.
  9605. !#zh Overflow 类型 */
  9606. export enum Overflow {
  9607. NONE = 0,
  9608. CLAMP = 0,
  9609. SHRINK = 0,
  9610. RESIZE_HEIGHT = 0,
  9611. }
  9612. }
  9613. /****************************************************
  9614. * Label
  9615. *****************************************************/
  9616. export module Label {
  9617. /** !#en Enum for font type.
  9618. !#zh Type 类型 */
  9619. export enum Type {
  9620. TTF = 0,
  9621. BMFont = 0,
  9622. SystemFont = 0,
  9623. }
  9624. }
  9625. /****************************************************
  9626. * Layout
  9627. *****************************************************/
  9628. export module Layout {
  9629. /** !#en Enum for Layout type
  9630. !#zh 布局类型 */
  9631. export enum Type {
  9632. NONE = 0,
  9633. HORIZONTAL = 0,
  9634. VERTICAL = 0,
  9635. GRID = 0,
  9636. }
  9637. }
  9638. /****************************************************
  9639. * Layout
  9640. *****************************************************/
  9641. export module Layout {
  9642. /** !#en Enum for Layout Resize Mode
  9643. !#zh 缩放模式 */
  9644. export enum ResizeMode {
  9645. NONE = 0,
  9646. CONTAINER = 0,
  9647. CHILDREN = 0,
  9648. }
  9649. }
  9650. /****************************************************
  9651. * Layout
  9652. *****************************************************/
  9653. export module Layout {
  9654. /** !#en Enum for Grid Layout start axis direction.
  9655. !#zh 布局轴向,只用于 GRID 布局。 */
  9656. export enum AxisDirection {
  9657. HORIZONTAL = 0,
  9658. VERTICAL = 0,
  9659. }
  9660. }
  9661. /****************************************************
  9662. * Layout
  9663. *****************************************************/
  9664. export module Layout {
  9665. /** !#en Enum for vertical layout direction.
  9666. !#zh 垂直方向布局方式 */
  9667. export enum VerticalDirection {
  9668. BOTTOM_TO_TOP = 0,
  9669. TOP_TO_BOTTOM = 0,
  9670. }
  9671. }
  9672. /****************************************************
  9673. * Layout
  9674. *****************************************************/
  9675. export module Layout {
  9676. /** !#en Enum for horizontal layout direction.
  9677. !#zh 水平方向布局方式 */
  9678. export enum HorizontalDirection {
  9679. LEFT_TO_RIGHT = 0,
  9680. RIGHT_TO_LEFT = 0,
  9681. }
  9682. }
  9683. /****************************************************
  9684. * Mask
  9685. *****************************************************/
  9686. export module Mask {
  9687. /** !#en the type for mask.
  9688. !#zh 遮罩组件的类型 */
  9689. export enum Type {
  9690. RECT = 0,
  9691. ELLIPSE = 0,
  9692. type = 0,
  9693. segements = 0,
  9694. }
  9695. }
  9696. /****************************************************
  9697. * ProgressBar
  9698. *****************************************************/
  9699. export module ProgressBar {
  9700. /** !#en Enum for ProgressBar mode
  9701. !#zh 进度条模式 */
  9702. export enum Mode {
  9703. HORIZONTAL = 0,
  9704. VERTICAL = 0,
  9705. FILLED = 0,
  9706. }
  9707. }
  9708. /****************************************************
  9709. * Scrollbar
  9710. *****************************************************/
  9711. export module Scrollbar {
  9712. /** Enum for Scrollbar direction */
  9713. export enum Direction {
  9714. HORIZONTAL = 0,
  9715. VERTICAL = 0,
  9716. }
  9717. }
  9718. /****************************************************
  9719. * ScrollView
  9720. *****************************************************/
  9721. export module ScrollView {
  9722. /** !#en Enum for ScrollView event type.
  9723. !#zh 滚动视图事件类型 */
  9724. export enum EventType {
  9725. SCROLL_TO_TOP = 0,
  9726. SCROLL_TO_BOTTOM = 0,
  9727. SCROLL_TO_LEFT = 0,
  9728. SCROLL_TO_RIGHT = 0,
  9729. SCROLLING = 0,
  9730. BOUNCE_TOP = 0,
  9731. BOUNCE_BOTTOM = 0,
  9732. BOUNCE_LEFT = 0,
  9733. BOUNCE_RIGHT = 0,
  9734. AUTOSCROLL_ENDED = 0,
  9735. }
  9736. }
  9737. /****************************************************
  9738. * Sprite
  9739. *****************************************************/
  9740. export module Sprite {
  9741. /** !#en Enum for sprite type.
  9742. !#zh Sprite 类型 */
  9743. export enum SpriteType {
  9744. SIMPLE = 0,
  9745. SLICED = 0,
  9746. TILED = 0,
  9747. FILLED = 0,
  9748. }
  9749. }
  9750. /****************************************************
  9751. * Sprite
  9752. *****************************************************/
  9753. export module Sprite {
  9754. /** !#en Enum for fill type.
  9755. !#zh 填充类型 */
  9756. export enum FillType {
  9757. HORIZONTAL = 0,
  9758. VERTICAL = 0,
  9759. RADIAL = 0,
  9760. }
  9761. }
  9762. /****************************************************
  9763. * Sprite
  9764. *****************************************************/
  9765. export module Sprite {
  9766. /** !#en Sprite Size can track trimmed size, raw size or none.
  9767. !#zh 精灵尺寸调整模式 */
  9768. export enum SizeMode {
  9769. CUSTOM = 0,
  9770. TRIMMED = 0,
  9771. RAW = 0,
  9772. }
  9773. }
  9774. /****************************************************
  9775. * VideoPlayer
  9776. *****************************************************/
  9777. export module VideoPlayer {
  9778. /** !#en Video event type
  9779. !#zh 视频事件类型 */
  9780. export enum EventType {
  9781. PLAYING = 0,
  9782. PAUSED = 0,
  9783. STOPPED = 0,
  9784. COMPLETED = 0,
  9785. }
  9786. }
  9787. /****************************************************
  9788. * VideoPlayer
  9789. *****************************************************/
  9790. export module VideoPlayer {
  9791. /** !#en Enum for video resouce type type.
  9792. !#zh 视频来源 */
  9793. export enum ResourceType {
  9794. REMOTE = 0,
  9795. LOCAL = 0,
  9796. }
  9797. }
  9798. /****************************************************
  9799. * WebView
  9800. *****************************************************/
  9801. export module WebView {
  9802. /** !#en WebView event type
  9803. !#zh 网页视图事件类型 */
  9804. export enum EventType {
  9805. LOADED = 0,
  9806. LOADING = 0,
  9807. ERROR = 0,
  9808. }
  9809. }
  9810. /****************************************************
  9811. * Event
  9812. *****************************************************/
  9813. export module Event {
  9814. /** !#en The Custom event
  9815. !#zh 自定义事件 */
  9816. export class EventCustom extends Event {
  9817. constructor();
  9818. /**
  9819. @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
  9820. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  9821. */
  9822. EventCustom(type : string, bubbles : boolean) : EventCustom;
  9823. /** !#en A reference to the detailed data of the event
  9824. !#zh 事件的详细数据 */
  9825. detail : any;
  9826. /** !#en Sets user data
  9827. !#zh 设置用户数据
  9828. */
  9829. setUserData(data : any) : void;
  9830. /** !#en Gets user data
  9831. !#zh 获取用户数据
  9832. */
  9833. getUserData() : any;
  9834. /** !#en Gets event name
  9835. !#zh 获取事件名称
  9836. */
  9837. getEventName() : string;
  9838. }
  9839. }
  9840. /****************************************************
  9841. * Event
  9842. *****************************************************/
  9843. export module Event {
  9844. /** !#en The mouse event
  9845. !#zh 鼠标事件类型 */
  9846. export class EventMouse extends Event {
  9847. /**
  9848. @param eventType The mouse event type, UP, DOWN, MOVE, CANCELED
  9849. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  9850. */
  9851. constructor(eventType : number, bubbles? : boolean);
  9852. /** !#en Sets scroll data.
  9853. !#zh 设置鼠标的滚动数据。
  9854. */
  9855. setScrollData(scrollX : number, scrollY : number) : void;
  9856. /** !#en Returns the x axis scroll value.
  9857. !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。
  9858. */
  9859. getScrollX() : number;
  9860. /** !#en Returns the y axis scroll value.
  9861. !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。
  9862. */
  9863. getScrollY() : number;
  9864. /** !#en Sets cursor location.
  9865. !#zh 设置当前鼠标位置。
  9866. */
  9867. setLocation(x : number, y : number) : void;
  9868. /** !#en Returns cursor location.
  9869. !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。
  9870. */
  9871. getLocation() : Vec2;
  9872. /** !#en Returns the current cursor location in screen coordinates.
  9873. !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
  9874. */
  9875. getLocationInView() : Vec2;
  9876. /** !#en Returns the previous touch location.
  9877. !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。
  9878. */
  9879. getPreviousLocation() : Vec2;
  9880. /** !#en Returns the delta distance from the previous location to current location.
  9881. !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  9882. */
  9883. getDelta() : Vec2;
  9884. /** !#en Returns the X axis delta distance from the previous location to current location.
  9885. !#zh 获取鼠标距离上一次事件移动的 X 轴距离。
  9886. */
  9887. getDeltaX() : number;
  9888. /** !#en Returns the Y axis delta distance from the previous location to current location.
  9889. !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。
  9890. */
  9891. getDeltaY() : number;
  9892. /** !#en Sets mouse button.
  9893. !#zh 设置鼠标按键。
  9894. */
  9895. setButton(button : number) : void;
  9896. /** !#en Returns mouse button.
  9897. !#zh 获取鼠标按键。
  9898. */
  9899. getButton() : number;
  9900. /** !#en Returns location X axis data.
  9901. !#zh 获取鼠标当前位置 X 轴。
  9902. */
  9903. getLocationX() : number;
  9904. /** !#en Returns location Y axis data.
  9905. !#zh 获取鼠标当前位置 Y 轴。
  9906. */
  9907. getLocationY() : number;
  9908. }
  9909. }
  9910. /****************************************************
  9911. * Event
  9912. *****************************************************/
  9913. export module Event {
  9914. /** !#en The touch event
  9915. !#zh 触摸事件 */
  9916. export class EventTouch extends Event {
  9917. /**
  9918. @param touchArr The array of the touches
  9919. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  9920. */
  9921. constructor(touchArr : any[], bubbles : boolean);
  9922. /** !#en Returns event code.
  9923. !#zh 获取事件类型。
  9924. */
  9925. getEventCode() : number;
  9926. /** !#en Returns touches of event.
  9927. !#zh 获取触摸点的列表。
  9928. */
  9929. getTouches() : any[];
  9930. /** !#en Sets touch location.
  9931. !#zh 设置当前触点位置
  9932. */
  9933. setLocation(x : number, y : number) : void;
  9934. /** !#en Returns touch location.
  9935. !#zh 获取触点位置。
  9936. */
  9937. getLocation() : Vec2;
  9938. /** !#en Returns the current touch location in screen coordinates.
  9939. !#zh 获取当前触点在游戏窗口中的位置。
  9940. */
  9941. getLocationInView() : Vec2;
  9942. /** !#en Returns the previous touch location.
  9943. !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
  9944. */
  9945. getPreviousLocation() : Vec2;
  9946. /** !#en Returns the start touch location.
  9947. !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。
  9948. */
  9949. getStartLocation() : Vec2;
  9950. /** !#en Returns the id of cc.Touch.
  9951. !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
  9952. */
  9953. getID() : number;
  9954. /** !#en Returns the delta distance from the previous location to current location.
  9955. !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  9956. */
  9957. getDelta() : Vec2;
  9958. /** !#en Returns the X axis delta distance from the previous location to current location.
  9959. !#zh 获取触点距离上一次事件移动的 x 轴距离。
  9960. */
  9961. getDeltaX() : number;
  9962. /** !#en Returns the Y axis delta distance from the previous location to current location.
  9963. !#zh 获取触点距离上一次事件移动的 y 轴距离。
  9964. */
  9965. getDeltaY() : number;
  9966. /** !#en Returns location X axis data.
  9967. !#zh 获取当前触点 X 轴位置。
  9968. */
  9969. getLocationX() : number;
  9970. /** !#en Returns location Y axis data.
  9971. !#zh 获取当前触点 Y 轴位置。
  9972. */
  9973. getLocationY() : number;
  9974. }
  9975. }
  9976. /****************************************************
  9977. * Event
  9978. *****************************************************/
  9979. export module Event {
  9980. /** !#en The acceleration event
  9981. !#zh 加速度事件 */
  9982. export class EventAcceleration extends Event {
  9983. /**
  9984. @param acc The acceleration
  9985. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  9986. */
  9987. constructor(acc : any, bubbles : boolean);
  9988. }
  9989. }
  9990. /****************************************************
  9991. * Event
  9992. *****************************************************/
  9993. export module Event {
  9994. /** !#en The keyboard event
  9995. !#zh 键盘事件 */
  9996. export class EventKeyboard extends Event {
  9997. /**
  9998. @param keyCode The key code of which triggered this event
  9999. @param isPressed A boolean indicating whether the key have been pressed
  10000. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  10001. */
  10002. constructor(keyCode : number, isPressed : boolean, bubbles : boolean);
  10003. }
  10004. }
  10005. /****************************************************
  10006. * Graphics
  10007. *****************************************************/
  10008. export module Graphics {
  10009. /** !#en Enum for LineCap.
  10010. !#zh 线段末端属性 */
  10011. export enum LineCap {
  10012. BUTT = 0,
  10013. ROUND = 0,
  10014. SQUARE = 0,
  10015. }
  10016. }
  10017. /****************************************************
  10018. * Graphics
  10019. *****************************************************/
  10020. export module Graphics {
  10021. /** !#en Enum for LineJoin.
  10022. !#zh 线段拐角属性 */
  10023. export enum LineJoin {
  10024. BEVEL = 0,
  10025. ROUND = 0,
  10026. MITER = 0,
  10027. }
  10028. }
  10029. /****************************************************
  10030. * Pipeline
  10031. *****************************************************/
  10032. export module Pipeline {
  10033. /** The downloader pipe, it can download several types of files:
  10034. 1. Text
  10035. 2. Image
  10036. 3. Script
  10037. 4. Audio
  10038. All unknown type will be downloaded as plain text.
  10039. You can pass custom supported types in the constructor. */
  10040. export class Downloader {
  10041. /** Constructor of Downloader, you can pass custom supported types.
  10042. @param extMap Custom supported types with corresponded handler
  10043. @example
  10044. ```js
  10045. var downloader = new Downloader({
  10046. // This will match all url with `.scene` extension or all url with `scene` type
  10047. 'scene' : function (url, callback) {}
  10048. });
  10049. ```
  10050. */
  10051. Downloader(extMap : any) : void;
  10052. /** Add custom supported types handler or modify existing type handler.
  10053. @param extMap Custom supported types with corresponded handler
  10054. */
  10055. addHandlers(extMap : any) : void;
  10056. }
  10057. }
  10058. /****************************************************
  10059. * Pipeline
  10060. *****************************************************/
  10061. export module Pipeline {
  10062. /** The loader pipe, it can load several types of files:
  10063. 1. Images
  10064. 2. JSON
  10065. 3. Plist
  10066. 4. Audio
  10067. 5. Font
  10068. 6. Cocos Creator scene
  10069. It will not interfere with items of unknown type.
  10070. You can pass custom supported types in the constructor. */
  10071. export class Loader {
  10072. /** Constructor of Loader, you can pass custom supported types.
  10073. @param extMap Custom supported types with corresponded handler
  10074. @example
  10075. ```js
  10076. var loader = new Loader({
  10077. // This will match all url with `.scene` extension or all url with `scene` type
  10078. 'scene' : function (url, callback) {}
  10079. });
  10080. ```
  10081. */
  10082. Loader(extMap : any) : void;
  10083. /** Add custom supported types handler or modify existing type handler.
  10084. @param extMap Custom supported types with corresponded handler
  10085. */
  10086. addHandlers(extMap : any) : void;
  10087. }
  10088. }
  10089. /****************************************************
  10090. * Texture2D
  10091. *****************************************************/
  10092. export module Texture2D {
  10093. /** The texture wrap mode */
  10094. export enum WrapMode {
  10095. REPEAT = 0,
  10096. CLAMP_TO_EDGE = 0,
  10097. MIRRORED_REPEAT = 0,
  10098. }
  10099. }
  10100. }
  10101. /** !#en
  10102. AnySDK is a third party solution that offers game developers SDK integration without making changes to the SDK's features or parameters.It can do all of this while remaining invisible to your end user.Our goal is to handle all the tedious SDK integration work for you so that you can use your time to focus on the game itself.No matter if it’s the channel SDK, user system, payment system, ad system, statistics system, sharing system or any other type of SDK: we’ll take care of it for you.
  10103. !#zh
  10104. AnySDK 为 CP 提供一套第三方 SDK 接入解决方案,整个接入过程,不改变任何 SDK 的功能、特性、参数等,对于最终玩家而言是完全透明无感知的。
  10105. 目的是让 CP 商能有更多时间更专注于游戏本身的品质,所有 SDK 的接入工作统统交给我们吧。第三方 SDK 包括了渠道SDK、用户系统、支付系统、广告系统、统计系统、分享系统等等。 */
  10106. declare module anysdk {
  10107. /** !#en
  10108. agent manager of plugin
  10109. !#zh
  10110. 插件管理对象 */
  10111. export var agentManager : anysdk.AgentManager;
  10112. /** !#en
  10113. agent manager of plugin
  10114. !#zh
  10115. 插件管理类 */
  10116. export class AgentManager {
  10117. constructor();
  10118. /** !#en
  10119. AppKey appSecret and privateKey are the only three parameters generated
  10120. after the packing tool client finishes creating the game.
  10121. The oauthLoginServer parameter is the API address provided by the game service
  10122. to login verification
  10123. !#zh
  10124. appKey、appSecret、privateKey是通过 AnySDK 客户端工具创建游戏后生成的。
  10125. oauthLoginServer参数是游戏服务提供的用来做登陆验证转发的接口地址。
  10126. */
  10127. init(appKey : string, appSecret : string, privateKey : string, oauthLoginServer : string) : void;
  10128. /** !#en
  10129. load all plugins, the operation includes SDK`s initialization
  10130. !#zh
  10131. 加载所有插件,该操作包含了 SDKs 初始化
  10132. @param target The object to bind to.
  10133. */
  10134. loadAllPlugins(callback : Function, target : any) : void;
  10135. /** !#en
  10136. unload all plugins
  10137. !#zh
  10138. 卸载插件
  10139. */
  10140. unloadAllPlugins() : void;
  10141. /** !#en
  10142. get user system plugin
  10143. !#zh
  10144. 获取用户系统插件
  10145. */
  10146. getUserPlugin() : anysdk.ProtocolUser;
  10147. /** !#en
  10148. get IAP system plugins
  10149. !#zh
  10150. 获取支付系统插件
  10151. */
  10152. getIAPPlugins() : anysdk.ProtocolIAP;
  10153. /** !#en
  10154. get IAP system plugin
  10155. !#zh
  10156. 获取支付系统插件
  10157. */
  10158. getIAPPlugin() : anysdk.ProtocolIAP;
  10159. /** !#en
  10160. get social system plugin
  10161. !#zh
  10162. 获取社交系统插件
  10163. */
  10164. getSocialPlugin() : anysdk.ProtocolSocial;
  10165. /** !#en
  10166. get share system plugin
  10167. !#zh
  10168. 获取分享系统插件
  10169. */
  10170. getSharePlugin() : anysdk.ProtocolShare;
  10171. /** !#en
  10172. get analytics system plugin
  10173. !#zh
  10174. 获取统计系统插件
  10175. */
  10176. getAnalyticsPlugin() : anysdk.ProtocolAnalytics;
  10177. /** !#en
  10178. get ads system plugin
  10179. !#zh
  10180. 获取广告系统插件
  10181. */
  10182. getAdsPlugin() : anysdk.ProtocolAds;
  10183. /** !#en
  10184. get push system plugin
  10185. !#zh
  10186. 获取推送系统插件
  10187. */
  10188. getPushPlugin() : anysdk.ProtocolPush;
  10189. /** !#en
  10190. get REC system plugin
  10191. !#zh
  10192. 获取录屏系统插件
  10193. */
  10194. getRECPlugin() : anysdk.ProtocolREC;
  10195. /** !#en
  10196. get crash system plugin
  10197. !#zh
  10198. 获取崩溃分析系统插件
  10199. */
  10200. getCrashPlugin() : anysdk.ProtocolCrash;
  10201. /** !#en
  10202. get ad track system plugin
  10203. !#zh
  10204. 获取广告追踪系统插件
  10205. */
  10206. getAdTrackingPlugin() : anysdk.ProtocolAdTracking;
  10207. /** !#en
  10208. get custom system plugin
  10209. !#zh
  10210. 获取自定义系统插件
  10211. */
  10212. getCustomPlugin() : anysdk.ProtocolCustom;
  10213. /** !#en
  10214. get custom parameter
  10215. !#zh
  10216. 获取自定义参数
  10217. */
  10218. getCustomParam() : string;
  10219. /** !#en
  10220. get channel id
  10221. !#zh
  10222. 获取渠道唯一表示符
  10223. */
  10224. getChannelId() : string;
  10225. /** !#en
  10226. get status of analytics
  10227. !#zh
  10228. 获取统计状态
  10229. */
  10230. isAnaylticsEnabled() : boolean;
  10231. /** !#en
  10232. set whether to analytics
  10233. !#zh
  10234. 设置是否统计
  10235. */
  10236. setIsAnaylticsEnabled(enabled : boolean) : void;
  10237. /** !#en
  10238. destory instance
  10239. !#zh
  10240. 销毁单例
  10241. */
  10242. end() : void;
  10243. /** !#en
  10244. get instance
  10245. !#zh
  10246. 获取单例
  10247. */
  10248. getInstance() : anysdk.AgentManager;
  10249. }
  10250. /** !#en
  10251. plugin protocol
  10252. !#zh
  10253. 插件协议 */
  10254. export class PluginProtocol {
  10255. /** !#en
  10256. Check whether the function is supported
  10257. !#zh
  10258. 判断函数是否支持
  10259. */
  10260. isFunctionSupported(functionName : string) : boolean;
  10261. /** !#en
  10262. get plugin name
  10263. !#zh
  10264. 获取插件名称
  10265. */
  10266. getPluginName() : string;
  10267. /** !#en
  10268. get plugin version
  10269. !#zh
  10270. 获取插件版本
  10271. */
  10272. getPluginVersion() : string;
  10273. /** !#en
  10274. get SDK version
  10275. !#zh
  10276. 获取 SDK 版本
  10277. */
  10278. getSDKVersion() : string;
  10279. /** !#en
  10280. void methods for reflections with parameter
  10281. !#zh
  10282. 反射调用带参数的void方法
  10283. @param args optional arguments
  10284. */
  10285. callFuncWithParam(funName : string, args? : any|anysdk.PluginParam) : void;
  10286. /** !#en
  10287. String methods for reflections with parameter
  10288. !#zh
  10289. 反射调用带参数的 String 方法
  10290. @param args optional arguments
  10291. */
  10292. callStringFuncWithParam(funName : string, args? : any|anysdk.PluginParam) : string;
  10293. /** !#en
  10294. int methods for reflections with parameter
  10295. !#zh
  10296. 反射调用带参数的 Int 方法
  10297. @param args optional arguments
  10298. */
  10299. callIntFuncWithParam(funName : string, args? : any|anysdk.PluginParam) : number;
  10300. /** !#en
  10301. boolean methods for reflections with parameter
  10302. !#zh
  10303. 反射调用带参数的 boolean 方法
  10304. @param args optional arguments
  10305. */
  10306. callBoolFuncWithParam(funName : string, args? : any|anysdk.PluginParam) : boolean;
  10307. /** !#en
  10308. float methods for reflections with parameter
  10309. !#zh
  10310. 反射调用带参数的 float 方法
  10311. @param args optional arguments
  10312. */
  10313. callFloatFuncWithParam(funName : string, args? : any|anysdk.PluginParam) : number;
  10314. }
  10315. /** !#en
  10316. user protocol
  10317. !#zh
  10318. 用户系统协议接口 */
  10319. export class ProtocolUser extends PluginProtocol {
  10320. /** !#en
  10321. login interface
  10322. !#zh
  10323. 登录接口
  10324. @param args optional arguments
  10325. */
  10326. login(args? : string|any) : void;
  10327. /** !#en
  10328. get status of login
  10329. !#zh
  10330. 获取登录状态
  10331. */
  10332. isLogined() : boolean;
  10333. /** !#en
  10334. get user ID
  10335. !#zh
  10336. 获取用户唯一标示符
  10337. */
  10338. getUserID() : string;
  10339. /** !#en
  10340. get plugin ID
  10341. !#zh
  10342. 获取插件ID
  10343. */
  10344. getPluginId() : string;
  10345. /** !#en
  10346. set listener
  10347. !#zh
  10348. 设置用户系统的监听
  10349. */
  10350. setListener(listener : Function, target : any) : void;
  10351. /** !#en
  10352. get listener
  10353. !#zh
  10354. 获取用户系统的监听
  10355. */
  10356. getListener() : Function;
  10357. /** !#en
  10358. logout
  10359. Before to invoke, you need to verdict whether this properties existed
  10360. !#zh
  10361. 登出,调用前需要判断属性是否存在
  10362. */
  10363. logout() : void;
  10364. /** !#en
  10365. show toolbar
  10366. Before to invoke, you need to verdict whether this properties existed
  10367. !#zh
  10368. 显示悬浮窗,调用前需要判断属性是否存在
  10369. */
  10370. showToolBar(place : anysdk.ToolBarPlace) : void;
  10371. /** !#en
  10372. hide toolbar
  10373. Before to invoke, you need to verdict whether this properties existed
  10374. !#zh
  10375. 隐藏悬浮窗,调用前需要判断属性是否存在
  10376. */
  10377. hideToolBar() : void;
  10378. /** !#en
  10379. enter platform
  10380. Before to invoke, you need to verdict whether this properties existed
  10381. !#zh
  10382. 显示平台中心,调用前需要判断属性是否存在
  10383. */
  10384. enterPlatform() : void;
  10385. /** !#en
  10386. show exit page
  10387. Before to invoke, you need to verdict whether this properties existed
  10388. !#zh
  10389. 显示退出界面,调用前需要判断属性是否存在
  10390. */
  10391. exit() : void;
  10392. /** !#en
  10393. show pause page
  10394. Before to invoke, you need to verdict whether this properties existed
  10395. !#zh
  10396. 显示暂停界面,调用前需要判断属性是否存在
  10397. */
  10398. pause() : void;
  10399. /** !#en
  10400. Real-name registration
  10401. Before to invoke, you need to verdict whether this properties existed
  10402. !#zh
  10403. 实名注册,调用前需要判断属性是否存在
  10404. */
  10405. realNameRegister() : void;
  10406. /** !#en
  10407. Anti-addiction query
  10408. Before to invoke, you need to verdict whether this properties existed
  10409. !#zh
  10410. 防沉迷查询,调用前需要判断属性是否存在
  10411. */
  10412. antiAddictionQuery() : void;
  10413. /** !#en
  10414. submit game role information
  10415. Before to invoke, you need to verdict whether this properties existed
  10416. !#zh
  10417. 提交角色信息,调用前需要判断属性是否存在
  10418. */
  10419. submitLoginGameRole(data : any) : void;
  10420. /** !#en
  10421. get user information
  10422. Before to invoke, you need to verdict whether this properties existed
  10423. !#zh
  10424. 获取用户信息,调用前需要判断属性是否存在
  10425. */
  10426. getUserInfo(info : any) : void;
  10427. /** !#en
  10428. set login type
  10429. Before to invoke, you need to verdict whether this properties existed
  10430. !#zh
  10431. 设置登录类型,调用前需要判断属性是否存在
  10432. */
  10433. getAvailableLoginType(info : any) : void;
  10434. /** !#en
  10435. set login type
  10436. Before to invoke, you need to verdict whether this properties existed
  10437. !#zh
  10438. 设置登录类型,调用前需要判断属性是否存在
  10439. */
  10440. setLoginType(loginType : string) : void;
  10441. /** !#en
  10442. send to desktop
  10443. Before to invoke, you need to verdict whether this properties existed
  10444. !#zh
  10445. 发送到桌面,调用前需要判断属性是否存在
  10446. */
  10447. sendToDesktop() : void;
  10448. /** !#en
  10449. open bbs
  10450. Before to invoke, you need to verdict whether this properties existed
  10451. !#zh
  10452. 打开论坛,调用前需要判断属性是否存在
  10453. */
  10454. openBBS() : void;
  10455. }
  10456. /** !#en
  10457. IAP protocol
  10458. !#zh
  10459. 支付系统协议接口 */
  10460. export class ProtocolIAP extends PluginProtocol {
  10461. /** !#en
  10462. pay interface
  10463. !#zh
  10464. 支付接口
  10465. @param info Type:map
  10466. */
  10467. payForProduct(info : any) : void;
  10468. /** !#en
  10469. get order ID
  10470. !#zh
  10471. 获取订单ID
  10472. */
  10473. getOrderId() : string;
  10474. /** !#en
  10475. reset the pay status
  10476. !#zh
  10477. 重置支付状态
  10478. */
  10479. resetPayState() : void;
  10480. /** !#en
  10481. get plugin ID
  10482. !#zh
  10483. 获取插件ID
  10484. */
  10485. getPluginId() : string;
  10486. /** !#en
  10487. set listener
  10488. !#zh
  10489. 设置支付系统的监听
  10490. */
  10491. setListener(listener : Function, target : any) : void;
  10492. /** !#en
  10493. get listener
  10494. !#zh
  10495. 获取支付系统的监听
  10496. */
  10497. getListener() : Function;
  10498. }
  10499. /** !#en
  10500. analytics protocol
  10501. !#zh
  10502. 统计系统协议接口 */
  10503. export class ProtocolAnalytics extends PluginProtocol {
  10504. /** !#en
  10505. Start a new session.
  10506. !#zh
  10507. 启动会话
  10508. */
  10509. startSession() : void;
  10510. /** !#en
  10511. Stop a session.
  10512. !#zh
  10513. 关闭会话
  10514. */
  10515. stopSession() : void;
  10516. /** !#en
  10517. Set the timeout for expiring a session.
  10518. !#zh
  10519. 设置会话超时时间
  10520. @param millis Type: long
  10521. */
  10522. setSessionContinueMillis(millis : number) : void;
  10523. /** !#en
  10524. log an error
  10525. !#zh
  10526. 捕捉异常
  10527. */
  10528. logError(errorId : string, message : string) : void;
  10529. /** !#en
  10530. log an event.
  10531. !#zh
  10532. 捕捉事件
  10533. @param args optional arguments Type: map
  10534. */
  10535. logEvent(errorId : string, args? : any) : void;
  10536. /** !#en
  10537. Track an event begin.
  10538. !#zh
  10539. 统计事件开始
  10540. */
  10541. logTimedEventBegin(eventId : string) : void;
  10542. /** !#en
  10543. Track an event end.
  10544. !#zh
  10545. 统计事件结束
  10546. */
  10547. logTimedEventEnd(eventId : string) : void;
  10548. /** !#en
  10549. set Whether to catch uncaught exceptions to server.
  10550. !#zh
  10551. 设置是否开启自动异常捕捉
  10552. */
  10553. setCaptureUncaughtException(enabled : boolean) : void;
  10554. /** !#en
  10555. analytics account information
  10556. !#zh
  10557. 统计玩家帐户信息
  10558. @param paramMap Type: map
  10559. */
  10560. setAccount(paramMap : any) : void;
  10561. /** !#en
  10562. track user to request payment
  10563. !#zh
  10564. 跟踪用户支付请求
  10565. @param paramMap Type: map
  10566. */
  10567. onChargeRequest(paramMap : any) : void;
  10568. /** !#en
  10569. track Successful payment
  10570. !#zh
  10571. 追踪用户支付成功
  10572. */
  10573. onChargeSuccess(orderID : string) : void;
  10574. /** !#en
  10575. track failed payment
  10576. !#zh
  10577. 追踪用户支付失败
  10578. @param paramMap Type: map
  10579. */
  10580. onChargeFail(paramMap : any) : void;
  10581. /** !#en
  10582. track Successful payment
  10583. !#zh
  10584. 统计玩家支付成功
  10585. @param paramMap Type: map
  10586. */
  10587. onChargeOnlySuccess(paramMap : any) : void;
  10588. /** !#en
  10589. track user purchase
  10590. !#zh
  10591. 统计玩家消费
  10592. @param paramMap Type: map
  10593. */
  10594. onPurchase(paramMap : any) : void;
  10595. /** !#en
  10596. track user to use goods
  10597. !#zh
  10598. 统计玩家使用道具
  10599. @param paramMap Type: map
  10600. */
  10601. onUse(paramMap : any) : void;
  10602. /** !#en
  10603. track user to reward goods
  10604. !#zh
  10605. 统计玩家获取奖励
  10606. @param paramMap Type: map
  10607. */
  10608. onReward(paramMap : any) : void;
  10609. /** !#en
  10610. start level
  10611. !#zh
  10612. 开始关卡
  10613. @param paramMap Type: map
  10614. */
  10615. startLevel(paramMap : any) : void;
  10616. /** !#en
  10617. finish level
  10618. !#zh
  10619. 结束关卡
  10620. */
  10621. finishLevel(levelID : string) : void;
  10622. /** !#en
  10623. failed level
  10624. !#zh
  10625. 关卡失败
  10626. @param paramMap Type: map
  10627. */
  10628. failLevel(paramMap : any) : void;
  10629. /** !#en
  10630. start task
  10631. !#zh
  10632. 开始任务
  10633. @param paramMap Type: map
  10634. */
  10635. startTask(paramMap : any) : void;
  10636. /** !#en
  10637. finish task
  10638. !#zh
  10639. 完成任务
  10640. */
  10641. finishTask(taskID : string) : void;
  10642. /** !#en
  10643. failed task
  10644. !#zh
  10645. 任务失败
  10646. @param paramMap Type: map
  10647. */
  10648. failTask(paramMap : any) : void;
  10649. }
  10650. /** !#en
  10651. share protocol
  10652. !#zh
  10653. 分享系统协议接口 */
  10654. export class ProtocolShare extends PluginProtocol {
  10655. /** !#en
  10656. share interface
  10657. !#zh
  10658. 分享
  10659. @param info Type: map
  10660. */
  10661. share(info : any) : void;
  10662. /** !#en
  10663. set listener
  10664. !#zh
  10665. 设置分享系统的监听
  10666. */
  10667. setListener(listener : Function, target : any) : void;
  10668. /** !#en
  10669. get listener
  10670. !#zh
  10671. 获取分享系统的监听
  10672. */
  10673. getListener() : Function;
  10674. }
  10675. /** !#en
  10676. ads protocol
  10677. !#zh
  10678. 广告系统协议接口 */
  10679. export class ProtocolAds extends PluginProtocol {
  10680. /** !#en
  10681. hide ads view
  10682. !#zh
  10683. 隐藏广告
  10684. */
  10685. hideAds(adstype : anysdk.AdsType, idx : number) : void;
  10686. /** !#en
  10687. preload ads view
  10688. !#zh
  10689. 预加载广告
  10690. */
  10691. preloadAds(adstype : anysdk.AdsType, idx : number) : void;
  10692. /** !#en
  10693. query points
  10694. !#zh
  10695. 查询分数
  10696. */
  10697. queryPoints() : number;
  10698. /** !#en
  10699. get whether the ads type is supported
  10700. !#zh
  10701. 获取广告类型是否支持
  10702. */
  10703. isAdTypeSupported(arg0 : anysdk.AdsType) : boolean;
  10704. /** !#en
  10705. spend point
  10706. !#zh
  10707. 消费分数
  10708. */
  10709. spendPoints(points : number) : void;
  10710. /** !#en
  10711. set listener
  10712. !#zh
  10713. 设置广告系统的监听
  10714. */
  10715. setListener(listener : Function, target : any) : void;
  10716. /** !#en
  10717. get listener
  10718. !#zh
  10719. 获取广告系统的监听
  10720. */
  10721. getListener() : Function;
  10722. }
  10723. /** !#en
  10724. social protocol
  10725. !#zh
  10726. 社交系统协议接口 */
  10727. export class ProtocolSocial extends PluginProtocol {
  10728. /** !#en
  10729. sign in
  10730. !#zh
  10731. 登录
  10732. */
  10733. signIn() : void;
  10734. /** !#en
  10735. sign out
  10736. !#zh
  10737. 登出
  10738. */
  10739. signOut() : void;
  10740. /** !#en
  10741. submit score
  10742. !#zh
  10743. 提交分数
  10744. @param score Type: long
  10745. */
  10746. submitScore(leadboardID : string, score : number) : void;
  10747. /** !#en
  10748. show the id of Leaderboard page
  10749. !#zh
  10750. 根据唯一标识符显示排行榜
  10751. */
  10752. showLeaderboard(leaderboardID : string) : void;
  10753. /** !#en
  10754. show the page of achievements
  10755. !#zh
  10756. 显示成就榜
  10757. */
  10758. showAchievements() : void;
  10759. /** !#en
  10760. unlock achievement
  10761. !#zh
  10762. 解锁成就
  10763. @param info Type: map
  10764. */
  10765. share(info : any) : void;
  10766. /** !#en
  10767. set listener
  10768. !#zh
  10769. 设置社交系统的监听
  10770. */
  10771. setListener(listener : Function, target : any) : void;
  10772. /** !#en
  10773. get listener
  10774. !#zh
  10775. 获取社交系统的监听
  10776. */
  10777. getListener() : Function;
  10778. /** !#en
  10779. get friends info
  10780. Before to invoke, you need to verdict whether this properties existed
  10781. !#zh
  10782. 获取好友信息,调用前需要判断属性是否存在
  10783. */
  10784. pauseRecording() : void;
  10785. /** !#en
  10786. interact
  10787. Before to invoke, you need to verdict whether this properties existed
  10788. !#zh
  10789. 订阅,调用前需要判断属性是否存在
  10790. */
  10791. interact() : void;
  10792. /** !#en
  10793. subscribe
  10794. Before to invoke, you need to verdict whether this properties existed
  10795. !#zh
  10796. 关注,调用前需要判断属性是否存在
  10797. */
  10798. subscribe() : void;
  10799. }
  10800. /** !#en
  10801. push protocol
  10802. !#zh
  10803. 推送系统协议接口 */
  10804. export class ProtocolPush extends PluginProtocol {
  10805. /** !#en
  10806. start Push services
  10807. !#zh
  10808. 启动推送服务
  10809. */
  10810. startPush() : void;
  10811. /** !#en
  10812. close Push services
  10813. !#zh
  10814. 暂停推送服务
  10815. */
  10816. closePush() : void;
  10817. /** !#en
  10818. delete alias
  10819. !#zh
  10820. 删除别名
  10821. */
  10822. delAlias(alias : string) : void;
  10823. /** !#en
  10824. set alias
  10825. !#zh
  10826. 设置别名
  10827. */
  10828. setAlias(alias : string) : void;
  10829. /** !#en
  10830. delete tags
  10831. !#zh
  10832. 删除标签
  10833. @param tags Type: list
  10834. */
  10835. delTags(tags : any) : void;
  10836. /** !#en
  10837. set tags
  10838. !#zh
  10839. 设置标签
  10840. @param tags Type: list
  10841. */
  10842. setTags(tags : any) : void;
  10843. /** !#en
  10844. set listener
  10845. !#zh
  10846. 设置推送系统的监听
  10847. */
  10848. setListener(listener : Function, target : any) : void;
  10849. /** !#en
  10850. get listener
  10851. !#zh
  10852. 获取推送系统的监听
  10853. */
  10854. getListener() : Function;
  10855. }
  10856. /** !#en
  10857. crash protocol
  10858. !#zh
  10859. 崩溃分析系统协议接口 */
  10860. export class ProtocolCrash extends PluginProtocol {
  10861. /** !#en
  10862. set user identifier
  10863. !#zh
  10864. 统计用户唯一标识符
  10865. */
  10866. setUserIdentifier(identifier : string) : void;
  10867. /** !#en
  10868. The uploader captured in exception information
  10869. !#zh
  10870. 上报异常信息
  10871. */
  10872. reportException(message : string, exception : string) : void;
  10873. /** !#en
  10874. customize logging
  10875. !#zh
  10876. 自定义日志记录
  10877. */
  10878. leaveBreadcrumb(breadcrumb : string) : void;
  10879. }
  10880. /** !#en
  10881. REC protocol
  10882. !#zh
  10883. 录屏系统协议接口 */
  10884. export class ProtocolREC extends PluginProtocol {
  10885. /** !#en
  10886. share video
  10887. !#zh
  10888. 分享视频
  10889. @param info Type: map
  10890. */
  10891. share(info : any) : void;
  10892. /** !#en
  10893. Start to record video
  10894. !#zh
  10895. 开始录制视频
  10896. */
  10897. startRecording() : void;
  10898. /** !#en
  10899. Start to record video
  10900. !#zh
  10901. 结束录制视频
  10902. */
  10903. stopRecording() : void;
  10904. /** !#en
  10905. set listener
  10906. !#zh
  10907. 设置录屏系统的监听
  10908. */
  10909. setListener(listener : Function, target : any) : void;
  10910. /** !#en
  10911. get listener
  10912. !#zh
  10913. 获取录屏系统的监听
  10914. */
  10915. getListener() : Function;
  10916. /** !#en
  10917. pause to record video
  10918. Before to invoke, you need to verdict whether this properties existed
  10919. !#zh
  10920. 暂停录制视频,调用前需要判断属性是否存在
  10921. */
  10922. pauseRecording() : void;
  10923. /** !#en
  10924. resume to record video
  10925. Before to invoke, you need to verdict whether this properties existed
  10926. !#zh
  10927. 恢复录制视频,调用前需要判断属性是否存在
  10928. */
  10929. resumeRecording() : void;
  10930. /** !#en
  10931. get whether the device is isAvailable
  10932. Before to invoke, you need to verdict whether this properties existed
  10933. !#zh
  10934. 获取设备是否可用,调用前需要判断属性是否存在
  10935. */
  10936. isAvailable() : boolean;
  10937. /** !#en
  10938. get status of recording
  10939. Before to invoke, you need to verdict whether this properties existed
  10940. !#zh
  10941. 获取录制状态,调用前需要判断属性是否存在
  10942. */
  10943. isRecording() : boolean;
  10944. /** !#en
  10945. show toolbar
  10946. Before to invoke, you need to verdict whether this properties existed
  10947. !#zh
  10948. 显示悬浮窗,调用前需要判断属性是否存在
  10949. */
  10950. showToolBar() : void;
  10951. /** !#en
  10952. hide toolbar
  10953. Before to invoke, you need to verdict whether this properties existed
  10954. !#zh
  10955. 隐藏悬浮窗,调用前需要判断属性是否存在
  10956. */
  10957. hideToolBar() : void;
  10958. /** !#en
  10959. show video center
  10960. Before to invoke, you need to verdict whether this properties existed
  10961. !#zh
  10962. 显示视频中心,调用前需要判断属性是否存在
  10963. */
  10964. showVideoCenter() : void;
  10965. /** !#en
  10966. enter platform
  10967. Before to invoke, you need to verdict whether this properties existed
  10968. !#zh
  10969. 显示平台中心,调用前需要判断属性是否存在
  10970. */
  10971. enterPlatform() : void;
  10972. /** !#en
  10973. Set the video data, it is recommended to check whether are recorded firstly
  10974. Before to invoke, you need to verdict whether this properties existed
  10975. !#zh
  10976. 设置视频相关数据,建议先检查是否是正在录制,调用前需要判断属性是否存在
  10977. @param info Type: map
  10978. */
  10979. setMetaData(info : any) : void;
  10980. }
  10981. /** !#en
  10982. ad tracking protocol
  10983. !#zh
  10984. 广告追踪系统协议接口 */
  10985. export class ProtocolAdTracking extends PluginProtocol {
  10986. /** !#en
  10987. Call this method if you want to track register events as happening during a section.
  10988. !#zh
  10989. 统计用户注册信息
  10990. @param productInfo Type: map
  10991. */
  10992. onPay(productInfo : any) : void;
  10993. /** !#en
  10994. Call this method if you want to track register events as happening during a section.
  10995. !#zh
  10996. 统计用户注册信息
  10997. @param userInfo Type: map
  10998. */
  10999. onLogin(userInfo : any) : void;
  11000. /** !#en
  11001. Call this method if you want to track register events as happening during a section.
  11002. !#zh
  11003. 统计用户注册信息
  11004. */
  11005. onRegister(userId : string) : void;
  11006. /** !#en
  11007. Call this method if you want to track custom events with parameters as happening during a section.
  11008. !#zh
  11009. 统计自定义事件
  11010. @param paramMap Type: map
  11011. */
  11012. trackEvent(eventId : string, paramMap : any) : void;
  11013. /** !#en
  11014. Call this method with parameters if you want to create role as happening during a section.
  11015. !#zh
  11016. 统计创建角色事件,调用前需要判断属性是否存在
  11017. @param userInfo Type: map
  11018. */
  11019. onCreateRole(userInfo : any) : void;
  11020. /** !#en
  11021. Call this method if you want to track levelup events with parameters as happening during a section.
  11022. Before to invoke, you need to verdict whether this properties existed
  11023. !#zh
  11024. 统计角色升级事件,调用前需要判断属性是否存在
  11025. @param info Type: map
  11026. */
  11027. onLevelUp(info : any) : void;
  11028. /** !#en
  11029. Invoke this method with parameters if you want to start to pay as happening during a section.
  11030. Before to invoke, you need to verdict whether this properties existed
  11031. !#zh
  11032. 统计开始充值事件,调用前需要判断属性是否存在
  11033. @param info Type: map
  11034. */
  11035. onStartToPay(info : any) : void;
  11036. }
  11037. /** !#en
  11038. custom protocol
  11039. !#zh
  11040. 自定义系统协议接口 */
  11041. export class ProtocolCustom extends PluginProtocol {
  11042. /** !#en
  11043. set listener
  11044. !#zh
  11045. 设置自定义系统的监听
  11046. */
  11047. setListener(listener : Function, target : any) : void;
  11048. /** !#en
  11049. get listener
  11050. !#zh
  11051. 获取自定义系统的监听
  11052. */
  11053. getListener() : Function;
  11054. }
  11055. /** !#en
  11056. Data structure class
  11057. !#zh
  11058. 数据结构类 */
  11059. export class PluginParam {
  11060. constructor();
  11061. /** !#en
  11062. create plugin parameters
  11063. !#zh
  11064. 创建对象
  11065. */
  11066. create(parameters : number|string|any) : anysdk.PluginParam;
  11067. }
  11068. /** !#en The callback of user system
  11069. !#zh 用户系统回调 */
  11070. export enum UserActionResultCode {
  11071. kInitSuccess = 0,
  11072. kInitFail = 0,
  11073. kLoginSuccess = 0,
  11074. kLoginNetworkError = 0,
  11075. kLoginNoNeed = 0,
  11076. kLoginFail = 0,
  11077. kLoginCancel = 0,
  11078. kLogoutSuccess = 0,
  11079. kLogoutFail = 0,
  11080. kPlatformEnter = 0,
  11081. kPlatformBack = 0,
  11082. kPausePage = 0,
  11083. kExitPage = 0,
  11084. kAntiAddictionQuery = 0,
  11085. kRealNameRegister = 0,
  11086. kAccountSwitchSuccess = 0,
  11087. kAccountSwitchFail = 0,
  11088. kOpenShop = 0,
  11089. kAccountSwitchCancel = 0,
  11090. kUserExtension = 0,
  11091. kSendToDesktopSuccess = 0,
  11092. kSendToDesktopFail = 0,
  11093. kGetAvailableLoginTypeSuccess = 0,
  11094. kGetAvailableLoginTypeFail = 0,
  11095. kGetUserInfoSuccess = 0,
  11096. kGetUserInfoFail = 0,
  11097. kOpenBBSSuccess = 0,
  11098. kOpenBBSFail = 0,
  11099. }
  11100. /** !#en The toolbar position of user type
  11101. !#zh 用户系统悬浮窗位置 */
  11102. export enum ToolBarPlace {
  11103. kToolBarTopLeft = 0,
  11104. kToolBarTopRight = 0,
  11105. kToolBarMidLeft = 0,
  11106. kToolBarMidRight = 0,
  11107. kToolBarBottomLeft = 0,
  11108. kToolBarBottomRight = 0,
  11109. }
  11110. /** !#en The callback of requesting reStringge
  11111. !#zh 支付系统支付请求回调 */
  11112. export enum PayResultCode {
  11113. kPaySuccess = 0,
  11114. kPayFail = 0,
  11115. kPayCancel = 0,
  11116. kPayNetworkError = 0,
  11117. kPayProductionInforIncomplete = 0,
  11118. kPayInitSuccess = 0,
  11119. kPayInitFail = 0,
  11120. kPayNowPaying = 0,
  11121. kPayReStringgeSuccess = 0,
  11122. kPayExtension = 0,
  11123. kPayNeedLoginAgain = 0,
  11124. kRequestSuccess = 0,
  11125. kRequestFail = 0,
  11126. }
  11127. /** !#en The enum of account type
  11128. !#zh 统计系统的账号类型 */
  11129. export enum AccountType {
  11130. ANONYMOUS = 0,
  11131. REGISTED = 0,
  11132. SINA_WEIBO = 0,
  11133. TENCENT_WEIBO = 0,
  11134. QQ = 0,
  11135. ND91 = 0,
  11136. }
  11137. /** !#en The enum of account operation
  11138. !#zh 统计系统的账号操作 */
  11139. export enum AccountOperate {
  11140. LOGIN = 0,
  11141. LOGOUT = 0,
  11142. REGISTER = 0,
  11143. }
  11144. /** !#en The enum of gender
  11145. !#zh 统计系统的账号性别 */
  11146. export enum AccountGender {
  11147. MALE = 0,
  11148. FEMALE = 0,
  11149. UNKNOWN = 0,
  11150. }
  11151. /** !#en The enum of task type
  11152. !#zh 统计系统的任务类型 */
  11153. export enum TaskType {
  11154. GUIDE_LINE = 0,
  11155. MAIN_LINE = 0,
  11156. BRANCH_LINE = 0,
  11157. DAILY = 0,
  11158. ACTIVITY = 0,
  11159. OTHER = 0,
  11160. }
  11161. /** !#en The callback of share system
  11162. !#zh 分享系统回调 */
  11163. export enum ShareResultCode {
  11164. kShareSuccess = 0,
  11165. kShareFail = 0,
  11166. kShareCancel = 0,
  11167. kShareNetworkError = 0,
  11168. kShareExtension = 0,
  11169. }
  11170. /** !#en The callback of social system
  11171. !#zh 社交系统回调 */
  11172. export enum SocialRetCode {
  11173. kScoreSubmitSucceed = 0,
  11174. kScoreSubmitfail = 0,
  11175. kAchUnlockSucceed = 0,
  11176. kAchUnlockFail = 0,
  11177. kSocialSignInSucceed = 0,
  11178. kSocialSignInFail = 0,
  11179. kSocialSignOutSucceed = 0,
  11180. kSocialSignOutFail = 0,
  11181. kSocialGetGameFriends = 0,
  11182. kSocialExtensionCode = 0,
  11183. kSocialGetFriendsInfoSuccess = 0,
  11184. kSocialGetFriendsInfoFail = 0,
  11185. kSocialAlreadySubscription = 0,
  11186. kSocialNoSubscription = 0,
  11187. kSocialSubscriptionFail = 0,
  11188. }
  11189. /** !#en The callback of ads system
  11190. !#zh 广告系统回调 */
  11191. export enum AdsResultCode {
  11192. kAdsReceived = 0,
  11193. kAdsShown = 0,
  11194. kAdsDismissed = 0,
  11195. kPointsSpendSucceed = 0,
  11196. kPointsSpendFailed = 0,
  11197. kNetworkError = 0,
  11198. kUnknownError = 0,
  11199. kOfferWallOnPointsChanged = 0,
  11200. kRewardedVideoWithReward = 0,
  11201. kInAppPurchaseFinished = 0,
  11202. kAdsClicked = 0,
  11203. kAdsExtension = 0,
  11204. }
  11205. /** !#en The enum of ads position
  11206. !#zh 广告位置 */
  11207. export enum AdsPos {
  11208. kPosCenter = 0,
  11209. kPosTop = 0,
  11210. kPosTopLeft = 0,
  11211. kPosTopRight = 0,
  11212. kPosBottom = 0,
  11213. kPosBottomLeft = 0,
  11214. kPosBottomRight = 0,
  11215. }
  11216. /** !#en The enum of ads type
  11217. !#zh 广告类型 */
  11218. export enum AdsType {
  11219. AD_TYPE_BANNER = 0,
  11220. AD_TYPE_FULLSCREEN = 0,
  11221. AD_TYPE_MOREAPP = 0,
  11222. AD_TYPE_OFFERWALL = 0,
  11223. AD_TYPE_REWARDEDVIDEOc = 0,
  11224. AD_TYPE_NATIVEEXPRESS = 0,
  11225. AD_TYPE_NATIVEADVANCED = 0,
  11226. }
  11227. /** !#en The callback of push system
  11228. !#zh 推送系统回调 */
  11229. export enum PushActionResultCode {
  11230. kPushReceiveMessage = 0,
  11231. kPushExtensionCode = 0,
  11232. }
  11233. /** !#en The callback of custom system
  11234. !#zh 自定义系统回调 */
  11235. export enum CustomResultCode {
  11236. kCustomExtension = 0,
  11237. }
  11238. /** !#en The callback of REC system
  11239. !#zh 录屏系统回调 */
  11240. export enum RECResultCode {
  11241. kRECInitSuccess = 0,
  11242. kRECInitFail = 0,
  11243. kRECStartRecording = 0,
  11244. kRECStopRecording = 0,
  11245. kRECPauseRecording = 0,
  11246. kRECResumeRecording = 0,
  11247. kRECEnterSDKPage = 0,
  11248. kRECQuitSDKPage = 0,
  11249. kRECShareSuccess = 0,
  11250. kRECShareFail = 0,
  11251. kRECExtension = 0,
  11252. }
  11253. }
  11254. /** !#en
  11255. The global main namespace of Spine, all classes, functions,
  11256. properties and constants of Spine are defined in this namespace
  11257. !#zh
  11258. Spine 的全局的命名空间,
  11259. 与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */
  11260. declare module sp {
  11261. /** !#en
  11262. The official spine runtime.<br/>
  11263. See http://en.esotericsoftware.com/spine-using-runtimes
  11264. !#zh
  11265. 官方 Spine Runtime。<br/>
  11266. 可查看 Spine 官方文档 http://en.esotericsoftware.com/spine-using-runtimes */
  11267. export var spine : any;
  11268. /** !#en
  11269. The skeleton of Spine <br/>
  11270. <br/>
  11271. (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance,
  11272. which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
  11273. Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.) <br/>
  11274. !#zh
  11275. Spine 骨骼动画 <br/>
  11276. <br/>
  11277. (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态,
  11278. 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。<br/>
  11279. 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */
  11280. export class Skeleton extends cc._RendererUnderSG {
  11281. constructor();
  11282. /** !#en The skeletal animation is paused?
  11283. !#zh 该骨骼动画是否暂停。 */
  11284. paused : boolean;
  11285. /** !#en
  11286. The skeleton data contains the skeleton information (bind pose bones, slots, draw order,
  11287. attachments, skins, etc) and animations but does not hold any state.<br/>
  11288. Multiple skeletons can share the same skeleton data.
  11289. !#zh
  11290. 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
  11291. attachments,皮肤等等)和动画但不持有任何状态。<br/>
  11292. 多个 Skeleton 可以共用相同的骨骼数据。 */
  11293. skeletonData : SkeletonData;
  11294. /** !#en The name of default skin.
  11295. !#zh 默认的皮肤名称。 */
  11296. defaultSkin : string;
  11297. /** !#en The name of default animation.
  11298. !#zh 默认的动画名称。 */
  11299. defaultAnimation : string;
  11300. /** !#en The name of current playing animation.
  11301. !#zh 当前播放的动画名称。 */
  11302. animation : string;
  11303. _defaultSkinIndex : number;
  11304. /** !#en TODO
  11305. !#zh 是否循环播放当前骨骼动画。 */
  11306. loop : boolean;
  11307. /** !#en The time scale of this skeleton.
  11308. !#zh 当前骨骼中所有动画的时间缩放率。 */
  11309. timeScale : number;
  11310. /** !#en Indicates whether open debug slots.
  11311. !#zh 是否显示 slot 的 debug 信息。 */
  11312. debugSlots : boolean;
  11313. /** !#en Indicates whether open debug bones.
  11314. !#zh 是否显示 bone 的 debug 信息。 */
  11315. debugBones : boolean;
  11316. /** !#en Computes the world SRT from the local SRT for each bone.
  11317. !#zh 重新更新所有骨骼的世界 Transform,
  11318. 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。
  11319. @example
  11320. ```js
  11321. var bone = spine.findBone('head');
  11322. cc.log(bone.worldX); // return 0;
  11323. spine.updateWorldTransform();
  11324. bone = spine.findBone('head');
  11325. cc.log(bone.worldX); // return -23.12;
  11326. ```
  11327. */
  11328. updateWorldTransform() : void;
  11329. /** !#en Sets the bones and slots to the setup pose.
  11330. !#zh 还原到起始动作
  11331. */
  11332. setToSetupPose() : void;
  11333. /** !#en
  11334. Sets the bones to the setup pose,
  11335. using the values from the `BoneData` list in the `SkeletonData`.
  11336. !#zh
  11337. 设置 bone 到起始动作
  11338. 使用 SkeletonData 中的 BoneData 列表中的值。
  11339. */
  11340. setBonesToSetupPose() : void;
  11341. /** !#en
  11342. Sets the slots to the setup pose,
  11343. using the values from the `SlotData` list in the `SkeletonData`.
  11344. !#zh
  11345. 设置 slot 到起始动作。
  11346. 使用 SkeletonData 中的 SlotData 列表中的值。
  11347. */
  11348. setSlotsToSetupPose() : void;
  11349. /** !#en
  11350. Finds a bone by name.
  11351. This does a string comparison for every bone.
  11352. !#zh
  11353. 通过名称查找 bone。
  11354. 这里对每个 bone 的名称进行了对比。
  11355. */
  11356. findBone(boneName : string) : spine.Bone;
  11357. /** !#en
  11358. Finds a slot by name.
  11359. This does a string comparison for every slot.
  11360. !#zh
  11361. 通过名称查找 slot。
  11362. 这里对每个 slot 的名称进行了比较。
  11363. */
  11364. findSlot(slotName : string) : spine.Slot;
  11365. /** !#en
  11366. Finds a skin by name and makes it the active skin.
  11367. This does a string comparison for every skin.
  11368. Note that setting the skin does not change which attachments are visible.
  11369. !#zh
  11370. 按名称查找皮肤,激活该皮肤。
  11371. 这里对每个皮肤的名称进行了比较。
  11372. 注意:设置皮肤不会改变 attachment 的可见性。。
  11373. */
  11374. setSkin(skinName : string) : spine.Skin;
  11375. /** !#en
  11376. Returns the attachment for the slot and attachment name.
  11377. The skeleton looks first in its skin, then in the skeleton data’s default skin.
  11378. !#zh
  11379. 通过 slot 和 attachment 的名称获取 attachment。
  11380. Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
  11381. */
  11382. getAttachment(slotName : string, attachmentName : string) : spine.RegionAttachment;
  11383. /** !#en
  11384. Sets the attachment for the slot and attachment name.
  11385. The skeleton looks first in its skin, then in the skeleton data’s default skin.
  11386. !#zh
  11387. 通过 slot 和 attachment 的名字来设置 attachment。
  11388. Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
  11389. */
  11390. setAttachment(slotName : string, attachmentName : string) : void;
  11391. /** !#en Sets skeleton data to sp.Skeleton.
  11392. !#zh 设置 Skeleton 中的 Skeleton Data。
  11393. */
  11394. setSkeletonData(skeletonData : spine.SkeletonData, ownsSkeletonData : spine.SkeletonData) : void;
  11395. /** !#en Sets animation state data.
  11396. !#zh 设置动画状态数据。
  11397. */
  11398. setAnimationStateData(stateData : spine.AnimationStateData) : void;
  11399. /** !#en
  11400. Mix applies all keyframe values,
  11401. interpolated for the specified time and mixed with the current values.
  11402. !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。
  11403. */
  11404. setMix(fromAnimation : string, toAnimation : string, duration : number) : void;
  11405. /** !#en Sets event listener.
  11406. !#zh 设置动画事件监听器。
  11407. */
  11408. setAnimationListener(target : any, callback : Function) : void;
  11409. /** !#en Set the current animation. Any queued animations are cleared.
  11410. !#zh 设置当前动画。队列中的任何的动画将被清除。
  11411. */
  11412. setAnimation(trackIndex : number, name : string, loop : boolean) : spine.TrackEntry;
  11413. /** !#en Adds an animation to be played delay seconds after the current or last queued animation.
  11414. !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。
  11415. */
  11416. addAnimation(trackIndex : number, name : string, loop : boolean, delay? : number) : spine.TrackEntry;
  11417. /** !#en Returns track entry by trackIndex.
  11418. !#zh 通过 track 索引获取 TrackEntry。
  11419. */
  11420. getCurrent(trackIndex : void) : spine.TrackEntry;
  11421. /** !#en Clears all tracks of animation state.
  11422. !#zh 清除所有 track 的动画状态。
  11423. */
  11424. clearTracks() : void;
  11425. /** !#en Clears track of animation state by trackIndex.
  11426. !#zh 清除出指定 track 的动画状态。
  11427. */
  11428. clearTrack(trackIndex : number) : void;
  11429. /** !#en Set the start event listener.
  11430. !#zh 用来设置开始播放动画的事件监听。
  11431. */
  11432. setStartListener(listener : Function) : void;
  11433. /** !#en Set the end event listener.
  11434. !#zh 用来设置动画播放完后的事件监听。
  11435. */
  11436. setEndListener(listener : Function) : void;
  11437. }
  11438. /** !#en The skeleton data of spine.
  11439. !#zh Spine 的 骨骼数据。 */
  11440. export class SkeletonData extends cc.Asset {
  11441. /** !#en See http://en.esotericsoftware.com/spine-json-format
  11442. !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */
  11443. skeletonJson : any;
  11444. atlasText : string;
  11445. textures : cc.Texture2D;
  11446. /** !#en
  11447. A scale can be specified on the JSON or binary loader which will scale the bone positions,
  11448. image sizes, and animation translations.
  11449. This can be useful when using different sized images than were used when designing the skeleton
  11450. in Spine. For example, if using images that are half the size than were used in Spine,
  11451. a scale of 0.5 can be used. This is commonly used for games that can run with either low or high
  11452. resolution texture atlases.
  11453. see http://en.esotericsoftware.com/spine-using-runtimes#Scaling
  11454. !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */
  11455. scale : number;
  11456. /** !#en Get the included SkeletonData used in spine runtime.
  11457. !#zh 获取 Spine Runtime 使用的 SkeletonData。
  11458. */
  11459. getRuntimeData(quiet? : boolean) : spine.SkeletonData;
  11460. }
  11461. /** !#en The event type of spine skeleton animation.
  11462. !#zh 骨骼动画事件类型。 */
  11463. export enum AnimationEventType {
  11464. START = 0,
  11465. END = 0,
  11466. COMPLETE = 0,
  11467. EVENT = 0,
  11468. }
  11469. }
  11470. /** This module provides some JavaScript utilities.
  11471. All members can be accessed with cc.js */
  11472. declare module js {
  11473. /** Check the obj whether is number or not
  11474. If a number is created by using 'new Number(10086)', the typeof it will be "object"...
  11475. Then you can use this function if you care about this case.
  11476. */
  11477. export function isNumber(obj : any) : boolean;
  11478. /** Check the obj whether is string or not.
  11479. If a string is created by using 'new String("blabla")', the typeof it will be "object"...
  11480. Then you can use this function if you care about this case.
  11481. */
  11482. export function isString(obj : any) : boolean;
  11483. /** This method is deprecated, use cc.js.mixin please.<br>
  11484. Copy all properties not defined in obj from arguments[1...n]
  11485. @param obj object to extend its properties
  11486. @param sourceObj source object to copy properties from
  11487. */
  11488. export function addon(obj : any, sourceObj : any) : any;
  11489. /** copy all properties from arguments[1...n] to obj
  11490. */
  11491. export function mixin(obj : any, sourceObj : any) : any;
  11492. /** Derive the class from the supplied base class.
  11493. Both classes are just native javascript constructors, not created by cc.Class, so
  11494. usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead.
  11495. @param base the baseclass to inherit
  11496. */
  11497. export function extend(cls : Function, base : Function) : Function;
  11498. /** Removes all enumerable properties from object
  11499. */
  11500. export function clear(obj : any) : void;
  11501. /** Get property descriptor in object and all its ancestors
  11502. */
  11503. export function getPropertyDescriptor(obj : any, name : string) : any;
  11504. /** Get class name of the object, if object is just a {} (and which class named 'Object'), it will return null.
  11505. (modified from <a href="http://stackoverflow.com/questions/1249531/how-to-get-a-javascript-objects-class">the code from this stackoverflow post</a>)
  11506. @param obj instance or constructor
  11507. */
  11508. export function getClassName(obj : any|Function) : string;
  11509. /** Register the class by specified name manually
  11510. */
  11511. export function setClassName(className : string, constructor : Function) : void;
  11512. /** Unregister a class from fireball.
  11513. If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore.
  11514. Please note that its still your responsibility to free other references to the class.
  11515. @param constructor the class you will want to unregister, any number of classes can be added
  11516. */
  11517. export function unregisterClass(constructor : Function) : void;
  11518. /** Get the registered class by name
  11519. */
  11520. export function getClassByName(classname : string) : Function;
  11521. /** Define get set accessor, just help to call Object.defineProperty(...)
  11522. */
  11523. export function getset(obj : any, prop : string, getter : Function, setter : Function, enumerable? : boolean) : void;
  11524. /** Define get accessor, just help to call Object.defineProperty(...)
  11525. */
  11526. export function get(obj : any, prop : string, getter : Function, enumerable? : boolean) : void;
  11527. /** Define set accessor, just help to call Object.defineProperty(...)
  11528. */
  11529. export function set(obj : any, prop : string, setter : Function, enumerable? : boolean) : void;
  11530. /** Defines a polyfill field for obsoleted codes.
  11531. @param obj YourObject or YourClass.prototype
  11532. @param obsoleted "OldParam" or "YourClass.OldParam"
  11533. @param newPropName "NewParam"
  11534. */
  11535. export function obsolete(obj : any, obsoleted : string, newPropName : string, writable? : boolean) : void;
  11536. /** Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props.
  11537. @param obj YourObject or YourClass.prototype
  11538. @param objName "YourObject" or "YourClass"
  11539. */
  11540. export function obsoletes(obj : any, objName : any, props : any, writable? : boolean) : void;
  11541. /** A string tool to construct a string with format string.
  11542. for example:
  11543. cc.js.formatStr("a: %s, b: %s", a, b);
  11544. cc.js.formatStr(a, b, c);
  11545. */
  11546. export function formatStr() : string;
  11547. /** undefined */
  11548. export class array {
  11549. /** Removes the first occurrence of a specific object from the array.
  11550. */
  11551. remove(array : any[], value : any) : boolean;
  11552. /** Removes the array item at the specified index.
  11553. */
  11554. removeAt(array : any[], index : number) : void;
  11555. /** Determines whether the array contains a specific value.
  11556. */
  11557. contains(array : any[], value : any) : boolean;
  11558. /** Verify array's Type
  11559. */
  11560. verifyType(array : any[], type : Function) : boolean;
  11561. /** Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed.
  11562. @param array Source Array
  11563. @param minusArr minus Array
  11564. */
  11565. removeArray(array : any[], minusArr : any[]) : void;
  11566. /** Inserts some objects at index
  11567. */
  11568. appendObjectsAt(array : any[], addObjs : any[], index : number) : any[];
  11569. /** Copy an array's item to a new array (its performance is better than Array.slice)
  11570. */
  11571. copy(array : any[]) : any[];
  11572. /** Exact same function as Array.prototype.indexOf.
  11573. HACK: ugliy hack for Baidu mobile browser compatibility,
  11574. stupid Baidu guys modify Array.prototype.indexOf for all pages loaded,
  11575. their version changes strict comparison to non-strict comparison,
  11576. it also ignores the second parameter of the original API,
  11577. and this will cause event handler enter infinite loop.
  11578. Baidu developers, if you ever see this documentation,
  11579. here is the standard: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
  11580. Seriously !
  11581. @param searchElement Element to locate in the array.
  11582. @param fromIndex The index to start the search at
  11583. */
  11584. indexOf(searchElement : any, fromIndex? : number) : number;
  11585. }
  11586. }