creator.d.ts 681 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613
  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. /** The current version of Cocos2d being used.<br/>
  7. Please DO NOT remove this String, it is an important flag for bug tracking.<br/>
  8. If you post a bug to forum, please attach this flag. */
  9. export var ENGINE_VERSION: string;
  10. /** The element contains the game canvas */
  11. export var container: HTMLDivElement;
  12. /**
  13. !#en Init Debug setting.
  14. !#zh 设置调试模式。
  15. @param mode mode
  16. */
  17. export function _initDebugSetting(mode: DebugMode): void;
  18. /**
  19. !#en
  20. Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).<br/>
  21. - In Cocos Creator, error is red.<br/>
  22. - In Chrome, error have a red icon along with red message text.<br/>
  23. !#zh
  24. 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。<br/>
  25. - 在 Cocos Creator 中,错误信息显示是红色的。<br/>
  26. - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。<br/>
  27. @param msg A JavaScript string containing zero or more substitution strings.
  28. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  29. */
  30. export function error(msg: any, ...subst: any[]): void;
  31. /**
  32. !#en
  33. Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime).
  34. - In Cocos Creator, warning is yellow.
  35. - In Chrome, warning have a yellow warning icon with the message text.
  36. !#zh
  37. 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。<br/>
  38. - 在 Cocos Creator 中,警告信息显示是黄色的。<br/>
  39. - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。<br/>
  40. @param msg A JavaScript string containing zero or more substitution strings.
  41. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  42. */
  43. export function warn(msg: any, ...subst: any[]): void;
  44. /**
  45. !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime).
  46. !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
  47. @param msg A JavaScript string containing zero or more substitution strings.
  48. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  49. */
  50. export function log(msg: string|any, ...subst: any[]): void;
  51. /**
  52. !#en
  53. Outputs an informational message to the Cocos Creator Console (editor) or Web Console (runtime).
  54. - In Cocos Creator, info is blue.
  55. - In Firefox and Chrome, a small "i" icon is displayed next to these items in the Web Console's log.
  56. !#zh
  57. 输出一条信息消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
  58. - 在 Cocos Creator 中,Info 信息显示是蓝色的。<br/>
  59. - 在 Firefox 和 Chrome 中,Info 信息有着小 “i” 图标。
  60. @param msg A JavaScript string containing zero or more substitution strings.
  61. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  62. */
  63. export function info(msg: any, ...subst: any[]): void;
  64. /**
  65. !#en
  66. Creates the speed action which changes the speed of an action, making it take longer (speed > 1)
  67. or less (speed < 1) time. <br/>
  68. Useful to simulate 'slow motion' or 'fast forward' effect.
  69. !#zh 修改目标动作的速率。
  70. @param action action
  71. @param speed speed
  72. @example
  73. ```js
  74. // change the target action speed;
  75. var action = cc.scaleTo(0.2, 1, 0.6);
  76. var newAction = cc.speed(action, 0.5);
  77. ```
  78. */
  79. export function speed(action: ActionInterval, speed: number): Action;
  80. /**
  81. !#en Create a follow action which makes its target follows another node.
  82. !#zh 追踪目标节点的位置。
  83. @param followedNode followedNode
  84. @param rect rect
  85. @example
  86. ```js
  87. // example
  88. // creates the action with a set boundary
  89. var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight));
  90. node.runAction(followAction);
  91. // creates the action with no boundary set
  92. var followAction = cc.follow(targetNode);
  93. node.runAction(followAction);
  94. ```
  95. */
  96. export function follow(followedNode: Node, rect: Rect): Action;
  97. /**
  98. Points setter
  99. @param points points
  100. */
  101. export function setPoints(points: any[]): void;
  102. /**
  103. !#en Creates an action with a Cardinal Spline array of points and tension.
  104. !#zh 按基数样条曲线轨迹移动到目标位置。
  105. @param duration duration
  106. @param points array of control points
  107. @param tension tension
  108. @example
  109. ```js
  110. //create a cc.CardinalSplineTo
  111. var action1 = cc.cardinalSplineTo(3, array, 0);
  112. ```
  113. */
  114. export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval;
  115. /**
  116. update position of target
  117. @param newPos newPos
  118. */
  119. export function updatePosition(newPos: Vec2): void;
  120. /**
  121. !#en Creates an action with a Cardinal Spline array of points and tension.
  122. !#zh 按基数样条曲线轨迹移动指定的距离。
  123. @param duration duration
  124. @param points points
  125. @param tension tension
  126. */
  127. export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval;
  128. /**
  129. !#en Creates an action with a Cardinal Spline array of points and tension.
  130. !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。
  131. @param dt dt
  132. @param points points
  133. @example
  134. ```js
  135. var action1 = cc.catmullRomTo(3, array);
  136. ```
  137. */
  138. export function catmullRomTo(dt: number, points: any[]): ActionInterval;
  139. /**
  140. !#en Creates an action with a Cardinal Spline array of points and tension.
  141. !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。
  142. @param dt dt
  143. @param points points
  144. @example
  145. ```js
  146. var action1 = cc.catmullRomBy(3, array);
  147. ```
  148. */
  149. export function catmullRomBy(dt: number, points: any[]): ActionInterval;
  150. /**
  151. !#en
  152. Creates the action easing object with the rate parameter. <br />
  153. From slow to fast.
  154. !#zh 创建 easeIn 缓动对象,由慢到快。
  155. @param rate rate
  156. @example
  157. ```js
  158. action.easing(cc.easeIn(3.0));
  159. ```
  160. */
  161. export function easeIn(rate: number): any;
  162. /**
  163. !#en
  164. Creates the action easing object with the rate parameter. <br />
  165. From fast to slow.
  166. !#zh 创建 easeOut 缓动对象,由快到慢。
  167. @param rate rate
  168. @example
  169. ```js
  170. action.easing(cc.easeOut(3.0));
  171. ```
  172. */
  173. export function easeOut(rate: number): any;
  174. /**
  175. !#en
  176. Creates the action easing object with the rate parameter. <br />
  177. Slow to fast then to slow.
  178. !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。
  179. @param rate rate
  180. @example
  181. ```js
  182. action.easing(cc.easeInOut(3.0));
  183. ```
  184. */
  185. export function easeInOut(rate: number): any;
  186. /**
  187. !#en
  188. Creates the action easing object with the rate parameter. <br />
  189. Reference easeInExpo: <br />
  190. http://www.zhihu.com/question/21981571/answer/19925418
  191. !#zh
  192. 创建 easeExponentialIn 缓动对象。<br />
  193. EaseExponentialIn 是按指数函数缓动进入的动作。<br />
  194. 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418
  195. @example
  196. ```js
  197. action.easing(cc.easeExponentialIn());
  198. ```
  199. */
  200. export function easeExponentialIn(): any;
  201. /**
  202. !#en
  203. Creates the action easing object. <br />
  204. Reference easeOutExpo: <br />
  205. http://www.zhihu.com/question/21981571/answer/19925418
  206. !#zh
  207. 创建 easeExponentialOut 缓动对象。<br />
  208. EaseExponentialOut 是按指数函数缓动退出的动作。<br />
  209. 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
  210. @example
  211. ```js
  212. action.easing(cc.easeExponentialOut());
  213. ```
  214. */
  215. export function easeExponentialOut(): any;
  216. /**
  217. !#en
  218. Creates an EaseExponentialInOut action easing object. <br />
  219. Reference easeInOutExpo: <br />
  220. http://www.zhihu.com/question/21981571/answer/19925418
  221. !#zh
  222. 创建 easeExponentialInOut 缓动对象。<br />
  223. EaseExponentialInOut 是按指数函数缓动进入并退出的动作。<br />
  224. 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
  225. @example
  226. ```js
  227. action.easing(cc.easeExponentialInOut());
  228. ```
  229. */
  230. export function easeExponentialInOut(): any;
  231. /**
  232. !#en
  233. Creates an EaseSineIn action. <br />
  234. Reference easeInSine: <br />
  235. http://www.zhihu.com/question/21981571/answer/19925418
  236. !#zh
  237. 创建 EaseSineIn 缓动对象。<br />
  238. EaseSineIn 是按正弦函数缓动进入的动作。<br />
  239. 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418
  240. @example
  241. ```js
  242. action.easing(cc.easeSineIn());
  243. ```
  244. */
  245. export function easeSineIn(): any;
  246. /**
  247. !#en
  248. Creates an EaseSineOut action easing object. <br />
  249. Reference easeOutSine: <br />
  250. http://www.zhihu.com/question/21981571/answer/19925418
  251. !#zh
  252. 创建 EaseSineOut 缓动对象。<br />
  253. EaseSineIn 是按正弦函数缓动退出的动作。<br />
  254. 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418
  255. @example
  256. ```js
  257. action.easing(cc.easeSineOut());
  258. ```
  259. */
  260. export function easeSineOut(): any;
  261. /**
  262. !#en
  263. Creates the action easing object. <br />
  264. Reference easeInOutSine: <br />
  265. http://www.zhihu.com/question/21981571/answer/19925418
  266. !#zh
  267. 创建 easeSineInOut 缓动对象。<br />
  268. EaseSineIn 是按正弦函数缓动进入并退出的动作。<br />
  269. 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418
  270. @example
  271. ```js
  272. action.easing(cc.easeSineInOut());
  273. ```
  274. */
  275. export function easeSineInOut(): any;
  276. /**
  277. !#en
  278. Creates the action easing obejct with the period in radians (default is 0.3). <br />
  279. Reference easeInElastic: <br />
  280. http://www.zhihu.com/question/21981571/answer/19925418
  281. !#zh
  282. 创建 easeElasticIn 缓动对象。<br />
  283. EaseElasticIn 是按弹性曲线缓动进入的动作。<br />
  284. 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418
  285. @param period period
  286. @example
  287. ```js
  288. // example
  289. action.easing(cc.easeElasticIn(3.0));
  290. ```
  291. */
  292. export function easeElasticIn(period: number): any;
  293. /**
  294. !#en
  295. Creates the action easing object with the period in radians (default is 0.3). <br />
  296. Reference easeOutElastic: <br />
  297. http://www.zhihu.com/question/21981571/answer/19925418
  298. !#zh
  299. 创建 easeElasticOut 缓动对象。<br />
  300. EaseElasticOut 是按弹性曲线缓动退出的动作。<br />
  301. 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
  302. @param period period
  303. @example
  304. ```js
  305. // example
  306. action.easing(cc.easeElasticOut(3.0));
  307. ```
  308. */
  309. export function easeElasticOut(period: number): any;
  310. /**
  311. !#en
  312. Creates the action easing object with the period in radians (default is 0.3). <br />
  313. Reference easeInOutElastic: <br />
  314. http://www.zhihu.com/question/21981571/answer/19925418
  315. !#zh
  316. 创建 easeElasticInOut 缓动对象。<br />
  317. EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。<br />
  318. 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
  319. @param period period
  320. @example
  321. ```js
  322. // example
  323. action.easing(cc.easeElasticInOut(3.0));
  324. ```
  325. */
  326. export function easeElasticInOut(period: number): any;
  327. /**
  328. !#en
  329. Creates the action easing object. <br />
  330. Eased bounce effect at the beginning.
  331. !#zh
  332. 创建 easeBounceIn 缓动对象。<br />
  333. EaseBounceIn 是按弹跳动作缓动进入的动作。
  334. @example
  335. ```js
  336. // example
  337. action.easing(cc.easeBounceIn());
  338. ```
  339. */
  340. export function easeBounceIn(): any;
  341. /**
  342. !#en
  343. Creates the action easing object. <br />
  344. Eased bounce effect at the ending.
  345. !#zh
  346. 创建 easeBounceOut 缓动对象。<br />
  347. EaseBounceOut 是按弹跳动作缓动退出的动作。
  348. @example
  349. ```js
  350. // example
  351. action.easing(cc.easeBounceOut());
  352. ```
  353. */
  354. export function easeBounceOut(): any;
  355. /**
  356. !#en
  357. Creates the action easing object. <br />
  358. Eased bounce effect at the begining and ending.
  359. !#zh
  360. 创建 easeBounceInOut 缓动对象。<br />
  361. EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。
  362. @example
  363. ```js
  364. // example
  365. action.easing(cc.easeBounceInOut());
  366. ```
  367. */
  368. export function easeBounceInOut(): any;
  369. /**
  370. !#en
  371. Creates the action easing object. <br />
  372. In the opposite direction to move slowly, and then accelerated to the right direction.
  373. !#zh
  374. 创建 easeBackIn 缓动对象。<br />
  375. easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。<br />
  376. @example
  377. ```js
  378. // example
  379. action.easing(cc.easeBackIn());
  380. ```
  381. */
  382. export function easeBackIn(): any;
  383. /**
  384. !#en
  385. Creates the action easing object. <br />
  386. Fast moving more than the finish, and then slowly back to the finish.
  387. !#zh
  388. 创建 easeBackOut 缓动对象。<br />
  389. easeBackOut 快速移动超出目标,然后慢慢回到目标点。
  390. @example
  391. ```js
  392. // example
  393. action.easing(cc.easeBackOut());
  394. ```
  395. */
  396. export function easeBackOut(): any;
  397. /**
  398. !#en
  399. Creates the action easing object. <br />
  400. Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.
  401. !#zh
  402. 创建 easeBackInOut 缓动对象。<br />
  403. @example
  404. ```js
  405. // example
  406. action.easing(cc.easeBackInOut());
  407. ```
  408. */
  409. export function easeBackInOut(): any;
  410. /**
  411. !#en
  412. Creates the action easing object. <br />
  413. Into the 4 reference point. <br />
  414. To calculate the motion curve.
  415. !#zh
  416. 创建 easeBezierAction 缓动对象。<br />
  417. EaseBezierAction 是按贝塞尔曲线缓动的动作。
  418. @param p0 The first bezier parameter
  419. @param p1 The second bezier parameter
  420. @param p2 The third bezier parameter
  421. @param p3 The fourth bezier parameter
  422. @example
  423. ```js
  424. // example
  425. action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
  426. ```
  427. */
  428. export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any;
  429. /**
  430. !#en
  431. Creates the action easing object. <br />
  432. Reference easeInQuad: <br />
  433. http://www.zhihu.com/question/21981571/answer/19925418
  434. !#zh
  435. 创建 easeQuadraticActionIn 缓动对象。<br />
  436. EaseQuadraticIn是按二次函数缓动进入的动作。<br />
  437. 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418
  438. @example
  439. ```js
  440. //example
  441. action.easing(cc.easeQuadraticActionIn());
  442. ```
  443. */
  444. export function easeQuadraticActionIn(): any;
  445. /**
  446. !#en
  447. Creates the action easing object. <br />
  448. Reference easeOutQuad: <br />
  449. http://www.zhihu.com/question/21981571/answer/19925418
  450. !#zh
  451. 创建 easeQuadraticActionOut 缓动对象。<br />
  452. EaseQuadraticOut 是按二次函数缓动退出的动作。<br />
  453. 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
  454. @example
  455. ```js
  456. //example
  457. action.easing(cc.easeQuadraticActionOut());
  458. ```
  459. */
  460. export function easeQuadraticActionOut(): any;
  461. /**
  462. !#en
  463. Creates the action easing object. <br />
  464. Reference easeInOutQuad: <br />
  465. http://www.zhihu.com/question/21981571/answer/19925418
  466. !#zh
  467. 创建 easeQuadraticActionInOut 缓动对象。<br />
  468. EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。<br />
  469. 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
  470. @example
  471. ```js
  472. //example
  473. action.easing(cc.easeQuadraticActionInOut());
  474. ```
  475. */
  476. export function easeQuadraticActionInOut(): any;
  477. /**
  478. !#en
  479. Creates the action easing object. <br />
  480. Reference easeIntQuart: <br />
  481. http://www.zhihu.com/question/21981571/answer/19925418
  482. !#zh
  483. 创建 easeQuarticActionIn 缓动对象。<br />
  484. EaseQuarticIn 是按四次函数缓动进入的动作。<br />
  485. 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418
  486. @example
  487. ```js
  488. //example
  489. action.easing(cc.easeQuarticActionIn());
  490. ```
  491. */
  492. export function easeQuarticActionIn(): any;
  493. /**
  494. !#en
  495. Creates the action easing object. <br />
  496. Reference easeOutQuart: <br />
  497. http://www.zhihu.com/question/21981571/answer/19925418
  498. !#zh
  499. 创建 easeQuarticActionOut 缓动对象。<br />
  500. EaseQuarticOut 是按四次函数缓动退出的动作。<br />
  501. 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
  502. @example
  503. ```js
  504. //example
  505. action.easing(cc.QuarticActionOut());
  506. ```
  507. */
  508. export function easeQuarticActionOut(): any;
  509. /**
  510. !#en
  511. Creates the action easing object. <br />
  512. Reference easeInOutQuart: <br />
  513. http://www.zhihu.com/question/21981571/answer/19925418
  514. !#zh
  515. 创建 easeQuarticActionInOut 缓动对象。<br />
  516. EaseQuarticInOut 是按四次函数缓动进入并退出的动作。<br />
  517. 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
  518. */
  519. export function easeQuarticActionInOut(): any;
  520. /**
  521. !#en
  522. Creates the action easing object. <br />
  523. Reference easeInQuint: <br />
  524. http://www.zhihu.com/question/21981571/answer/19925418
  525. !#zh
  526. 创建 easeQuinticActionIn 缓动对象。<br />
  527. EaseQuinticIn 是按五次函数缓动进的动作。<br />
  528. 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418
  529. @example
  530. ```js
  531. //example
  532. action.easing(cc.easeQuinticActionIn());
  533. ```
  534. */
  535. export function easeQuinticActionIn(): any;
  536. /**
  537. !#en
  538. Creates the action easing object. <br />
  539. Reference easeOutQuint: <br />
  540. http://www.zhihu.com/question/21981571/answer/19925418
  541. !#zh
  542. 创建 easeQuinticActionOut 缓动对象。<br />
  543. EaseQuinticOut 是按五次函数缓动退出的动作
  544. 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
  545. @example
  546. ```js
  547. //example
  548. action.easing(cc.easeQuadraticActionOut());
  549. ```
  550. */
  551. export function easeQuinticActionOut(): any;
  552. /**
  553. !#en
  554. Creates the action easing object. <br />
  555. Reference easeInOutQuint: <br />
  556. http://www.zhihu.com/question/21981571/answer/19925418
  557. !#zh
  558. 创建 easeQuinticActionInOut 缓动对象。<br />
  559. EaseQuinticInOut是按五次函数缓动进入并退出的动作。<br />
  560. 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
  561. @example
  562. ```js
  563. //example
  564. action.easing(cc.easeQuinticActionInOut());
  565. ```
  566. */
  567. export function easeQuinticActionInOut(): any;
  568. /**
  569. !#en
  570. Creates the action easing object. <br />
  571. Reference easeInCirc: <br />
  572. http://www.zhihu.com/question/21981571/answer/19925418
  573. !#zh
  574. 创建 easeCircleActionIn 缓动对象。<br />
  575. EaseCircleIn是按圆形曲线缓动进入的动作。<br />
  576. 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418
  577. @example
  578. ```js
  579. //example
  580. action.easing(cc.easeCircleActionIn());
  581. ```
  582. */
  583. export function easeCircleActionIn(): any;
  584. /**
  585. !#en
  586. Creates the action easing object. <br />
  587. Reference easeOutCirc: <br />
  588. http://www.zhihu.com/question/21981571/answer/19925418
  589. !#zh
  590. 创建 easeCircleActionOut 缓动对象。<br />
  591. EaseCircleOut是按圆形曲线缓动退出的动作。<br />
  592. 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
  593. */
  594. export function easeCircleActionOut(): any;
  595. /**
  596. !#en
  597. Creates the action easing object. <br />
  598. Reference easeInOutCirc: <br />
  599. http://www.zhihu.com/question/21981571/answer/19925418
  600. !#zh
  601. 创建 easeCircleActionInOut 缓动对象。<br />
  602. EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。<br />
  603. 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
  604. @example
  605. ```js
  606. //example
  607. action.easing(cc.easeCircleActionInOut());
  608. ```
  609. */
  610. export function easeCircleActionInOut(): any;
  611. /**
  612. !#en
  613. Creates the action easing object. <br />
  614. Reference easeInCubic: <br />
  615. http://www.zhihu.com/question/21981571/answer/19925418
  616. !#zh
  617. 创建 easeCubicActionIn 缓动对象。<br />
  618. EaseCubicIn 是按三次函数缓动进入的动作。<br />
  619. 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418
  620. @example
  621. ```js
  622. //example
  623. action.easing(cc.easeCubicActionIn());
  624. ```
  625. */
  626. export function easeCubicActionIn(): any;
  627. /**
  628. !#en
  629. Creates the action easing object. <br />
  630. Reference easeOutCubic: <br />
  631. http://www.zhihu.com/question/21981571/answer/19925418
  632. !#zh
  633. 创建 easeCubicActionOut 缓动对象。<br />
  634. EaseCubicOut 是按三次函数缓动退出的动作。<br />
  635. 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
  636. @example
  637. ```js
  638. //example
  639. action.easing(cc.easeCubicActionOut());
  640. ```
  641. */
  642. export function easeCubicActionOut(): any;
  643. /**
  644. !#en
  645. Creates the action easing object. <br />
  646. Reference easeInOutCubic: <br />
  647. http://www.zhihu.com/question/21981571/answer/19925418
  648. !#zh
  649. 创建 easeCubicActionInOut 缓动对象。<br />
  650. EaseCubicInOut是按三次函数缓动进入并退出的动作。<br />
  651. 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
  652. */
  653. export function easeCubicActionInOut(): any;
  654. /**
  655. !#en Show the Node.
  656. !#zh 立即显示。
  657. @example
  658. ```js
  659. // example
  660. var showAction = cc.show();
  661. ```
  662. */
  663. export function show(): ActionInstant;
  664. /**
  665. !#en Hide the node.
  666. !#zh 立即隐藏。
  667. @example
  668. ```js
  669. // example
  670. var hideAction = cc.hide();
  671. ```
  672. */
  673. export function hide(): ActionInstant;
  674. /**
  675. !#en Toggles the visibility of a node.
  676. !#zh 显隐状态切换。
  677. @example
  678. ```js
  679. // example
  680. var toggleVisibilityAction = cc.toggleVisibility();
  681. ```
  682. */
  683. export function toggleVisibility(): ActionInstant;
  684. /**
  685. !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.
  686. !#zh 从父节点移除自身。
  687. @param isNeedCleanUp isNeedCleanUp
  688. @example
  689. ```js
  690. // example
  691. var removeSelfAction = cc.removeSelf();
  692. ```
  693. */
  694. export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant;
  695. /**
  696. !#en Create a FlipX action to flip or unflip the target.
  697. !#zh X轴翻转。
  698. @param flip Indicate whether the target should be flipped or not
  699. @example
  700. ```js
  701. var flipXAction = cc.flipX(true);
  702. ```
  703. */
  704. export function flipX(flip: boolean): ActionInstant;
  705. /**
  706. !#en Create a FlipY action to flip or unflip the target.
  707. !#zh Y轴翻转。
  708. @param flip flip
  709. @example
  710. ```js
  711. var flipYAction = cc.flipY(true);
  712. ```
  713. */
  714. export function flipY(flip: boolean): ActionInstant;
  715. /**
  716. !#en Creates a Place action with a position.
  717. !#zh 放置在目标位置。
  718. @param pos pos
  719. @param y y
  720. @example
  721. ```js
  722. // example
  723. var placeAction = cc.place(cc.p(200, 200));
  724. var placeAction = cc.place(200, 200);
  725. ```
  726. */
  727. export function place(pos: Vec2|number, y?: number): ActionInstant;
  728. /**
  729. !#en Creates the action with the callback.
  730. !#zh 执行回调函数。
  731. @param selector selector
  732. @param selectorTarget selectorTarget
  733. @param data data for function, it accepts all data types.
  734. @example
  735. ```js
  736. // example
  737. // CallFunc without data
  738. var finish = cc.callFunc(this.removeSprite, this);
  739. // CallFunc with data
  740. var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true);
  741. ```
  742. */
  743. export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant;
  744. /**
  745. !#en
  746. Helper constructor to create an array of sequenceable actions
  747. The created action will run actions sequentially, one after another.
  748. !#zh 顺序执行动作,创建的动作将按顺序依次运行。
  749. @param actionOrActionArray actionOrActionArray
  750. @param tempArray tempArray
  751. @example
  752. ```js
  753. // example
  754. // create sequence with actions
  755. var seq = cc.sequence(act1, act2);
  756. // create sequence with array
  757. var seq = cc.sequence(actArray);
  758. ```
  759. */
  760. export function sequence(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval;
  761. /**
  762. !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30)
  763. !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。
  764. @param action action
  765. @param times times
  766. @example
  767. ```js
  768. // example
  769. var rep = cc.repeat(cc.sequence(jump2, jump1), 5);
  770. ```
  771. */
  772. export function repeat(action: FiniteTimeAction, times: number): ActionInterval;
  773. /**
  774. !#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn.
  775. !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。
  776. @param action action
  777. @example
  778. ```js
  779. // example
  780. var repeat = cc.repeatForever(cc.rotateBy(1.0, 360));
  781. ```
  782. */
  783. export function repeatForever(action: FiniteTimeAction): ActionInterval;
  784. /**
  785. !#en Create a spawn action which runs several actions in parallel.
  786. !#zh 同步执行动作,同步执行一组动作。
  787. @param actionOrActionArray actionOrActionArray
  788. @param tempArray tempArray
  789. @example
  790. ```js
  791. // example
  792. var action = cc.spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720));
  793. todo:It should be the direct use new
  794. ```
  795. */
  796. export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction;
  797. /**
  798. !#en
  799. Rotates a Node object to a certain angle by modifying its rotation property. <br/>
  800. The direction will be decided by the shortest angle.
  801. !#zh 旋转到目标角度,通过逐帧修改它的 rotation 属性,旋转方向将由最短的角度决定。
  802. @param duration duration in seconds
  803. @param deltaAngleX deltaAngleX in degrees.
  804. @param deltaAngleY deltaAngleY in degrees.
  805. @example
  806. ```js
  807. // example
  808. var rotateTo = cc.rotateTo(2, 61.0);
  809. ```
  810. */
  811. export function rotateTo(duration: number, deltaAngleX: number, deltaAngleY?: number): ActionInterval;
  812. /**
  813. !#en
  814. Rotates a Node object clockwise a number of degrees by modifying its rotation property.
  815. Relative to its properties to modify.
  816. !#zh 旋转指定的角度。
  817. @param duration duration in seconds
  818. @param deltaAngleX deltaAngleX in degrees
  819. @param deltaAngleY deltaAngleY in degrees
  820. @example
  821. ```js
  822. // example
  823. var actionBy = cc.rotateBy(2, 360);
  824. ```
  825. */
  826. export function rotateBy(duration: number, deltaAngleX: number, deltaAngleY?: number): ActionInterval;
  827. /**
  828. !#en
  829. Moves a Node object x,y pixels by modifying its position property. <br/>
  830. x and y are relative to the position of the object. <br/>
  831. Several MoveBy actions can be concurrently called, and the resulting <br/>
  832. movement will be the sum of individual movements.
  833. !#zh 移动指定的距离。
  834. @param duration duration in seconds
  835. @param deltaPos deltaPos
  836. @param deltaY deltaY
  837. @example
  838. ```js
  839. // example
  840. var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40));
  841. ```
  842. */
  843. export function moveBy(duration: number, deltaPos: Vec2|number, deltaY?: number): ActionInterval;
  844. /**
  845. !#en
  846. Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property. <br/>
  847. Several MoveTo actions can be concurrently called, and the resulting <br/>
  848. movement will be the sum of individual movements.
  849. !#zh 移动到目标位置。
  850. @param duration duration in seconds
  851. @param position position
  852. @param y y
  853. @example
  854. ```js
  855. // example
  856. var actionBy = cc.moveTo(2, cc.p(80, 80));
  857. ```
  858. */
  859. export function moveTo(duration: number, position: Vec2|number, y?: number): ActionInterval;
  860. /**
  861. !#en
  862. Create a action which skews a Node object to given angles by modifying its skewX and skewY properties.
  863. Changes to the specified value.
  864. !#zh 偏斜到目标角度。
  865. @param t time in seconds
  866. @param sx sx
  867. @param sy sy
  868. @example
  869. ```js
  870. // example
  871. var actionTo = cc.skewTo(2, 37.2, -37.2);
  872. ```
  873. */
  874. export function skewTo(t: number, sx: number, sy: number): ActionInterval;
  875. /**
  876. !#en
  877. Skews a Node object by skewX and skewY degrees. <br />
  878. Relative to its property modification.
  879. !#zh 偏斜指定的角度。
  880. @param t time in seconds
  881. @param sx sx skew in degrees for X axis
  882. @param sy sy skew in degrees for Y axis
  883. @example
  884. ```js
  885. // example
  886. var actionBy = cc.skewBy(2, 0, -90);
  887. ```
  888. */
  889. export function skewBy(t: number, sx: number, sy: number): ActionInterval;
  890. /**
  891. !#en
  892. Moves a Node object simulating a parabolic jump movement by modifying it's position property.
  893. Relative to its movement.
  894. !#zh 用跳跃的方式移动指定的距离。
  895. @param duration duration
  896. @param position position
  897. @param y y
  898. @param height height
  899. @param jumps jumps
  900. @example
  901. ```js
  902. // example
  903. var actionBy = cc.jumpBy(2, cc.p(300, 0), 50, 4);
  904. var actionBy = cc.jumpBy(2, 300, 0, 50, 4);
  905. ```
  906. */
  907. export function jumpBy(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval;
  908. /**
  909. !#en
  910. Moves a Node object to a parabolic position simulating a jump movement by modifying its position property. <br />
  911. Jump to the specified location.
  912. !#zh 用跳跃的方式移动到目标位置。
  913. @param duration duration
  914. @param position position
  915. @param y y
  916. @param height height
  917. @param jumps jumps
  918. @example
  919. ```js
  920. // example
  921. var actionTo = cc.jumpTo(2, cc.p(300, 300), 50, 4);
  922. var actionTo = cc.jumpTo(2, 300, 300, 50, 4);
  923. ```
  924. */
  925. export function jumpTo(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval;
  926. /**
  927. !#en
  928. An action that moves the target with a cubic Bezier curve by a certain distance.
  929. Relative to its movement.
  930. !#zh 按贝赛尔曲线轨迹移动指定的距离。
  931. @param t time in seconds
  932. @param c Array of points
  933. @example
  934. ```js
  935. // example
  936. var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
  937. var bezierForward = cc.bezierBy(3, bezier);
  938. ```
  939. */
  940. export function bezierBy(t: number, c: Vec2[]): ActionInterval;
  941. /**
  942. !#en An action that moves the target with a cubic Bezier curve to a destination point.
  943. !#zh 按贝赛尔曲线轨迹移动到目标位置。
  944. @param t t
  945. @param c Array of points
  946. @example
  947. ```js
  948. // example
  949. var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
  950. var bezierTo = cc.bezierTo(2, bezier);
  951. ```
  952. */
  953. export function bezierTo(t: number, c: Vec2[]): ActionInterval;
  954. /**
  955. !#en Scales a Node object to a zoom factor by modifying it's scale property.
  956. !#zh 将节点大小缩放到指定的倍数。
  957. @param duration duration
  958. @param sx scale parameter in X
  959. @param sy scale parameter in Y, if Null equal to sx
  960. @example
  961. ```js
  962. // example
  963. // It scales to 0.5 in both X and Y.
  964. var actionTo = cc.scaleTo(2, 0.5);
  965. // It scales to 0.5 in x and 2 in Y
  966. var actionTo = cc.scaleTo(2, 0.5, 2);
  967. ```
  968. */
  969. export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval;
  970. /**
  971. !#en
  972. Scales a Node object a zoom factor by modifying it's scale property.
  973. Relative to its changes.
  974. !#zh 按指定的倍数缩放节点大小。
  975. @param duration duration in seconds
  976. @param sx sx scale parameter in X
  977. @param sy sy scale parameter in Y, if Null equal to sx
  978. @example
  979. ```js
  980. // example without sy, it scales by 2 both in X and Y
  981. var actionBy = cc.scaleBy(2, 2);
  982. //example with sy, it scales by 0.25 in X and 4.5 in Y
  983. var actionBy2 = cc.scaleBy(2, 0.25, 4.5);
  984. ```
  985. */
  986. export function scaleBy(duration: number, sx: number, sy?: number|void): ActionInterval;
  987. /**
  988. !#en Blinks a Node object by modifying it's visible property.
  989. !#zh 闪烁(基于透明度)。
  990. @param duration duration in seconds
  991. @param blinks blinks in times
  992. @example
  993. ```js
  994. // example
  995. var action = cc.blink(2, 10);
  996. ```
  997. */
  998. export function blink(duration: number, blinks: number): ActionInterval;
  999. /**
  1000. !#en
  1001. Fades an object that implements the cc.RGBAProtocol protocol.
  1002. It modifies the opacity from the current value to a custom one.
  1003. !#zh 修改透明度到指定值。
  1004. @param duration duration
  1005. @param opacity 0-255, 0 is transparent
  1006. @example
  1007. ```js
  1008. // example
  1009. var action = cc.fadeTo(1.0, 0);
  1010. ```
  1011. */
  1012. export function fadeTo(duration: number, opacity: number): ActionInterval;
  1013. /**
  1014. !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.
  1015. !#zh 渐显效果。
  1016. @param duration duration in seconds
  1017. @example
  1018. ```js
  1019. //example
  1020. var action = cc.fadeIn(1.0);
  1021. ```
  1022. */
  1023. export function fadeIn(duration: number): ActionInterval;
  1024. /**
  1025. !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0.
  1026. !#zh 渐隐效果。
  1027. @param d duration in seconds
  1028. @example
  1029. ```js
  1030. // example
  1031. var action = cc.fadeOut(1.0);
  1032. ```
  1033. */
  1034. export function fadeOut(d: number): ActionInterval;
  1035. /**
  1036. !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
  1037. !#zh 修改颜色到指定值。
  1038. @param duration duration
  1039. @param red 0-255
  1040. @param green 0-255
  1041. @param blue 0-255
  1042. @example
  1043. ```js
  1044. // example
  1045. var action = cc.tintTo(2, 255, 0, 255);
  1046. ```
  1047. */
  1048. export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval;
  1049. /**
  1050. !#en
  1051. Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
  1052. Relative to their own color change.
  1053. !#zh 按照指定的增量修改颜色。
  1054. @param duration duration in seconds
  1055. @param deltaRed deltaRed
  1056. @param deltaGreen deltaGreen
  1057. @param deltaBlue deltaBlue
  1058. @example
  1059. ```js
  1060. // example
  1061. var action = cc.tintBy(2, -127, -255, -127);
  1062. ```
  1063. */
  1064. export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval;
  1065. /**
  1066. !#en Delays the action a certain amount of seconds.
  1067. !#en 延迟指定的时间量。
  1068. @param d duration in seconds
  1069. @example
  1070. ```js
  1071. // example
  1072. var delay = cc.delayTime(1);
  1073. ```
  1074. */
  1075. export function delayTime(d: number): ActionInterval;
  1076. /**
  1077. !#en Executes an action in reverse order, from time=duration to time=0.
  1078. !#zh 反转目标动作的时间轴。
  1079. @param action action
  1080. @example
  1081. ```js
  1082. // example
  1083. var reverse = cc.reverseTime(this);
  1084. ```
  1085. */
  1086. export function reverseTime(action: FiniteTimeAction): ActionInterval;
  1087. /**
  1088. !#en Create an action with the specified action and forced target.
  1089. !#zh 用已有动作和一个新的目标节点创建动作。
  1090. @param target target
  1091. @param action action
  1092. */
  1093. export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval;
  1094. /** !#en cc.view is the shared view object.
  1095. !#zh cc.view 是全局的视图对象。 */
  1096. export var view: View;
  1097. /** !#en Director
  1098. !#zh 导演类。 */
  1099. export var director: Director;
  1100. /** !#en cc.winSize is the alias object for the size of the current game window.
  1101. !#zh cc.winSize 为当前的游戏窗口的大小。 */
  1102. export var winSize: Size;
  1103. export var game: Game;
  1104. /** !#en The System event singleton for global usage
  1105. !#zh 系统事件单例,方便全局使用 */
  1106. export var systemEvent: SystemEvent;
  1107. /**
  1108. @param touches touches
  1109. */
  1110. export function handleTouchesBegin(touches: any[]): void;
  1111. /**
  1112. @param touches touches
  1113. */
  1114. export function handleTouchesMove(touches: any[]): void;
  1115. /**
  1116. @param touches touches
  1117. */
  1118. export function handleTouchesEnd(touches: any[]): void;
  1119. /**
  1120. @param touches touches
  1121. */
  1122. export function handleTouchesCancel(touches: any[]): void;
  1123. /**
  1124. @param touches touches
  1125. */
  1126. export function getSetOfTouchesEndOrCancel(touches: any[]): any[];
  1127. /**
  1128. @param element element
  1129. */
  1130. export function getHTMLElementPosition(element: HTMLElement): any;
  1131. /**
  1132. @param touch touch
  1133. */
  1134. export function getPreTouch(touch: Touch): Touch;
  1135. /**
  1136. @param touch touch
  1137. */
  1138. export function setPreTouch(touch: Touch): void;
  1139. /**
  1140. @param tx tx
  1141. @param ty ty
  1142. @param pos pos
  1143. */
  1144. export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch;
  1145. /**
  1146. @param event event
  1147. @param pos pos
  1148. */
  1149. export function getPointByEvent(event: Touch, pos: Vec2): Vec2;
  1150. /**
  1151. @param event event
  1152. @param pos pos
  1153. */
  1154. export function getTouchesByEvent(event: Touch, pos: Vec2): any[];
  1155. /**
  1156. @param element element
  1157. */
  1158. export function registerSystemEvent(element: HTMLElement): void;
  1159. /**
  1160. !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details.
  1161. !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。
  1162. @param options options
  1163. @example
  1164. ```js
  1165. // define base class
  1166. var Node = cc.Class();
  1167. // define sub class
  1168. var Sprite = cc.Class({
  1169. name: 'Sprite',
  1170. extends: Node,
  1171. ctor: function () {
  1172. this.url = "";
  1173. this.id = 0;
  1174. },
  1175. statics: {
  1176. // define static members
  1177. count: 0,
  1178. getBounds: function (spriteList) {
  1179. // compute bounds...
  1180. }
  1181. },
  1182. properties {
  1183. width: {
  1184. default: 128,
  1185. type: 'Integer',
  1186. tooltip: 'The width of sprite'
  1187. },
  1188. height: 128,
  1189. size: {
  1190. get: function () {
  1191. return cc.v2(this.width, this.height);
  1192. }
  1193. }
  1194. },
  1195. load: function () {
  1196. // load this.url...
  1197. };
  1198. });
  1199. // instantiate
  1200. var obj = new Sprite();
  1201. obj.url = 'sprite.png';
  1202. obj.load();
  1203. ```
  1204. */
  1205. export function Class(options?: {name?: string; extends?: Function; ctor?: Function; __ctor__?: Function; properties?: any; statics?: any; mixins?: Function[]; editor?: {executeInEditMode?: boolean; requireComponent?: Function; menu?: string; executionOrder?: number; disallowMultiple?: boolean; playOnFocus?: boolean; inspector?: string; icon?: string; help?: string; }; update?: Function; lateUpdate?: Function; onLoad?: Function; start?: Function; onEnable?: Function; onDisable?: Function; onDestroy?: Function; onFocusInEditor?: Function; onLostFocusInEditor?: Function; resetInEditor?: Function; onRestore?: Function; _getLocalBounds?: Function; }): Function;
  1206. /**
  1207. Checks whether subclass is child of superclass or equals to superclass
  1208. @param subclass subclass
  1209. @param superclass superclass
  1210. */
  1211. export function isChildClassOf(subclass: Function, superclass: Function): boolean;
  1212. /**
  1213. Return all super classes
  1214. @param constructor constructor
  1215. */
  1216. export function getInheritanceChain(constructor: Function): Function[];
  1217. /**
  1218. !#en
  1219. Define an enum type. <br/>
  1220. 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/>
  1221. Otherwise it will use the value specified by user who writes the enum definition.
  1222. !#zh
  1223. 定义一个枚举类型。<br/>
  1224. 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。
  1225. @param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type
  1226. @example
  1227. ```js
  1228. // JavaScript:
  1229. var WrapMode = cc.Enum({
  1230. Repeat: -1,
  1231. Clamp: -1
  1232. });
  1233. // Texture.WrapMode.Repeat == 0
  1234. // Texture.WrapMode.Clamp == 1
  1235. // Texture.WrapMode[0] == "Repeat"
  1236. // Texture.WrapMode[1] == "Clamp"
  1237. var FlagType = cc.Enum({
  1238. Flag1: 1,
  1239. Flag2: 2,
  1240. Flag3: 4,
  1241. Flag4: 8,
  1242. });
  1243. var AtlasSizeList = cc.Enum({
  1244. 128: 128,
  1245. 256: 256,
  1246. 512: 512,
  1247. 1024: 1024,
  1248. });
  1249. // TypeScript:
  1250. // If used in TypeScript, just define a TypeScript enum:
  1251. enum Direction {
  1252. Up,
  1253. Down,
  1254. Left,
  1255. Right
  1256. }
  1257. // If you need to inspect the enum in Properties panel, you can call cc.Enum:
  1258. const {ccclass, property} = cc._decorator;
  1259. @ccclass
  1260. class NewScript extends cc.Component {
  1261. @property({
  1262. default: Direction.Up,
  1263. type: cc.Enum(Direction) // call cc.Enum
  1264. })
  1265. direction: Direction = Direction.Up;
  1266. }
  1267. ```
  1268. */
  1269. export function Enum<T>(obj: T): T;
  1270. /**
  1271. whether enable accelerometer event
  1272. @param isEnable isEnable
  1273. */
  1274. export function setAccelerometerEnabled(isEnable: boolean): void;
  1275. /**
  1276. set accelerometer interval value
  1277. @param interval interval
  1278. */
  1279. export function setAccelerometerInterval(interval: number): void;
  1280. /**
  1281. @param touches touches
  1282. */
  1283. export function handleTouchesBegin(touches: any[]): void;
  1284. /**
  1285. @param touches touches
  1286. */
  1287. export function handleTouchesMove(touches: any[]): void;
  1288. /**
  1289. @param touches touches
  1290. */
  1291. export function handleTouchesEnd(touches: any[]): void;
  1292. /**
  1293. @param touches touches
  1294. */
  1295. export function handleTouchesCancel(touches: any[]): void;
  1296. /**
  1297. @param touches touches
  1298. */
  1299. export function getSetOfTouchesEndOrCancel(touches: any[]): any[];
  1300. /**
  1301. @param element element
  1302. */
  1303. export function getHTMLElementPosition(element: HTMLElement): any;
  1304. /**
  1305. @param touch touch
  1306. */
  1307. export function getPreTouch(touch: Touch): Touch;
  1308. /**
  1309. @param touch touch
  1310. */
  1311. export function setPreTouch(touch: Touch): void;
  1312. /**
  1313. @param tx tx
  1314. @param ty ty
  1315. @param pos pos
  1316. */
  1317. export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch;
  1318. /**
  1319. @param location location
  1320. @param pos pos
  1321. @param eventType eventType
  1322. */
  1323. export function getTouchByXY(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse;
  1324. /**
  1325. @param event event
  1326. @param pos pos
  1327. */
  1328. export function getPointByEvent(event: Touch, pos: Vec2): Vec2;
  1329. /**
  1330. @param event event
  1331. @param pos pos
  1332. */
  1333. export function getTouchesByEvent(event: Touch, pos: Vec2): any[];
  1334. /**
  1335. @param element element
  1336. */
  1337. export function registerSystemEvent(element: HTMLElement): void;
  1338. /**
  1339. @param dt dt
  1340. */
  1341. export function update(dt: number): void;
  1342. /**
  1343. <p>
  1344. Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end
  1345. </p>
  1346. @param a number A
  1347. @param b number B
  1348. @param r ratio between 0 and 1
  1349. @example
  1350. ```js
  1351. ----
  1352. lerp
  1353. cc.lerp(2,10,0.5)//returns 6
  1354. cc.lerp(2,10,0.2)//returns 3.6
  1355. ```
  1356. */
  1357. export function lerp(a: number, b: number, r: number): void;
  1358. /**
  1359. get a random number from 0 to 0xffffff
  1360. */
  1361. export function rand(): number;
  1362. /**
  1363. returns a random float between -1 and 1
  1364. */
  1365. export function randomMinus1To1(): number;
  1366. /**
  1367. returns a random float between 0 and 1, use Math.random directly
  1368. */
  1369. export function random0To1(): number;
  1370. /**
  1371. converts degrees to radians
  1372. @param angle angle
  1373. */
  1374. export function degreesToRadians(angle: number): number;
  1375. /**
  1376. converts radians to degrees
  1377. @param angle angle
  1378. */
  1379. export function radiansToDegrees(angle: number): number;
  1380. /**
  1381. Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix
  1382. @param node setup node
  1383. */
  1384. export function nodeDrawSetup(node: Node): void;
  1385. /**
  1386. <p>
  1387. Increments the GL Draws counts by one.<br/>
  1388. The number of calls per frame are displayed on the screen when the CCDirector's stats are enabled.<br/>
  1389. </p>
  1390. @param addNumber addNumber
  1391. */
  1392. export function incrementGLDraws(addNumber: number): void;
  1393. /**
  1394. Check webgl error.Error will be shown in console if exists.
  1395. */
  1396. export function checkGLErrorDebug(): void;
  1397. /**
  1398. !#en Checks whether the object is non-nil and not yet destroyed.
  1399. !#zh 检查该对象是否不为 null 并且尚未销毁。
  1400. @param value value
  1401. @example
  1402. ```js
  1403. cc.log(cc.isValid(target));
  1404. ```
  1405. */
  1406. export function isValid(value: any): boolean;
  1407. /** Specify that the input value must be integer in Inspector.
  1408. Also used to indicates that the elements in array should be type integer. */
  1409. export var Integer: string;
  1410. /** Indicates that the elements in array should be type double. */
  1411. export var Float: string;
  1412. /** Indicates that the elements in array should be type boolean. */
  1413. export var Boolean: string;
  1414. /** Indicates that the elements in array should be type string. */
  1415. export var String: string;
  1416. /**
  1417. !#en Deserialize json to cc.Asset
  1418. !#zh 将 JSON 反序列化为对象实例。
  1419. 当指定了 target 选项时,如果 target 引用的其它 asset 的 uuid 不变,则不会改变 target 对 asset 的引用,
  1420. 也不会将 uuid 保存到 result 对象中。
  1421. @param data the serialized cc.Asset json string or json object.
  1422. @param details additional loading result
  1423. @param options options
  1424. */
  1425. export function deserialize(data: string|any, details?: Details, options?: any): any;
  1426. /**
  1427. !#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab.
  1428. !#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。
  1429. (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。)
  1430. @param original An existing object that you want to make a copy of.
  1431. @example
  1432. ```js
  1433. // instantiate node from prefab
  1434. var scene = cc.director.getScene();
  1435. var node = cc.instantiate(prefabAsset);
  1436. node.parent = scene;
  1437. // clone node
  1438. var scene = cc.director.getScene();
  1439. var node = cc.instantiate(targetNode);
  1440. node.parent = scene;
  1441. ```
  1442. */
  1443. export function instantiate(original: Prefab): Node;
  1444. export function instantiate<T>(original: T): T;
  1445. /**
  1446. Finds a node by hierarchy path, the path is case-sensitive.
  1447. It will traverse the hierarchy by splitting the path using '/' character.
  1448. This function will still returns the node even if it is inactive.
  1449. It is recommended to not use this function every frame instead cache the result at startup.
  1450. @param path path
  1451. @param referenceNode referenceNode
  1452. */
  1453. export function find(path: string, referenceNode?: Node): Node;
  1454. /**
  1455. !#en
  1456. The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}}
  1457. Alpha channel is optional. Default value is 255.
  1458. !#zh
  1459. 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。
  1460. Alpha 通道是可选的。默认值是 255。
  1461. @param r r
  1462. @param g g
  1463. @param b b
  1464. @param a a
  1465. @example
  1466. ```js
  1467. -----------------------
  1468. // 1. All channels seperately as parameters
  1469. var color1 = new cc.Color(255, 255, 255, 255);
  1470. // 2. Convert a hex string to a color
  1471. var color2 = new cc.Color("#000000");
  1472. // 3. An color object as parameter
  1473. var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255});
  1474. ```
  1475. */
  1476. export function color(r?: number, g?: number, b?: number, a?: number): Color;
  1477. /**
  1478. !#en returns true if both ccColor3B are equal. Otherwise it returns false.
  1479. !#zh 判断两个颜色对象的 RGB 部分是否相等,不比较透明度。
  1480. @param color1 color1
  1481. @param color2 color2
  1482. @example
  1483. ```js
  1484. cc.log(cc.colorEqual(cc.Color.RED, new cc.Color(255, 0, 0))); // true
  1485. ```
  1486. */
  1487. export function colorEqual(color1: Color, color2: Color): boolean;
  1488. /**
  1489. !#en
  1490. convert a string of color for style to Color.
  1491. e.g. "#ff06ff" to : cc.color(255,6,255)。
  1492. !#zh 16 进制转换为 Color
  1493. @param hex hex
  1494. @example
  1495. ```js
  1496. cc.hexToColor("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
  1497. ```
  1498. */
  1499. export function hexToColor(hex: string): Color;
  1500. /**
  1501. !#en
  1502. convert Color to a string of color for style.
  1503. e.g. cc.color(255,6,255) to : "#ff06ff"
  1504. !#zh Color 转换为 16进制。
  1505. @param color color
  1506. @example
  1507. ```js
  1508. var color = new cc.Color(255, 6, 255)
  1509. cc.colorToHex(color); // #ff06ff;
  1510. ```
  1511. */
  1512. export function colorToHex(color: Color): string;
  1513. /**
  1514. !#en Returns opposite of Vec2.
  1515. !#zh 返回相反的向量。
  1516. @param point point
  1517. @example
  1518. ```js
  1519. cc.pNeg(cc.v2(10, 10));// Vec2 {x: -10, y: -10};
  1520. ```
  1521. */
  1522. export function pNeg(point: Vec2): Vec2;
  1523. /**
  1524. !#en Calculates sum of two points.
  1525. !#zh 返回两个向量的和。
  1526. @param v1 v1
  1527. @param v2 v2
  1528. @example
  1529. ```js
  1530. cc.pAdd(cc.v2(1, 1), cc.v2(2, 2));// Vec2 {x: 3, y: 3};
  1531. ```
  1532. */
  1533. export function pAdd(v1: Vec2, v2: Vec2): Vec2;
  1534. /**
  1535. !#en Calculates difference of two points.
  1536. !#zh 返回两个向量的差。
  1537. @param v1 v1
  1538. @param v2 v2
  1539. @example
  1540. ```js
  1541. cc.pSub(cc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 15, y: 15};
  1542. ```
  1543. */
  1544. export function pSub(v1: Vec2, v2: Vec2): Vec2;
  1545. /**
  1546. !#en Returns point multiplied by given factor.
  1547. !#zh 向量缩放。
  1548. @param point point
  1549. @param floatVar floatVar
  1550. @example
  1551. ```js
  1552. cc.pMult(cc.v2(5, 5), 4); // Vec2 {x: 20, y: 20};
  1553. ```
  1554. */
  1555. export function pMult(point: Vec2, floatVar: number): Vec2;
  1556. /**
  1557. !#en Calculates midpoint between two points.
  1558. !#zh 两个向量之间的中心点。
  1559. @param v1 v1
  1560. @param v2 v2
  1561. @example
  1562. ```js
  1563. cc.pMidpoint(cc.v2(10, 10), cc.v2(5, 5)); // Vec2 {x: 7.5, y: 7.5};
  1564. ```
  1565. */
  1566. export function pMidpoint(v1: Vec2, v2: Vec2): Vec2;
  1567. /**
  1568. !#en Calculates dot product of two points.
  1569. !#zh 两个向量之间进行点乘。
  1570. @param v1 v1
  1571. @param v2 v2
  1572. @example
  1573. ```js
  1574. cc.pDot(cc.v2(20, 20), cc.v2(5, 5)); // 200;
  1575. ```
  1576. */
  1577. export function pDot(v1: Vec2, v2: Vec2): number;
  1578. /**
  1579. !#en Calculates cross product of two points.
  1580. !#zh 两个向量之间进行叉乘。
  1581. @param v1 v1
  1582. @param v2 v2
  1583. @example
  1584. ```js
  1585. cc.pCross(cc.v2(20, 20), cc.v2(5, 5)); // 0;
  1586. ```
  1587. */
  1588. export function pCross(v1: Vec2, v2: Vec2): number;
  1589. /**
  1590. !#en Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) greater than 0.
  1591. !#zh 返回逆时针旋转 90 度后的新向量。
  1592. @param point point
  1593. @example
  1594. ```js
  1595. cc.pPerp(cc.v2(20, 20)); // Vec2 {x: -20, y: 20};
  1596. ```
  1597. */
  1598. export function pPerp(point: Vec2): Vec2;
  1599. /**
  1600. !#en Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) smaller than 0.
  1601. !#zh 将指定向量顺时针旋转 90 度并返回。
  1602. @param point point
  1603. @example
  1604. ```js
  1605. cc.pRPerp(cc.v2(20, 20)); // Vec2 {x: 20, y: -20};
  1606. ```
  1607. */
  1608. export function pRPerp(point: Vec2): Vec2;
  1609. /**
  1610. !#en Calculates the projection of v1 over v2.
  1611. !#zh 返回 v1 在 v2 上的投影向量。
  1612. @param v1 v1
  1613. @param v2 v2
  1614. @example
  1615. ```js
  1616. var v1 = cc.v2(20, 20);
  1617. var v2 = cc.v2(5, 5);
  1618. cc.pProject(v1, v2); // Vec2 {x: 20, y: 20};
  1619. ```
  1620. */
  1621. export function pProject(v1: Vec2, v2: Vec2): Vec2;
  1622. /**
  1623. !#en Calculates the square length of a cc.Vec2 (not calling sqrt() ).
  1624. !#zh 返回指定向量长度的平方。
  1625. @param v v
  1626. @example
  1627. ```js
  1628. cc.pLengthSQ(cc.v2(20, 20)); // 800;
  1629. ```
  1630. */
  1631. export function pLengthSQ(v: Vec2): number;
  1632. /**
  1633. !#en Calculates the square distance between two points (not calling sqrt() ).
  1634. !#zh 返回两个点之间距离的平方。
  1635. @param point1 point1
  1636. @param point2 point2
  1637. @example
  1638. ```js
  1639. var point1 = cc.v2(20, 20);
  1640. var point2 = cc.v2(5, 5);
  1641. cc.pDistanceSQ(point1, point2); // 450;
  1642. ```
  1643. */
  1644. export function pDistanceSQ(point1: Vec2, point2: Vec2): number;
  1645. /**
  1646. !#en Calculates distance between point an origin.
  1647. !#zh 返回指定向量的长度.
  1648. @param v v
  1649. @example
  1650. ```js
  1651. cc.pLength(cc.v2(20, 20)); // 28.284271247461902;
  1652. ```
  1653. */
  1654. export function pLength(v: Vec2): number;
  1655. /**
  1656. !#en Calculates the distance between two points.
  1657. !#zh 返回指定 2 个向量之间的距离。
  1658. @param v1 v1
  1659. @param v2 v2
  1660. @example
  1661. ```js
  1662. var v1 = cc.v2(20, 20);
  1663. var v2 = cc.v2(5, 5);
  1664. cc.pDistance(v1, v2); // 21.213203435596427;
  1665. ```
  1666. */
  1667. export function pDistance(v1: Vec2, v2: Vec2): number;
  1668. /**
  1669. !#en Returns this vector with a magnitude of 1.
  1670. !#zh 返回一个长度为 1 的标准化过后的向量。
  1671. @param v v
  1672. @example
  1673. ```js
  1674. cc.pNormalize(cc.v2(20, 20)); // Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
  1675. ```
  1676. */
  1677. export function pNormalize(v: Vec2): Vec2;
  1678. /**
  1679. !#en Converts radians to a normalized vector.
  1680. !#zh 将弧度转换为一个标准化后的向量,返回坐标 x = cos(a) , y = sin(a)。
  1681. @param a a
  1682. @example
  1683. ```js
  1684. cc.pForAngle(20); // Vec2 {x: 0.40808206181339196, y: 0.9129452507276277};
  1685. ```
  1686. */
  1687. export function pForAngle(a: number): Vec2;
  1688. /**
  1689. !#en Converts a vector to radians.
  1690. !#zh 返回指定向量的弧度。
  1691. @param v v
  1692. @example
  1693. ```js
  1694. cc.pToAngle(cc.v2(20, 20)); // 0.7853981633974483;
  1695. ```
  1696. */
  1697. export function pToAngle(v: Vec2): number;
  1698. /**
  1699. !#en Clamp a value between from and to.
  1700. !#zh
  1701. 限定浮点数的最大最小值。<br/>
  1702. 数值大于 max_inclusive 则返回 max_inclusive。<br/>
  1703. 数值小于 min_inclusive 则返回 min_inclusive。<br/>
  1704. 否则返回自身。
  1705. @param value value
  1706. @param min_inclusive min_inclusive
  1707. @param max_inclusive max_inclusive
  1708. @example
  1709. ```js
  1710. var v1 = cc.clampf(20, 0, 20); // 20;
  1711. var v2 = cc.clampf(-1, 0, 20); // 0;
  1712. var v3 = cc.clampf(10, 0, 20); // 10;
  1713. ```
  1714. */
  1715. export function clampf(value: number, min_inclusive: number, max_inclusive: number): number;
  1716. /**
  1717. !#en Clamp a value between 0 and 1.
  1718. !#zh 限定浮点数的取值范围为 0 ~ 1 之间。
  1719. @param value value
  1720. @example
  1721. ```js
  1722. var v1 = cc.clampf(20); // 1;
  1723. var v2 = cc.clampf(-1); // 0;
  1724. var v3 = cc.clampf(0.5); // 0.5;
  1725. ```
  1726. */
  1727. export function clamp01(value: number): number;
  1728. /**
  1729. !#en Clamp a point between from and to.
  1730. !#zh
  1731. 返回指定限制区域后的向量。<br/>
  1732. 向量大于 max_inclusive 则返回 max_inclusive。<br/>
  1733. 向量小于 min_inclusive 则返回 min_inclusive。<br/>
  1734. 否则返回自身。
  1735. @param p p
  1736. @param min_inclusive min_inclusive
  1737. @param max_inclusive max_inclusive
  1738. @example
  1739. ```js
  1740. var min_inclusive = cc.v2(0, 0);
  1741. var max_inclusive = cc.v2(20, 20);
  1742. var v1 = cc.pClamp(cc.v2(20, 20), min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20};
  1743. var v2 = cc.pClamp(cc.v2(0, 0), min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0};
  1744. var v3 = cc.pClamp(cc.v2(10, 10), min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10};
  1745. ```
  1746. */
  1747. export function pClamp(p: Vec2, min_inclusive: Vec2, max_inclusive: Vec2): Vec2;
  1748. /**
  1749. !#en Quickly convert cc.Size to a cc.Vec2.
  1750. !#zh 快速转换 cc.Size 为 cc.Vec2。
  1751. @param s s
  1752. @example
  1753. ```js
  1754. cc.pFromSize(new cc.size(20, 20)); // Vec2 {x: 20, y: 20};
  1755. ```
  1756. */
  1757. export function pFromSize(s: Size): Vec2;
  1758. /**
  1759. !#en
  1760. Run a math operation function on each point component <br />
  1761. Math.abs, Math.fllor, Math.ceil, Math.round.
  1762. !#zh 通过运行指定的数学运算函数来计算指定的向量。
  1763. @param p p
  1764. @param opFunc opFunc
  1765. @example
  1766. ```js
  1767. cc.pCompOp(cc.p(-10, -10), Math.abs); // Vec2 {x: 10, y: 10};
  1768. ```
  1769. */
  1770. export function pCompOp(p: Vec2, opFunc: Function): Vec2;
  1771. /**
  1772. !#en
  1773. Linear Interpolation between two points a and b.<br />
  1774. alpha == 0 ? a <br />
  1775. alpha == 1 ? b <br />
  1776. otherwise a value between a..b.
  1777. !#zh
  1778. 两个点 A 和 B 之间的线性插值。 <br />
  1779. alpha == 0 ? a <br />
  1780. alpha == 1 ? b <br />
  1781. 否则这个数值在 a ~ b 之间。
  1782. @param a a
  1783. @param b b
  1784. @param alpha alpha
  1785. @example
  1786. ```js
  1787. cc.pLerp(cc.v2(20, 20), cc.v2(5, 5), 0.5); // Vec2 {x: 12.5, y: 12.5};
  1788. ```
  1789. */
  1790. export function pLerp(a: Vec2, b: Vec2, alpha: number): Vec2;
  1791. /**
  1792. !#en TODO
  1793. !#zh
  1794. 近似判断两个点是否相等。<br/>
  1795. 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。
  1796. @param a a
  1797. @param b b
  1798. @param variance variance
  1799. @example
  1800. ```js
  1801. var a = cc.v2(20, 20);
  1802. var b = cc.v2(5, 5);
  1803. var b1 = cc.pFuzzyEqual(a, b, 10); // false;
  1804. var b2 = cc.pFuzzyEqual(a, b, 18); // true;
  1805. ```
  1806. */
  1807. export function pFuzzyEqual(a: Vec2, b: Vec2, variance: number): boolean;
  1808. /**
  1809. !#en Multiplies a nd b components, a.x*b.x, a.y*b.y.
  1810. !#zh 计算两个向量的每个分量的乘积, a.x * b.x, a.y * b.y。
  1811. @param a a
  1812. @param b b
  1813. @example
  1814. ```js
  1815. cc.pCompMult(acc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 100, y: 100};
  1816. ```
  1817. */
  1818. export function pCompMult(a: Vec2, b: Vec2): Vec2;
  1819. /**
  1820. !#en TODO
  1821. !#zh 返回两个向量之间带正负号的弧度。
  1822. @param a a
  1823. @param b b
  1824. */
  1825. export function pAngleSigned(a: Vec2, b: Vec2): number;
  1826. /**
  1827. !#en TODO
  1828. !#zh 获取当前向量与指定向量之间的弧度角。
  1829. @param a a
  1830. @param b b
  1831. */
  1832. export function pAngle(a: Vec2, b: Vec2): number;
  1833. /**
  1834. !#en Rotates a point counter clockwise by the angle around a pivot.
  1835. !#zh 返回给定向量围绕指定轴心顺时针旋转一定弧度后的结果。
  1836. @param v v is the point to rotate
  1837. @param pivot pivot is the pivot, naturally
  1838. @param angle angle is the angle of rotation cw in radians
  1839. */
  1840. export function pRotateByAngle(v: Vec2, pivot: Vec2, angle: number): Vec2;
  1841. /**
  1842. !#en
  1843. A general line-line intersection test
  1844. indicating successful intersection of a line<br />
  1845. note that to truly test intersection for segments we have to make<br />
  1846. sure that s & t lie within [0..1] and for rays, make sure s & t > 0<br />
  1847. the hit point is p3 + t * (p4 - p3);<br />
  1848. the hit point also is p1 + s * (p2 - p1);
  1849. !#zh
  1850. 返回 A 为起点 B 为终点线段 1 所在直线和 C 为起点 D 为终点线段 2 所在的直线是否相交,<br />
  1851. 如果相交返回 true,反之则为 false,参数 retP 是返回交点在线段 1、线段 2 上的比例。
  1852. @param A A is the startpoint for the first line P1 = (p1 - p2).
  1853. @param B B is the endpoint for the first line P1 = (p1 - p2).
  1854. @param C C is the startpoint for the second line P2 = (p3 - p4).
  1855. @param D D is the endpoint for the second line P2 = (p3 - p4).
  1856. @param retP retP.x is the range for a hitpoint in P1 (pa = p1 + s*(p2 - p1)), <br />
  1857. retP.y is the range for a hitpoint in P3 (pa = p2 + t*(p4 - p3)).
  1858. */
  1859. export function pLineIntersect(A: Vec2, B: Vec2, C: Vec2, D: Vec2, retP: Vec2): boolean;
  1860. /**
  1861. !#en ccpSegmentIntersect return YES if Segment A-B intersects with segment C-D.
  1862. !#zh 返回线段 A - B 和线段 C - D 是否相交。
  1863. @param A A
  1864. @param B B
  1865. @param C C
  1866. @param D D
  1867. */
  1868. export function pSegmentIntersect(A: Vec2, B: Vec2, C: Vec2, D: Vec2): boolean;
  1869. /**
  1870. !#en ccpIntersectPoint return the intersection point of line A-B, C-D.
  1871. !#zh 返回线段 A - B 和线段 C - D 的交点。
  1872. @param A A
  1873. @param B B
  1874. @param C C
  1875. @param D D
  1876. */
  1877. export function pIntersectPoint(A: Vec2, B: Vec2, C: Vec2, D: Vec2): Vec2;
  1878. /**
  1879. !#en check to see if both points are equal.
  1880. !#zh 检查指定的 2 个向量是否相等。
  1881. @param A A ccp a
  1882. @param B B ccp b to be compared
  1883. */
  1884. export function pSameAs(A: Vec2, B: Vec2): boolean;
  1885. /**
  1886. !#en sets the position of the point to 0.
  1887. !#zh 设置指定向量归 0。
  1888. @param v v
  1889. */
  1890. export function pZeroIn(v: Vec2): void;
  1891. /**
  1892. !#en copies the position of one point to another.
  1893. !#zh 令 v1 向量等同于 v2。
  1894. @param v1 v1
  1895. @param v2 v2
  1896. */
  1897. export function pIn(v1: Vec2, v2: Vec2): void;
  1898. /**
  1899. !#en multiplies the point with the given factor (inplace).
  1900. !#zh 向量缩放,结果保存到第一个向量。
  1901. @param point point
  1902. @param floatVar floatVar
  1903. */
  1904. export function pMultIn(point: Vec2, floatVar: number): void;
  1905. /**
  1906. !#en subtracts one point from another (inplace).
  1907. !#zh 向量减法,结果保存到第一个向量。
  1908. @param v1 v1
  1909. @param v2 v2
  1910. */
  1911. export function pSubIn(v1: Vec2, v2: Vec2): void;
  1912. /**
  1913. !#en adds one point to another (inplace).
  1914. !#zh 向量加法,结果保存到第一个向量。
  1915. @param v1 v1
  1916. @param v2 v2
  1917. */
  1918. export function pAddIn(v1: Vec2, v2: Vec2): void;
  1919. /**
  1920. !#en normalizes the point (inplace).
  1921. !#zh 规范化 v 向量,设置 v 向量长度为 1。
  1922. @param v v
  1923. */
  1924. export function pNormalizeIn(v: Vec2): void;
  1925. /**
  1926. !#en
  1927. The convenience method to create a new Rect.
  1928. see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
  1929. !#zh
  1930. 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
  1931. @param x x
  1932. @param y y
  1933. @param w w
  1934. @param h h
  1935. @example
  1936. ```js
  1937. var a = new cc.Rect(0 , 0, 10, 0);
  1938. ```
  1939. */
  1940. export function rect(x?: number, y?: number, w?: number, h?: number): Rect;
  1941. /**
  1942. !#en Check whether a rect's value equals to another.
  1943. !#zh 判断两个矩形是否相等。
  1944. @param rect1 rect1
  1945. @param rect2 rect2
  1946. @example
  1947. ```js
  1948. var a = new cc.Rect(0, 0, 10, 10);
  1949. var b = new cc.Rect(0, 0, 5, 5);
  1950. cc.rectEqualToRect(a, b); // false;
  1951. var c = new cc.Rect(0, 0, 5, 5);
  1952. cc.rectEqualToRect(b, c); // true;
  1953. ```
  1954. */
  1955. export function rectEqualToRect(rect1: Rect, rect2: Rect): boolean;
  1956. /**
  1957. !#en Check whether the rect1 contains rect2.
  1958. !#zh
  1959. 检查 rect1 矩形是否包含 rect2 矩形。 <br/>
  1960. 注意:如果要允许 rect1 和 rect2 的边界重合,应该用 cc.rectOverlapsRect
  1961. @param rect1 rect1
  1962. @param rect2 rect2
  1963. @example
  1964. ```js
  1965. var a = new cc.Rect(0, 0, 20, 20);
  1966. var b = new cc.Rect(10, 10, 20, 20);
  1967. cc.rectContainsRect(a, b); // true;
  1968. ```
  1969. */
  1970. export function rectContainsRect(rect1: Rect, rect2: Rect): boolean;
  1971. /**
  1972. !#en Returns the rightmost x-value of a rect.
  1973. !#zh 返回矩形在 x 轴上的最大值
  1974. @param rect rect
  1975. @example
  1976. ```js
  1977. var a = new cc.Rect(10, 0, 20, 20);
  1978. cc.rectGetMaxX(a); // 30;
  1979. ```
  1980. */
  1981. export function rectGetMaxX(rect: Rect): number;
  1982. /**
  1983. !#en Return the midpoint x-value of a rect.
  1984. !#zh 返回矩形在 x 轴上的中点。
  1985. @param rect rect
  1986. @example
  1987. ```js
  1988. var a = new cc.Rect(10, 0, 20, 20);
  1989. cc.rectGetMidX(a); // 20;
  1990. ```
  1991. */
  1992. export function rectGetMidX(rect: Rect): number;
  1993. /**
  1994. !#en Returns the leftmost x-value of a rect.
  1995. !#zh 返回矩形在 x 轴上的最小值。
  1996. @param rect rect
  1997. @example
  1998. ```js
  1999. var a = new cc.Rect(10, 0, 20, 20);
  2000. cc.rectGetMinX(a); // 10;
  2001. ```
  2002. */
  2003. export function rectGetMinX(rect: Rect): number;
  2004. /**
  2005. !#en Return the topmost y-value of a rect.
  2006. !#zh 返回矩形在 y 轴上的最大值。
  2007. @param rect rect
  2008. @example
  2009. ```js
  2010. var a = new cc.Rect(0, 10, 20, 20);
  2011. cc.rectGetMaxY(a); // 30;
  2012. ```
  2013. */
  2014. export function rectGetMaxY(rect: Rect): number;
  2015. /**
  2016. !#en Return the midpoint y-value of `rect'.
  2017. !#zh 返回矩形在 y 轴上的中点。
  2018. @param rect rect
  2019. @example
  2020. ```js
  2021. var a = new cc.Rect(0, 10, 20, 20);
  2022. cc.rectGetMidY(a); // 20;
  2023. ```
  2024. */
  2025. export function rectGetMidY(rect: Rect): number;
  2026. /**
  2027. !#en Return the bottommost y-value of a rect.
  2028. !#zh 返回矩形在 y 轴上的最小值。
  2029. @param rect rect
  2030. @example
  2031. ```js
  2032. var a = new cc.Rect(0, 10, 20, 20);
  2033. cc.rectGetMinY(a); // 10;
  2034. ```
  2035. */
  2036. export function rectGetMinY(rect: Rect): number;
  2037. /**
  2038. !#en Check whether a rect contains a point.
  2039. !#zh 检查一个矩形是否包含某个坐标点。
  2040. @param rect rect
  2041. @param point point
  2042. @example
  2043. ```js
  2044. var a = new cc.Rect(0, 10, 20, 20);
  2045. var b = new cc.Vec2(0, 10, 10, 10);
  2046. cc.rectContainsPoint(a, b); // true;
  2047. ```
  2048. */
  2049. export function rectContainsPoint(rect: Rect, point: Vec2): boolean;
  2050. /**
  2051. !#en Check whether a rect intersect with another.
  2052. !#zh 检查一个矩形是否与另一个相交。
  2053. @param rectA rectA
  2054. @param rectB rectB
  2055. @example
  2056. ```js
  2057. var a = new cc.Rect(0, 10, 20, 20);
  2058. var b = new cc.Rect(0, 10, 10, 10);
  2059. cc.rectIntersectsRect(a, b); // true;
  2060. ```
  2061. */
  2062. export function rectIntersectsRect(rectA: Rect, rectB: Rect): boolean;
  2063. /**
  2064. !#en Check whether a rect overlaps another.
  2065. !#zh 检查一个矩形是否重叠另一个。
  2066. @param rectA rectA
  2067. @param rectB rectB
  2068. @example
  2069. ```js
  2070. var a = new cc.Rect(0, 10, 20, 20);
  2071. var b = new cc.Rect(0, 10, 10, 10);
  2072. cc.rectOverlapsRect(a, b); // true;
  2073. ```
  2074. */
  2075. export function rectOverlapsRect(rectA: Rect, rectB: Rect): boolean;
  2076. /**
  2077. !#en Returns the smallest rectangle that contains the two source rectangles.
  2078. !#zh 返回一个包含两个指定矩形的最小矩形。
  2079. @param rectA rectA
  2080. @param rectB rectB
  2081. @example
  2082. ```js
  2083. var a = new cc.Rect(0, 10, 20, 20);
  2084. var b = new cc.Rect(0, 10, 10, 10);
  2085. cc.rectUnion(a, b); // Rect {x: 0, y: 10, width: 20, height: 20};
  2086. ```
  2087. */
  2088. export function rectUnion(rectA: Rect, rectB: Rect): Rect;
  2089. /**
  2090. !#en Returns the overlapping portion of 2 rectangles.
  2091. !#zh 返回 2 个矩形重叠的部分。
  2092. @param rectA rectA
  2093. @param rectB rectB
  2094. @example
  2095. ```js
  2096. var a = new cc.Rect(0, 10, 20, 20);
  2097. var b = new cc.Rect(0, 10, 10, 10);
  2098. cc.rectIntersection(a, b); // Rect {x: 0, y: 10, width: 10, height: 10};
  2099. ```
  2100. */
  2101. export function rectIntersection(rectA: Rect, rectB: Rect): Rect;
  2102. /**
  2103. !#en
  2104. Helper function that creates a cc.Size.<br/>
  2105. Please use cc.p or cc.v2 instead, it will soon replace cc.Size.
  2106. !#zh
  2107. 创建一个 cc.Size 对象的帮助函数。<br/>
  2108. 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。
  2109. @param w width or a size object
  2110. @param h height
  2111. @example
  2112. ```js
  2113. var size1 = cc.size();
  2114. var size2 = cc.size(100,100);
  2115. var size3 = cc.size(size2);
  2116. var size4 = cc.size({width: 100, height: 100});
  2117. ```
  2118. */
  2119. export function size(w: number|Size, h?: number): Size;
  2120. /**
  2121. !#en Check whether a point's value equals to another.
  2122. !#zh 检查 Size 对象是否等于另一个。
  2123. @param size1 size1
  2124. @param size2 size2
  2125. @example
  2126. ```js
  2127. var a = new cc.size(10, 10);
  2128. var b = new cc.size(10, 10);
  2129. cc.sizeEqualToSize(a, b);// return true;
  2130. var b = new cc.size(5, 10);
  2131. cc.sizeEqualToSize(a, b);// return false;
  2132. ```
  2133. */
  2134. export function sizeEqualToSize(size1: Size, size2: Size): boolean;
  2135. export function V3F_C4B_T2F_QuadZero(): V3F_C4B_T2F_Quad;
  2136. /**
  2137. @param sourceQuad sourceQuad
  2138. */
  2139. export function V3F_C4B_T2F_QuadCopy(sourceQuad: V3F_C4B_T2F_Quad): V3F_C4B_T2F_Quad;
  2140. /**
  2141. @param sourceQuads sourceQuads
  2142. */
  2143. export function V3F_C4B_T2F_QuadsCopy(sourceQuads: any[]): any[];
  2144. /**
  2145. !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}.
  2146. !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。
  2147. @param x x
  2148. @param y y
  2149. @example
  2150. ```js
  2151. var v1 = cc.v2();
  2152. var v2 = cc.v2(0, 0);
  2153. var v3 = cc.v2(v2);
  2154. var v4 = cc.v2({x: 100, y: 100});
  2155. ```
  2156. */
  2157. export function v2(x?: number|any, y?: number): Vec2;
  2158. /**
  2159. !#en The convenience method to creates a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}.
  2160. !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。
  2161. @param x a Number or a size object
  2162. @param y y
  2163. @example
  2164. ```js
  2165. var point1 = cc.p();
  2166. var point2 = cc.p(100, 100);
  2167. var point3 = cc.p(point2);
  2168. var point4 = cc.p({x: 100, y: 100});
  2169. ```
  2170. */
  2171. export function p(x?: number|any, y?: number): Vec2;
  2172. /**
  2173. !#en Check whether a point's value equals to another.
  2174. !#zh 判断两个向量是否相等。
  2175. @param point1 point1
  2176. @param point2 point2
  2177. */
  2178. export function pointEqualToPoint(point1: Vec2, point2: Vec2): boolean;
  2179. /** !#en Enum for debug modes.
  2180. !#zh 调试模式 */
  2181. export enum DebugMode {
  2182. NONE = 0,
  2183. INFO = 0,
  2184. WARN = 0,
  2185. ERROR = 0,
  2186. INFO_FOR_WEB_PAGE = 0,
  2187. WARN_FOR_WEB_PAGE = 0,
  2188. ERROR_FOR_WEB_PAGE = 0,
  2189. }
  2190. /** !#en Base class cc.Action for action classes.
  2191. !#zh Action 类是所有动作类型的基类。 */
  2192. export class Action {
  2193. /**
  2194. !#en
  2195. to copy object with deep copy.
  2196. returns a clone of action.
  2197. !#zh 返回一个克隆的动作。
  2198. */
  2199. clone(): Action;
  2200. /**
  2201. !#en
  2202. return true if the action has finished.
  2203. !#zh 如果动作已完成就返回 true。
  2204. */
  2205. isDone(): boolean;
  2206. /**
  2207. !#en get the target.
  2208. !#zh 获取当前目标节点。
  2209. */
  2210. getTarget(): Node;
  2211. /**
  2212. !#en The action will modify the target properties.
  2213. !#zh 设置目标节点。
  2214. @param target target
  2215. */
  2216. setTarget(target: Node): void;
  2217. /**
  2218. !#en get the original target.
  2219. !#zh 获取原始目标节点。
  2220. */
  2221. getOriginalTarget(): Node;
  2222. /**
  2223. !#en get tag number.
  2224. !#zh 获取用于识别动作的标签。
  2225. */
  2226. getTag(): number;
  2227. /**
  2228. !#en set tag number.
  2229. !#zh 设置标签,用于识别动作。
  2230. @param tag tag
  2231. */
  2232. setTag(tag: number): void;
  2233. /** !#en Default Action tag.
  2234. !#zh 默认动作标签。 */
  2235. static TAG_INVALID: number;
  2236. }
  2237. /** !#en
  2238. Base class actions that do have a finite time duration. <br/>
  2239. Possible actions: <br/>
  2240. - An action with a duration of 0 seconds. <br/>
  2241. - An action with a duration of 35.5 seconds.
  2242. Infinite time actions are valid
  2243. !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */
  2244. export class FiniteTimeAction extends Action {
  2245. /**
  2246. !#en get duration of the action. (seconds).
  2247. !#zh 获取动作以秒为单位的持续时间。
  2248. */
  2249. getDuration(): number;
  2250. /**
  2251. !#en set duration of the action. (seconds).
  2252. !#zh 设置动作以秒为单位的持续时间。
  2253. @param duration duration
  2254. */
  2255. setDuration(duration: number): void;
  2256. /**
  2257. !#en
  2258. Returns a reversed action. <br />
  2259. For example: <br />
  2260. - The action will be x coordinates of 0 move to 100. <br />
  2261. - The reversed action will be x of 100 move to 0.
  2262. - Will be rewritten
  2263. !#zh 返回一个新的动作,执行与原动作完全相反的动作。
  2264. */
  2265. reverse(): void;
  2266. /**
  2267. !#en
  2268. to copy object with deep copy.
  2269. returns a clone of action.
  2270. !#zh 返回一个克隆的动作。
  2271. */
  2272. clone(): FiniteTimeAction;
  2273. }
  2274. /** !#en Base class for Easing actions.
  2275. !#zh 所有缓动动作基类,用于修饰 ActionInterval。 */
  2276. export class ActionEase extends ActionInterval {
  2277. }
  2278. /** !#en Base class for Easing actions with rate parameters
  2279. !#zh 拥有速率属性的缓动动作基类。 */
  2280. export class EaseRateAction extends ActionEase {
  2281. }
  2282. /** !#en Ease Elastic abstract class.
  2283. !#zh 弹性缓动动作基类。 */
  2284. export class EaseElastic extends ActionEase {
  2285. }
  2286. /** !#en cc.EaseBounce abstract class.
  2287. !#zh 反弹缓动动作基类。 */
  2288. export class EaseBounce extends ActionEase {
  2289. }
  2290. /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions.
  2291. !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */
  2292. export class ActionInstant extends FiniteTimeAction {
  2293. }
  2294. /** !#en
  2295. <p> An interval action is an action that takes place within a certain period of time. <br/>
  2296. It has an start time, and a finish time. The finish time is the parameter<br/>
  2297. duration plus the start time.</p>
  2298. <p>These CCActionInterval actions have some interesting properties, like:<br/>
  2299. - They can run normally (default) <br/>
  2300. - They can run reversed with the reverse method <br/>
  2301. - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions. </p>
  2302. <p>For example, you can simulate a Ping Pong effect running the action normally and<br/>
  2303. then running it again in Reverse mode. </p>
  2304. !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */
  2305. export class ActionInterval extends FiniteTimeAction {
  2306. /**
  2307. !#en Implementation of ease motion.
  2308. !#zh 缓动运动。
  2309. @param easeObj easeObj
  2310. @example
  2311. ```js
  2312. action.easing(cc.easeIn(3.0));
  2313. ```
  2314. */
  2315. easing(easeObj: any): ActionInterval;
  2316. /**
  2317. !#en
  2318. Repeats an action a number of times.
  2319. To repeat an action forever use the CCRepeatForever action.
  2320. !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。
  2321. @param times times
  2322. */
  2323. repeat(times: number): ActionInterval;
  2324. /**
  2325. !#en
  2326. Repeats an action for ever. <br/>
  2327. To repeat the an action for a limited number of times use the Repeat action. <br/>
  2328. !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。
  2329. */
  2330. repeatForever(): ActionInterval;
  2331. }
  2332. /** !#en
  2333. cc.ActionManager is a class that can manage actions.<br/>
  2334. Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface,
  2335. which uses this class's singleton object.
  2336. But there are some cases where you might need to use this class. <br/>
  2337. Examples:<br/>
  2338. - When you want to run an action where the target is different from a CCNode.<br/>
  2339. - When you want to pause / resume the actions<br/>
  2340. !#zh
  2341. cc.ActionManager 是可以管理动作的单例类。<br/>
  2342. 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。<br/>
  2343. 但也有一些情况下,您可能需要使用这个类。 <br/>
  2344. 例如:
  2345. - 当你想要运行一个动作,但目标不是 CCNode 类型时。 <br/>
  2346. - 当你想要暂停/恢复动作时。 <br/> */
  2347. export class ActionManager {
  2348. /**
  2349. !#en
  2350. Adds an action with a target.<br/>
  2351. If the target is already present, then the action will be added to the existing target.
  2352. 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.
  2353. When the target is paused, the queued actions won't be 'ticked'.
  2354. !#zh
  2355. 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。<br/>
  2356. 如果目标已存在,动作将会被直接添加到现有的节点中。<br/>
  2357. 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。<br/>
  2358. 当目标状态的 paused 为 true,动作将不会被执行
  2359. @param action action
  2360. @param target target
  2361. @param paused paused
  2362. */
  2363. addAction(action: Action, target: Node, paused: boolean): void;
  2364. /**
  2365. !#en Removes all actions from all the targets.
  2366. !#zh 移除所有对象的所有动作。
  2367. */
  2368. removeAllActions(): void;
  2369. /**
  2370. !#en
  2371. Removes all actions from a certain target. <br/>
  2372. All the actions that belongs to the target will be removed.
  2373. !#zh
  2374. 移除指定对象上的所有动作。<br/>
  2375. 属于该目标的所有的动作将被删除。
  2376. @param target target
  2377. @param forceDelete forceDelete
  2378. */
  2379. removeAllActionsFromTarget(target: Node, forceDelete: boolean): void;
  2380. /**
  2381. !#en Removes an action given an action reference.
  2382. !#zh 移除指定的动作。
  2383. @param action action
  2384. */
  2385. removeAction(action: Action): void;
  2386. /**
  2387. !#en Removes an action given its tag and the target.
  2388. !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。
  2389. @param tag tag
  2390. @param target target
  2391. */
  2392. removeActionByTag(tag: number, target: Node): void;
  2393. /**
  2394. !#en Gets an action given its tag an a target.
  2395. !#zh 通过目标对象和标签获取一个动作。
  2396. @param tag tag
  2397. @param target target
  2398. */
  2399. getActionByTag(tag: number, target: Node): Action;
  2400. /**
  2401. !#en
  2402. Returns the numbers of actions that are running in a certain target. <br/>
  2403. Composable actions are counted as 1 action. <br/>
  2404. Example: <br/>
  2405. - If you are running 1 Sequence of 7 actions, it will return 1. <br/>
  2406. - If you are running 7 Sequences of 2 actions, it will return 7.
  2407. !#zh
  2408. 返回指定对象下所有正在运行的动作数量。 <br/>
  2409. 组合动作被算作一个动作。<br/>
  2410. 例如:<br/>
  2411. - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。<br/>
  2412. - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。<br/>
  2413. @param target target
  2414. */
  2415. getNumberOfRunningActionsInTarget(target: Node): number;
  2416. /**
  2417. !#en Pauses the target: all running actions and newly added actions will be paused.
  2418. !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。
  2419. @param target target
  2420. */
  2421. pauseTarget(target: Node): void;
  2422. /**
  2423. !#en Resumes the target. All queued actions will be resumed.
  2424. !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。
  2425. @param target target
  2426. */
  2427. resumeTarget(target: Node): void;
  2428. /**
  2429. !#en Pauses all running actions, returning a list of targets whose actions were paused.
  2430. !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。
  2431. */
  2432. pauseAllRunningActions(): any[];
  2433. /**
  2434. !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call).
  2435. !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。
  2436. @param targetsToResume targetsToResume
  2437. */
  2438. resumeTargets(targetsToResume: any[]): void;
  2439. /**
  2440. !#en Pause a set of targets.
  2441. !#zh 暂停一组指定对象。
  2442. @param targetsToPause targetsToPause
  2443. */
  2444. pauseTargets(targetsToPause: any[]): void;
  2445. /**
  2446. !#en
  2447. purges the shared action manager. It releases the retained instance. <br/>
  2448. because it uses this, so it can not be static.
  2449. !#zh
  2450. 清除共用的动作管理器。它释放了持有的实例。 <br/>
  2451. 因为它使用 this,因此它不能是静态的。
  2452. */
  2453. purgeSharedManager(): void;
  2454. /**
  2455. !#en The ActionManager update。
  2456. !#zh ActionManager 主循环。
  2457. @param dt delta time in seconds
  2458. */
  2459. update(dt: number): void;
  2460. }
  2461. /** !#en Class for animation data handling.
  2462. !#zh 动画剪辑,用于存储动画数据。 */
  2463. export class AnimationClip extends Asset {
  2464. /** !#en Duration of this animation.
  2465. !#zh 动画的持续时间。 */
  2466. duration: number;
  2467. /** !#en FrameRate of this animation.
  2468. !#zh 动画的帧速率。 */
  2469. sample: number;
  2470. /** !#en Speed of this animation.
  2471. !#zh 动画的播放速度。 */
  2472. speed: number;
  2473. /** !#en WrapMode of this animation.
  2474. !#zh 动画的循环模式。 */
  2475. wrapMode: WrapMode;
  2476. /** !#en Curve data.
  2477. !#zh 曲线数据。 */
  2478. curveData: any;
  2479. /** !#en Event data.
  2480. !#zh 事件数据。 */
  2481. events: {frame: number, func: string, params: string[]}[];
  2482. /**
  2483. !#en Crate clip with a set of sprite frames
  2484. !#zh 使用一组序列帧图片来创建动画剪辑
  2485. @param spriteFrames spriteFrames
  2486. @param sample sample
  2487. @example
  2488. ```js
  2489. var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10);
  2490. ```
  2491. */
  2492. static createWithSpriteFrames(spriteFrames: [SpriteFrame], sample: number): AnimationClip;
  2493. }
  2494. /** undefined */
  2495. export class Playable {
  2496. /** !#en Is playing or paused in play mode?
  2497. !#zh 当前是否正在播放。 */
  2498. isPlaying: boolean;
  2499. /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false).
  2500. !#zh 当前是否正在暂停 */
  2501. isPaused: boolean;
  2502. /**
  2503. !#en Play this animation.
  2504. !#zh 播放动画。
  2505. */
  2506. play(): void;
  2507. /**
  2508. !#en Stop this animation.
  2509. !#zh 停止动画播放。
  2510. */
  2511. stop(): void;
  2512. /**
  2513. !#en Pause this animation.
  2514. !#zh 暂停动画。
  2515. */
  2516. pause(): void;
  2517. /**
  2518. !#en Resume this animation.
  2519. !#zh 重新播放动画。
  2520. */
  2521. resume(): void;
  2522. /**
  2523. !#en Perform a single frame step.
  2524. !#zh 执行一帧动画。
  2525. */
  2526. step(): void;
  2527. }
  2528. /** !#en
  2529. The AnimationState gives full control over animation playback process.
  2530. In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control.
  2531. !#zh
  2532. AnimationState 完全控制动画播放过程。<br/>
  2533. 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */
  2534. export class AnimationState extends Playable {
  2535. /**
  2536. @param clip clip
  2537. @param name name
  2538. */
  2539. constructor(clip: AnimationClip, name?: string);
  2540. animator: AnimationAnimator;
  2541. /** !#en The curves list.
  2542. !#zh 曲线列表。 */
  2543. curves: any[];
  2544. /** !#en The start delay which represents the number of seconds from an animation's start time to the start of
  2545. the active interval.
  2546. !#zh 延迟多少秒播放。 */
  2547. delay: number;
  2548. /** !#en The animation's iteration count property.
  2549. A real number greater than or equal to zero (including positive infinity) representing the number of times
  2550. to repeat the animation node.
  2551. Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model
  2552. calculations.
  2553. !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */
  2554. repeatCount: number;
  2555. /** !#en The iteration duration of this animation in seconds. (length)
  2556. !#zh 单次动画的持续时间,秒。 */
  2557. duration: number;
  2558. /** !#en The animation's playback speed. 1 is normal playback speed.
  2559. !#zh 播放速率。 */
  2560. speed: number;
  2561. /** !#en
  2562. Wrapping mode of the playing animation.
  2563. Notice : dynamic change wrapMode will reset time and repeatCount property
  2564. !#zh
  2565. 动画循环方式。
  2566. 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */
  2567. wrapMode: WrapMode;
  2568. /** !#en The current time of this animation in seconds.
  2569. !#zh 动画当前的时间,秒。 */
  2570. time: number;
  2571. /** !#en The clip that is being played by this animation state.
  2572. !#zh 此动画状态正在播放的剪辑。 */
  2573. clip: AnimationClip;
  2574. /** !#en The name of the playing animation.
  2575. !#zh 动画的名字 */
  2576. name: string;
  2577. }
  2578. /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation.
  2579. !#zh 动画使用的循环模式。 */
  2580. export enum WrapMode {
  2581. Default = 0,
  2582. Normal = 0,
  2583. Reverse = 0,
  2584. Loop = 0,
  2585. LoopReverse = 0,
  2586. PingPong = 0,
  2587. PingPongReverse = 0,
  2588. }
  2589. /** !#en
  2590. cc.MotionStreak manages a Ribbon based on it's motion in absolute space. <br/>
  2591. You construct it with a fadeTime, minimum segment size, texture path, texture <br/>
  2592. length and color. The fadeTime controls how long it takes each vertex in <br/>
  2593. the streak to fade out, the minimum segment size it how many pixels the <br/>
  2594. streak will move before adding a new ribbon segment, and the texture <br/>
  2595. length is the how many pixels the texture is stretched across. The texture <br/>
  2596. is vertically aligned along the streak segment.
  2597. !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */
  2598. export class MotionStreak extends Component {
  2599. /** !#en
  2600. !#zh 在编辑器模式下预览拖尾效果。 */
  2601. preview: boolean;
  2602. /** !#en The fade time to fade.
  2603. !#zh 拖尾的渐隐时间,以秒为单位。 */
  2604. fadeTime: number;
  2605. /** !#en The minimum segment size.
  2606. !#zh 拖尾之间最小距离。 */
  2607. minSeg: number;
  2608. /** !#en The stroke's width.
  2609. !#zh 拖尾的宽度。 */
  2610. stroke: number;
  2611. /** !#en The texture of the MotionStreak.
  2612. !#zh 拖尾的贴图。 */
  2613. texture: Texture2D;
  2614. /** !#en The color of the MotionStreak.
  2615. !#zh 拖尾的颜色 */
  2616. color: Color;
  2617. /** !#en The fast Mode.
  2618. !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */
  2619. fastMode: boolean;
  2620. /**
  2621. !#en Remove all living segments of the ribbon.
  2622. !#zh 删除当前所有的拖尾片段。
  2623. @example
  2624. ```js
  2625. // stop particle system.
  2626. myParticleSystem.stopSystem();
  2627. ```
  2628. */
  2629. reset(): void;
  2630. }
  2631. /** !#en cc.audioEngine is the singleton object, it provide simple audio APIs.
  2632. !#zh
  2633. cc.audioengine是单例对象。<br/>
  2634. 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。<br/>
  2635. 不使用的时候,请使用 cc.audioEngine.uncache(filePath); 进行资源释放 <br/>
  2636. 注意:<br/>
  2637. 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。<br/>
  2638. 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,<br/>
  2639. 有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */
  2640. export class audioEngine {
  2641. /**
  2642. !#en Play audio.
  2643. !#zh 播放音频
  2644. @param filePath The path of the audio file without filename extension.
  2645. @param loop Whether the music loop or not.
  2646. @param volume Volume size.
  2647. @example
  2648. ```js
  2649. var audioID = cc.audioEngine.play(path, false, 0.5);
  2650. ```
  2651. */
  2652. static play(filePath: string, loop: boolean, volume: number): number;
  2653. /**
  2654. !#en Set audio loop.
  2655. !#zh 设置音频是否循环。
  2656. @param audioID audio id.
  2657. @param loop Whether cycle.
  2658. @example
  2659. ```js
  2660. cc.audioEngine.setLoop(id, true);
  2661. ```
  2662. */
  2663. static setLoop(audioID: number, loop: boolean): void;
  2664. /**
  2665. !#en Get audio cycle state.
  2666. !#zh 获取音频的循环状态。
  2667. @param audioID audio id.
  2668. @example
  2669. ```js
  2670. cc.audioEngine.isLoop(id);
  2671. ```
  2672. */
  2673. static isLoop(audioID: number): boolean;
  2674. /**
  2675. !#en Set the volume of audio.
  2676. !#zh 设置音量(0.0 ~ 1.0)。
  2677. @param audioID audio id.
  2678. @param volume Volume must be in 0.0~1.0 .
  2679. @example
  2680. ```js
  2681. cc.audioEngine.setVolume(id, 0.5);
  2682. ```
  2683. */
  2684. static setVolume(audioID: number, volume: number): void;
  2685. /**
  2686. !#en The volume of the music max value is 1.0,the min value is 0.0 .
  2687. !#zh 获取音量(0.0 ~ 1.0)。
  2688. @param audioID audio id.
  2689. @example
  2690. ```js
  2691. var volume = cc.audioEngine.getVolume(id);
  2692. ```
  2693. */
  2694. static getVolume(audioID: number): number;
  2695. /**
  2696. !#en Set current time
  2697. !#zh 设置当前的音频时间。
  2698. @param audioID audio id.
  2699. @param sec current time.
  2700. @example
  2701. ```js
  2702. cc.audioEngine.setCurrentTime(id, 2);
  2703. ```
  2704. */
  2705. static setCurrentTime(audioID: number, sec: number): boolean;
  2706. /**
  2707. !#en Get current time
  2708. !#zh 获取当前的音频播放时间。
  2709. @param audioID audio id.
  2710. @example
  2711. ```js
  2712. var time = cc.audioEngine.getCurrentTime(id);
  2713. ```
  2714. */
  2715. static getCurrentTime(audioID: number): number;
  2716. /**
  2717. !#en Get audio duration
  2718. !#zh 获取音频总时长。
  2719. @param audioID audio id.
  2720. @example
  2721. ```js
  2722. var time = cc.audioEngine.getDuration(id);
  2723. ```
  2724. */
  2725. static getDuration(audioID: number): number;
  2726. /**
  2727. !#en Get audio state
  2728. !#zh 获取音频状态。
  2729. @param audioID audio id.
  2730. @example
  2731. ```js
  2732. var state = cc.audioEngine.getState(id);
  2733. ```
  2734. */
  2735. static getState(audioID: number): audioEngine.AudioState;
  2736. /**
  2737. !#en Set Audio finish callback
  2738. !#zh 设置一个音频结束后的回调
  2739. @param audioID audio id.
  2740. @param callback loaded callback.
  2741. @example
  2742. ```js
  2743. cc.audioEngine.setFinishCallback(id, function () {});
  2744. ```
  2745. */
  2746. static setFinishCallback(audioID: number, callback: Function): void;
  2747. /**
  2748. !#en Pause playing audio.
  2749. !#zh 暂停正在播放音频。
  2750. @param audioID The return value of function play.
  2751. @example
  2752. ```js
  2753. cc.audioEngine.pause(audioID);
  2754. ```
  2755. */
  2756. static pause(audioID: number): void;
  2757. /**
  2758. !#en Pause all playing audio
  2759. !#zh 暂停现在正在播放的所有音频。
  2760. @example
  2761. ```js
  2762. cc.audioEngine.pauseAll();
  2763. ```
  2764. */
  2765. static pauseAll(): void;
  2766. /**
  2767. !#en Resume playing audio.
  2768. !#zh 恢复播放指定的音频。
  2769. @param audioID The return value of function play.
  2770. @example
  2771. ```js
  2772. cc.audioEngine.resume(audioID);
  2773. ```
  2774. */
  2775. static resume(audioID: number): void;
  2776. /**
  2777. !#en Resume all playing audio.
  2778. !#zh 恢复播放所有之前暂停的所有音频。
  2779. @example
  2780. ```js
  2781. cc.audioEngine.resumeAll();
  2782. ```
  2783. */
  2784. static resumeAll(): void;
  2785. /**
  2786. !#en Stop playing audio.
  2787. !#zh 停止播放指定音频。
  2788. @param audioID The return value of function play.
  2789. @example
  2790. ```js
  2791. cc.audioEngine.stop(audioID);
  2792. ```
  2793. */
  2794. static stop(audioID: number): void;
  2795. /**
  2796. !#en Stop all playing audio.
  2797. !#zh 停止正在播放的所有音频。
  2798. @example
  2799. ```js
  2800. cc.audioEngine.stopAll();
  2801. ```
  2802. */
  2803. static stopAll(): void;
  2804. /**
  2805. !#en Set up an audio can generate a few examples.
  2806. !#zh 设置一个音频可以设置几个实例
  2807. @param num a number of instances to be created from within an audio
  2808. @example
  2809. ```js
  2810. cc.audioEngine.setMaxAudioInstance(20);
  2811. ```
  2812. */
  2813. static setMaxAudioInstance(num: number): void;
  2814. /**
  2815. !#en Getting audio can produce several examples.
  2816. !#zh 获取一个音频可以设置几个实例
  2817. @example
  2818. ```js
  2819. cc.audioEngine.getMaxAudioInstance();
  2820. ```
  2821. */
  2822. static getMaxAudioInstance(): number;
  2823. /**
  2824. !#en Unload the preloaded audio from internal buffer.
  2825. !#zh 卸载预加载的音频。
  2826. @param filePath filePath
  2827. @example
  2828. ```js
  2829. cc.audioEngine.uncache(filePath);
  2830. ```
  2831. */
  2832. static uncache(filePath: string): void;
  2833. /**
  2834. !#en Unload all audio from internal buffer.
  2835. !#zh 卸载所有音频。
  2836. @example
  2837. ```js
  2838. cc.audioEngine.uncacheAll();
  2839. ```
  2840. */
  2841. static uncacheAll(): void;
  2842. /**
  2843. !#en Preload audio file.
  2844. !#zh 预加载一个音频
  2845. @param filePath The file path of an audio.
  2846. @param callback The callback of an audio.
  2847. @example
  2848. ```js
  2849. cc.audioEngine.preload(path);
  2850. ```
  2851. */
  2852. static preload(filePath: string, callback?: Function): void;
  2853. /**
  2854. !#en Set a size, the unit is KB. Over this size is directly resolved into DOM nodes.
  2855. !#zh 设置一个以 KB 为单位的尺寸,大于这个尺寸的音频在加载的时候会强制使用 dom 方式加载
  2856. @param kb The file path of an audio.
  2857. @example
  2858. ```js
  2859. cc.audioEngine.setMaxWebAudioSize(300);
  2860. ```
  2861. */
  2862. static setMaxWebAudioSize(kb: number): void;
  2863. }
  2864. /** Particle System base class. <br/>
  2865. Attributes of a Particle System:<br/>
  2866. - emmision rate of the particles<br/>
  2867. - Gravity Mode (Mode A): <br/>
  2868. - gravity <br/>
  2869. - direction <br/>
  2870. - speed +- variance <br/>
  2871. - tangential acceleration +- variance<br/>
  2872. - radial acceleration +- variance<br/>
  2873. - Radius Mode (Mode B): <br/>
  2874. - startRadius +- variance <br/>
  2875. - endRadius +- variance <br/>
  2876. - rotate +- variance <br/>
  2877. - Properties common to all modes: <br/>
  2878. - life +- life variance <br/>
  2879. - start spin +- variance <br/>
  2880. - end spin +- variance <br/>
  2881. - start size +- variance <br/>
  2882. - end size +- variance <br/>
  2883. - start color +- variance <br/>
  2884. - end color +- variance <br/>
  2885. - life +- variance <br/>
  2886. - blending function <br/>
  2887. - texture <br/>
  2888. <br/>
  2889. cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).<br/>
  2890. 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, <br/>
  2891. cocos2d uses a another approach, but the results are almost identical.<br/>
  2892. cocos2d supports all the variables used by Particle Designer plus a bit more: <br/>
  2893. - spinning particles (supported when using ParticleSystem) <br/>
  2894. - tangential acceleration (Gravity mode) <br/>
  2895. - radial acceleration (Gravity mode) <br/>
  2896. - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only) <br/>
  2897. It is possible to customize any of the above mentioned properties in runtime. Example: <br/> */
  2898. export class ParticleSystem extends _RendererUnderSG {
  2899. /** !#en Play particle in edit mode.
  2900. !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */
  2901. preview: boolean;
  2902. /** !#en
  2903. If set custom to true, then use custom properties insteadof read particle file.
  2904. !#zh 是否自定义粒子属性。 */
  2905. custom: boolean;
  2906. /** !#en The plist file.
  2907. !#zh plist 格式的粒子配置文件。 */
  2908. file: string;
  2909. /** . */
  2910. texture: Texture2D;
  2911. /** !#en Current quantity of particles that are being simulated.
  2912. !#zh 当前播放的粒子数量。 */
  2913. particleCount: number;
  2914. /** !#en Specify the source Blend Factor.
  2915. !#zh 指定原图混合模式。 */
  2916. srcBlendFactor: BlendFactor;
  2917. /** !#en Specify the destination Blend Factor.
  2918. !#zh 指定目标的混合模式。 */
  2919. dstBlendFactor: BlendFactor;
  2920. /** !#en If set to true, the particle system will automatically start playing on onLoad.
  2921. !#zh 如果设置为 true 运行时会自动发射粒子。 */
  2922. playOnLoad: boolean;
  2923. /** !#en Indicate whether the owner node will be auto-removed when it has no particles left.
  2924. !#zh 粒子播放完毕后自动销毁所在的节点。 */
  2925. autoRemoveOnFinish: boolean;
  2926. /** !#en Indicate whether the particle system is activated.
  2927. !#zh 是否激活粒子。 */
  2928. active: boolean;
  2929. /** !#en Maximum particles of the system.
  2930. !#zh 粒子最大数量。 */
  2931. totalParticles: number;
  2932. /** !#en How many seconds the emitter wil run. -1 means 'forever'.
  2933. !#zh 发射器生存时间,单位秒,-1表示持续发射。 */
  2934. duration: number;
  2935. /** !#en Emission rate of the particles.
  2936. !#zh 每秒发射的粒子数目。 */
  2937. emissionRate: number;
  2938. /** !#en Life of each particle setter.
  2939. !#zh 粒子的运行时间。 */
  2940. life: number;
  2941. /** !#en Variation of life.
  2942. !#zh 粒子的运行时间变化范围。 */
  2943. lifeVar: number;
  2944. /** !#en Start color of each particle.
  2945. !#zh 粒子初始颜色。 */
  2946. startColor: Color;
  2947. /** !#en Variation of the start color.
  2948. !#zh 粒子初始颜色变化范围。 */
  2949. startColorVar: Color;
  2950. /** !#en Ending color of each particle.
  2951. !#zh 粒子结束颜色。 */
  2952. endColor: Color;
  2953. /** !#en Variation of the end color.
  2954. !#zh 粒子结束颜色变化范围。 */
  2955. endColorVar: Color;
  2956. /** !#en Angle of each particle setter.
  2957. !#zh 粒子角度。 */
  2958. angle: number;
  2959. /** !#en Variation of angle of each particle setter.
  2960. !#zh 粒子角度变化范围。 */
  2961. angleVar: number;
  2962. /** !#en Start size in pixels of each particle.
  2963. !#zh 粒子的初始大小。 */
  2964. startSize: number;
  2965. /** !#en Variation of start size in pixels.
  2966. !#zh 粒子初始大小的变化范围。 */
  2967. startSizeVar: number;
  2968. /** !#en End size in pixels of each particle.
  2969. !#zh 粒子结束时的大小。 */
  2970. endSize: number;
  2971. /** !#en Variation of end size in pixels.
  2972. !#zh 粒子结束大小的变化范围。 */
  2973. endSizeVar: number;
  2974. /** !#en Start angle of each particle.
  2975. !#zh 粒子开始自旋角度。 */
  2976. startSpin: number;
  2977. /** !#en Variation of start angle.
  2978. !#zh 粒子开始自旋角度变化范围。 */
  2979. startSpinVar: number;
  2980. /** !#en End angle of each particle.
  2981. !#zh 粒子结束自旋角度。 */
  2982. endSpin: number;
  2983. /** !#en Variation of end angle.
  2984. !#zh 粒子结束自旋角度变化范围。 */
  2985. endSpinVar: number;
  2986. /** !#en Source position of the emitter.
  2987. !#zh 发射器位置。 */
  2988. sourcePos: Vec2;
  2989. /** !#en Variation of source position.
  2990. !#zh 发射器位置的变化范围。(横向和纵向) */
  2991. posVar: Vec2;
  2992. /** !#en Particles movement type.
  2993. !#zh 粒子位置类型。 */
  2994. positionType: ParticleSystem.PositionType;
  2995. /** !#en Particles emitter modes.
  2996. !#zh 发射器类型。 */
  2997. emitterMode: ParticleSystem.EmitterMode;
  2998. /** !#en Gravity of the emitter.
  2999. !#zh 重力。 */
  3000. gravity: Vec2;
  3001. /** !#en Speed of the emitter.
  3002. !#zh 速度。 */
  3003. speed: number;
  3004. /** !#en Variation of the speed.
  3005. !#zh 速度变化范围。 */
  3006. speedVar: number;
  3007. /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode.
  3008. !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */
  3009. tangentialAccel: number;
  3010. /** !#en Variation of the tangential acceleration.
  3011. !#zh 每个粒子的切向加速度变化范围。 */
  3012. tangentialAccelVar: number;
  3013. /** !#en Acceleration of each particle. Only available in 'Gravity' mode.
  3014. !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */
  3015. radialAccel: number;
  3016. /** !#en Variation of the radial acceleration.
  3017. !#zh 粒子径向加速度变化范围。 */
  3018. radialAccelVar: number;
  3019. /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode.
  3020. !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */
  3021. rotationIsDir: boolean;
  3022. /** !#en Starting radius of the particles. Only available in 'Radius' mode.
  3023. !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */
  3024. startRadius: number;
  3025. /** !#en Variation of the starting radius.
  3026. !#zh 初始半径变化范围。 */
  3027. startRadiusVar: number;
  3028. /** !#en Ending radius of the particles. Only available in 'Radius' mode.
  3029. !#zh 结束半径,只有在半径模式下可用。 */
  3030. endRadius: number;
  3031. /** !#en Variation of the ending radius.
  3032. !#zh 结束半径变化范围。 */
  3033. endRadiusVar: number;
  3034. /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
  3035. !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */
  3036. rotatePerS: number;
  3037. /** !#en Variation of the degress to rotate a particle around the source pos per second.
  3038. !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */
  3039. rotatePerSVar: number;
  3040. /** !#en The Particle emitter lives forever.
  3041. !#zh 表示发射器永久存在 */
  3042. static DURATION_INFINITY: number;
  3043. /** !#en The starting size of the particle is equal to the ending size.
  3044. !#zh 表示粒子的起始大小等于结束大小。 */
  3045. static START_SIZE_EQUAL_TO_END_SIZE: number;
  3046. /** !#en The starting radius of the particle is equal to the ending radius.
  3047. !#zh 表示粒子的起始半径等于结束半径。 */
  3048. static START_RADIUS_EQUAL_TO_END_RADIUS: number;
  3049. /**
  3050. !#en Add a particle to the emitter.
  3051. !#zh 添加一个粒子到发射器中。
  3052. */
  3053. addParticle(): boolean;
  3054. /**
  3055. !#en Stop emitting particles. Running particles will continue to run until they die.
  3056. !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。
  3057. @example
  3058. ```js
  3059. // stop particle system.
  3060. myParticleSystem.stopSystem();
  3061. ```
  3062. */
  3063. stopSystem(): void;
  3064. /**
  3065. !#en Kill all living particles.
  3066. !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。
  3067. @example
  3068. ```js
  3069. // play particle system.
  3070. myParticleSystem.resetSystem();
  3071. ```
  3072. */
  3073. resetSystem(): void;
  3074. /**
  3075. !#en Whether or not the system is full.
  3076. !#zh 发射器中粒子是否大于等于设置的总粒子数量。
  3077. */
  3078. isFull(): boolean;
  3079. /**
  3080. !#en
  3081. <p> Sets a new CCSpriteFrame as particle.</br>
  3082. WARNING: this method is experimental. Use setTextureWithRect instead.
  3083. </p>
  3084. !#zh
  3085. <p> 设置一个新的精灵帧为粒子。</br>
  3086. 警告:这个函数只是试验,请使用 setTextureWithRect 实现。
  3087. </p>
  3088. @param spriteFrame spriteFrame
  3089. */
  3090. setDisplayFrame(spriteFrame: SpriteFrame): void;
  3091. /**
  3092. !#en Sets a new texture with a rect. The rect is in texture position and size.
  3093. !#zh 设置一张新贴图和关联的矩形。
  3094. @param texture texture
  3095. @param rect rect
  3096. */
  3097. setTextureWithRect(texture: Texture2D, rect: Rect): void;
  3098. }
  3099. /** !#en
  3100. <p>
  3101. ATTENTION: USE cc.director INSTEAD OF cc.Director.<br/>
  3102. cc.director is a singleton object which manage your game's logic flow.<br/>
  3103. Since the cc.director is a singleton, you don't need to call any constructor or create functions,<br/>
  3104. the standard way to use it is by calling:<br/>
  3105. - cc.director.methodName(); <br/>
  3106. It creates and handle the main Window and manages how and when to execute the Scenes.<br/>
  3107. <br/>
  3108. The cc.director is also responsible for:<br/>
  3109. - initializing the OpenGL context<br/>
  3110. - setting the OpenGL pixel format (default on is RGB565)<br/>
  3111. - setting the OpenGL buffer depth (default on is 0-bit)<br/>
  3112. - setting the color for clear screen (default one is BLACK)<br/>
  3113. - setting the projection (default one is 3D)<br/>
  3114. - setting the orientation (default one is Portrait)<br/>
  3115. <br/>
  3116. <br/>
  3117. The cc.director also sets the default OpenGL context:<br/>
  3118. - GL_TEXTURE_2D is enabled<br/>
  3119. - GL_VERTEX_ARRAY is enabled<br/>
  3120. - GL_COLOR_ARRAY is enabled<br/>
  3121. - GL_TEXTURE_COORD_ARRAY is enabled<br/>
  3122. </p>
  3123. <p>
  3124. cc.director also synchronizes timers with the refresh rate of the display.<br/>
  3125. Features and Limitations:<br/>
  3126. - Scheduled timers & drawing are synchronizes with the refresh rate of the display<br/>
  3127. - Only supports animation intervals of 1/60 1/30 & 1/15<br/>
  3128. </p>
  3129. !#zh
  3130. <p>
  3131. 注意:用 cc.director 代替 cc.Director。<br/>
  3132. cc.director 一个管理你的游戏的逻辑流程的单例对象。<br/>
  3133. 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,<br/>
  3134. 使用它的标准方法是通过调用:<br/>
  3135. - cc.director.methodName();
  3136. <br/>
  3137. 它创建和处理主窗口并且管理什么时候执行场景。<br/>
  3138. <br/>
  3139. cc.director 还负责:<br/>
  3140. - 初始化 OpenGL 环境。<br/>
  3141. - 设置OpenGL像素格式。(默认是 RGB565)<br/>
  3142. - 设置OpenGL缓冲区深度 (默认是 0-bit)<br/>
  3143. - 设置空白场景的颜色 (默认是 黑色)<br/>
  3144. - 设置投影 (默认是 3D)<br/>
  3145. - 设置方向 (默认是 Portrait)<br/>
  3146. <br/>
  3147. cc.director 设置了 OpenGL 默认环境 <br/>
  3148. - GL_TEXTURE_2D 启用。<br/>
  3149. - GL_VERTEX_ARRAY 启用。<br/>
  3150. - GL_COLOR_ARRAY 启用。<br/>
  3151. - GL_TEXTURE_COORD_ARRAY 启用。<br/>
  3152. </p>
  3153. <p>
  3154. cc.director 也同步定时器与显示器的刷新速率。
  3155. <br/>
  3156. 特点和局限性: <br/>
  3157. - 将计时器 & 渲染与显示器的刷新频率同步。<br/>
  3158. - 只支持动画的间隔 1/60 1/30 & 1/15。<br/>
  3159. </p> */
  3160. export class Director extends EventTarget {
  3161. /**
  3162. !#en
  3163. Converts an OpenGL coordinate to a view coordinate<br/>
  3164. Useful to convert node points to window points for calls such as glScissor<br/>
  3165. Implementation can be found in CCDirectorWebGL.
  3166. !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。
  3167. @param glPoint glPoint
  3168. */
  3169. convertToUI(glPoint: Vec2): Vec2;
  3170. /**
  3171. !#en
  3172. Returns the size of the WebGL view in points.<br/>
  3173. It takes into account any possible rotation (device orientation) of the window.
  3174. !#zh 获取视图的大小,以点为单位。
  3175. */
  3176. getWinSize(): Size;
  3177. /**
  3178. !#en
  3179. Returns the size of the OpenGL view in pixels.<br/>
  3180. It takes into account any possible rotation (device orientation) of the window.<br/>
  3181. On Mac winSize and winSizeInPixels return the same value.
  3182. (The pixel here refers to the resource resolution. If you want to get the physics resolution of device, you need to use cc.view.getFrameSize())
  3183. !#zh
  3184. 获取视图大小,以像素为单位(这里的像素指的是资源分辨率。
  3185. 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize())
  3186. */
  3187. getWinSizeInPixels(): Size;
  3188. /**
  3189. !#en Returns the visible size of the running scene.
  3190. !#zh 获取运行场景的可见大小。
  3191. */
  3192. getVisibleSize(): Size;
  3193. /**
  3194. !#en Returns the visible origin of the running scene.
  3195. !#zh 获取视图在游戏内容中的坐标原点。
  3196. */
  3197. getVisibleOrigin(): Vec2;
  3198. /**
  3199. !#en Pause the director's ticker, only involve the game logic execution.
  3200. It won't pause the rendering process nor the event manager.
  3201. If you want to pause the entier game including rendering, audio and event,
  3202. please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}
  3203. !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。
  3204. 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。
  3205. */
  3206. pause(): void;
  3207. /**
  3208. !#en
  3209. Run a scene. Replaces the running scene with a new one or enter the first scene.<br/>
  3210. The new scene will be launched immediately.
  3211. !#zh 立刻切换指定场景。
  3212. @param scene The need run scene.
  3213. @param onBeforeLoadScene The function invoked at the scene before loading.
  3214. @param onLaunched The function invoked at the scene after launch.
  3215. */
  3216. runSceneImmediate(scene: Scene, onBeforeLoadScene?: Function, onLaunched?: Function): void;
  3217. /**
  3218. !#en Loads the scene by its name.
  3219. !#zh 通过场景名称进行加载场景。
  3220. @param sceneName The name of the scene to load.
  3221. @param onLaunched callback, will be called after scene launched.
  3222. */
  3223. loadScene(sceneName: string, onLaunched?: Function): boolean;
  3224. /**
  3225. !#en
  3226. Preloads the scene to reduces loading time. You can call this method at any time you want.
  3227. After calling this method, you still need to launch the scene by `cc.director.loadScene`.
  3228. It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not
  3229. yet finished, the scene will be launched after loaded automatically.
  3230. !#zh 预加载场景,你可以在任何时候调用这个方法。
  3231. 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。
  3232. 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。
  3233. @param sceneName The name of the scene to preload.
  3234. @param onLoaded callback, will be called after scene loaded.
  3235. */
  3236. preloadScene(sceneName: string, onLoaded?: (error: Error) => void): void;
  3237. /**
  3238. !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen.
  3239. !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。
  3240. */
  3241. resume(): void;
  3242. /**
  3243. !#en
  3244. Enables or disables WebGL depth test.<br/>
  3245. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js
  3246. !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。
  3247. @param on on
  3248. */
  3249. setDepthTest(on: boolean): void;
  3250. /**
  3251. !#en
  3252. Set color for clear screen.<br/>
  3253. (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js)
  3254. !#zh
  3255. 设置场景的默认擦除颜色。<br/>
  3256. 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。
  3257. @param clearColor clearColor
  3258. */
  3259. setClearColor(clearColor: Color): void;
  3260. /**
  3261. !#en
  3262. Sets an OpenGL projection.<br/>
  3263. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3264. !#zh 设置 OpenGL 投影。
  3265. @param projection projection
  3266. */
  3267. setProjection(projection: number): void;
  3268. /**
  3269. !#en
  3270. Update the view port.<br/>
  3271. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3272. !#zh 设置视窗(请不要主动调用这个接口,除非你知道你在做什么)。
  3273. */
  3274. setViewport(): void;
  3275. /**
  3276. !#en
  3277. Sets an OpenGL projection.<br/>
  3278. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3279. !#zh 获取 OpenGL 投影。
  3280. */
  3281. getProjection(): number;
  3282. /**
  3283. !#en
  3284. Enables/disables OpenGL alpha blending.<br/>
  3285. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3286. !#zh 启用/禁用 透明度融合。
  3287. @param on on
  3288. */
  3289. setAlphaBlending(on: boolean): void;
  3290. /**
  3291. !#en
  3292. Returns whether or not the replaced scene will receive the cleanup message.<br/>
  3293. If the new scene is pushed, then the old scene won't receive the "cleanup" message.<br/>
  3294. If the new scene replaces the old one, the it will receive the "cleanup" message.
  3295. !#zh
  3296. 更换场景时是否接收清理消息。<br>
  3297. 如果新场景是采用 push 方式进入的,那么旧的场景将不会接收到 “cleanup” 消息。<br/>
  3298. 如果新场景取代旧的场景,它将会接收到 “cleanup” 消息。</br>
  3299. */
  3300. isSendCleanupToScene(): boolean;
  3301. /**
  3302. !#en Returns current logic Scene.
  3303. !#zh 获取当前逻辑场景。
  3304. @example
  3305. ```js
  3306. // This will help you to get the Canvas node in scene
  3307. cc.director.getScene().getChildByName('Canvas');
  3308. ```
  3309. */
  3310. getScene(): Scene;
  3311. /**
  3312. !#en Returns the FPS value.
  3313. !#zh 获取单位帧执行时间。
  3314. */
  3315. getAnimationInterval(): number;
  3316. /**
  3317. !#en Returns whether or not to display the FPS informations.
  3318. !#zh 获取是否显示 FPS 信息。
  3319. */
  3320. isDisplayStats(): boolean;
  3321. /**
  3322. !#en Sets whether display the FPS on the bottom-left corner.
  3323. !#zh 设置是否在左下角显示 FPS。
  3324. @param displayStats displayStats
  3325. */
  3326. setDisplayStats(displayStats: boolean): void;
  3327. /**
  3328. !#en Returns whether next delta time equals to zero.
  3329. !#zh 返回下一个 “delta time” 是否等于零。
  3330. */
  3331. isNextDeltaTimeZero(): boolean;
  3332. /**
  3333. !#en Returns whether or not the Director is paused.
  3334. !#zh 是否处于暂停状态。
  3335. */
  3336. isPaused(): boolean;
  3337. /**
  3338. !#en Returns how many frames were called since the director started.
  3339. !#zh 获取 director 启动以来游戏运行的总帧数。
  3340. */
  3341. getTotalFrames(): number;
  3342. /**
  3343. !#en Returns the cc.Scheduler associated with this director.
  3344. !#zh 获取和 director 相关联的 cc.Scheduler。
  3345. */
  3346. getScheduler(): Scheduler;
  3347. /**
  3348. !#en Sets the cc.Scheduler associated with this director.
  3349. !#zh 设置和 director 相关联的 cc.Scheduler。
  3350. @param scheduler scheduler
  3351. */
  3352. setScheduler(scheduler: Scheduler): void;
  3353. /**
  3354. !#en Returns the cc.ActionManager associated with this director.
  3355. !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。
  3356. */
  3357. getActionManager(): ActionManager;
  3358. /**
  3359. !#en Sets the cc.ActionManager associated with this director.
  3360. !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。
  3361. @param actionManager actionManager
  3362. */
  3363. setActionManager(actionManager: ActionManager): void;
  3364. /**
  3365. Returns the cc.CollisionManager associated with this director.
  3366. */
  3367. getCollisionManager(): CollisionManager;
  3368. /**
  3369. Returns the cc.PhysicsManager associated with this director.
  3370. */
  3371. getPhysicsManager(): PhysicsManager;
  3372. /**
  3373. !#en Returns the delta time since last frame.
  3374. !#zh 获取上一帧的 “delta time”。
  3375. */
  3376. getDeltaTime(): number;
  3377. /** !#en The event projection changed of cc.Director.
  3378. !#zh cc.Director 投影变化的事件。 */
  3379. static EVENT_PROJECTION_CHANGED: string;
  3380. /** !#en The event which will be triggered before loading a new scene.
  3381. !#zh 加载新场景之前所触发的事件。 */
  3382. static EVENT_BEFORE_SCENE_LOADING: string;
  3383. /** !#en The event which will be triggered before launching a new scene.
  3384. !#zh 运行新场景之前所触发的事件。 */
  3385. static EVENT_BEFORE_SCENE_LAUNCH: string;
  3386. /** !#en The event which will be triggered after launching a new scene.
  3387. !#zh 运行新场景之后所触发的事件。 */
  3388. static EVENT_AFTER_SCENE_LAUNCH: string;
  3389. /** !#en The event which will be triggered at the beginning of every frame.
  3390. !#zh 每个帧的开始时所触发的事件。 */
  3391. static EVENT_BEFORE_UPDATE: string;
  3392. /** !#en The event which will be triggered after engine and components update logic.
  3393. !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。 */
  3394. static EVENT_AFTER_UPDATE: string;
  3395. /** !#en The event which will be triggered before visiting the rendering scene graph.
  3396. !#zh 访问渲染场景树之前所触发的事件。 */
  3397. static EVENT_BEFORE_VISIT: string;
  3398. /** !#en
  3399. The event which will be triggered after visiting the rendering scene graph,
  3400. the render queue is ready but not rendered at this point.
  3401. !#zh
  3402. 访问渲染场景图之后所触发的事件,渲染队列已准备就绪,但在这一时刻还没有呈现在画布上。 */
  3403. static EVENT_AFTER_VISIT: string;
  3404. /** !#en The event which will be triggered after the rendering process.
  3405. !#zh 渲染过程之后所触发的事件。 */
  3406. static EVENT_AFTER_DRAW: string;
  3407. /** Constant for 2D projection (orthogonal projection) */
  3408. static PROJECTION_2D: number;
  3409. /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */
  3410. static PROJECTION_3D: number;
  3411. /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */
  3412. static PROJECTION_CUSTOM: number;
  3413. /** Constant for default projection of cc.Director, default projection is 2D projection */
  3414. static PROJECTION_DEFAULT: number;
  3415. }
  3416. /** !#en cc.game is the singleton object for game related functions.
  3417. !#zh cc.game 是 Game 的实例,用来驱动整个游戏。 */
  3418. export class Game extends EventTarget {
  3419. /** !#en Event triggered when game hide to background.
  3420. Please note that this event is not 100% guaranteed to be fired on Web platform,
  3421. on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event.
  3422. !#zh 游戏进入后台时触发的事件。
  3423. 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。
  3424. 在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */
  3425. EVENT_HIDE: string;
  3426. /** Event triggered when game back to foreground
  3427. Please note that this event is not 100% guaranteed to be fired on Web platform,
  3428. on native platforms, it corresponds to enter foreground event.
  3429. !#zh 游戏进入前台运行时触发的事件。
  3430. 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。
  3431. 在原生平台,它对应的是应用被切换到前台事件。 */
  3432. EVENT_SHOW: string;
  3433. /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */
  3434. EVENT_GAME_INITED: string;
  3435. /** Event triggered after renderer inited, at this point you will be able to use the render context */
  3436. EVENT_RENDERER_INITED: string;
  3437. /** Key of config */
  3438. CONFIG_KEY: any;
  3439. /** !#en The outer frame of the game canvas, parent of cc.container.
  3440. !#zh 游戏画布的外框,cc.container 的父类。 */
  3441. frame: any;
  3442. /** !#en The container of game canvas, equals to cc.container.
  3443. !#zh 游戏画布的容器。 */
  3444. container: HTMLDivElement;
  3445. /** !#en The canvas of the game, equals to cc._canvas.
  3446. !#zh 游戏的画布。 */
  3447. canvas: HTMLCanvasElement;
  3448. /** !#en
  3449. The current game configuration, including:<br/>
  3450. 1. debugMode<br/>
  3451. "debugMode" possible values :<br/>
  3452. 0 - No message will be printed. <br/>
  3453. 1 - cc.error, cc.assert, cc.warn, cc.log will print in console. <br/>
  3454. 2 - cc.error, cc.assert, cc.warn will print in console. <br/>
  3455. 3 - cc.error, cc.assert will print in console. <br/>
  3456. 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.<br/>
  3457. 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. <br/>
  3458. 6 - cc.error, cc.assert will print on canvas, available only on web. <br/>
  3459. 2. showFPS<br/>
  3460. Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.<br/>
  3461. 3. exposeClassName<br/>
  3462. Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.<br/>
  3463. 4. frameRate<br/>
  3464. "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.<br/>
  3465. 5. id<br/>
  3466. "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.<br/>
  3467. 6. renderMode<br/>
  3468. "renderMode" sets the renderer type, only useful on web :<br/>
  3469. 0 - Automatically chosen by engine<br/>
  3470. 1 - Forced to use canvas renderer<br/>
  3471. 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers<br/>
  3472. 7. scenes<br/>
  3473. "scenes" include available scenes in the current bundle.<br/>
  3474. <br/>
  3475. Please DO NOT modify this object directly, it won't have any effect.<br/>
  3476. !#zh
  3477. 当前的游戏配置,包括: <br/>
  3478. 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略) <br/>
  3479. "debugMode" 各种设置选项的意义。 <br/>
  3480. 0 - 没有消息被打印出来。 <br/>
  3481. 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。 <br/>
  3482. 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。 <br/>
  3483. 3 - cc.error,cc.assert 将打印在 console 中。 <br/>
  3484. 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3485. 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3486. 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3487. 2. showFPS(显示 FPS) <br/>
  3488. 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。 <br/>
  3489. 3. exposeClassName <br/>
  3490. 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。 <br/>
  3491. 4. frameRate (帧率) <br/>
  3492. “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。 <br/>
  3493. 5. id <br/>
  3494. "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。 <br/>
  3495. 6. renderMode(渲染模式) <br/>
  3496. “renderMode” 设置渲染器类型,仅适用于 web 端: <br/>
  3497. 0 - 通过引擎自动选择。 <br/>
  3498. 1 - 强制使用 canvas 渲染。
  3499. 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。 <br/>
  3500. 7. scenes <br/>
  3501. “scenes” 当前包中可用场景。 <br/>
  3502. <br/>
  3503. 注意:请不要直接修改这个对象,它不会有任何效果。 */
  3504. config: any;
  3505. /**
  3506. !#en Callback when the scripts of engine have been load.
  3507. !#zh 当引擎完成启动后的回调函数。
  3508. */
  3509. onStart(): void;
  3510. /**
  3511. !#en Set frameRate of game.
  3512. !#zh 设置游戏帧率。
  3513. @param frameRate frameRate
  3514. */
  3515. setFrameRate(frameRate: number): void;
  3516. /**
  3517. !#en Run the game frame by frame.
  3518. !#zh 执行一帧游戏循环。
  3519. */
  3520. step(): void;
  3521. /**
  3522. !#en Pause the game main loop. This will pause:
  3523. game logic execution, rendering process, event manager, background music and all audio effects.
  3524. This is different with cc.director.pause which only pause the game logic execution.
  3525. !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。
  3526. */
  3527. pause(): void;
  3528. /**
  3529. !#en Resume the game from pause. This will resume:
  3530. game logic execution, rendering process, event manager, background music and all audio effects.
  3531. !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。
  3532. */
  3533. resume(): void;
  3534. /**
  3535. !#en Check whether the game is paused.
  3536. !#zh 判断游戏是否暂停。
  3537. */
  3538. isPaused(): boolean;
  3539. /**
  3540. !#en Restart game.
  3541. !#zh 重新开始游戏
  3542. */
  3543. restart(): void;
  3544. /**
  3545. !#en End game, it will close the game window
  3546. !#zh 退出游戏
  3547. */
  3548. end(): void;
  3549. /**
  3550. !#en Prepare game.
  3551. !#zh 准备引擎,请不要直接调用这个函数。
  3552. @param cb cb
  3553. */
  3554. prepare(cb: Function): void;
  3555. /**
  3556. !#en Run game with configuration object and onStart function.
  3557. !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。
  3558. @param config Pass configuration object or onStart function
  3559. @param onStart function to be executed after game initialized
  3560. */
  3561. run(config?: any|Function, onStart?: Function): void;
  3562. /**
  3563. !#en
  3564. Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.<br/>
  3565. The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect.
  3566. !#zh
  3567. 声明常驻根节点,该节点不会被在场景切换中被销毁。<br/>
  3568. 目标节点必须位于为层级的根节点,否则无效。
  3569. @param node The node to be made persistent
  3570. */
  3571. addPersistRootNode(node: Node): void;
  3572. /**
  3573. !#en Remove a persistent root node.
  3574. !#zh 取消常驻根节点。
  3575. @param node The node to be removed from persistent node list
  3576. */
  3577. removePersistRootNode(node: Node): void;
  3578. /**
  3579. !#en Check whether the node is a persistent root node.
  3580. !#zh 检查节点是否是常驻根节点。
  3581. @param node The node to be checked
  3582. */
  3583. isPersistRootNode(node: Node): boolean;
  3584. }
  3585. /** !#en
  3586. Class of all entities in Cocos Creator scenes.<br/>
  3587. Node also inherits from {{#crossLink "EventTarget"}}Event Target{{/crossLink}}, it permits Node to dispatch events.
  3588. For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}}
  3589. !#zh
  3590. Cocos Creator 场景中的所有节点类。节点也继承了 {{#crossLink "EventTarget"}}EventTarget{{/crossLink}},它允许节点发送事件。<br/>
  3591. 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */
  3592. export class Node extends _BaseNode {
  3593. /** !#en
  3594. Group index of node.<br/>
  3595. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  3596. !#zh
  3597. 节点的分组索引。<br/>
  3598. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  3599. groupIndex: number;
  3600. /** !#en
  3601. Group of node.<br/>
  3602. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  3603. !#zh
  3604. 节点的分组。<br/>
  3605. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  3606. group: string;
  3607. /** !#en The position (x, y) of the node in its parent's coordinates.
  3608. !#zh 节点在父节点坐标系中的位置(x, y)。 */
  3609. position: Vec2;
  3610. /** !#en x axis position of node.
  3611. !#zh 节点 X 轴坐标。 */
  3612. x: number;
  3613. /** !#en y axis position of node.
  3614. !#zh 节点 Y 轴坐标。 */
  3615. y: number;
  3616. /** !#en Rotation of node.
  3617. !#zh 该节点旋转角度。 */
  3618. rotation: number;
  3619. /** !#en Rotation on x axis.
  3620. !#zh 该节点 X 轴旋转角度。 */
  3621. rotationX: number;
  3622. /** !#en Rotation on y axis.
  3623. !#zh 该节点 Y 轴旋转角度。 */
  3624. rotationY: number;
  3625. /** !#en Scale on x axis.
  3626. !#zh 节点 X 轴缩放。 */
  3627. scaleX: number;
  3628. /** !#en Scale on y axis.
  3629. !#zh 节点 Y 轴缩放。 */
  3630. scaleY: number;
  3631. /** !#en Skew x
  3632. !#zh 该节点 Y 轴倾斜角度。 */
  3633. skewX: number;
  3634. /** !#en Skew y
  3635. !#zh 该节点 X 轴倾斜角度。 */
  3636. skewY: number;
  3637. /** !#en Opacity of node, default value is 255.
  3638. !#zh 节点透明度,默认值为 255。 */
  3639. opacity: number;
  3640. /** !#en Indicate whether node's opacity value affect its child nodes, default value is true.
  3641. !#zh 节点的不透明度值是否影响其子节点,默认值为 true。 */
  3642. cascadeOpacity: boolean;
  3643. /** !#en Color of node, default value is white: (255, 255, 255).
  3644. !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */
  3645. color: Color;
  3646. /** !#en Anchor point's position on x axis.
  3647. !#zh 节点 X 轴锚点位置。 */
  3648. anchorX: number;
  3649. /** !#en Anchor point's position on y axis.
  3650. !#zh 节点 Y 轴锚点位置。 */
  3651. anchorY: number;
  3652. /** !#en Width of node.
  3653. !#zh 节点宽度。 */
  3654. width: number;
  3655. /** !#en Height of node.
  3656. !#zh 节点高度。 */
  3657. height: number;
  3658. /** !#en Z order in depth which stands for the drawing order.
  3659. !#zh 该节点渲染排序的 Z 轴深度。 */
  3660. zIndex: number;
  3661. /**
  3662. @param name name
  3663. */
  3664. constructor(name?: string);
  3665. /**
  3666. !#en
  3667. Register a callback of a specific event type on Node.<br/>
  3668. Use this method to register touch or mouse event permit propagation based on scene graph,
  3669. you can propagate the event to the parents or swallow it by calling stopPropagation on the event.<br/>
  3670. It's the recommended way to register touch/mouse event for Node,
  3671. please do not use cc.eventManager directly for Node.
  3672. !#zh
  3673. 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。<br/>
  3674. 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。<br/>
  3675. 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。
  3676. @param type A string representing the event type to listen for.<br>
  3677. See {{#crossLink "Node/position-changed:event"}}Node Events{{/crossLink}} for all builtin events.
  3678. @param callback The callback that will be invoked when the event is dispatched.
  3679. The callback is ignored if it is a duplicate (the callbacks are unique).
  3680. @param target The target (this object) to invoke the callback, can be null
  3681. @param useCapture When set to true, the capture argument prevents callback
  3682. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  3683. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  3684. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  3685. @example
  3686. ```js
  3687. this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass.
  3688. node.on(cc.Node.EventType.TOUCH_START, callback, this.node);
  3689. node.on(cc.Node.EventType.TOUCH_MOVE, callback, this.node);
  3690. node.on(cc.Node.EventType.TOUCH_END, callback, this.node);
  3691. node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this.node);
  3692. node.on("anchor-changed", callback, this);
  3693. ```
  3694. */
  3695. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  3696. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  3697. /**
  3698. !#en
  3699. Removes the callback previously registered with the same type, callback, target and or useCapture.
  3700. This method is merely an alias to removeEventListener.
  3701. !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。
  3702. @param type A string representing the event type being removed.
  3703. @param callback The callback to remove.
  3704. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  3705. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  3706. If not specified, useCapture defaults to false. If a callback was registered twice,
  3707. one with capture and one without, each must be removed separately. Removal of a capturing callback
  3708. does not affect a non-capturing version of the same listener, and vice versa.
  3709. @example
  3710. ```js
  3711. this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this);
  3712. node.off(cc.Node.EventType.TOUCH_START, callback, this.node);
  3713. node.off("anchor-changed", callback, this);
  3714. ```
  3715. */
  3716. off(type: string, callback: Function, target?: any, useCapture?: boolean): void;
  3717. /**
  3718. !#en Removes all callbacks previously registered with the same target.
  3719. !#zh 移除目标上的所有注册事件。
  3720. @param target The target to be searched for all related callbacks
  3721. @example
  3722. ```js
  3723. node.targetOff(target);
  3724. ```
  3725. */
  3726. targetOff(target: any): void;
  3727. /**
  3728. !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events.
  3729. If recursive is set to true, then this API will pause the node system events for the node and all nodes in its sub node tree.
  3730. Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/
  3731. !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。
  3732. 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。
  3733. 参考:http://cocos.com/docs/creator/scripting/internal-events.html
  3734. @param recursive Whether to pause node system events on the sub node tree.
  3735. @example
  3736. ```js
  3737. node.pauseSystemEvents(true);
  3738. ```
  3739. */
  3740. pauseSystemEvents(recursive: boolean): void;
  3741. /**
  3742. !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events.
  3743. If recursive is set to true, then this API will resume the node system events for the node and all nodes in its sub node tree.
  3744. Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/
  3745. !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。
  3746. 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。
  3747. 参考:http://cocos.com/docs/creator/scripting/internal-events.html
  3748. @param recursive Whether to resume node system events on the sub node tree.
  3749. @example
  3750. ```js
  3751. node.resumeSystemEvents(true);
  3752. ```
  3753. */
  3754. resumeSystemEvents(recursive: boolean): void;
  3755. /**
  3756. !#en
  3757. Executes an action, and returns the action that is executed.<br/>
  3758. The node becomes the action's target. Refer to cc.Action's getTarget() <br/>
  3759. Calling runAction while the node is not active won't have any effect. <br/>
  3760. Note:You shouldn't modify the action after runAction, that won't take any effect.<br/>
  3761. if you want to modify, when you define action plus.
  3762. !#zh
  3763. 执行并返回该执行的动作。该节点将会变成动作的目标。<br/>
  3764. 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。<br/>
  3765. 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。
  3766. @param action action
  3767. @example
  3768. ```js
  3769. var action = cc.scaleTo(0.2, 1, 0.6);
  3770. node.runAction(action);
  3771. node.runAction(action).repeatForever(); // fail
  3772. node.runAction(action.repeatForever()); // right
  3773. ```
  3774. */
  3775. runAction(action: Action): Action;
  3776. /**
  3777. !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`.
  3778. !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。
  3779. @example
  3780. ```js
  3781. node.pauseAllActions();
  3782. ```
  3783. */
  3784. pauseAllActions(): void;
  3785. /**
  3786. !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`.
  3787. !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。
  3788. @example
  3789. ```js
  3790. node.resumeAllActions();
  3791. ```
  3792. */
  3793. resumeAllActions(): void;
  3794. /**
  3795. !#en Stops and removes all actions from the running action list .
  3796. !#zh 停止并且移除所有正在运行的动作列表。
  3797. @example
  3798. ```js
  3799. node.stopAllActions();
  3800. ```
  3801. */
  3802. stopAllActions(): void;
  3803. /**
  3804. !#en Stops and removes an action from the running action list.
  3805. !#zh 停止并移除指定的动作。
  3806. @param action An action object to be removed.
  3807. @example
  3808. ```js
  3809. var action = cc.scaleTo(0.2, 1, 0.6);
  3810. node.stopAction(action);
  3811. ```
  3812. */
  3813. stopAction(action: Action): void;
  3814. /**
  3815. !#en Removes an action from the running action list by its tag.
  3816. !#zh 停止并且移除指定标签的动作。
  3817. @param tag A tag that indicates the action to be removed.
  3818. @example
  3819. ```js
  3820. node.stopAction(1);
  3821. ```
  3822. */
  3823. stopActionByTag(tag: number): void;
  3824. /**
  3825. !#en Returns an action from the running action list by its tag.
  3826. !#zh 通过标签获取指定动作。
  3827. @param tag tag
  3828. @example
  3829. ```js
  3830. var action = node.getActionByTag(1);
  3831. ```
  3832. */
  3833. getActionByTag(tag: number): Action;
  3834. /**
  3835. !#en
  3836. Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).<br/>
  3837. Composable actions are counted as 1 action. Example:<br/>
  3838. If you are running 1 Sequence of 7 actions, it will return 1. <br/>
  3839. If you are running 7 Sequences of 2 actions, it will return 7.</p>
  3840. !#zh
  3841. 获取运行着的动作加上正在调度运行的动作的总数。<br/>
  3842. 例如:<br/>
  3843. - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。<br/>
  3844. - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。<br/>
  3845. @example
  3846. ```js
  3847. var count = node.getNumberOfRunningActions();
  3848. cc.log("Running Action Count: " + count);
  3849. ```
  3850. */
  3851. getNumberOfRunningActions(): number;
  3852. /**
  3853. !#en Returns a copy of the position (x, y) of the node in its parent's coordinates.
  3854. !#zh 获取节点在父节点坐标系中的位置(x, y)。
  3855. @example
  3856. ```js
  3857. cc.log("Node Position: " + node.getPosition());
  3858. ```
  3859. */
  3860. getPosition(): Vec2;
  3861. /**
  3862. !#en
  3863. Sets the position (x, y) of the node in its parent's coordinates.<br/>
  3864. Usually we use cc.v2(x, y) to compose cc.Vec2 object.<br/>
  3865. and Passing two numbers (x, y) is more efficient than passing cc.Vec2 object.
  3866. !#zh
  3867. 设置节点在父节点坐标系中的位置。<br/>
  3868. 可以通过两种方式设置坐标点:<br/>
  3869. 1. 传入 2 个数值 x 和 y。<br/>
  3870. 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象。
  3871. @param newPosOrX X coordinate for position or the position (x, y) of the node in coordinates
  3872. @param y Y coordinate for position
  3873. @example
  3874. ```js
  3875. node.setPosition(cc.v2(0, 0));
  3876. node.setPosition(0, 0);
  3877. ```
  3878. */
  3879. setPosition(newPosOrX: Vec2|number, y?: number): void;
  3880. /**
  3881. !#en
  3882. Returns the scale factor of the node.
  3883. Assertion will fail when _scaleX != _scaleY.
  3884. !#zh 获取节点的缩放。当 X 轴和 Y 轴有相同的缩放数值时。
  3885. @example
  3886. ```js
  3887. cc.log("Node Scale: " + node.getScale());
  3888. ```
  3889. */
  3890. getScale(): number;
  3891. /**
  3892. !#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.
  3893. !#zh 设置节点的缩放比例,默认值为 1.0。这个函数可以在同一时间修改 X 和 Y 缩放。
  3894. @param scaleX scaleX or scale
  3895. @param scaleY scaleY
  3896. @example
  3897. ```js
  3898. node.setScale(cc.v2(1, 1));
  3899. node.setScale(1, 1);
  3900. ```
  3901. */
  3902. setScale(scaleX: number|Vec2, scaleY?: number): void;
  3903. /**
  3904. !#en
  3905. Returns a copy the untransformed size of the node. <br/>
  3906. The contentSize remains the same no matter the node is scaled or rotated.<br/>
  3907. All nodes has a size. Layer and Scene has the same size of the screen by default. <br/>
  3908. !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。
  3909. @param ignoreSizeProvider true if you need to get the original size of the node
  3910. @example
  3911. ```js
  3912. cc.log("Content Size: " + node.getContentSize());
  3913. ```
  3914. */
  3915. getContentSize(ignoreSizeProvider?: boolean): Size;
  3916. /**
  3917. !#en
  3918. Sets the untransformed size of the node.<br/>
  3919. The contentSize remains the same no matter the node is scaled or rotated.<br/>
  3920. All nodes has a size. Layer and Scene has the same size of the screen.
  3921. !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。
  3922. @param size The untransformed size of the node or The untransformed size's width of the node.
  3923. @param height The untransformed size's height of the node.
  3924. @example
  3925. ```js
  3926. node.setContentSize(cc.size(100, 100));
  3927. node.setContentSize(100, 100);
  3928. ```
  3929. */
  3930. setContentSize(size: Size|number, height?: number): void;
  3931. /**
  3932. !#en
  3933. Set whether color should be changed with the opacity value,
  3934. useless in ccsg.Node, but this function is override in some class to have such behavior.
  3935. !#zh 设置更改透明度时是否修改RGB值,
  3936. @param opacityValue opacityValue
  3937. @example
  3938. ```js
  3939. node.setOpacityModifyRGB(true);
  3940. ```
  3941. */
  3942. setOpacityModifyRGB(opacityValue: boolean): void;
  3943. /**
  3944. !#en Get whether color should be changed with the opacity value.
  3945. !#zh 更改透明度时是否修改RGB值。
  3946. @example
  3947. ```js
  3948. var hasChange = node.isOpacityModifyRGB();
  3949. ```
  3950. */
  3951. isOpacityModifyRGB(): boolean;
  3952. /**
  3953. !#en
  3954. Returns a copy of the anchor point.<br/>
  3955. Anchor point is the point around which all transformations and positioning manipulations take place.<br/>
  3956. It's like a pin in the node where it is "attached" to its parent. <br/>
  3957. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. <br/>
  3958. But you can use values higher than (1,1) and lower than (0,0) too. <br/>
  3959. The default anchor point is (0.5,0.5), so it starts at the center of the node.
  3960. !#zh
  3961. 获取节点锚点,用百分比表示。<br/>
  3962. 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
  3963. 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
  3964. 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
  3965. 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
  3966. 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
  3967. @example
  3968. ```js
  3969. cc.log("Node AnchorPoint: " + node.getAnchorPoint());
  3970. ```
  3971. */
  3972. getAnchorPoint(): Vec2;
  3973. /**
  3974. !#en
  3975. Sets the anchor point in percent. <br/>
  3976. anchor point is the point around which all transformations and positioning manipulations take place. <br/>
  3977. It's like a pin in the node where it is "attached" to its parent. <br/>
  3978. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.<br/>
  3979. But you can use values higher than (1,1) and lower than (0,0) too.<br/>
  3980. The default anchor point is (0.5,0.5), so it starts at the center of the node.
  3981. !#zh
  3982. 设置锚点的百分比。<br/>
  3983. 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
  3984. 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
  3985. 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
  3986. 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
  3987. 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
  3988. @param point The anchor point of node or The x axis anchor of node.
  3989. @param y The y axis anchor of node.
  3990. @example
  3991. ```js
  3992. node.setAnchorPoint(cc.v2(1, 1));
  3993. node.setAnchorPoint(1, 1);
  3994. ```
  3995. */
  3996. setAnchorPoint(point: Vec2|number, y?: number): void;
  3997. /**
  3998. !#en
  3999. Returns a copy of the anchor point in absolute pixels. <br/>
  4000. you can only read it. If you wish to modify it, use setAnchorPoint.
  4001. !#zh
  4002. 返回锚点的绝对像素位置。<br/>
  4003. 你只能读它。如果您要修改它,使用 setAnchorPoint。
  4004. @example
  4005. ```js
  4006. cc.log("AnchorPointInPoints: " + node.getAnchorPointInPoints());
  4007. ```
  4008. */
  4009. getAnchorPointInPoints(): Vec2;
  4010. /**
  4011. !#en
  4012. Returns the displayed opacity of Node,
  4013. 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.
  4014. !#zh
  4015. 获取节点显示透明度,
  4016. 显示透明度和透明度之间的不同之处在于当启用级连透明度时,
  4017. 显示透明度是基于自身透明度和父节点透明度计算的。
  4018. @example
  4019. ```js
  4020. var displayOpacity = node.getDisplayedOpacity();
  4021. ```
  4022. */
  4023. getDisplayedOpacity(): number;
  4024. /**
  4025. !#en
  4026. Returns the displayed color of Node,
  4027. 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.
  4028. !#zh
  4029. 获取节点的显示颜色,
  4030. 显示颜色和颜色之间的不同之处在于当启用级连颜色时,
  4031. 显示颜色是基于自身颜色和父节点颜色计算的。
  4032. @example
  4033. ```js
  4034. var displayColor = node.getDisplayedColor();
  4035. ```
  4036. */
  4037. getDisplayedColor(): Color;
  4038. /**
  4039. !#en
  4040. Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
  4041. The matrix is in Pixels.<br/>
  4042. This method is AR (Anchor Relative).
  4043. !#zh
  4044. 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。<br/>
  4045. 这个矩阵以像素为单位。<br/>
  4046. 该方法基于节点坐标。
  4047. @example
  4048. ```js
  4049. var affineTransform = node.getNodeToParentTransformAR();
  4050. ```
  4051. */
  4052. getNodeToParentTransformAR(): AffineTransform;
  4053. /**
  4054. !#en
  4055. Returns a "local" axis aligned bounding box of the node. <br/>
  4056. The returned box is relative only to its parent.
  4057. !#zh 返回父节坐标系下的轴向对齐的包围盒。
  4058. @example
  4059. ```js
  4060. var boundingBox = node.getBoundingBox();
  4061. ```
  4062. */
  4063. getBoundingBox(): Rect;
  4064. /**
  4065. !#en
  4066. Returns a "world" axis aligned bounding box of the node.<br/>
  4067. The bounding box contains self and active children's world bounding box.
  4068. !#zh
  4069. 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。<br/>
  4070. 该边框包含自身和已激活的子节点的世界边框。
  4071. @example
  4072. ```js
  4073. var newRect = node.getBoundingBoxToWorld();
  4074. ```
  4075. */
  4076. getBoundingBoxToWorld(): Rect;
  4077. /**
  4078. !#en
  4079. Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
  4080. The matrix is in Pixels.
  4081. !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。
  4082. @example
  4083. ```js
  4084. var affineTransform = node.getNodeToParentTransform();
  4085. ```
  4086. */
  4087. getNodeToParentTransform(): AffineTransform;
  4088. /**
  4089. !#en Returns the world affine transform matrix. The matrix is in Pixels.
  4090. !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。
  4091. @example
  4092. ```js
  4093. var affineTransform = node.getNodeToWorldTransform();
  4094. ```
  4095. */
  4096. getNodeToWorldTransform(): AffineTransform;
  4097. /**
  4098. !#en
  4099. Returns the world affine transform matrix. The matrix is in Pixels.<br/>
  4100. This method is AR (Anchor Relative).
  4101. !#zh
  4102. 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。<br/>
  4103. 该方法基于节点坐标。
  4104. @example
  4105. ```js
  4106. var mat = node.getNodeToWorldTransformAR();
  4107. ```
  4108. */
  4109. getNodeToWorldTransformAR(): AffineTransform;
  4110. /**
  4111. !#en
  4112. Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.<br/>
  4113. The matrix is in Pixels. The returned transform is readonly and cannot be changed.
  4114. !#zh
  4115. 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。<br/>
  4116. 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。
  4117. @example
  4118. ```js
  4119. var affineTransform = node.getParentToNodeTransform();
  4120. ```
  4121. */
  4122. getParentToNodeTransform(): AffineTransform;
  4123. /**
  4124. !#en Returns the inverse world affine transform matrix. The matrix is in Pixels.
  4125. !#en 返回世界坐标系到节点坐标系的逆矩阵。
  4126. @example
  4127. ```js
  4128. var affineTransform = node.getWorldToNodeTransform();
  4129. ```
  4130. */
  4131. getWorldToNodeTransform(): AffineTransform;
  4132. /**
  4133. !#en Converts a Point to node (local) space coordinates. The result is in Vec2.
  4134. !#zh 将一个点转换到节点 (局部) 坐标系。结果以 Vec2 为单位。
  4135. @param worldPoint worldPoint
  4136. @example
  4137. ```js
  4138. var newVec2 = node.convertToNodeSpace(cc.v2(100, 100));
  4139. ```
  4140. */
  4141. convertToNodeSpace(worldPoint: Vec2): Vec2;
  4142. /**
  4143. !#en Converts a Point to world space coordinates. The result is in Points.
  4144. !#zh 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。
  4145. @param nodePoint nodePoint
  4146. @example
  4147. ```js
  4148. var newVec2 = node.convertToWorldSpace(cc.v2(100, 100));
  4149. ```
  4150. */
  4151. convertToWorldSpace(nodePoint: Vec2): Vec2;
  4152. /**
  4153. !#en
  4154. Converts a Point to node (local) space coordinates. The result is in Points.<br/>
  4155. treating the returned/received node point as anchor relative.
  4156. !#zh
  4157. 将一个点转换到节点 (局部) 空间坐标系。结果以 Vec2 为单位。<br/>
  4158. 返回值将基于节点坐标。
  4159. @param worldPoint worldPoint
  4160. @example
  4161. ```js
  4162. var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100));
  4163. ```
  4164. */
  4165. convertToNodeSpaceAR(worldPoint: Vec2): Vec2;
  4166. /**
  4167. !#en
  4168. Converts a local Point to world space coordinates.The result is in Points.<br/>
  4169. treating the returned/received node point as anchor relative.
  4170. !#zh
  4171. 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。<br/>
  4172. 返回值将基于世界坐标。
  4173. @param nodePoint nodePoint
  4174. @example
  4175. ```js
  4176. var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100));
  4177. ```
  4178. */
  4179. convertToWorldSpaceAR(nodePoint: Vec2): Vec2;
  4180. /**
  4181. !#en convenience methods which take a cc.Touch instead of cc.Vec2.
  4182. !#zh 将触摸点转换成本地坐标系中位置。
  4183. @param touch The touch object
  4184. @example
  4185. ```js
  4186. var newVec2 = node.convertTouchToNodeSpace(touch);
  4187. ```
  4188. */
  4189. convertTouchToNodeSpace(touch: Touch): Vec2;
  4190. /**
  4191. !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative).
  4192. !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。
  4193. @param touch The touch object
  4194. @example
  4195. ```js
  4196. var newVec2 = node.convertTouchToNodeSpaceAR(touch);
  4197. ```
  4198. */
  4199. convertTouchToNodeSpaceAR(touch: Touch): Vec2;
  4200. /**
  4201. !#en
  4202. Adds a child to the node with z order and tag.
  4203. !#zh
  4204. 添加子节点,并且可以修改该节点的 局部 Z 顺序和标签。
  4205. @param child A child node
  4206. @param localZOrder Z order for drawing priority. Please refer to setZOrder(int)
  4207. @param tag An integer or a name to identify the node easily. Please refer to setTag(int) and setName(string)
  4208. @example
  4209. ```js
  4210. node.addChild(newNode, 1, 1001);
  4211. ```
  4212. */
  4213. addChild(child: Node, localZOrder?: number, tag?: number|string): void;
  4214. /**
  4215. !#en Stops all running actions and schedulers.
  4216. !#zh 停止所有正在播放的动作和计时器。
  4217. @example
  4218. ```js
  4219. node.cleanup();
  4220. ```
  4221. */
  4222. cleanup(): void;
  4223. /**
  4224. !#en Sorts the children array depends on children's zIndex and arrivalOrder,
  4225. normally you won't need to invoke this function.
  4226. !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。
  4227. */
  4228. sortAllChildren(): void;
  4229. /** !#en The local scale relative to the parent.
  4230. !#zh 节点相对父节点的缩放。 */
  4231. scale: number;
  4232. /**
  4233. !#en Returns the x axis position of the node in cocos2d coordinates.
  4234. !#zh 获取节点 X 轴坐标。
  4235. @example
  4236. ```js
  4237. var posX = node.getPositionX();
  4238. ```
  4239. */
  4240. getPositionX(): number;
  4241. /**
  4242. !#en Sets the x axis position of the node in cocos2d coordinates.
  4243. !#zh 设置节点 X 轴坐标。
  4244. @param x x
  4245. @example
  4246. ```js
  4247. node.setPositionX(1);
  4248. ```
  4249. */
  4250. setPositionX(x: number): void;
  4251. /**
  4252. !#en Returns the y axis position of the node in cocos2d coordinates.
  4253. !#zh 获取节点 Y 轴坐标。
  4254. @example
  4255. ```js
  4256. var posY = node.getPositionY();
  4257. ```
  4258. */
  4259. getPositionY(): number;
  4260. /**
  4261. !#en Sets the y axis position of the node in cocos2d coordinates.
  4262. !#zh 设置节点 Y 轴坐标。
  4263. @param y The new position in y axis
  4264. @example
  4265. ```js
  4266. node.setPositionY(100);
  4267. ```
  4268. */
  4269. setPositionY(y: number): void;
  4270. /**
  4271. !#en Returns the local Z order of this node.
  4272. !#zh 获取节点局部 Z 轴顺序。
  4273. @example
  4274. ```js
  4275. var localZorder = node.getLocalZOrder();
  4276. ```
  4277. */
  4278. getLocalZOrder(): number;
  4279. /**
  4280. !#en
  4281. LocalZOrder is the 'key' used to sort the node relative to its siblings. <br/>
  4282. <br/>
  4283. The Node's parent will sort all its children based ont the LocalZOrder value. <br/>
  4284. If two nodes have the same LocalZOrder, then the node that was added first to the children's array <br/>
  4285. will be in front of the other node in the array. <br/>
  4286. Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) <br/>
  4287. And Nodes that have LocalZOder values smaller than 0 are the "left" subtree <br/>
  4288. While Nodes with LocalZOder greater than 0 are the "right" subtree.
  4289. !#zh
  4290. LocalZOrder 是 “key” (关键)来分辨节点和它兄弟节点的相关性。
  4291. 父节点将会通过 LocalZOrder 的值来分辨所有的子节点。
  4292. 如果两个节点有同样的 LocalZOrder,那么先加入子节点数组的节点将会显示在后加入的节点的前面。
  4293. 同样的,场景图使用 “In-Order(按顺序)” 遍历数算法来遍历
  4294. ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) 并且拥有小于 0 的 LocalZOrder 的值的节点是 “ left ” 子树(左子树)
  4295. 所以拥有大于 0 的 LocalZOrder 的值得节点是 “ right ”子树(右子树)。
  4296. @param localZOrder localZOrder
  4297. @example
  4298. ```js
  4299. node.setLocalZOrder(1);
  4300. ```
  4301. */
  4302. setLocalZOrder(localZOrder: number): void;
  4303. /**
  4304. !#en Returns whether node's opacity value affect its child nodes.
  4305. !#zh 返回节点的不透明度值是否影响其子节点。
  4306. @example
  4307. ```js
  4308. cc.log(node.isCascadeOpacityEnabled());
  4309. ```
  4310. */
  4311. isCascadeOpacityEnabled(): boolean;
  4312. /**
  4313. !#en Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity.
  4314. !#zh 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。
  4315. @param cascadeOpacityEnabled cascadeOpacityEnabled
  4316. @example
  4317. ```js
  4318. node.setCascadeOpacityEnabled(true);
  4319. ```
  4320. */
  4321. setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void;
  4322. }
  4323. /** !#en
  4324. cc.Scene is a subclass of cc.Node that is used only as an abstract concept.<br/>
  4325. cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually.
  4326. !#zh
  4327. cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。<br/>
  4328. cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */
  4329. export class Scene extends Node {
  4330. /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading.
  4331. !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */
  4332. autoReleaseAssets: boolean;
  4333. }
  4334. /** !#en
  4335. Scheduler is responsible of triggering the scheduled callbacks.<br/>
  4336. You should not use NSTimer. Instead use this class.<br/>
  4337. <br/>
  4338. There are 2 different types of callbacks (selectors):<br/>
  4339. - update callback: the 'update' callback will be called every frame. You can customize the priority.<br/>
  4340. - custom callback: A custom callback will be called every frame, or with a custom interval of time<br/>
  4341. <br/>
  4342. The 'custom selectors' should be avoided when possible. It is faster,
  4343. and consumes less memory to use the 'update callback'. *
  4344. !#zh
  4345. Scheduler 是负责触发回调函数的类。<br/>
  4346. 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。<br/>
  4347. 有两种不同类型的定时器:<br/>
  4348. - update 定时器:每一帧都会触发。您可以自定义优先级。<br/>
  4349. - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。<br/>
  4350. 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */
  4351. export class Scheduler {
  4352. /**
  4353. !#en
  4354. Modifies the time of all scheduled callbacks.<br/>
  4355. You can use this property to create a 'slow motion' or 'fast forward' effect.<br/>
  4356. Default is 1.0. To create a 'slow motion' effect, use values below 1.0.<br/>
  4357. To create a 'fast forward' effect, use values higher than 1.0.<br/>
  4358. Note:It will affect EVERY scheduled selector / action.
  4359. !#zh
  4360. 设置时间间隔的缩放比例。<br/>
  4361. 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。<br/>
  4362. 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。<br/>
  4363. 要使用 “fast forward(快进)” 效果,使用值大于 1.0。<br/>
  4364. 注意:它影响该 Scheduler 下管理的所有定时器。
  4365. @param timeScale timeScale
  4366. */
  4367. setTimeScale(timeScale: number): void;
  4368. /**
  4369. !#en Returns time scale of scheduler.
  4370. !#zh 获取时间间隔的缩放比例。
  4371. */
  4372. getTimeScale(): number;
  4373. /**
  4374. !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.)
  4375. !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果)
  4376. @param dt delta time
  4377. */
  4378. update(dt: number): void;
  4379. /**
  4380. !#en
  4381. <p>
  4382. The scheduled method will be called every 'interval' seconds.</br>
  4383. If paused is YES, then it won't be called until it is resumed.<br/>
  4384. If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.<br/>
  4385. If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.<br/>
  4386. repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously<br/>
  4387. delay is the amount of time the action will wait before it'll start<br/>
  4388. </p>
  4389. !#zh
  4390. 指定回调函数,调用对象等信息来添加一个新的定时器。</br>
  4391. 当时间间隔达到指定值时,设置的回调函数将会被调用。</br>
  4392. 如果 paused 值为 true,那么直到 resume 被调用才开始计时。</br>
  4393. 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样,
  4394. 建议使用 scheduleUpdateForTarget 代替。</br>
  4395. 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。<br/>
  4396. repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER
  4397. 可以让定时器一直循环触发。<br/>
  4398. delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。
  4399. @param target target
  4400. @param callback_fn callback_fn
  4401. @param interval interval
  4402. @param repeat repeat
  4403. @param delay delay
  4404. @param paused paused
  4405. @example
  4406. ```js
  4407. //register a schedule to scheduler
  4408. var scheduler = cc.director.getScheduler();
  4409. scheduler.scheduleCallbackForTarget(this, function, interval, repeat, delay, !this._isRunning);
  4410. ```
  4411. */
  4412. scheduleCallbackForTarget(target: any, callback: Function, interval: number, repeat: number, delay: number, paused?: boolean): void;
  4413. scheduleCallbackForTarget(target: any, callback: Function, interval: number, paused?: boolean): void;
  4414. /**
  4415. !#en The schedule
  4416. !#zh 定时器
  4417. @param callback callback
  4418. @param target target
  4419. @param interval interval
  4420. @param repeat repeat
  4421. @param delay delay
  4422. @param paused paused
  4423. @example
  4424. ```js
  4425. //register a schedule to scheduler
  4426. cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning);
  4427. ```
  4428. */
  4429. schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void;
  4430. schedule(callback: Function, target: any, interval: number, paused?: boolean): void;
  4431. /**
  4432. !#en
  4433. Schedules the update callback for a given target,
  4434. the callback will be invoked every frame after schedule started.
  4435. !#zh
  4436. 使用指定的优先级为指定的对象设置 update 定时器。
  4437. update 定时器每一帧都会被触发。优先级的值越低,定时器被触发的越早。
  4438. @param target target
  4439. @param priority priority
  4440. @param paused paused
  4441. @param updateFunc updateFunc
  4442. */
  4443. scheduleUpdate(target: any, priority: number, paused: boolean, updateFunc: Function): void;
  4444. /**
  4445. !#en
  4446. Unschedules a callback for a callback and a given target.
  4447. If you want to unschedule the "update", use `unscheduleUpdate()`
  4448. !#zh
  4449. 根据指定的回调函数和调用对象。
  4450. 如果需要取消 update 定时器,请使用 unscheduleUpdate()。
  4451. @param callback The callback to be unscheduled
  4452. @param target The target bound to the callback.
  4453. */
  4454. unschedule(callback: Function, target: any): void;
  4455. /**
  4456. !#en Unschedules the update callback for a given target.
  4457. !#zh 取消指定对象的 update 定时器。
  4458. @param target The target to be unscheduled.
  4459. */
  4460. unscheduleUpdate(target: any): void;
  4461. /**
  4462. !#en
  4463. Unschedules all scheduled callbacks for a given target.
  4464. This also includes the "update" callback.
  4465. !#zh 取消指定对象的所有定时器,包括 update 定时器。
  4466. @param target The target to be unscheduled.
  4467. */
  4468. unscheduleAllForTarget(target: any): void;
  4469. /**
  4470. !#en
  4471. Unschedules all scheduled callbacks from all targets including the system callbacks.<br/>
  4472. You should NEVER call this method, unless you know what you are doing.
  4473. !#zh
  4474. 取消所有对象的所有定时器,包括系统定时器。<br/>
  4475. 不用调用此函数,除非你确定你在做什么。
  4476. */
  4477. unscheduleAll(): void;
  4478. /**
  4479. !#en
  4480. Unschedules all callbacks from all targets with a minimum priority.<br/>
  4481. You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher.
  4482. !#zh
  4483. 取消所有优先级的值大于指定优先级的定时器。<br/>
  4484. 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  4485. @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which
  4486. priority is higher than minPriority will be unscheduled.
  4487. */
  4488. unscheduleAllWithMinPriority(minPriority: number): void;
  4489. /**
  4490. !#en Checks whether a callback for a given target is scheduled.
  4491. !#zh 检查指定的回调函数和回调对象组合是否存在定时器。
  4492. @param callback The callback to check.
  4493. @param target The target of the callback.
  4494. */
  4495. isScheduled(callback: Function, target: any): boolean;
  4496. /**
  4497. !#en
  4498. Pause all selectors from all targets.<br/>
  4499. You should NEVER call this method, unless you know what you are doing.
  4500. !#zh
  4501. 暂停所有对象的所有定时器。<br/>
  4502. 不要调用这个方法,除非你知道你正在做什么。
  4503. */
  4504. pauseAllTargets(): void;
  4505. /**
  4506. !#en
  4507. Pause all selectors from all targets with a minimum priority. <br/>
  4508. You should only call this with kCCPriorityNonSystemMin or higher.
  4509. !#zh
  4510. 暂停所有优先级的值大于指定优先级的定时器。<br/>
  4511. 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  4512. @param minPriority minPriority
  4513. */
  4514. pauseAllTargetsWithMinPriority(minPriority: number): void;
  4515. /**
  4516. !#en
  4517. Resume selectors on a set of targets.<br/>
  4518. This can be useful for undoing a call to pauseAllCallbacks.
  4519. !#zh
  4520. 恢复指定数组中所有对象的定时器。<br/>
  4521. 这个函数是 pauseAllCallbacks 的逆操作。
  4522. @param targetsToResume targetsToResume
  4523. */
  4524. resumeTargets(targetsToResume: any[]): void;
  4525. /**
  4526. !#en
  4527. Pauses the target.<br/>
  4528. All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.<br/>
  4529. If the target is not present, nothing happens.
  4530. !#zh
  4531. 暂停指定对象的定时器。<br/>
  4532. 指定对象的所有定时器都会被暂停。<br/>
  4533. 如果指定的对象没有定时器,什么也不会发生。
  4534. @param target target
  4535. */
  4536. pauseTarget(target: any): void;
  4537. /**
  4538. !#en
  4539. Resumes the target.<br/>
  4540. The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.<br/>
  4541. If the target is not present, nothing happens.
  4542. !#zh
  4543. 恢复指定对象的所有定时器。<br/>
  4544. 指定对象的所有定时器将继续工作。<br/>
  4545. 如果指定的对象没有定时器,什么也不会发生。
  4546. @param target target
  4547. */
  4548. resumeTarget(target: any): void;
  4549. /**
  4550. !#en Returns whether or not the target is paused.
  4551. !#zh 返回指定对象的定时器是否暂停了。
  4552. @param target target
  4553. */
  4554. isTargetPaused(target: any): boolean;
  4555. /**
  4556. !#en
  4557. Schedules the 'update' callback_fn for a given target with a given priority.<br/>
  4558. The 'update' callback_fn will be called every frame.<br/>
  4559. The lower the priority, the earlier it is called.
  4560. !#zh
  4561. 为指定对象设置 update 定时器。<br/>
  4562. update 定时器每一帧都会被调用。<br/>
  4563. 优先级的值越低,越早被调用。
  4564. @param target target
  4565. @param priority priority
  4566. @param paused paused
  4567. @example
  4568. ```js
  4569. //register this object to scheduler
  4570. var scheduler = cc.director.getScheduler();
  4571. scheduler.scheduleUpdateForTarget(this, priority, !this._isRunning );
  4572. ```
  4573. */
  4574. scheduleUpdateForTarget(target: any, priority: number, paused: boolean): void;
  4575. /**
  4576. !#en
  4577. Unschedule a callback function for a given target.<br/>
  4578. If you want to unschedule the "update", use unscheduleUpdateForTarget.
  4579. !#zh
  4580. 根据指定的回调函数和调用对象对象取消相应的定时器。<br/>
  4581. 如果需要取消 update 定时器,请使用 unscheduleUpdateForTarget()。
  4582. @param target target
  4583. @param callback callback[Function] or key[String]
  4584. @example
  4585. ```js
  4586. //unschedule a callback of target
  4587. var scheduler = cc.director.getScheduler();
  4588. scheduler.unscheduleCallbackForTarget(this, callback);
  4589. ```
  4590. */
  4591. unscheduleCallbackForTarget(target: any, callback: Function): void;
  4592. /**
  4593. !#en Unschedules the update callback function for a given target.
  4594. !#zh 取消指定对象的所有定时器。
  4595. @param target target
  4596. @example
  4597. ```js
  4598. //unschedules the "update" method.
  4599. var scheduler = cc.director.getScheduler();
  4600. scheduler.unscheduleUpdateForTarget(this);
  4601. ```
  4602. */
  4603. unscheduleUpdateForTarget(target: any): void;
  4604. /**
  4605. !#en
  4606. Unschedules all function callbacks for a given target.<br/>
  4607. This also includes the "update" callback function.
  4608. !#zh 取消指定对象的所有定时器,包括 update 定时器。
  4609. @param target target
  4610. */
  4611. unscheduleAllCallbacksForTarget(target: any): void;
  4612. /**
  4613. !#en
  4614. Unschedules all function callbacks from all targets. <br/>
  4615. You should NEVER call this method, unless you know what you are doing.
  4616. !#zh
  4617. 取消所有对象的所有定时器。<br/>
  4618. 不要调用这个方法,除非你知道你正在做什么。
  4619. */
  4620. unscheduleAllCallbacks(): void;
  4621. /**
  4622. !#en
  4623. Unschedules all function callbacks from all targets with a minimum priority.<br/>
  4624. You should only call this with kCCPriorityNonSystemMin or higher.
  4625. !#zh
  4626. 取消所有优先级的值大于指定优先级的所有对象的所有定时器。<br/>
  4627. 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  4628. @param minPriority minPriority
  4629. */
  4630. unscheduleAllCallbacksWithMinPriority(minPriority: number): void;
  4631. /** !#en Priority level reserved for system services.
  4632. !#zh 系统服务的优先级。 */
  4633. static PRIORITY_SYSTEM: number;
  4634. /** !#en Minimum priority level for user scheduling.
  4635. !#zh 用户调度最低优先级。 */
  4636. static PRIORITY_NON_SYSTEM: number;
  4637. }
  4638. /** !#en Renders the TMX object.
  4639. !#zh 渲染 tmx object。 */
  4640. export class TMXObject {
  4641. /**
  4642. !#en Get the name of object
  4643. !#zh 获取对象的名称
  4644. */
  4645. getObjectName(): string;
  4646. /**
  4647. !#en Get the property of object
  4648. !#zh 获取对象的属性
  4649. @param propertyName propertyName
  4650. */
  4651. getProperty(propertyName: string): any;
  4652. /**
  4653. !#en Get the properties of object
  4654. !#zh 获取对象的属性
  4655. */
  4656. getProperties(): any;
  4657. /**
  4658. !#en Set the object name
  4659. !#zh 设置对象名称
  4660. @param name name
  4661. */
  4662. setObjectName(name: string): void;
  4663. /**
  4664. !#en Set the properties of the object
  4665. !#zh 设置对象的属性
  4666. @param props props
  4667. */
  4668. setProperties(props: any): void;
  4669. }
  4670. /** !#en Renders a TMX Tile Map in the scene.
  4671. !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */
  4672. export class TiledMap extends Component {
  4673. /** !#en The TiledMap Asset.
  4674. !#zh TiledMap 资源。 */
  4675. tmxAsset: TiledMapAsset;
  4676. /**
  4677. !#en Gets the map size.
  4678. !#zh 获取地图大小。
  4679. @example
  4680. ```js
  4681. var mapSize = tiledMap.getMapSize();
  4682. cc.log("Map Size: " + mapSize);
  4683. ```
  4684. */
  4685. getMapSize(): Size;
  4686. /**
  4687. !#en Set the map size.
  4688. !#zh 设置地图大小。
  4689. @param mapSize mapSize
  4690. @example
  4691. ```js
  4692. tiledMap.setMapSize(new cc.size(960, 640));
  4693. ```
  4694. */
  4695. setMapSize(mapSize: Size): void;
  4696. /**
  4697. !#en Gets the tile size.
  4698. !#zh 获取地图背景中 tile 元素的大小。
  4699. @example
  4700. ```js
  4701. var tileSize = tiledMap.getTileSize();
  4702. cc.log("Tile Size: " + tileSize);
  4703. ```
  4704. */
  4705. getTileSize(): Size;
  4706. /**
  4707. !#en Set the tile size.
  4708. !#zh 设置地图背景中 tile 元素的大小。
  4709. @param tileSize tileSize
  4710. @example
  4711. ```js
  4712. tiledMap.setTileSize(new cc.size(10, 10));
  4713. ```
  4714. */
  4715. setTileSize(tileSize: Size): void;
  4716. /**
  4717. !#en map orientation.
  4718. !#zh 获取地图方向。
  4719. @example
  4720. ```js
  4721. var mapOrientation = tiledMap.getMapOrientation();
  4722. cc.log("Map Orientation: " + mapOrientation);
  4723. ```
  4724. */
  4725. getMapOrientation(): number;
  4726. /**
  4727. !#en map orientation.
  4728. !#zh 设置地图方向。
  4729. @param orientation orientation
  4730. @example
  4731. ```js
  4732. tiledMap.setMapOrientation(TiledMap.Orientation.ORTHO);
  4733. ```
  4734. */
  4735. setMapOrientation(orientation: TiledMap.Orientation): void;
  4736. /**
  4737. !#en object groups.
  4738. !#zh 获取所有的对象层。
  4739. @example
  4740. ```js
  4741. var objGroups = titledMap.getObjectGroups();
  4742. for (var i = 0; i < objGroups.length; ++i) {
  4743. cc.log("obj: " + objGroups[i]);
  4744. }
  4745. ```
  4746. */
  4747. getObjectGroups(): TiledObjectGroup[];
  4748. /**
  4749. !#en Gets the map properties.
  4750. !#zh 获取地图的属性。
  4751. @example
  4752. ```js
  4753. var properties = titledMap.getProperties();
  4754. for (var i = 0; i < properties.length; ++i) {
  4755. cc.log("Properties: " + properties[i]);
  4756. }
  4757. ```
  4758. */
  4759. getProperties(): any[];
  4760. /**
  4761. !#en Set the map properties.
  4762. !#zh 设置地图的属性。
  4763. @param properties properties
  4764. @example
  4765. ```js
  4766. titledMap.setProperties(properties);
  4767. ```
  4768. */
  4769. setProperties(properties: any[]): void;
  4770. /**
  4771. !#en Return All layers array.
  4772. !#zh 返回包含所有 layer 的数组。
  4773. @example
  4774. ```js
  4775. var layers = titledMap.allLayers();
  4776. for (var i = 0; i < layers.length; ++i) {
  4777. cc.log("Layers: " + layers[i]);
  4778. }
  4779. ```
  4780. */
  4781. allLayers(): TiledLayer[];
  4782. /**
  4783. !#en return the cc.TiledLayer for the specific layer.
  4784. !#zh 获取指定名称的 layer。
  4785. @param layerName layerName
  4786. @example
  4787. ```js
  4788. var layer = titledMap.getLayer("Player");
  4789. cc.log(layer);
  4790. ```
  4791. */
  4792. getLayer(layerName: string): TiledLayer;
  4793. /**
  4794. !#en Return the TMXObjectGroup for the specific group.
  4795. !#zh 获取指定的 TMXObjectGroup。
  4796. @param groupName groupName
  4797. @example
  4798. ```js
  4799. var group = titledMap.getObjectGroup("Players");
  4800. cc.log("ObjectGroup: " + group);
  4801. ```
  4802. */
  4803. getObjectGroup(groupName: string): TiledObjectGroup;
  4804. /**
  4805. !#en Return the value for the specific property name.
  4806. !#zh 通过属性名称,获取指定的属性。
  4807. @param propertyName propertyName
  4808. @example
  4809. ```js
  4810. var property = titledMap.getProperty("info");
  4811. cc.log("Property: " + property);
  4812. ```
  4813. */
  4814. getProperty(propertyName: string): string;
  4815. /**
  4816. !#en Return properties dictionary for tile GID.
  4817. !#zh 通过 GID ,获取指定的属性。
  4818. @param GID GID
  4819. @example
  4820. ```js
  4821. var properties = titledMap.getPropertiesForGID(GID);
  4822. cc.log("Properties: " + properties);
  4823. ```
  4824. */
  4825. getPropertiesForGID(GID: number): any;
  4826. }
  4827. /** !#en Render the TMX layer.
  4828. !#zh 渲染 TMX layer。 */
  4829. export class TiledLayer extends _SGComponent {
  4830. /**
  4831. !#en Gets the layer name.
  4832. !#zh 获取层的名称。
  4833. @example
  4834. ```js
  4835. var layerName = tiledLayer.getLayerName();
  4836. cc.log(layerName);
  4837. ```
  4838. */
  4839. getLayerName(): string;
  4840. /**
  4841. !#en Set the layer name.
  4842. !#zh 设置层的名称
  4843. @param layerName layerName
  4844. @example
  4845. ```js
  4846. tiledLayer.setLayerName("New Layer");
  4847. ```
  4848. */
  4849. SetLayerName(layerName: string): void;
  4850. /**
  4851. !#en Return the value for the specific property name.
  4852. !#zh 获取指定属性名的值。
  4853. @param propertyName propertyName
  4854. @example
  4855. ```js
  4856. var property = tiledLayer.getProperty("info");
  4857. cc.log(property);
  4858. ```
  4859. */
  4860. getProperty(propertyName: string): any;
  4861. /**
  4862. !#en Returns the position in pixels of a given tile coordinate.
  4863. !#zh 获取指定 tile 的像素坐标。
  4864. @param pos position or x
  4865. @param y y
  4866. @example
  4867. ```js
  4868. var pos = tiledLayer.getPositionAt(cc.v2(0, 0));
  4869. cc.log("Pos: " + pos);
  4870. var pos = tiledLayer.getPositionAt(0, 0);
  4871. cc.log("Pos: " + pos);
  4872. ```
  4873. */
  4874. getPositionAt(pos: Vec2|number, y?: number): Vec2;
  4875. /**
  4876. !#en Removes a tile at given tile coordinate.
  4877. !#zh 删除指定坐标上的 tile。
  4878. @param pos position or x
  4879. @param y y
  4880. @example
  4881. ```js
  4882. tiledLayer.removeTileAt(cc.v2(0, 0));
  4883. tiledLayer.removeTileAt(0, 0);
  4884. ```
  4885. */
  4886. removeTileAt(pos: Vec2|number, y?: number): void;
  4887. /**
  4888. !#en
  4889. Sets the tile gid (gid = tile global id) at a given tile coordinate.<br />
  4890. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.<br />
  4891. If a tile is already placed at that position, then it will be removed.
  4892. !#zh
  4893. 设置给定坐标的 tile 的 gid (gid = tile 全局 id),
  4894. tile 的 GID 可以使用方法 “tileGIDAt” 来获得。<br />
  4895. 如果一个 tile 已经放在那个位置,那么它将被删除。
  4896. @param gid gid
  4897. @param posOrX position or x
  4898. @param flagsOrY flags or y
  4899. @param flags flags
  4900. @example
  4901. ```js
  4902. tiledLayer.setTileGID(1001, 10, 10, 1)
  4903. ```
  4904. */
  4905. setTileGID(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void;
  4906. /**
  4907. !#en
  4908. Returns the tile gid at a given tile coordinate. <br />
  4909. if it returns 0, it means that the tile is empty. <br />
  4910. This method requires the the tile map has not been previously released (eg. don't call layer.releaseMap())<br />
  4911. !#zh
  4912. 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID. <br />
  4913. 如果它返回 0,则表示该 tile 为空。<br />
  4914. 该方法要求 tile 地图之前没有被释放过(如:没有调用过layer.releaseMap()).
  4915. @param pos or x
  4916. @param y y
  4917. @example
  4918. ```js
  4919. var tileGid = tiledLayer.getTileGIDAt(0, 0);
  4920. ```
  4921. */
  4922. getTileGIDAt(pos: Vec2|number, y?: number): number;
  4923. /**
  4924. !#en
  4925. Returns the tile (_ccsg.Sprite) at a given a tile coordinate. <br/>
  4926. The returned _ccsg.Sprite will be already added to the _ccsg.TMXLayer. Don't add it again.<br/>
  4927. The _ccsg.Sprite can be treated like any other _ccsg.Sprite: rotated, scaled, translated, opacity, color, etc. <br/>
  4928. You can remove either by calling: <br/>
  4929. - layer.removeChild(sprite, cleanup); <br/>
  4930. - or layer.removeTileAt(ccp(x,y));
  4931. !#zh
  4932. 通过指定的 tile 坐标获取对应的 tile(Sprite)。 返回的 tile(Sprite) 应是已经添加到 TMXLayer,请不要重复添加。<br/>
  4933. 这个 tile(Sprite) 如同其他的 Sprite 一样,可以旋转、缩放、翻转、透明化、设置颜色等。<br/>
  4934. 你可以通过调用以下方法来对它进行删除:<br/>
  4935. 1. layer.removeChild(sprite, cleanup);<br/>
  4936. 2. 或 layer.removeTileAt(cc.v2(x,y));
  4937. @param pos or x
  4938. @param y y
  4939. @example
  4940. ```js
  4941. var title = tiledLayer.getTileAt(100, 100);
  4942. cc.log(title);
  4943. ```
  4944. */
  4945. getTileAt(pos: Vec2|number, y?: number): _ccsg.Sprite;
  4946. /**
  4947. !#en
  4948. Dealloc the map that contains the tile position from memory. <br />
  4949. Unless you want to know at runtime the tiles positions, you can safely call this method. <br />
  4950. If you are going to call layer.getTileGIDAt() then, don't release the map.
  4951. !#zh
  4952. 从内存中释放包含 tile 位置信息的地图。<br />
  4953. 除了在运行时想要知道 tiles 的位置信息外,你都可安全的调用此方法。<br />
  4954. 如果你之后还要调用 layer.tileGIDAt(), 请不要释放地图.
  4955. @example
  4956. ```js
  4957. tiledLayer.releaseMap();
  4958. ```
  4959. */
  4960. releaseMap(): void;
  4961. /**
  4962. !#en Sets the untransformed size of the _ccsg.TMXLayer.
  4963. !#zh 设置未转换的 layer 大小。
  4964. @param size The untransformed size of the _ccsg.TMXLayer or The untransformed size's width of the TMXLayer.
  4965. @param height The untransformed size's height of the _ccsg.TMXLayer.
  4966. @example
  4967. ```js
  4968. tiledLayer.setContentSize(100, 100);
  4969. ```
  4970. */
  4971. setContentSize(size: Size|number, height?: number): void;
  4972. /**
  4973. !#en Return texture of cc.SpriteBatchNode.
  4974. !#zh 获取纹理。
  4975. @example
  4976. ```js
  4977. var texture = tiledLayer.getTexture();
  4978. cc.log("Texture: " + texture);
  4979. ```
  4980. */
  4981. getTexture(): Texture2D;
  4982. /**
  4983. !#en Set the texture of cc.SpriteBatchNode.
  4984. !#zh 设置纹理。
  4985. @param texture texture
  4986. @example
  4987. ```js
  4988. tiledLayer.setTexture(texture);
  4989. ```
  4990. */
  4991. setTexture(texture: Texture2D): void;
  4992. /**
  4993. !#en Set the opacity of all tiles
  4994. !#zh 设置所有 Tile 的透明度
  4995. @param opacity opacity
  4996. @example
  4997. ```js
  4998. tiledLayer.setTileOpacity(128);
  4999. ```
  5000. */
  5001. setTileOpacity(opacity: number): void;
  5002. /**
  5003. !#en Gets layer size.
  5004. !#zh 获得层大小。
  5005. @example
  5006. ```js
  5007. var size = tiledLayer.getLayerSize();
  5008. cc.log("layer size: " + size);
  5009. ```
  5010. */
  5011. getLayerSize(): Size;
  5012. /**
  5013. !#en Set layer size.
  5014. !#zh 设置层大小。
  5015. @param layerSize layerSize
  5016. @example
  5017. ```js
  5018. tiledLayer.setLayerSize(new cc.size(5, 5));
  5019. ```
  5020. */
  5021. setLayerSize(layerSize: Size): void;
  5022. /**
  5023. !#en Size of the map's tile (could be different from the tile's size).
  5024. !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。
  5025. @example
  5026. ```js
  5027. var mapTileSize = tiledLayer.getMapTileSize();
  5028. cc.log("MapTile size: " + mapTileSize);
  5029. ```
  5030. */
  5031. getMapTileSize(): Size;
  5032. /**
  5033. !#en Set the map tile size.
  5034. !#zh 设置 tile 的大小。
  5035. @param tileSize tileSize
  5036. @example
  5037. ```js
  5038. tiledLayer.setMapTileSize(new cc.size(10, 10));
  5039. ```
  5040. */
  5041. setMapTileSize(tileSize: Size): void;
  5042. /**
  5043. !#en Pointer to the map of tiles.
  5044. !#zh 获取地图 tiles。
  5045. @example
  5046. ```js
  5047. var tiles = tiledLayer.getTiles();
  5048. ```
  5049. */
  5050. getTiles(): any[];
  5051. /**
  5052. !#en Pointer to the map of tiles.
  5053. !#zh 设置地图 tiles
  5054. @param tiles tiles
  5055. @example
  5056. ```js
  5057. tiledLayer.setTiles(tiles);
  5058. ```
  5059. */
  5060. setTiles(tiles: any[]): void;
  5061. /**
  5062. !#en Tile set information for the layer.
  5063. !#zh 获取 layer 的 Tileset 信息。
  5064. @example
  5065. ```js
  5066. var tileset = tiledLayer.getTileSet();
  5067. ```
  5068. */
  5069. getTileSet(): TMXTilesetInfo;
  5070. /**
  5071. !#en Tile set information for the layer.
  5072. !#zh 设置 layer 的 Tileset 信息。
  5073. @param tileset tileset
  5074. @example
  5075. ```js
  5076. tiledLayer.setTileSet(tileset);
  5077. ```
  5078. */
  5079. setTileSet(tileset: TMXTilesetInfo): void;
  5080. /**
  5081. !#en Layer orientation, which is the same as the map orientation.
  5082. !#zh 获取 Layer 方向(同地图方向)。
  5083. @example
  5084. ```js
  5085. var orientation = tiledLayer.getLayerOrientation();
  5086. cc.log("Layer Orientation: " + orientation);
  5087. ```
  5088. */
  5089. getLayerOrientation(): number;
  5090. /**
  5091. !#en Layer orientation, which is the same as the map orientation.
  5092. !#zh 设置 Layer 方向(同地图方向)。
  5093. @param orientation orientation
  5094. @example
  5095. ```js
  5096. tiledLayer.setLayerOrientation(TiledMap.Orientation.ORTHO);
  5097. ```
  5098. */
  5099. setLayerOrientation(orientation: TiledMap.Orientation): void;
  5100. /**
  5101. !#en properties from the layer. They can be added using Tiled.
  5102. !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。
  5103. @example
  5104. ```js
  5105. var properties = tiledLayer.getProperties();
  5106. cc.log("Properties: " + properties);
  5107. ```
  5108. */
  5109. getProperties(): any[];
  5110. /**
  5111. !#en properties from the layer. They can be added using Tiled.
  5112. !#zh 设置层属性。
  5113. @param properties properties
  5114. @example
  5115. ```js
  5116. tiledLayer.setLayerOrientation(properties);
  5117. ```
  5118. */
  5119. setProperties(properties: any[]): void;
  5120. }
  5121. /** Class for tiled map asset handling. */
  5122. export class TiledMapAsset extends Asset {
  5123. }
  5124. /** !#en Renders the TMX object group.
  5125. !#zh 渲染 tmx object group。 */
  5126. export class TiledObjectGroup extends _SGComponent {
  5127. /**
  5128. !#en Offset position of child objects.
  5129. !#zh 获取子对象的偏移位置。
  5130. @example
  5131. ```js
  5132. var offset = tMXObjectGroup.getPositionOffset();
  5133. ```
  5134. */
  5135. getPositionOffset(): Vec2;
  5136. /**
  5137. !#en Offset position of child objects.
  5138. !#zh 设置子对象的偏移位置。
  5139. @param offset offset
  5140. @example
  5141. ```js
  5142. tMXObjectGroup.setPositionOffset(cc.v2(5, 5));
  5143. ```
  5144. */
  5145. setPositionOffset(offset: Vec2): void;
  5146. /**
  5147. !#en List of properties stored in a dictionary.
  5148. !#zh 以映射的形式获取属性列表。
  5149. @example
  5150. ```js
  5151. var offset = tMXObjectGroup.getProperties();
  5152. ```
  5153. */
  5154. getProperties(): any;
  5155. /**
  5156. !#en Set the properties of the object group.
  5157. !#zh 设置属性列表。
  5158. @param Var Var
  5159. @example
  5160. ```js
  5161. tMXObjectGroup.setProperties(obj);
  5162. ```
  5163. */
  5164. setProperties(Var: any): void;
  5165. /**
  5166. !#en Gets the Group name.
  5167. !#zh 获取组名称。
  5168. @example
  5169. ```js
  5170. var groupName = tMXObjectGroup.getGroupName;
  5171. ```
  5172. */
  5173. getGroupName(): string;
  5174. /**
  5175. !#en Set the Group name.
  5176. !#zh 设置组名称。
  5177. @param groupName groupName
  5178. @example
  5179. ```js
  5180. tMXObjectGroup.setGroupName("New Group");
  5181. ```
  5182. */
  5183. setGroupName(groupName: string): void;
  5184. /**
  5185. !#en
  5186. Return the object for the specific object name. <br />
  5187. It will return the 1st object found on the array for the given name.
  5188. !#zh 获取指定的对象。
  5189. @param objectName objectName
  5190. @example
  5191. ```js
  5192. var object = tMXObjectGroup.getObject("Group");
  5193. ```
  5194. */
  5195. getObject(objectName: string): any;
  5196. /**
  5197. !#en Gets the objects.
  5198. !#zh 获取对象数组。
  5199. @example
  5200. ```js
  5201. var objects = tMXObjectGroup.getObjects();
  5202. ```
  5203. */
  5204. getObjects(): any[];
  5205. }
  5206. /** !#en
  5207. Attention: In creator, it's strongly not recommended to use cc.pool to manager cc.Node.
  5208. We provided {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} instead.
  5209. cc.pool is a singleton object serves as an object cache pool.<br/>
  5210. It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  5211. !#zh
  5212. 首先请注意,在 Creator 中我们强烈不建议使用 cc.pool 来管理 cc.Node 节点对象,请使用 {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} 代替
  5213. 因为 cc.pool 是面向类来设计的,而 cc.Node 中使用 Component 来进行组合,它的类永远都一样,实际却千差万别。
  5214. cc.pool 是一个单例对象,用作为对象缓存池。<br/>
  5215. 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁<br/> */
  5216. export class pool {
  5217. /**
  5218. !#en Put the obj in pool.
  5219. !#zh 加入对象到对象池中。
  5220. @param obj The need put in pool object.
  5221. @example
  5222. ```js
  5223. ---------------------------------
  5224. var sp = new _ccsg.Sprite("a.png");
  5225. this.addChild(sp);
  5226. cc.pool.putInPool(sp);
  5227. cc.pool.getFromPool(_ccsg.Sprite, "a.png");
  5228. ```
  5229. */
  5230. putInPool(obj: any): void;
  5231. /**
  5232. !#en Check if this kind of obj has already in pool.
  5233. !#zh 检查对象池中是否有指定对象的存在。
  5234. @param objClass The check object class.
  5235. */
  5236. hasObject(objClass: any): boolean;
  5237. /**
  5238. !#en Remove the obj if you want to delete it.
  5239. !#zh 移除在对象池中指定的对象。
  5240. */
  5241. removeObject(): void;
  5242. /**
  5243. !#en Get the obj from pool.
  5244. !#zh 获取对象池中的指定对象。
  5245. */
  5246. getFromPool(): any;
  5247. /**
  5248. !#en Remove all objs in pool and reset the pool.
  5249. !#zh 移除对象池中的所有对象,并且重置对象池。
  5250. */
  5251. drainAllPools(): void;
  5252. }
  5253. /** !#en
  5254. cc.NodePool is the cache pool designed for node type.<br/>
  5255. It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  5256. It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class,
  5257. for example, a prefab is a specific node type. <br/>
  5258. When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.<br/>
  5259. Some common use case is :<br/>
  5260. 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)<br/>
  5261. 2. Blocks in candy crash (massive creation and recreation)<br/>
  5262. etc...
  5263. !#zh
  5264. cc.NodePool 是用于管理节点对象的对象缓存池。<br/>
  5265. 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁<br/>
  5266. 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。
  5267. 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。<br/>
  5268. 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。<br/>
  5269. 一些常见的用例是:<br/>
  5270. 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)<br/>
  5271. 2.糖果粉碎传奇中的木块(频繁创建)。
  5272. 等等.... */
  5273. export class NodePool {
  5274. /**
  5275. !#en
  5276. 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.
  5277. !#zh
  5278. 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。
  5279. @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。
  5280. @example
  5281. ```js
  5282. properties: {
  5283. template: cc.Prefab
  5284. },
  5285. onLoad () {
  5286. // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled.
  5287. this.myPool = new cc.NodePool('MyTemplateHandler');
  5288. }
  5289. ```
  5290. */
  5291. constructor(poolHandlerComp?: {prototype: Component}|string);
  5292. /** !#en The pool handler component, it could be the class name or the constructor.
  5293. !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */
  5294. poolHandlerComp: Function|string;
  5295. /**
  5296. !#en The current available size in the pool
  5297. !#zh 获取当前缓冲池的可用对象数量
  5298. */
  5299. size(): number;
  5300. /**
  5301. !#en Destroy all cached nodes in the pool
  5302. !#zh 销毁对象池中缓存的所有节点
  5303. */
  5304. clear(): void;
  5305. /**
  5306. !#en Put a new Node into the pool.
  5307. It will automatically remove the node from its parent without cleanup.
  5308. It will also invoke unuse method of the poolHandlerComp if exist.
  5309. !#zh 向缓冲池中存入一个不再需要的节点对象。
  5310. 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。
  5311. 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。
  5312. @param obj obj
  5313. @example
  5314. ```js
  5315. let myNode = cc.instantiate(this.template);
  5316. this.myPool.put(myNode);
  5317. ```
  5318. */
  5319. put(obj: Node): void;
  5320. /**
  5321. !#en Get a obj from pool, if no available object in pool, null will be returned.
  5322. This function will invoke the reuse function of poolHandlerComp if exist.
  5323. !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。
  5324. 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。
  5325. @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数
  5326. @example
  5327. ```js
  5328. let newNode = this.myPool.get();
  5329. ```
  5330. */
  5331. get(...params: any[]): Node;
  5332. }
  5333. /** !#en
  5334. Camera is usefull when making reel game or other games which need scroll screen.
  5335. Using camera will be more efficient than moving node to scroll screen.
  5336. Camera
  5337. !#zh
  5338. 摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */
  5339. export class Camera extends _RendererUnderSG {
  5340. /** !#en
  5341. The camera zoom ratio.
  5342. !#zh
  5343. 摄像机缩放比率 */
  5344. zoomRatio: number;
  5345. /** !#en
  5346. Current active camera, the scene should only have one active camera at the same time.
  5347. !#zh
  5348. 当前激活的摄像机,场景中在同一时间内只能有一个激活的摄像机。 */
  5349. static main: Camera;
  5350. /**
  5351. !#en
  5352. Add the specified target to camera.
  5353. !#zh
  5354. 将指定的节点添加到摄像机中。
  5355. @param target target
  5356. */
  5357. addTarget(target: Node): void;
  5358. /**
  5359. !#en
  5360. Remove the specified target from camera.
  5361. !#zh
  5362. 将指定的节点从摄像机中移除。
  5363. @param target target
  5364. */
  5365. removeTarget(target: Node): void;
  5366. /**
  5367. !#en
  5368. Get all camera targets.
  5369. !#zh
  5370. 获取所有摄像机目标节点。
  5371. */
  5372. getTargets(): [Node];
  5373. /**
  5374. !#en
  5375. Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates.
  5376. !#zh
  5377. 返回一个将节点坐标系转换到摄像机坐标系下的矩阵
  5378. @param node the node which should transform
  5379. */
  5380. getNodeToCameraTransform(node: Node): AffineTransform;
  5381. /**
  5382. !#en
  5383. Conver a camera coordinates point to world coordinates.
  5384. !#zh
  5385. 将一个摄像机坐标系下的点转换到世界坐标系下。
  5386. @param point the point which should transform
  5387. */
  5388. getCameraToWorldPoint(point: Node): Vec2;
  5389. /**
  5390. !#en
  5391. Check whether the node is in the camera.
  5392. !#zh
  5393. 检测节点是否被此摄像机影响
  5394. @param node the node which need to check
  5395. */
  5396. containsNode(node: Node): boolean;
  5397. }
  5398. /** !#en Box Collider.
  5399. !#zh 包围盒碰撞组件 */
  5400. export class BoxCollider extends Collider implements Collider.Box {
  5401. /** !#en Position offset
  5402. !#zh 位置偏移量 */
  5403. offset: Vec2;
  5404. /** !#en Box size
  5405. !#zh 包围盒大小 */
  5406. size: Size;
  5407. }
  5408. /** !#en Circle Collider.
  5409. !#zh 圆形碰撞组件 */
  5410. export class CircleCollider extends Collider implements Collider.Circle {
  5411. /** !#en Position offset
  5412. !#zh 位置偏移量 */
  5413. offset: Vec2;
  5414. /** !#en Circle radius
  5415. !#zh 圆形半径 */
  5416. radius: number;
  5417. }
  5418. /** !#en Collider component base class.
  5419. !#zh 碰撞组件基类 */
  5420. export class Collider extends Component {
  5421. /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag.
  5422. !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */
  5423. tag: number;
  5424. }
  5425. /** !#en
  5426. A simple collision manager class.
  5427. It will calculate whether the collider collides other colliders, if collides then call the callbacks.
  5428. !#zh
  5429. 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */
  5430. export class CollisionManager implements EventTarget {
  5431. /** !#en
  5432. !#zh
  5433. 是否开启碰撞管理,默认为不开启 */
  5434. enabled: boolean;
  5435. /** !#en
  5436. !#zh
  5437. 是否绘制碰撞组件的包围盒,默认为不绘制 */
  5438. enabledDrawBoundingBox: boolean;
  5439. /** !#en
  5440. !#zh
  5441. 是否绘制碰撞组件的形状,默认为不绘制 */
  5442. enabledDebugDraw: boolean;
  5443. /**
  5444. !#en
  5445. Register an callback of a specific event type on the EventTarget.
  5446. !#zh
  5447. 注册事件目标的特定事件类型回调。
  5448. @param type A string representing the event type to listen for.
  5449. @param callback The callback that will be invoked when the event is dispatched.
  5450. The callback is ignored if it is a duplicate (the callbacks are unique).
  5451. @param target The target (this object) to invoke the callback, can be null
  5452. @param useCapture When set to true, the capture argument prevents callback
  5453. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5454. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5455. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5456. @example
  5457. ```js
  5458. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  5459. cc.log("this is callback");
  5460. }, node);
  5461. ```
  5462. */
  5463. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5464. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5465. /**
  5466. !#en
  5467. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  5468. if only type is passed as parameter, all listeners registered with that type will be removed.
  5469. !#zh
  5470. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  5471. @param type A string representing the event type being removed.
  5472. @param callback The callback to remove.
  5473. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  5474. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  5475. If not specified, useCapture defaults to false. If a callback was registered twice,
  5476. one with capture and one without, each must be removed separately. Removal of a capturing callback
  5477. does not affect a non-capturing version of the same listener, and vice versa.
  5478. @example
  5479. ```js
  5480. // register touchEnd eventListener
  5481. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  5482. cc.log("this is callback");
  5483. }, node);
  5484. // remove touch end event listener
  5485. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  5486. // remove all touch end event listeners
  5487. node.off(cc.Node.EventType.TOUCH_END);
  5488. ```
  5489. */
  5490. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  5491. /**
  5492. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  5493. This is not for removing all listeners in the current event target,
  5494. and this is not for removing all listeners the target parameter have registered.
  5495. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  5496. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  5497. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  5498. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  5499. @param target The target to be searched for all related listeners
  5500. */
  5501. targetOff(target: any): void;
  5502. /**
  5503. !#en
  5504. Register an callback of a specific event type on the EventTarget,
  5505. the callback will remove itself after the first time it is triggered.
  5506. !#zh
  5507. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  5508. @param type A string representing the event type to listen for.
  5509. @param callback The callback that will be invoked when the event is dispatched.
  5510. The callback is ignored if it is a duplicate (the callbacks are unique).
  5511. @param target The target (this object) to invoke the callback, can be null
  5512. @param useCapture When set to true, the capture argument prevents callback
  5513. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5514. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5515. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5516. @example
  5517. ```js
  5518. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  5519. cc.log("this is callback");
  5520. }, node);
  5521. ```
  5522. */
  5523. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5524. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5525. /**
  5526. !#en
  5527. Dispatches an event into the event flow.
  5528. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  5529. !#zh 分发事件到事件流中。
  5530. @param event The Event object that is dispatched into the event flow
  5531. */
  5532. dispatchEvent(event: Event): void;
  5533. /**
  5534. !#en
  5535. Send an event to this object directly, this method will not propagate the event to any other objects.
  5536. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  5537. !#zh
  5538. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  5539. @param message the message to send
  5540. @param detail whatever argument the message needs
  5541. */
  5542. emit(message: string, detail?: any): void;
  5543. }
  5544. /** !#en Intersection helper class
  5545. !#zh 辅助类,用于测试形状与形状是否相交 */
  5546. export class Intersection {
  5547. /**
  5548. !#en Test line and line
  5549. !#zh 测试线段与线段是否相交
  5550. @param a1 The start point of the first line
  5551. @param a2 The end point of the first line
  5552. @param b1 The start point of the second line
  5553. @param b2 The end point of the second line
  5554. */
  5555. static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean;
  5556. /**
  5557. !#en Test line and rect
  5558. !#zh 测试线段与矩形是否相交
  5559. @param a1 The start point of the line
  5560. @param a2 The end point of the line
  5561. @param b The rect
  5562. */
  5563. static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean;
  5564. /**
  5565. !#en Test line and polygon
  5566. !#zh 测试线段与多边形是否相交
  5567. @param a1 The start point of the line
  5568. @param a2 The end point of the line
  5569. @param b The polygon, a set of points
  5570. */
  5571. static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean;
  5572. /**
  5573. !#en Test rect and rect
  5574. !#zh 测试矩形与矩形是否相交
  5575. @param a The first rect
  5576. @param b The second rect
  5577. */
  5578. static rectRect(a: Rect, b: Rect): boolean;
  5579. /**
  5580. !#en Test rect and polygon
  5581. !#zh 测试矩形与多边形是否相交
  5582. @param a The rect
  5583. @param b The polygon, a set of points
  5584. */
  5585. static rectPolygon(a: Rect, b: Vec2[]): boolean;
  5586. /**
  5587. !#en Test polygon and polygon
  5588. !#zh 测试多边形与多边形是否相交
  5589. @param a The first polygon, a set of points
  5590. @param b The second polygon, a set of points
  5591. */
  5592. static polygonPolygon(a: Vec2[], b: Vec2[]): boolean;
  5593. /**
  5594. !#en Test circle and circle
  5595. !#zh 测试圆形与圆形是否相交
  5596. @param a Object contains position and radius
  5597. @param b Object contains position and radius
  5598. */
  5599. static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean;
  5600. /**
  5601. !#en Test polygon and circle
  5602. !#zh 测试矩形与圆形是否相交
  5603. @param polygon The Polygon, a set of points
  5604. @param circle Object contains position and radius
  5605. */
  5606. static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean;
  5607. /**
  5608. !#en Test whether the point is in the polygon
  5609. !#zh 测试一个点是否在一个多边形中
  5610. @param point The point
  5611. @param polygon The polygon, a set of points
  5612. */
  5613. static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean;
  5614. /**
  5615. !#en Calculate the distance of point to line.
  5616. !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。
  5617. @param point The point
  5618. @param start The start point of line
  5619. @param end The end point of line
  5620. @param isSegment whether this line is a segment
  5621. */
  5622. static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): boolean;
  5623. }
  5624. /** !#en Polygon Collider.
  5625. !#zh 多边形碰撞组件 */
  5626. export class PolygonCollider extends Collider implements Collider.Polygon {
  5627. /** !#en Position offset
  5628. !#zh 位置偏移量 */
  5629. offset: Vec2;
  5630. /** !#en Polygon points
  5631. !#zh 多边形顶点数组 */
  5632. points: [Vec2];
  5633. }
  5634. /** !#en
  5635. Base class for handling assets used in Fireball. This class can be instantiate.
  5636. You may want to override:<br/>
  5637. - createNode<br/>
  5638. - cc.Object._serialize<br/>
  5639. - cc.Object._deserialize<br/>
  5640. !#zh
  5641. 资源基类,该类可以被实例化。<br/>
  5642. 您可能需要重写:<br/>
  5643. - createNode <br/>
  5644. - cc.Object._serialize<br/>
  5645. - cc.Object._deserialize<br/> */
  5646. export class Asset extends RawAsset {
  5647. /** !#en
  5648. Returns the url of this asset's first raw file, if none of rawFile exists,
  5649. it will returns an empty string.
  5650. !#zh 返回该资源的原始文件的 URL,如果不支持 RAW 文件,它将返回一个空字符串。 */
  5651. rawUrl: string;
  5652. /** !#en
  5653. Returns the url of this asset's raw files, if none of rawFile exists,
  5654. it will returns an empty array.
  5655. !#zh 返回该资源的原文件的 URL 数组,如果不支持 RAW 文件,它将返回一个空数组。 */
  5656. rawUrls: string[];
  5657. /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`.
  5658. !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它 RawAsset。 */
  5659. static preventDeferredLoadDependents: boolean;
  5660. /**
  5661. !#en
  5662. Create a new node using this asset in the scene.<br/>
  5663. If this type of asset dont have its corresponding node type, this method should be null.
  5664. !#zh
  5665. 使用该资源在场景中创建一个新节点。<br/>
  5666. 如果这类资源没有相应的节点类型,该方法应该是空的。
  5667. @param callback callback
  5668. */
  5669. createNode(callback: (error: string, node: any) => void): void;
  5670. }
  5671. /** !#en Class for audio data handling.
  5672. !#zh 音频资源类。 */
  5673. export class AudioClip extends RawAsset {
  5674. }
  5675. /** !#en Class for BitmapFont handling.
  5676. !#zh 位图字体资源类。 */
  5677. export class BitmapFont extends RawAsset {
  5678. }
  5679. /** !#en Class for Font handling.
  5680. !#zh 字体资源类。 */
  5681. export class Font extends RawAsset {
  5682. }
  5683. /** !#en Class for LabelAtlas handling.
  5684. !#zh 艺术数字字体资源类。 */
  5685. export class LabelAtlas extends BitmapFont {
  5686. }
  5687. /** !#en Class for prefab handling.
  5688. !#zh 预制资源类。 */
  5689. export class Prefab extends Asset {
  5690. /** the main cc.Node in the prefab */
  5691. data: Node;
  5692. /** !#en Indicates the raw assets of this prefab can be load after prefab loaded.
  5693. !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */
  5694. asyncLoadAssets: boolean;
  5695. /**
  5696. Dynamically translation prefab data into minimized code.<br/>
  5697. This method will be called automatically before the first time the prefab being instantiated,
  5698. but you can re-call to refresh the create function once you modified the original prefab data in script.
  5699. */
  5700. compileCreateFunction(): void;
  5701. }
  5702. /** !#en Class for scene handling.
  5703. !#zh 场景资源类。 */
  5704. export class SceneAsset extends Asset {
  5705. scene: Scene;
  5706. /** !#en Indicates the raw assets of this scene can be load after scene launched.
  5707. !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */
  5708. asyncLoadAssets: boolean;
  5709. }
  5710. /** !#en
  5711. The base class for registering asset types.
  5712. You may want to override:
  5713. - createNode (static)
  5714. !#zh
  5715. 注册用的资源基类。<br/>
  5716. 你可能要重写:<br/>
  5717. - createNode (static) */
  5718. export class RawAsset extends Object {
  5719. /**
  5720. !#en
  5721. Create a new node in the scene.<br/>
  5722. If this type of asset dont have its corresponding node type, this method should be null.
  5723. !#zh
  5724. 在场景中创建一个新节点。<br/>
  5725. 如果这类资源没有相应的节点类型,该方法应该是空的。
  5726. @param Info Info
  5727. @param callback callback
  5728. */
  5729. static createNodeByInfo(Info: any, callback: (error: string, node: any) => void): void;
  5730. }
  5731. /** !#en Class for script handling.
  5732. !#zh Script 资源类。 */
  5733. export class _Script extends Asset {
  5734. }
  5735. /** !#en Class for JavaScript handling.
  5736. !#zh JavaScript 资源类。 */
  5737. export class _JavaScript extends Asset {
  5738. }
  5739. /** !#en Class for coffeescript handling.
  5740. !#zh CoffeeScript 资源类。 */
  5741. export class CoffeeScript extends Asset {
  5742. }
  5743. /** !#en Class for TypeScript handling.
  5744. !#zh TypeScript 资源类。 */
  5745. export class TypeScript extends Asset {
  5746. }
  5747. /** !#en Class for sprite atlas handling.
  5748. !#zh 精灵图集资源类。 */
  5749. export class SpriteAtlas extends RawAsset {
  5750. /**
  5751. Returns the texture of the sprite atlas
  5752. */
  5753. getTexture(): Texture2D;
  5754. /**
  5755. Returns the sprite frame correspond to the given key in sprite atlas.
  5756. @param key key
  5757. */
  5758. getSpriteFrame(key: string): SpriteFrame;
  5759. /**
  5760. Returns the sprite frames in sprite atlas.
  5761. */
  5762. getSpriteFrames(): [SpriteFrame];
  5763. }
  5764. /** !#en Class for TTFFont handling.
  5765. !#zh TTF 字体资源类。 */
  5766. export class TTFFont extends Asset {
  5767. }
  5768. /** !#en Class for text file.
  5769. !#zh 文本资源类。 */
  5770. export class TextAsset extends Asset {
  5771. }
  5772. /** !#en The animation component is used to play back animations.
  5773. Animation provide several events to register:
  5774. - play : Emit when begin playing animation
  5775. - stop : Emit when stop playing animation
  5776. - pause : Emit when pause animation
  5777. - resume : Emit when resume animation
  5778. - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame
  5779. - finished : Emit when finish playing animation
  5780. !#zh Animation 组件用于播放动画。
  5781. Animation 提供了一系列可注册的事件:
  5782. - play : 开始播放时
  5783. - stop : 停止播放时
  5784. - pause : 暂停播放时
  5785. - resume : 恢复播放时
  5786. - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时
  5787. - finished : 动画播放完成时 */
  5788. export class Animation extends Component implements EventTarget {
  5789. /** !#en Animation will play the default clip when start game.
  5790. !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */
  5791. defaultClip: AnimationClip;
  5792. /** !#en Current played clip.
  5793. !#zh 当前播放的动画剪辑。 */
  5794. currentClip: AnimationClip;
  5795. /** !#en Whether the animation should auto play the default clip when start game.
  5796. !#zh 是否在运行游戏后自动播放默认动画剪辑。 */
  5797. playOnLoad: boolean;
  5798. /**
  5799. !#en Get all the clips used in this animation.
  5800. !#zh 获取动画组件上的所有动画剪辑。
  5801. */
  5802. getClips(): AnimationClip[];
  5803. /**
  5804. !#en Plays an animation and stop other animations.
  5805. !#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。
  5806. @param name The name of animation to play. If no name is supplied then the default animation will be played.
  5807. @param startTime play an animation from startTime
  5808. @example
  5809. ```js
  5810. var animCtrl = this.node.getComponent(cc.Animation);
  5811. animCtrl.play("linear");
  5812. ```
  5813. */
  5814. play(name?: string, startTime?: number): AnimationState;
  5815. /**
  5816. !#en
  5817. Plays an additive animation, it will not stop other animations.
  5818. If there are other animations playing, then will play several animations at the same time.
  5819. !#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。
  5820. @param name The name of animation to play. If no name is supplied then the default animation will be played.
  5821. @param startTime play an animation from startTime
  5822. @example
  5823. ```js
  5824. // linear_1 and linear_2 at the same time playing.
  5825. var animCtrl = this.node.getComponent(cc.Animation);
  5826. animCtrl.playAdditive("linear_1");
  5827. animCtrl.playAdditive("linear_2");
  5828. ```
  5829. */
  5830. playAdditive(name?: string, startTime?: number): AnimationState;
  5831. /**
  5832. !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation. <br/>
  5833. Stopping an animation also Rewinds it to the Start.
  5834. !#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。
  5835. @param name The animation to stop, if not supplied then stops all playing animations.
  5836. */
  5837. stop(name?: string): void;
  5838. /**
  5839. !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation.
  5840. !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。
  5841. @param name The animation to pauses, if not supplied then pauses all playing animations.
  5842. */
  5843. pause(name?: string): void;
  5844. /**
  5845. !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation.
  5846. !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。
  5847. @param name The animation to resumes, if not supplied then resumes all paused animations.
  5848. */
  5849. resume(name?: string): void;
  5850. /**
  5851. !#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.
  5852. !#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。
  5853. @param time The time to go to
  5854. @param name Specified animation name, if not supplied then make all animations go to the time.
  5855. */
  5856. setCurrentTime(time?: number, name?: string): void;
  5857. /**
  5858. !#en Returns the animation state named name. If no animation with the specified name, the function will return null.
  5859. !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。
  5860. @param name name
  5861. */
  5862. getAnimationState(name: string): AnimationState;
  5863. /**
  5864. !#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.
  5865. !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。
  5866. @param clip the clip to add
  5867. @param newName newName
  5868. */
  5869. addClip(clip: AnimationClip, newName?: string): AnimationState;
  5870. /**
  5871. !#en
  5872. Remove clip from the animation list. This will remove the clip and any animation states based on it.
  5873. If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip.
  5874. 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
  5875. !#zh
  5876. 从动画列表中移除指定的动画剪辑,<br/>
  5877. 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。
  5878. 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。
  5879. @param clip clip
  5880. @param force If force is true, then will always remove the clip and any animation states based on it.
  5881. */
  5882. removeClip(clip: AnimationClip, force?: boolean): void;
  5883. /**
  5884. !#en
  5885. Samples animations at the current state.<br/>
  5886. This is useful when you explicitly want to set up some animation state, and sample it once.
  5887. !#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。
  5888. @param name name
  5889. */
  5890. sample(name: string): void;
  5891. /**
  5892. !#en
  5893. Register animation event callback.
  5894. The event arguments will provide the AnimationState which emit the event.
  5895. When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped.
  5896. !#zh
  5897. 注册动画事件回调。
  5898. 回调的事件里将会附上发送事件的 AnimationState。
  5899. 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。
  5900. @param type A string representing the event type to listen for.
  5901. @param callback The callback that will be invoked when the event is dispatched.
  5902. The callback is ignored if it is a duplicate (the callbacks are unique).
  5903. @param target The target (this object) to invoke the callback, can be null
  5904. @param useCapture When set to true, the capture argument prevents callback
  5905. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5906. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5907. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5908. @example
  5909. ```js
  5910. onPlay: function (event) {
  5911. var state = event.detail; // state instanceof cc.AnimationState
  5912. var type = event.type; // type === 'play';
  5913. }
  5914. // register event to all animation
  5915. animation.on('play', this.onPlay, this);
  5916. ```
  5917. */
  5918. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5919. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5920. /**
  5921. !#en
  5922. Unregister animation event callback.
  5923. !#zh
  5924. 取消注册动画事件回调。
  5925. @param type A string representing the event type being removed.
  5926. @param callback The callback to remove.
  5927. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  5928. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  5929. If not specified, useCapture defaults to false. If a callback was registered twice,
  5930. one with capture and one without, each must be removed separately. Removal of a capturing callback
  5931. does not affect a non-capturing version of the same listener, and vice versa.
  5932. @example
  5933. ```js
  5934. // unregister event to all animation
  5935. animation.off('play', this.onPlay, this);
  5936. ```
  5937. */
  5938. off(type: string, callback: Function, target?: any, useCapture?: boolean): void;
  5939. /**
  5940. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  5941. This is not for removing all listeners in the current event target,
  5942. and this is not for removing all listeners the target parameter have registered.
  5943. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  5944. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  5945. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  5946. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  5947. @param target The target to be searched for all related listeners
  5948. */
  5949. targetOff(target: any): void;
  5950. /**
  5951. !#en
  5952. Register an callback of a specific event type on the EventTarget,
  5953. the callback will remove itself after the first time it is triggered.
  5954. !#zh
  5955. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  5956. @param type A string representing the event type to listen for.
  5957. @param callback The callback that will be invoked when the event is dispatched.
  5958. The callback is ignored if it is a duplicate (the callbacks are unique).
  5959. @param target The target (this object) to invoke the callback, can be null
  5960. @param useCapture When set to true, the capture argument prevents callback
  5961. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5962. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5963. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5964. @example
  5965. ```js
  5966. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  5967. cc.log("this is callback");
  5968. }, node);
  5969. ```
  5970. */
  5971. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5972. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5973. /**
  5974. !#en
  5975. Dispatches an event into the event flow.
  5976. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  5977. !#zh 分发事件到事件流中。
  5978. @param event The Event object that is dispatched into the event flow
  5979. */
  5980. dispatchEvent(event: Event): void;
  5981. /**
  5982. !#en
  5983. Send an event to this object directly, this method will not propagate the event to any other objects.
  5984. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  5985. !#zh
  5986. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  5987. @param message the message to send
  5988. @param detail whatever argument the message needs
  5989. */
  5990. emit(message: string, detail?: any): void;
  5991. }
  5992. /** !#en Audio Source.
  5993. !#zh 音频源组件,能对音频剪辑。 */
  5994. export class AudioSource extends Component {
  5995. /** !#en
  5996. Is the audio source playing (Read Only). <br/>
  5997. Note: isPlaying is not supported for Native platforms.
  5998. !#zh
  5999. 该音频剪辑是否正播放(只读)。<br/>
  6000. 注意:Native 平台暂时不支持 isPlaying。 */
  6001. isPlaying: boolean;
  6002. /** !#en The clip of the audio source.
  6003. !#zh 默认要播放的音频剪辑。 */
  6004. clip: AudioClip;
  6005. /** !#en The volume of the audio source.
  6006. !#zh 音频源的音量(0.0 ~ 1.0)。 */
  6007. volume: number;
  6008. /** !#en Is the audio source mute?
  6009. !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */
  6010. mute: boolean;
  6011. /** !#en Is the audio source looping?
  6012. !#zh 音频源是否循环播放? */
  6013. loop: boolean;
  6014. /** !#en If set to true, the audio source will automatically start playing on onLoad.
  6015. !#zh 如果设置为true,音频源将在 onLoad 时自动播放。 */
  6016. playOnLoad: boolean;
  6017. /**
  6018. !#en Plays the clip.
  6019. !#zh 播放音频剪辑。
  6020. */
  6021. play(): void;
  6022. /**
  6023. !#en Stops the clip.
  6024. !#zh 停止当前音频剪辑。
  6025. */
  6026. stop(): void;
  6027. /**
  6028. !#en Pause the clip.
  6029. !#zh 暂停当前音频剪辑。
  6030. */
  6031. pause(): void;
  6032. /**
  6033. !#en Resume the clip.
  6034. !#zh 恢复播放。
  6035. */
  6036. resume(): void;
  6037. /**
  6038. !#en Rewind playing music.
  6039. !#zh 从头开始播放。
  6040. */
  6041. rewind(): void;
  6042. /**
  6043. !#en Get current time
  6044. !#zh 获取当前的播放时间
  6045. */
  6046. getCurrentTime(): void;
  6047. /**
  6048. !#en Set current time
  6049. !#zh 设置当前的播放时间
  6050. @param time time
  6051. */
  6052. setCurrentTime(time: number): void;
  6053. /**
  6054. !#en Get audio duration
  6055. !#zh 获取当前音频的长度
  6056. */
  6057. getDuration(): void;
  6058. }
  6059. /** !#en
  6060. This component will block all input events (mouse and touch) within the bounding box of the node, preventing the input from penetrating into the underlying node, typically for the background of the top UI.<br>
  6061. This component does not have any API interface and can be added directly to the scene to take effect.
  6062. !#zh
  6063. 该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。<br>
  6064. 该组件没有任何 API 接口,直接添加到场景即可生效。 */
  6065. export class BlockInputEvents extends Component {
  6066. }
  6067. /** !#en
  6068. Button has 4 Transition types
  6069. When Button state changed:
  6070. If Transition type is Button.Transition.NONE, Button will do nothing
  6071. If Transition type is Button.Transition.COLOR, Button will change target's color
  6072. If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
  6073. If Transition type is Button.Transition.SCALE, Button will change target node's scale
  6074. Button will trigger 5 events:
  6075. Button.EVENT_TOUCH_DOWN
  6076. Button.EVENT_TOUCH_UP
  6077. Button.EVENT_HOVER_IN
  6078. Button.EVENT_HOVER_MOVE
  6079. Button.EVENT_HOVER_OUT
  6080. !#zh
  6081. 按钮组件。可以被按下,或者点击。</br>
  6082. 按钮可以通过修改 Transition 来设置按钮状态过渡的方式:</br>
  6083. -Button.Transition.NONE // 不做任何过渡</br>
  6084. -Button.Transition.COLOR // 进行颜色之间过渡</br>
  6085. -Button.Transition.SPRITE // 进行精灵之间过渡</br>
  6086. -Button.Transition.SCALE // 进行缩放过渡</br>
  6087. 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):</br>
  6088. // 以下事件可以在全平台上都触发</br>
  6089. -cc.Node.EventType.TOUCH_START // 按下时事件</br>
  6090. -cc.Node.EventType.TOUCH_Move // 按住移动后事件</br>
  6091. -cc.Node.EventType.TOUCH_END // 按下后松开后事件</br>
  6092. -cc.Node.EventType.TOUCH_CANCEL // 按下取消事件</br>
  6093. // 以下事件只在 PC 平台上触发</br>
  6094. -cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件</br>
  6095. -cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件</br>
  6096. -cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件</br>
  6097. -cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件</br>
  6098. -cc.Node.EventType.MOUSE_UP // 鼠标松开事件</br>
  6099. -cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件</br> */
  6100. export class Button extends Component {
  6101. /** !#en
  6102. Whether the Button is disabled.
  6103. If true, the Button will trigger event and do transition.
  6104. !#zh
  6105. 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */
  6106. interactable: boolean;
  6107. /** !#en When this flag is true, Button target sprite will turn gray when interactable is false.
  6108. !#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */
  6109. enableAutoGrayEffect: boolean;
  6110. /** !#en Transition type
  6111. !#zh 按钮状态改变时过渡方式。 */
  6112. transition: Button.Transition;
  6113. /** !#en Normal state color.
  6114. !#zh 普通状态下按钮所显示的颜色。 */
  6115. normalColor: Color;
  6116. /** !#en Pressed state color
  6117. !#zh 按下状态时按钮所显示的颜色。 */
  6118. pressedColor: Color;
  6119. /** !#en Hover state color
  6120. !#zh 悬停状态下按钮所显示的颜色。 */
  6121. hoverColor: Color;
  6122. /** !#en Disabled state color
  6123. !#zh 禁用状态下按钮所显示的颜色。 */
  6124. disabledColor: Color;
  6125. /** !#en Color and Scale transition duration
  6126. !#zh 颜色过渡和缩放过渡时所需时间 */
  6127. duration: number;
  6128. /** !#en When user press the button, the button will zoom to a scale.
  6129. The final scale of the button equals (button original scale * zoomScale)
  6130. !#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */
  6131. zoomScale: number;
  6132. /** !#en Normal state sprite
  6133. !#zh 普通状态下按钮所显示的 Sprite 。 */
  6134. normalSprite: SpriteFrame;
  6135. /** !#en Pressed state sprite
  6136. !#zh 按下状态时按钮所显示的 Sprite 。 */
  6137. pressedSprite: SpriteFrame;
  6138. /** !#en Hover state sprite
  6139. !#zh 悬停状态下按钮所显示的 Sprite 。 */
  6140. hoverSprite: SpriteFrame;
  6141. /** !#en Disabled state sprite
  6142. !#zh 禁用状态下按钮所显示的 Sprite 。 */
  6143. disabledSprite: SpriteFrame;
  6144. /** !#en
  6145. Transition target.
  6146. When Button state changed:
  6147. If Transition type is Button.Transition.NONE, Button will do nothing
  6148. If Transition type is Button.Transition.COLOR, Button will change target's color
  6149. If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
  6150. !#zh
  6151. 需要过渡的目标。
  6152. 当前按钮状态改变规则:
  6153. -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。
  6154. -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。
  6155. -如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */
  6156. target: Node;
  6157. /** !#en If Button is clicked, it will trigger event's handler
  6158. !#zh 按钮的点击事件列表。 */
  6159. clickEvents: Component.EventHandler[];
  6160. }
  6161. /** !#zh: 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。
  6162. 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */
  6163. export class Canvas extends Component {
  6164. /** !#en Current active canvas, the scene should only have one active canvas at the same time.
  6165. !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */
  6166. static instance: Canvas;
  6167. /** !#en The desigin resolution for current scene.
  6168. !#zh 当前场景设计分辨率。 */
  6169. designResolution: Size;
  6170. /** !#en TODO
  6171. !#zh: 是否优先将设计分辨率高度撑满视图高度。 */
  6172. fitHeight: boolean;
  6173. /** !#en TODO
  6174. !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */
  6175. fitWidth: boolean;
  6176. }
  6177. /** !#en
  6178. Base class for everything attached to Node(Entity).<br/>
  6179. <br/>
  6180. NOTE: Not allowed to use construction parameters for Component's subclasses,
  6181. because Component is created by the engine.
  6182. !#zh
  6183. 所有附加到节点的基类。<br/>
  6184. <br/>
  6185. 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */
  6186. export class Component extends Object {
  6187. /** !#en The node this component is attached to. A component is always attached to a node.
  6188. !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */
  6189. node: Node;
  6190. /** !#en The uuid for editor.
  6191. !#zh 组件的 uuid,用于编辑器。 */
  6192. uuid: string;
  6193. /** !#en indicates whether this component is enabled or not.
  6194. !#zh 表示该组件自身是否启用。 */
  6195. enabled: boolean;
  6196. /** !#en indicates whether this component is enabled and its node is also active in the hierarchy.
  6197. !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */
  6198. enabledInHierarchy: boolean;
  6199. /** !#en Returns a value which used to indicate the onLoad get called or not.
  6200. !#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */
  6201. _isOnLoadCalled: number;
  6202. /**
  6203. !#en Update is called every frame, if the Component is enabled.
  6204. !#zh 如果该组件启用,则每帧调用 update。
  6205. @param dt the delta time in seconds it took to complete the last frame
  6206. */
  6207. protected update(dt: number): void;
  6208. /**
  6209. !#en LateUpdate is called every frame, if the Component is enabled.
  6210. !#zh 如果该组件启用,则每帧调用 LateUpdate。
  6211. */
  6212. protected lateUpdate(): void;
  6213. /**
  6214. !#en
  6215. When attaching to an active node or its node first activated.
  6216. onLoad is always called before any start functions, this allows you to order initialization of scripts.
  6217. !#zh
  6218. 当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。
  6219. */
  6220. protected onLoad(): void;
  6221. /**
  6222. !#en
  6223. Called before all scripts' update if the Component is enabled the first time.
  6224. Usually used to initialize some logic which need to be called after all components' `onload` methods called.
  6225. !#zh
  6226. 如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。
  6227. */
  6228. protected start(): void;
  6229. /**
  6230. !#en Called when this component becomes enabled and its node is active.
  6231. !#zh 当该组件被启用,并且它的节点也激活时。
  6232. */
  6233. protected onEnable(): void;
  6234. /**
  6235. !#en Called when this component becomes disabled or its node becomes inactive.
  6236. !#zh 当该组件被禁用或节点变为无效时调用。
  6237. */
  6238. protected onDisable(): void;
  6239. /**
  6240. !#en Called when this component will be destroyed.
  6241. !#zh 当该组件被销毁时调用
  6242. */
  6243. protected onDestroy(): void;
  6244. protected onFocusInEditor(): void;
  6245. protected onLostFocusInEditor(): void;
  6246. /**
  6247. !#en Called to initialize the component or node’s properties when adding the component the first time or when the Reset command is used. This function is only called in editor.
  6248. !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。
  6249. */
  6250. protected resetInEditor(): void;
  6251. /**
  6252. !#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
  6253. !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。
  6254. @param typeOrClassName the constructor or the class name of the component to add
  6255. @example
  6256. ```js
  6257. var sprite = node.addComponent(cc.Sprite);
  6258. var test = node.addComponent("Test");
  6259. ```
  6260. */
  6261. addComponent<T extends Component>(type: {new(): T}): T;
  6262. addComponent(className: string): any;
  6263. /**
  6264. !#en
  6265. Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
  6266. You can also get component in the node by passing in the name of the script.
  6267. !#zh
  6268. 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。<br/>
  6269. 传入参数也可以是脚本的名称。
  6270. @param typeOrClassName typeOrClassName
  6271. @example
  6272. ```js
  6273. // get sprite component.
  6274. var sprite = node.getComponent(cc.Sprite);
  6275. // get custom test calss.
  6276. var test = node.getComponent("Test");
  6277. ```
  6278. */
  6279. getComponent<T extends Component>(type: {prototype: T}): T;
  6280. getComponent(className: string): any;
  6281. /**
  6282. !#en Returns all components of supplied Type in the node.
  6283. !#zh 返回节点上指定类型的所有组件。
  6284. @param typeOrClassName typeOrClassName
  6285. @example
  6286. ```js
  6287. var sprites = node.getComponents(cc.Sprite);
  6288. var tests = node.getComponents("Test");
  6289. ```
  6290. */
  6291. getComponents<T extends Component>(type: {prototype: T}): T[];
  6292. getComponents(className: string): any[];
  6293. /**
  6294. !#en Returns the component of supplied type in any of its children using depth first search.
  6295. !#zh 递归查找所有子节点中第一个匹配指定类型的组件。
  6296. @param typeOrClassName typeOrClassName
  6297. @example
  6298. ```js
  6299. var sprite = node.getComponentInChildren(cc.Sprite);
  6300. var Test = node.getComponentInChildren("Test");
  6301. ```
  6302. */
  6303. getComponentInChildren<T extends Component>(type: {prototype: T}): T;
  6304. getComponentInChildren(className: string): any;
  6305. /**
  6306. !#en Returns the components of supplied type in self or any of its children using depth first search.
  6307. !#zh 递归查找自身或所有子节点中指定类型的组件
  6308. @param typeOrClassName typeOrClassName
  6309. @example
  6310. ```js
  6311. var sprites = node.getComponentsInChildren(cc.Sprite);
  6312. var tests = node.getComponentsInChildren("Test");
  6313. ```
  6314. */
  6315. getComponentsInChildren<T extends Component>(type: {prototype: T}): T[];
  6316. getComponentsInChildren(className: string): any[];
  6317. /**
  6318. !#en
  6319. If the component's bounding box is different from the node's, you can implement this method to supply
  6320. a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly.
  6321. !#zh
  6322. 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB),
  6323. 以便编辑器的场景视图可以正确地执行点选测试。
  6324. @param out_rect the Rect to receive the bounding box
  6325. */
  6326. _getLocalBounds(out_rect: Rect): void;
  6327. /**
  6328. !#en
  6329. onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs
  6330. an undo operation on this component.<br/>
  6331. <br/>
  6332. If the component contains the "internal state", short for "temporary member variables which not included<br/>
  6333. in its CCClass properties", then you may need to implement this function.<br/>
  6334. <br/>
  6335. The editor will call the getset accessors of your component to record/restore the component's state<br/>
  6336. for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement<br/>
  6337. this function to manually synchronize your component's "internal states" with its public properties.<br/>
  6338. Once you implement this function, all the getset accessors of your component will not be called when<br/>
  6339. the user performs an undo/redo operation. Which means that only the properties with default value<br/>
  6340. will be recorded or restored by editor.<br/>
  6341. <br/>
  6342. Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need<br/>
  6343. to support the reset menu, you should manually synchronize your component's "internal states" with its<br/>
  6344. properties in this function. Once you implement this function, all the getset accessors of your component<br/>
  6345. will not be called during reset operation. Which means that only the properties with default value<br/>
  6346. will be reset by editor.
  6347. This function is only called in editor mode.
  6348. !#zh
  6349. onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。<br/>
  6350. <br/>
  6351. 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。<br/>
  6352. <br/>
  6353. 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。
  6354. 然而,在极端的情况下,它可能无法良好运作。<br/>
  6355. 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。
  6356. 一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。
  6357. 这意味着仅仅指定了默认值的属性将被编辑器记录和还原。<br/>
  6358. <br/>
  6359. 同样的,编辑可能无法在极端情况下正确地重置您的组件。<br/>
  6360. 于是如果你需要支持组件重置菜单,你需要在该方法中手工同步组件属性到“内部状态”。<br/>
  6361. 一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。
  6362. 这意味着仅仅指定了默认值的属性将被编辑器重置。
  6363. <br/>
  6364. 此方法仅在编辑器下会被调用。
  6365. */
  6366. onRestore(): void;
  6367. /**
  6368. !#en
  6369. Schedules a custom selector.<br/>
  6370. If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.
  6371. !#zh
  6372. 调度一个自定义的回调函数。<br/>
  6373. 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。
  6374. @param callback The callback function
  6375. @param interval Tick interval in seconds. 0 means tick every frame.
  6376. @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely.
  6377. @param delay The amount of time that the first tick will wait before execution.
  6378. @example
  6379. ```js
  6380. var timeCallback = function (dt) {
  6381. cc.log("time: " + dt);
  6382. }
  6383. this.schedule(timeCallback, 1);
  6384. ```
  6385. */
  6386. schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void;
  6387. /**
  6388. !#en Schedules a callback function that runs only once, with a delay of 0 or larger.
  6389. !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。
  6390. @param callback A function wrapped as a selector
  6391. @param delay The amount of time that the first tick will wait before execution.
  6392. @example
  6393. ```js
  6394. var timeCallback = function (dt) {
  6395. cc.log("time: " + dt);
  6396. }
  6397. this.scheduleOnce(timeCallback, 2);
  6398. ```
  6399. */
  6400. scheduleOnce(callback: Function, delay?: number): void;
  6401. /**
  6402. !#en Unschedules a custom callback function.
  6403. !#zh 取消调度一个自定义的回调函数。
  6404. @param callback_fn A function wrapped as a selector
  6405. @example
  6406. ```js
  6407. this.unschedule(_callback);
  6408. ```
  6409. */
  6410. unschedule(callback_fn: Function): void;
  6411. /**
  6412. !#en
  6413. unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.<br/>
  6414. Actions are not affected by this method.
  6415. !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 'update' 回调函数。动作不受此方法影响。
  6416. @example
  6417. ```js
  6418. this.unscheduleAllCallbacks();
  6419. ```
  6420. */
  6421. unscheduleAllCallbacks(): void;
  6422. }
  6423. /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users.
  6424. !#zh EditBox 组件,用于获取用户的输入文本。 */
  6425. export class EditBox extends _RendererUnderSG {
  6426. /** !#en Input string of EditBox.
  6427. !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */
  6428. string: string;
  6429. /** !#en The background image of EditBox.
  6430. !#zh 输入框的背景图片 */
  6431. backgroundImage: SpriteFrame;
  6432. /** !#en
  6433. The return key type of EditBox.
  6434. Note: it is meaningless for web platforms and desktop platforms.
  6435. !#zh
  6436. 指定移动设备上面回车按钮的样式。
  6437. 注意:这个选项对 web 平台与 desktop 平台无效。 */
  6438. returnType: EditBox.KeyboardReturnType;
  6439. /** !#en Set the input flags that are to be applied to the EditBox.
  6440. !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */
  6441. inputFlag: EditBox.InputFlag;
  6442. /** !#en
  6443. Set the input mode of the edit box.
  6444. If you pass ANY, it will create a multiline EditBox.
  6445. !#zh
  6446. 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */
  6447. inputMode: EditBox.InputMode;
  6448. /** !#en Font size of the input text.
  6449. !#zh 输入框文本的字体大小 */
  6450. fontSize: number;
  6451. /** !#en Change the lineHeight of displayed text.
  6452. !#zh 输入框文本的行高。 */
  6453. lineHeight: number;
  6454. /** !#en Font color of the input text.
  6455. !#zh 输入框文本的颜色。 */
  6456. fontColor: Color;
  6457. /** !#en The display text of placeholder.
  6458. !#zh 输入框占位符的文本内容。 */
  6459. placeholder: string;
  6460. /** !#en The font size of placeholder.
  6461. !#zh 输入框占位符的字体大小。 */
  6462. placeholderFontSize: number;
  6463. /** !#en The font color of placeholder.
  6464. !#zh 输入框最大允许输入的字符个数。 */
  6465. placeholderFontColor: Color;
  6466. /** !#en The maximize input length of EditBox.
  6467. - If pass a value less than 0, it won't limit the input number of characters.
  6468. - If pass 0, it doesn't allow input any characters.
  6469. !#zh 输入框最大允许输入的字符个数。
  6470. - 如果值为小于 0 的值,则不会限制输入字符个数。
  6471. - 如果值为 0,则不允许用户进行任何输入。 */
  6472. maxLength: number;
  6473. /** !#en The input is always visible and be on top of the game view.
  6474. !zh 输入框总是可见,并且永远在游戏视图的上面
  6475. Note: only available on Web at the moment. */
  6476. stayOnTop: boolean;
  6477. /** !#en Set the tabIndex of the DOM input element, only useful on Web.
  6478. !#zh 修改 DOM 输入元素的 tabIndex,这个属性只有在 Web 上面修改有意义。 */
  6479. tabIndex: number;
  6480. /** !#en The event handler to be called when EditBox began to edit text.
  6481. !#zh 开始编辑文本输入框触发的事件回调。 */
  6482. editingDidBegan: Component.EventHandler[];
  6483. /** !#en The event handler to be called when EditBox text changes.
  6484. !#zh 编辑文本输入框时触发的事件回调。 */
  6485. textChanged: Component.EventHandler[];
  6486. /** !#en The event handler to be called when EditBox edit ends.
  6487. !#zh 结束编辑文本输入框时触发的事件回调。 */
  6488. editingDidEnded: Component.EventHandler[];
  6489. /** !#en The event handler to be called when return key is pressed. Windows is not supported.
  6490. !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */
  6491. editingReturn: Component.EventHandler[];
  6492. /**
  6493. !#en Let the EditBox get focus, only valid when stayOnTop is true.
  6494. !#zh 让当前 EditBox 获得焦点,只有在 stayOnTop 为 true 的时候设置有效
  6495. Note: only available on Web at the moment.
  6496. */
  6497. setFocus(): void;
  6498. /**
  6499. !#en Determine whether EditBox is getting focus or not.
  6500. !#zh 判断 EditBox 是否获得了焦点
  6501. Note: only available on Web at the moment.
  6502. */
  6503. isFocused(): void;
  6504. /**
  6505. !#en if you don't need the EditBox and it isn't in any running Scene, you should
  6506. call the destroy method on this component or the associated node explicitly.
  6507. Otherwise, the created DOM element won't be removed from web page.
  6508. !#zh
  6509. 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  6510. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  6511. @example
  6512. ```js
  6513. editbox.node.parent = null; // or editbox.node.removeFromParent(false);
  6514. // when you don't need editbox anymore
  6515. editbox.node.destroy();
  6516. ```
  6517. */
  6518. destroy(): boolean;
  6519. }
  6520. /** !#en The Label Component.
  6521. !#zh 文字标签组件 */
  6522. export class Label extends _RendererUnderSG {
  6523. /** !#en Content string of label.
  6524. !#zh 标签显示的文本内容。 */
  6525. string: string;
  6526. /** !#en Horizontal Alignment of label.
  6527. !#zh 文本内容的水平对齐方式。 */
  6528. horizontalAlign: Label.HorizontalAlign;
  6529. /** !#en Vertical Alignment of label.
  6530. !#zh 文本内容的垂直对齐方式。 */
  6531. verticalAlign: Label.VerticalAlign;
  6532. /** !#en The actual rendering font size in shrink mode
  6533. !#zh SHRINK 模式下面文本实际渲染的字体大小 */
  6534. actualFontSize: number;
  6535. /** !#en Font size of label.
  6536. !#zh 文本字体大小。 */
  6537. fontSize: number;
  6538. /** !#en Font family of label, only take effect when useSystemFont property is true.
  6539. !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */
  6540. fontFamily: string;
  6541. /** !#en Line Height of label.
  6542. !#zh 文本行高。 */
  6543. lineHeight: number;
  6544. /** !#en Overflow of label.
  6545. !#zh 文字显示超出范围时的处理方式。 */
  6546. overflow: Label.Overflow;
  6547. /** !#en Whether auto wrap label when string width is large than label width.
  6548. !#zh 是否自动换行。 */
  6549. enableWrapText: boolean;
  6550. /** !#en The font of label.
  6551. !#zh 文本字体。 */
  6552. font: Font;
  6553. /** !#en Whether use system font name or not.
  6554. !#zh 是否使用系统字体。 */
  6555. isSystemFontUsed: boolean;
  6556. }
  6557. /** !#en Outline effect used to change the display, only used for TTF font
  6558. !#zh 描边效果组件,用于字体描边,只能用于系统字体 */
  6559. export class LabelOutline extends Component {
  6560. /** !#en Change the outline color
  6561. !#zh 改变描边的颜色 */
  6562. color: Color;
  6563. /** !#en Change the outline width
  6564. !#zh 改变描边的宽度 */
  6565. width: number;
  6566. }
  6567. /** !#en
  6568. The Layout is a container component, use it to arrange child elements easily.<br>
  6569. Note:<br>
  6570. 1.Scaling and rotation of child nodes are not considered.<br>
  6571. 2.After setting the Layout, the results need to be updated until the next frame,
  6572. unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。
  6573. !#zh
  6574. Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。<br>
  6575. 注意:<br>
  6576. 1.不会考虑子节点的缩放和旋转。<br>
  6577. 2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */
  6578. export class Layout extends Component {
  6579. /** !#en The layout type.
  6580. !#zh 布局类型 */
  6581. type: Layout.Type;
  6582. /** !#en
  6583. The are three resize modes for Layout.
  6584. None, resize Container and resize children.
  6585. !#zh 缩放模式 */
  6586. resizeMode: Layout.ResizeMode;
  6587. /** !#en The cell size for grid layout.
  6588. !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */
  6589. cellSize: Size;
  6590. /** !#en
  6591. The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first,
  6592. and then break line on demand. Choose vertical if you want to layout vertically at first .
  6593. !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */
  6594. startAxis: Layout.AxisDirection;
  6595. /** !#en The left padding of layout, it only effect the layout in one direction.
  6596. !#zh 容器内左边距,只会在一个布局方向上生效。 */
  6597. paddingLeft: number;
  6598. /** !#en The right padding of layout, it only effect the layout in one direction.
  6599. !#zh 容器内右边距,只会在一个布局方向上生效。 */
  6600. paddingRight: number;
  6601. /** !#en The top padding of layout, it only effect the layout in one direction.
  6602. !#zh 容器内上边距,只会在一个布局方向上生效。 */
  6603. paddingTop: number;
  6604. /** !#en The bottom padding of layout, it only effect the layout in one direction.
  6605. !#zh 容器内下边距,只会在一个布局方向上生效。 */
  6606. paddingBottom: number;
  6607. /** !#en The distance in x-axis between each element in layout.
  6608. !#zh 子节点之间的水平间距。 */
  6609. spacingX: number;
  6610. /** !#en The distance in y-axis between each element in layout.
  6611. !#zh 子节点之间的垂直间距。 */
  6612. spacingY: number;
  6613. /** !#en
  6614. Only take effect in Vertical layout mode.
  6615. This option changes the start element's positioning.
  6616. !#zh 垂直排列子节点的方向。 */
  6617. verticalDirection: Layout.VerticalDirection;
  6618. /** !#en
  6619. Only take effect in Horizontal layout mode.
  6620. This option changes the start element's positioning.
  6621. !#zh 水平排列子节点的方向。 */
  6622. horizontalDirection: Layout.HorizontalDirection;
  6623. /**
  6624. !#en Perform the layout update
  6625. !#zh 立即执行更新布局
  6626. @example
  6627. ```js
  6628. layout.type = cc.Layout.HORIZONTAL;
  6629. layout.node.addChild(childNode);
  6630. cc.log(childNode.x); // not yet changed
  6631. layout.updateLayout();
  6632. cc.log(childNode.x); // changed
  6633. ```
  6634. */
  6635. updateLayout(): void;
  6636. /** !#en The padding of layout, it effects the layout in four direction.
  6637. !#zh 容器内边距,该属性会在四个布局方向上生效。 */
  6638. padding: number;
  6639. }
  6640. /** !#en The Mask Component
  6641. !#zh 遮罩组件 */
  6642. export class Mask extends _RendererInSG {
  6643. /** !#en The mask type.
  6644. !#zh 遮罩类型 */
  6645. type: Mask.Type;
  6646. /** !#en The mask image
  6647. !#zh 遮罩所需要的贴图 */
  6648. spriteFrame: SpriteFrame;
  6649. /** !#en
  6650. The alpha threshold.(Not supported Canvas Mode) <br/>
  6651. The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold. <br/>
  6652. Should be a float between 0 and 1. <br/>
  6653. This default to 1 (so alpha test is disabled).
  6654. !#zh
  6655. Alpha 阈值(不支持 Canvas 模式)<br/>
  6656. 只有当模板的像素的 alpha 大于 alphaThreshold 时,才会绘制内容。<br/>
  6657. 该数值 0 ~ 1 之间的浮点数,默认值为 1(因此禁用 alpha) */
  6658. alphaThreshold: number;
  6659. /** !#en Reverse mask (Not supported Canvas Mode)
  6660. !#zh 反向遮罩(不支持 Canvas 模式) */
  6661. inverted: boolean;
  6662. /** !#en The segements for ellipse mask.
  6663. !#zh 椭圆遮罩的曲线细分数 */
  6664. segements: number;
  6665. }
  6666. /** !#en The PageView control
  6667. !#zh 页面视图组件 */
  6668. export class PageView extends ScrollView {
  6669. /** !#en Specify the size type of each page in PageView.
  6670. !#zh 页面视图中每个页面大小类型 */
  6671. sizeMode: PageView.SizeMode;
  6672. /** !#en The page view direction
  6673. !#zh 页面视图滚动类型 */
  6674. direction: PageView.Direction;
  6675. /** !#en
  6676. The scroll threshold value, when drag exceeds this value,
  6677. release the next page will automatically scroll, less than the restore
  6678. !#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */
  6679. scrollThreshold: number;
  6680. /** !#en
  6681. Auto page turning velocity threshold. When users swipe the PageView quickly,
  6682. it will calculate a velocity based on the scroll distance and time,
  6683. if the calculated velocity is larger than the threshold, then it will trigger page turning.
  6684. !#zh
  6685. 快速滑动翻页临界值。
  6686. 当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值,
  6687. 该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */
  6688. autoPageTurningThreshold: number;
  6689. /** !#en Change the PageTurning event timing of PageView.
  6690. !#zh 设置 PageView PageTurning 事件的发送时机。 */
  6691. pageTurningEventTiming: number;
  6692. /** !#en The Page View Indicator
  6693. !#zh 页面视图指示器组件 */
  6694. indicator: PageViewIndicator;
  6695. /** !#en The time required to turn over a page. unit: second
  6696. !#zh 每个页面翻页时所需时间。单位:秒 */
  6697. pageTurningSpeed: number;
  6698. /** !#en PageView events callback
  6699. !#zh 滚动视图的事件回调函数 */
  6700. pageEvents: Component.EventHandler[];
  6701. /**
  6702. !#en Returns current page index
  6703. !#zh 返回当前页面索引
  6704. */
  6705. getCurrentPageIndex(): number;
  6706. /**
  6707. !#en Set current page index
  6708. !#zh 设置当前页面索引
  6709. @param index index
  6710. */
  6711. setCurrentPageIndex(index: number): void;
  6712. /**
  6713. !#en Returns all pages of pageview
  6714. !#zh 返回视图中的所有页面
  6715. */
  6716. getPages(): Node[];
  6717. /**
  6718. !#en At the end of the current page view to insert a new view
  6719. !#zh 在当前页面视图的尾部插入一个新视图
  6720. @param page page
  6721. */
  6722. addPage(page: Node): void;
  6723. /**
  6724. !#en Inserts a page in the specified location
  6725. !#zh 将页面插入指定位置中
  6726. @param page page
  6727. @param index index
  6728. */
  6729. insertPage(page: Node, index: number): void;
  6730. /**
  6731. !#en Removes a page from PageView.
  6732. !#zh 移除指定页面
  6733. @param page page
  6734. */
  6735. removePage(page: Node): void;
  6736. /**
  6737. !#en Removes a page at index of PageView.
  6738. !#zh 移除指定下标的页面
  6739. @param index index
  6740. */
  6741. removePageAtIndex(index: number): void;
  6742. /**
  6743. !#en Removes all pages from PageView
  6744. !#zh 移除所有页面
  6745. */
  6746. removeAllPages(): void;
  6747. /**
  6748. !#en Scroll PageView to index.
  6749. !#zh 滚动到指定页面
  6750. @param idx index of page.
  6751. @param timeInSecond scrolling time
  6752. */
  6753. scrollToPage(idx: number, timeInSecond: number): void;
  6754. }
  6755. /** !#en The Page View Indicator Component
  6756. !#zh 页面视图每页标记组件 */
  6757. export class PageViewIndicator extends Component {
  6758. /** !#en The spriteFrame for each element.
  6759. !#zh 每个页面标记显示的图片 */
  6760. spriteFrame: SpriteFrame;
  6761. /** !#en The location direction of PageViewIndicator.
  6762. !#zh 页面标记摆放方向 */
  6763. direction: PageViewIndicator.Direction;
  6764. /** !#en The cellSize for each element.
  6765. !#zh 每个页面标记的大小 */
  6766. cellSize: Size;
  6767. /** !#en The distance between each element.
  6768. !#zh 每个页面标记之间的边距 */
  6769. spacing: number;
  6770. /**
  6771. !#en Set Page View
  6772. !#zh 设置页面视图
  6773. @param target target
  6774. */
  6775. setPageView(target: PageView): void;
  6776. }
  6777. /** !#en
  6778. Visual indicator of progress in some operation.
  6779. Displays a bar to the user representing how far the operation has progressed.
  6780. !#zh
  6781. 进度条组件,可用于显示加载资源时的进度。 */
  6782. export class ProgressBar extends Component {
  6783. /** !#en The targeted Sprite which will be changed progressively.
  6784. !#zh 用来显示进度条比例的 Sprite 对象。 */
  6785. barSprite: Sprite;
  6786. /** !#en The progress mode, there are two modes supported now: horizontal and vertical.
  6787. !#zh 进度条的模式 */
  6788. mode: ProgressBar.Mode;
  6789. /** !#en The total width or height of the bar sprite.
  6790. !#zh 进度条实际的总长度 */
  6791. totalLength: number;
  6792. /** !#en The current progress of the bar sprite. The valid value is between 0-1.
  6793. !#zh 当前进度值,该数值的区间是 0-1 之间。 */
  6794. progress: number;
  6795. /** !#en Whether reverse the progress direction of the bar sprite.
  6796. !#zh 进度条是否进行反方向变化。 */
  6797. reverse: boolean;
  6798. }
  6799. /** Rendering component in scene graph.
  6800. Maintains a node which will be the scene graph of component's Node. */
  6801. export class _RendererInSG extends _SGComponent {
  6802. }
  6803. /** The base rendering component which will attach a leaf node to the cocos2d scene graph. */
  6804. export class _RendererUnderSG extends _SGComponent {
  6805. }
  6806. /** !#en The RichText Component.
  6807. !#zh 富文本组件 */
  6808. export class RichText extends Component {
  6809. /** !#en Content string of RichText.
  6810. !#zh 富文本显示的文本内容。 */
  6811. string: string;
  6812. /** !#en Horizontal Alignment of each line in RichText.
  6813. !#zh 文本内容的水平对齐方式。 */
  6814. horizontalAlign: TextAlignment;
  6815. /** !#en Font size of RichText.
  6816. !#zh 富文本字体大小。 */
  6817. fontSize: number;
  6818. /** !#en Custom TTF font of RichText
  6819. !#zh 富文本定制字体 */
  6820. font: cc.TTFFont;
  6821. /** !#en The maximize width of the RichText
  6822. !#zh 富文本的最大宽度 */
  6823. maxWidth: number;
  6824. /** !#en Line Height of RichText.
  6825. !#zh 富文本行高。 */
  6826. lineHeight: number;
  6827. /** !#en The image atlas for the img tag. For each src value in the img tag, there should be a valid spriteFrame in the image atlas.
  6828. !#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */
  6829. imageAtlas: SpriteAtlas;
  6830. /** !#en
  6831. Once checked, the RichText will block all input events (mouse and touch) within
  6832. the bounding box of the node, preventing the input from penetrating into the underlying node.
  6833. !#zh
  6834. 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */
  6835. handleTouchEvent: boolean;
  6836. }
  6837. /** The base class for all rendering component in scene graph.
  6838. You should override:
  6839. - _createSgNode
  6840. - _initSgNode */
  6841. export class _SGComponent extends Component {
  6842. }
  6843. /** !#en
  6844. The Scrollbar control allows the user to scroll an image or other view that is too large to see completely
  6845. !#zh 滚动条组件 */
  6846. export class Scrollbar extends Component {
  6847. /** !#en The "handle" part of the scrollbar.
  6848. !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */
  6849. handle: Sprite;
  6850. /** !#en The direction of scrollbar.
  6851. !#zh ScrollBar 的滚动方向。 */
  6852. direction: Scrollbar.Direction;
  6853. /** !#en Whether enable auto hide or not.
  6854. !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */
  6855. enableAutoHide: boolean;
  6856. /** !#en
  6857. The time to hide scrollbar when scroll finished.
  6858. Note: This value is only useful when enableAutoHide is true.
  6859. !#zh
  6860. 没有滚动动作后经过多久会自动隐藏。
  6861. 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */
  6862. autoHideTime: number;
  6863. }
  6864. /** !#en
  6865. Layout container for a view hierarchy that can be scrolled by the user,
  6866. allowing it to be larger than the physical display.
  6867. !#zh
  6868. 滚动视图组件 */
  6869. export class ScrollView extends Component {
  6870. /** !#en This is a reference to the UI element to be scrolled.
  6871. !#zh 可滚动展示内容的节点。 */
  6872. content: Node;
  6873. /** !#en Enable horizontal scroll.
  6874. !#zh 是否开启水平滚动。 */
  6875. horizontal: boolean;
  6876. /** !#en Enable vertical scroll.
  6877. !#zh 是否开启垂直滚动。 */
  6878. vertical: boolean;
  6879. /** !#en When inertia is set, the content will continue to move when touch ended.
  6880. !#zh 是否开启滚动惯性。 */
  6881. inertia: boolean;
  6882. /** !#en
  6883. It determines how quickly the content stop moving. A value of 1 will stop the movement immediately.
  6884. A value of 0 will never stop the movement until it reaches to the boundary of scrollview.
  6885. !#zh
  6886. 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */
  6887. brake: number;
  6888. /** !#en When elastic is set, the content will be bounce back when move out of boundary.
  6889. !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */
  6890. elastic: boolean;
  6891. /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately.
  6892. !#zh 回弹持续的时间,0 表示将立即反弹。 */
  6893. bounceDuration: number;
  6894. /** !#en The horizontal scrollbar reference.
  6895. !#zh 水平滚动的 ScrollBar。 */
  6896. horizontalScrollBar: Scrollbar;
  6897. /** !#en The vertical scrollbar reference.
  6898. !#zh 垂直滚动的 ScrollBar。 */
  6899. verticalScrollBar: Scrollbar;
  6900. /** !#en Scrollview events callback
  6901. !#zh 滚动视图的事件回调函数 */
  6902. scrollEvents: Component.EventHandler[];
  6903. /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes
  6904. It's set to true by default.
  6905. !#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。
  6906. 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */
  6907. cancelInnerEvents: boolean;
  6908. /**
  6909. !#en Scroll the content to the bottom boundary of ScrollView.
  6910. !#zh 视图内容将在规定时间内滚动到视图底部。
  6911. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6912. the content will jump to the bottom boundary immediately.
  6913. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6914. @example
  6915. ```js
  6916. // Scroll to the bottom of the view.
  6917. scrollView.scrollToBottom(0.1);
  6918. ```
  6919. */
  6920. scrollToBottom(timeInSecond?: number, attenuated?: boolean): void;
  6921. /**
  6922. !#en Scroll the content to the top boundary of ScrollView.
  6923. !#zh 视图内容将在规定时间内滚动到视图顶部。
  6924. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6925. the content will jump to the top boundary immediately.
  6926. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6927. @example
  6928. ```js
  6929. // Scroll to the top of the view.
  6930. scrollView.scrollToTop(0.1);
  6931. ```
  6932. */
  6933. scrollToTop(timeInSecond?: number, attenuated?: boolean): void;
  6934. /**
  6935. !#en Scroll the content to the left boundary of ScrollView.
  6936. !#zh 视图内容将在规定时间内滚动到视图左边。
  6937. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6938. the content will jump to the left boundary immediately.
  6939. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6940. @example
  6941. ```js
  6942. // Scroll to the left of the view.
  6943. scrollView.scrollToLeft(0.1);
  6944. ```
  6945. */
  6946. scrollToLeft(timeInSecond?: number, attenuated?: boolean): void;
  6947. /**
  6948. !#en Scroll the content to the right boundary of ScrollView.
  6949. !#zh 视图内容将在规定时间内滚动到视图右边。
  6950. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6951. the content will jump to the right boundary immediately.
  6952. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6953. @example
  6954. ```js
  6955. // Scroll to the right of the view.
  6956. scrollView.scrollToRight(0.1);
  6957. ```
  6958. */
  6959. scrollToRight(timeInSecond?: number, attenuated?: boolean): void;
  6960. /**
  6961. !#en Scroll the content to the top left boundary of ScrollView.
  6962. !#zh 视图内容将在规定时间内滚动到视图左上角。
  6963. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6964. the content will jump to the top left boundary immediately.
  6965. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6966. @example
  6967. ```js
  6968. // Scroll to the upper left corner of the view.
  6969. scrollView.scrollToTopLeft(0.1);
  6970. ```
  6971. */
  6972. scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void;
  6973. /**
  6974. !#en Scroll the content to the top right boundary of ScrollView.
  6975. !#zh 视图内容将在规定时间内滚动到视图右上角。
  6976. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6977. the content will jump to the top right boundary immediately.
  6978. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6979. @example
  6980. ```js
  6981. // Scroll to the top right corner of the view.
  6982. scrollView.scrollToTopRight(0.1);
  6983. ```
  6984. */
  6985. scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void;
  6986. /**
  6987. !#en Scroll the content to the bottom left boundary of ScrollView.
  6988. !#zh 视图内容将在规定时间内滚动到视图左下角。
  6989. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6990. the content will jump to the bottom left boundary immediately.
  6991. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6992. @example
  6993. ```js
  6994. // Scroll to the lower left corner of the view.
  6995. scrollView.scrollToBottomLeft(0.1);
  6996. ```
  6997. */
  6998. scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void;
  6999. /**
  7000. !#en Scroll the content to the bottom right boundary of ScrollView.
  7001. !#zh 视图内容将在规定时间内滚动到视图右下角。
  7002. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7003. the content will jump to the bottom right boundary immediately.
  7004. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7005. @example
  7006. ```js
  7007. // Scroll to the lower right corner of the view.
  7008. scrollView.scrollToBottomRight(0.1);
  7009. ```
  7010. */
  7011. scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void;
  7012. /**
  7013. !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the
  7014. specific offset immediately.
  7015. !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。
  7016. @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset
  7017. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7018. the content will jump to the specific offset of ScrollView immediately.
  7019. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7020. @example
  7021. ```js
  7022. // Scroll to middle position in 0.1 second in x-axis
  7023. var maxScrollOffset = this.getMaxScrollOffset();
  7024. scrollView.scrollToOffset(cc.p(maxScrollOffset.x / 2, 0), 0.1);
  7025. ```
  7026. */
  7027. scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void;
  7028. /**
  7029. !#en Get the positive offset value corresponds to the content's top left boundary.
  7030. !#zh 获取滚动视图相对于左上角原点的当前滚动偏移
  7031. */
  7032. getScrollOffset(): Vec2;
  7033. /**
  7034. !#en Get the maximize available scroll offset
  7035. !#zh 获取滚动视图最大可以滚动的偏移量
  7036. */
  7037. getMaxScrollOffset(): Vec2;
  7038. /**
  7039. !#en Scroll the content to the horizontal percent position of ScrollView.
  7040. !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。
  7041. @param percent A value between 0 and 1.
  7042. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7043. the content will jump to the horizontal percent position of ScrollView immediately.
  7044. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7045. @example
  7046. ```js
  7047. // Scroll to middle position.
  7048. scrollView.scrollToBottomRight(0.5, 0.1);
  7049. ```
  7050. */
  7051. scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void;
  7052. /**
  7053. !#en Scroll the content to the percent position of ScrollView in any direction.
  7054. !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。
  7055. @param anchor A point which will be clamp between cc.p(0,0) and cc.p(1,1).
  7056. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7057. the content will jump to the percent position of ScrollView immediately.
  7058. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7059. @example
  7060. ```js
  7061. // Vertical scroll to the bottom of the view.
  7062. scrollView.scrollTo(cc.p(0, 1), 0.1);
  7063. // Horizontal scroll to view right.
  7064. scrollView.scrollTo(cc.p(1, 0), 0.1);
  7065. ```
  7066. */
  7067. scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void;
  7068. /**
  7069. !#en Scroll the content to the vertical percent position of ScrollView.
  7070. !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。
  7071. @param percent A value between 0 and 1.
  7072. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7073. the content will jump to the vertical percent position of ScrollView immediately.
  7074. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7075. // Scroll to middle position.
  7076. scrollView.scrollToPercentVertical(0.5, 0.1);
  7077. */
  7078. scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void;
  7079. /**
  7080. !#en Stop auto scroll immediately
  7081. !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动
  7082. */
  7083. stopAutoScroll(): void;
  7084. /**
  7085. !#en Modify the content position.
  7086. !#zh 设置当前视图内容的坐标点。
  7087. @param position The position in content's parent space.
  7088. */
  7089. setContentPosition(position: Vec2): void;
  7090. /**
  7091. !#en Query the content's position in its parent space.
  7092. !#zh 获取当前视图内容的坐标点。
  7093. */
  7094. getContentPosition(): Position;
  7095. /**
  7096. !#en Query whether the user is currently dragging the ScrollView to scroll it
  7097. !#zh 用户是否在拖拽当前滚动视图
  7098. */
  7099. isScrolling(): boolean;
  7100. /**
  7101. !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown.
  7102. !#zh 当前滚动视图是否在惯性滚动
  7103. */
  7104. isAutoScrolling(): boolean;
  7105. }
  7106. /** !#en The Slider Control
  7107. !#zh 滑动器组件 */
  7108. export class Slider extends Component {
  7109. /** !#en The "handle" part of the slider
  7110. !#zh 滑动器滑块按钮部件 */
  7111. handle: Button;
  7112. /** !#en The slider direction
  7113. !#zh 滑动器方向 */
  7114. direction: Slider.Direction;
  7115. /** !#en The current progress of the slider. The valid value is between 0-1
  7116. !#zh 当前进度值,该数值的区间是 0-1 之间 */
  7117. progress: number;
  7118. /** !#en The slider events callback
  7119. !#zh 滑动器组件事件回调函数 */
  7120. slideEvents: Component.EventHandler[];
  7121. }
  7122. /** !#en Renders a sprite in the scene.
  7123. !#zh 该组件用于在场景中渲染精灵。 */
  7124. export class Sprite extends _RendererUnderSG {
  7125. /** !#en The sprite frame of the sprite.
  7126. !#zh 精灵的精灵帧 */
  7127. spriteFrame: SpriteFrame;
  7128. /** !#en The sprite render type.
  7129. !#zh 精灵渲染类型 */
  7130. type: Sprite.SpriteType;
  7131. /** !#en
  7132. The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7133. !#zh
  7134. 精灵填充类型,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  7135. fillType: Sprite.FillType;
  7136. /** !#en
  7137. The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7138. !#zh
  7139. 填充中心点,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  7140. fillCenter: Vec2;
  7141. /** !#en
  7142. The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7143. !#zh
  7144. 填充起始点,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  7145. fillStart: number;
  7146. /** !#en
  7147. The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7148. !#zh
  7149. 填充范围,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  7150. fillRange: number;
  7151. /** !#en specify the frame is trimmed or not.
  7152. !#zh 是否使用裁剪模式 */
  7153. trim: boolean;
  7154. /** !#en specify the source Blend Factor.
  7155. !#zh 指定原图的混合模式 */
  7156. srcBlendFactor: BlendFactor;
  7157. /** !#en specify the destination Blend Factor.
  7158. !#zh 指定目标的混合模式 */
  7159. dstBlendFactor: BlendFactor;
  7160. /** !#en specify the size tracing mode.
  7161. !#zh 精灵尺寸调整模式 */
  7162. sizeMode: Sprite.SizeMode;
  7163. /**
  7164. !#en Change the left sprite's cap inset.
  7165. !#zh 设置精灵左边框-用于九宫格。
  7166. @param insetLeft The values to use for the cap inset.
  7167. @example
  7168. ```js
  7169. sprite.setInsetLeft(5);
  7170. ```
  7171. */
  7172. setInsetLeft(insetLeft: number): void;
  7173. /**
  7174. !#en Query the left sprite's cap inset.
  7175. !#zh 获取精灵左边框
  7176. @example
  7177. ```js
  7178. var insetLeft = sprite.getInsetLeft();
  7179. cc.log("Inset Left:" + insetLeft);
  7180. ```
  7181. */
  7182. getInsetLeft(): number;
  7183. /**
  7184. !#en Change the top sprite's cap inset.
  7185. !#zh 设置精灵上边框-用于九宫格。
  7186. @param insetTop The values to use for the cap inset.
  7187. @example
  7188. ```js
  7189. sprite.setInsetTop(5);
  7190. ```
  7191. */
  7192. setInsetTop(insetTop: number): void;
  7193. /**
  7194. !#en Query the top sprite's cap inset.
  7195. !#zh 获取精灵上边框。
  7196. @example
  7197. ```js
  7198. var insetTop = sprite.getInsetTop();
  7199. cc.log("Inset Top:" + insetTop);
  7200. ```
  7201. */
  7202. getInsetTop(): number;
  7203. /**
  7204. !#en Change the right sprite's cap inset.
  7205. !#zh 设置精灵右边框-用于九宫格。
  7206. @param insetRight The values to use for the cap inset.
  7207. @example
  7208. ```js
  7209. sprite.setInsetRight(5);
  7210. ```
  7211. */
  7212. setInsetRight(insetRight: number): void;
  7213. /**
  7214. !#en Query the right sprite's cap inset.
  7215. !#zh 获取精灵右边框。
  7216. @example
  7217. ```js
  7218. var insetRight = sprite.getInsetRight();
  7219. cc.log("Inset Right:" + insetRight);
  7220. ```
  7221. */
  7222. getInsetRight(): number;
  7223. /**
  7224. !#en Change the bottom sprite's cap inset.
  7225. !#zh 设置精灵下边框-用于九宫格。
  7226. @param bottomInset The values to use for the cap inset.
  7227. @example
  7228. ```js
  7229. sprite.setInsetBottom(5);
  7230. ```
  7231. */
  7232. setInsetBottom(bottomInset: number): void;
  7233. /**
  7234. !#en Query the bottom sprite's cap inset.
  7235. !#zh 获取精灵下边框。
  7236. @example
  7237. ```js
  7238. var insetBottom = sprite.getInsetBottom();
  7239. cc.log("Inset Bottom:" + insetBottom);
  7240. ```
  7241. */
  7242. getInsetBottom(): number;
  7243. }
  7244. /** !#en A distortion used to change the rendering of simple sprite.If will take effect after sprite component is added.
  7245. !#zh 扭曲效果组件,用于改变SIMPLE类型sprite的渲染,只有当sprite组件已经添加后,才能起作用. */
  7246. export class SpriteDistortion extends Component {
  7247. /** !#en Change the UV offset for distortion rendering.
  7248. !#zh 在渲染时改变UV的整体偏移. */
  7249. offset: Vec2;
  7250. /** !#en Change the UV scale for distortion rendering.
  7251. !#zh 在渲染时改变UV的寻址系数 */
  7252. tiling: Vec2;
  7253. }
  7254. /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it
  7255. could be treated as a RadioButton.
  7256. !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */
  7257. export class Toggle extends Button {
  7258. /** !#en When this value is true, the check mark component will be enabled, otherwise
  7259. the check mark component will be disabled.
  7260. !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */
  7261. isChecked: boolean;
  7262. /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox.
  7263. Otherwise, the toggle is a RadioButton.
  7264. !#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox,
  7265. 否则,Toggle 是一个 RadioButton。 */
  7266. toggleGroup: ToggleGroup;
  7267. /** !#en The image used for the checkmark.
  7268. !#zh Toggle 处于选中状态时显示的图片 */
  7269. checkMark: Sprite;
  7270. /** !#en If Toggle is clicked, it will trigger event's handler
  7271. !#zh Toggle 按钮的点击事件列表。 */
  7272. checkEvents: Component.EventHandler[];
  7273. /**
  7274. !#en Make the toggle button checked.
  7275. !#zh 使 toggle 按钮处于选中状态
  7276. */
  7277. check(): void;
  7278. /**
  7279. !#en Make the toggle button unchecked.
  7280. !#zh 使 toggle 按钮处于未选中状态
  7281. */
  7282. uncheck(): void;
  7283. }
  7284. /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles. </br>
  7285. Toggles that belong to the same group could only have one of them to be switched on at a time.</br>
  7286. Note: All the first layer child node containing the toggle component will auto be added to the container
  7287. !#zh ToggleContainer 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。</br>
  7288. 当一组 Toggle 属于同一个 ToggleContainer 的时候,任何时候只能有一个 Toggle 处于选中状态。</br>
  7289. 注意:所有包含 Toggle 组件的一级子节点都会自动被添加到该容器中 */
  7290. export class ToggleContainer extends Component {
  7291. /** !#en If this setting is true, a toggle could be switched off and on when pressed.
  7292. If it is false, it will make sure there is always only one toggle could be switched on
  7293. and the already switched on toggle can't be switched off.
  7294. !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */
  7295. allowSwitchOff: boolean;
  7296. /** !#en Read only property, return the toggle items array reference managed by ToggleContainer.
  7297. !#zh 只读属性,返回 ToggleContainer 管理的 toggle 数组引用 */
  7298. toggleItems: Toggle[];
  7299. }
  7300. /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game.
  7301. !#zh Video 组件,用于在游戏中播放视频 */
  7302. export class VideoPlayer extends _RendererUnderSG {
  7303. /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path.
  7304. !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */
  7305. resourceType: VideoPlayer.ResourceType;
  7306. /** !#en The remote URL of video.
  7307. !#zh 远程视频的 URL */
  7308. remoteURL: string;
  7309. /** !#en The local video full path.
  7310. !#zh 本地视频的 URL */
  7311. clip: string;
  7312. /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time.
  7313. !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */
  7314. currentTime: number;
  7315. /** !#en Whether keep the aspect ration of the original video.
  7316. !#zh 是否保持视频原来的宽高比 */
  7317. keepAspectRatio: boolean;
  7318. /** !#en Whether play video in fullscreen mode.
  7319. !#zh 是否全屏播放视频 */
  7320. isFullscreen: boolean;
  7321. /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed.
  7322. !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */
  7323. videoPlayerEvent: Component.EventHandler[];
  7324. /**
  7325. !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch.
  7326. !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。
  7327. */
  7328. play(): void;
  7329. /**
  7330. !#en If a video is paused, call this method to resume playing.
  7331. !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。
  7332. */
  7333. resume(): void;
  7334. /**
  7335. !#en If a video is playing, call this method to pause playing.
  7336. !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。
  7337. */
  7338. pause(): void;
  7339. /**
  7340. !#en If a video is playing, call this method to stop playing immediately.
  7341. !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。
  7342. */
  7343. stop(): void;
  7344. /**
  7345. !#en Gets the duration of the video
  7346. !#zh 获取视频文件的播放总时长
  7347. */
  7348. getDuration(): number;
  7349. /**
  7350. !#en Determine whether video is playing or not.
  7351. !#zh 判断当前视频是否处于播放状态
  7352. */
  7353. isPlaying(): boolean;
  7354. /**
  7355. !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should
  7356. call the destroy method on this component or the associated node explicitly.
  7357. Otherwise, the created DOM element won't be removed from web page.
  7358. !#zh
  7359. 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  7360. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  7361. @example
  7362. ```js
  7363. videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false);
  7364. // when you don't need videoplayer anymore
  7365. videoplayer.node.destroy();
  7366. ```
  7367. */
  7368. destroy(): boolean;
  7369. }
  7370. /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles.
  7371. Toggles that belong to the same group could only have one of them to be switched on at a time.
  7372. !#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候,
  7373. 任何时候只能有一个 Toggle 处于选中状态。 */
  7374. export class ToggleGroup extends Component {
  7375. /** !#en If this setting is true, a toggle could be switched off and on when pressed.
  7376. If it is false, it will make sure there is always only one toggle could be switched on
  7377. and the already switched on toggle can't be switched off.
  7378. !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */
  7379. allowSwitchOff: boolean;
  7380. /** !#en Read only property, return the toggle items array reference managed by toggleGroup.
  7381. !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */
  7382. toggleItems: any[];
  7383. }
  7384. /** !#en
  7385. Handling touch events in a ViewGroup takes special care,
  7386. because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself.
  7387. To make sure that each view correctly receives the touch events intended for it,
  7388. ViewGroup should register capture phase event and handle the event propagation properly.
  7389. Please refer to Scrollview for more information.
  7390. !#zh
  7391. ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。
  7392. 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。
  7393. 请参考 ScrollView 的实现来获取更多信息。 */
  7394. export class ViewGroup extends Component {
  7395. }
  7396. /** !#en cc.WebView is a component for display web pages in the game
  7397. !#zh WebView 组件,用于在游戏中显示网页 */
  7398. export class WebView extends _RendererUnderSG {
  7399. /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix.
  7400. !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */
  7401. url: string;
  7402. /** !#en The webview's event callback , it will be triggered when certain webview event occurs.
  7403. !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */
  7404. webviewLoadedEvents: Component.EventHandler[];
  7405. /**
  7406. !#en
  7407. Set javascript interface scheme (see also setOnJSCallback). <br/>
  7408. Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
  7409. Please refer to the official documentation for more details.
  7410. !#zh
  7411. 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。<br/>
  7412. 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。<br/>
  7413. 详情请参阅官方文档
  7414. @param scheme scheme
  7415. */
  7416. setJavascriptInterfaceScheme(scheme: string): void;
  7417. /**
  7418. !#en
  7419. This callback called when load URL that start with javascript
  7420. interface scheme (see also setJavascriptInterfaceScheme). <br/>
  7421. Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
  7422. Please refer to the official documentation for more details.
  7423. !#zh
  7424. 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。<br/>
  7425. 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。
  7426. 详情请参阅官方文档
  7427. @param callback callback
  7428. */
  7429. setOnJSCallback(callback: Function): void;
  7430. /**
  7431. !#en
  7432. Evaluates JavaScript in the context of the currently displayed page. <br/>
  7433. Please refer to the official document for more details <br/>
  7434. Note: Cross domain issues need to be resolved by yourself <br/>
  7435. !#zh
  7436. 执行 WebView 内部页面脚本(详情请参阅官方文档) <br/>
  7437. 注意:需要自行解决跨域问题
  7438. @param str str
  7439. */
  7440. evaluateJS(str: string): void;
  7441. /**
  7442. !#en if you don't need the WebView and it isn't in any running Scene, you should
  7443. call the destroy method on this component or the associated node explicitly.
  7444. Otherwise, the created DOM element won't be removed from web page.
  7445. !#zh
  7446. 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  7447. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  7448. @example
  7449. ```js
  7450. webview.node.parent = null; // or webview.node.removeFromParent(false);
  7451. // when you don't need webview anymore
  7452. webview.node.destroy();
  7453. ```
  7454. */
  7455. destroy(): void;
  7456. }
  7457. /** !#en
  7458. Stores and manipulate the anchoring based on its parent.
  7459. Widget are used for GUI but can also be used for other things.
  7460. Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame unless you call {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}} manually.
  7461. !#zh
  7462. Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。
  7463. Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */
  7464. export class Widget extends Component {
  7465. /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node.
  7466. The default value is null, and when null, indicates the current parent.
  7467. !#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */
  7468. target: Node;
  7469. /** !#en Whether to align the top.
  7470. !#zh 是否对齐上边。 */
  7471. isAlignTop: boolean;
  7472. /** !#en
  7473. Vertically aligns the midpoint, This will open the other vertical alignment options cancel.
  7474. !#zh
  7475. 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */
  7476. isAlignVerticalCenter: boolean;
  7477. /** !#en Whether to align the bottom.
  7478. !#zh 是否对齐下边。 */
  7479. isAlignBottom: boolean;
  7480. /** !#en Whether to align the left.
  7481. !#zh 是否对齐左边 */
  7482. isAlignLeft: boolean;
  7483. /** !#en
  7484. Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled.
  7485. !#zh
  7486. 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */
  7487. isAlignHorizontalCenter: boolean;
  7488. /** !#en Whether to align the right.
  7489. !#zh 是否对齐右边。 */
  7490. isAlignRight: boolean;
  7491. /** !#en
  7492. Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally,
  7493. the width setting is invalid (read only).
  7494. !#zh
  7495. 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */
  7496. isStretchWidth: boolean;
  7497. /** !#en
  7498. Whether the stretched vertically, when enable the left and right alignment will be stretched vertically,
  7499. then height setting is invalid (read only)
  7500. !#zh
  7501. 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */
  7502. isStretchHeight: boolean;
  7503. /** !#en
  7504. The margins between the top of this node and the top of parent node,
  7505. the value can be negative, Only available in 'isAlignTop' open.
  7506. !#zh
  7507. 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */
  7508. top: number;
  7509. /** !#en
  7510. The margins between the bottom of this node and the bottom of parent node,
  7511. the value can be negative, Only available in 'isAlignBottom' open.
  7512. !#zh
  7513. 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */
  7514. bottom: number;
  7515. /** !#en
  7516. The margins between the left of this node and the left of parent node,
  7517. the value can be negative, Only available in 'isAlignLeft' open.
  7518. !#zh
  7519. 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */
  7520. left: number;
  7521. /** !#en
  7522. The margins between the right of this node and the right of parent node,
  7523. the value can be negative, Only available in 'isAlignRight' open.
  7524. !#zh
  7525. 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */
  7526. right: number;
  7527. /** !#en
  7528. Horizontal aligns the midpoint offset value,
  7529. the value can be negative, Only available in 'isAlignHorizontalCenter' open.
  7530. !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */
  7531. horizontalCenter: number;
  7532. /** !#en
  7533. Vertical aligns the midpoint offset value,
  7534. the value can be negative, Only available in 'isAlignVerticalCenter' open.
  7535. !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */
  7536. verticalCenter: number;
  7537. /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
  7538. !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
  7539. isAbsoluteHorizontalCenter: boolean;
  7540. /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
  7541. !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
  7542. isAbsoluteVerticalCenter: boolean;
  7543. /** !#en
  7544. If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
  7545. !#zh
  7546. 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
  7547. isAbsoluteTop: boolean;
  7548. /** !#en
  7549. If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
  7550. !#zh
  7551. 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
  7552. isAbsoluteBottom: boolean;
  7553. /** !#en
  7554. If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
  7555. !#zh
  7556. 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
  7557. isAbsoluteLeft: boolean;
  7558. /** !#en
  7559. If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
  7560. !#zh
  7561. 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
  7562. isAbsoluteRight: boolean;
  7563. /** !#en TODO
  7564. !#zh
  7565. 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。
  7566. 这样便于脚本或动画继续控制当前节点。
  7567. 注意:onEnable 时所在的那一帧仍然会进行对齐。 */
  7568. isAlignOnce: boolean;
  7569. /**
  7570. !#en
  7571. Immediately perform the widget alignment. You need to manually call this method only if
  7572. you need to get the latest results after the alignment before the end of current frame.
  7573. !#zh
  7574. 立刻执行 widget 对齐操作。这个接口一般不需要手工调用。
  7575. 只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。
  7576. @example
  7577. ```js
  7578. widget.top = 10; // change top margin
  7579. cc.log(widget.node.y); // not yet changed
  7580. widget.updateAlignment();
  7581. cc.log(widget.node.y); // changed
  7582. ```
  7583. */
  7584. updateAlignment(): void;
  7585. }
  7586. /** !#en
  7587. EventTarget is an object to which an event is dispatched when something has occurred.
  7588. Entity are the most common event targets, but other objects can be event targets too.
  7589. Event targets are an important part of the Fireball event model.
  7590. The event target serves as the focal point for how events flow through the scene graph.
  7591. When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object
  7592. into the event flow from the root of the hierarchy. The event object then makes its way through
  7593. the scene graph until it reaches the event target, at which point it begins its return trip through
  7594. the scene graph. This round-trip journey to the event target is conceptually divided into three phases:
  7595. - The capture phase comprises the journey from the root to the last node before the event target's node
  7596. - The target phase comprises only the event target node
  7597. - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree
  7598. See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7599. Event targets can implement the following methods:
  7600. - _getCapturingTargets
  7601. - _getBubblingTargets
  7602. !#zh
  7603. 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标,
  7604. 但是其他对象也可以是事件目标。<br/> */
  7605. export class EventTarget {
  7606. /**
  7607. !#en
  7608. Register an callback of a specific event type on the EventTarget.
  7609. !#zh
  7610. 注册事件目标的特定事件类型回调。
  7611. @param type A string representing the event type to listen for.
  7612. @param callback The callback that will be invoked when the event is dispatched.
  7613. The callback is ignored if it is a duplicate (the callbacks are unique).
  7614. @param target The target (this object) to invoke the callback, can be null
  7615. @param useCapture When set to true, the capture argument prevents callback
  7616. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  7617. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  7618. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  7619. @example
  7620. ```js
  7621. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  7622. cc.log("this is callback");
  7623. }, node);
  7624. ```
  7625. */
  7626. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  7627. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  7628. /**
  7629. !#en
  7630. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  7631. if only type is passed as parameter, all listeners registered with that type will be removed.
  7632. !#zh
  7633. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  7634. @param type A string representing the event type being removed.
  7635. @param callback The callback to remove.
  7636. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  7637. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  7638. If not specified, useCapture defaults to false. If a callback was registered twice,
  7639. one with capture and one without, each must be removed separately. Removal of a capturing callback
  7640. does not affect a non-capturing version of the same listener, and vice versa.
  7641. @example
  7642. ```js
  7643. // register touchEnd eventListener
  7644. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  7645. cc.log("this is callback");
  7646. }, node);
  7647. // remove touch end event listener
  7648. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  7649. // remove all touch end event listeners
  7650. node.off(cc.Node.EventType.TOUCH_END);
  7651. ```
  7652. */
  7653. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  7654. /**
  7655. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  7656. This is not for removing all listeners in the current event target,
  7657. and this is not for removing all listeners the target parameter have registered.
  7658. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  7659. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  7660. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  7661. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  7662. @param target The target to be searched for all related listeners
  7663. */
  7664. targetOff(target: any): void;
  7665. /**
  7666. !#en
  7667. Register an callback of a specific event type on the EventTarget,
  7668. the callback will remove itself after the first time it is triggered.
  7669. !#zh
  7670. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  7671. @param type A string representing the event type to listen for.
  7672. @param callback The callback that will be invoked when the event is dispatched.
  7673. The callback is ignored if it is a duplicate (the callbacks are unique).
  7674. @param target The target (this object) to invoke the callback, can be null
  7675. @param useCapture When set to true, the capture argument prevents callback
  7676. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  7677. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  7678. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  7679. @example
  7680. ```js
  7681. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  7682. cc.log("this is callback");
  7683. }, node);
  7684. ```
  7685. */
  7686. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  7687. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  7688. /**
  7689. !#en
  7690. Dispatches an event into the event flow.
  7691. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  7692. !#zh 分发事件到事件流中。
  7693. @param event The Event object that is dispatched into the event flow
  7694. */
  7695. dispatchEvent(event: Event): void;
  7696. /**
  7697. !#en
  7698. Send an event to this object directly, this method will not propagate the event to any other objects.
  7699. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  7700. !#zh
  7701. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  7702. @param message the message to send
  7703. @param detail whatever argument the message needs
  7704. */
  7705. emit(message: string, detail?: any): void;
  7706. }
  7707. /** !#en Base class of all kinds of events.
  7708. !#zh 包含事件相关信息的对象。 */
  7709. export class Event {
  7710. /**
  7711. @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
  7712. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  7713. */
  7714. constructor(type: string, bubbles: boolean);
  7715. /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit".
  7716. !#zh 事件类型。 */
  7717. type: string;
  7718. /** !#en Indicate whether the event bubbles up through the tree or not.
  7719. !#zh 表示该事件是否进行冒泡。 */
  7720. bubbles: boolean;
  7721. /** !#en A reference to the target to which the event was originally dispatched.
  7722. !#zh 最初事件触发的目标 */
  7723. target: any;
  7724. /** !#en A reference to the currently registered target for the event.
  7725. !#zh 当前目标 */
  7726. currentTarget: any;
  7727. /** !#en
  7728. Indicates which phase of the event flow is currently being evaluated.
  7729. Returns an integer value represented by 4 constants:
  7730. - Event.NONE = 0
  7731. - Event.CAPTURING_PHASE = 1
  7732. - Event.AT_TARGET = 2
  7733. - Event.BUBBLING_PHASE = 3
  7734. The phases are explained in the [section 3.1, Event dispatch and DOM event flow]
  7735. (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification.
  7736. !#zh 事件阶段 */
  7737. eventPhase: number;
  7738. /**
  7739. !#en Reset the event for being stored in the object pool.
  7740. !#zh 重置对象池中存储的事件。
  7741. */
  7742. unuse(): string;
  7743. /**
  7744. !#en Reuse the event for being used again by the object pool.
  7745. !#zh 用于对象池再次使用的事件。
  7746. */
  7747. reuse(): string;
  7748. /**
  7749. !#en Stops propagation for current event.
  7750. !#zh 停止传递当前事件。
  7751. */
  7752. stopPropagation(): void;
  7753. /**
  7754. !#en Stops propagation for current event immediately,
  7755. the event won't even be dispatched to the listeners attached in the current target.
  7756. !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。
  7757. */
  7758. stopPropagationImmediate(): void;
  7759. /**
  7760. !#en Checks whether the event has been stopped.
  7761. !#zh 检查该事件是否已经停止传递.
  7762. */
  7763. isStopped(): boolean;
  7764. /**
  7765. !#en
  7766. <p>
  7767. Gets current target of the event <br/>
  7768. note: It only be available when the event listener is associated with node. <br/>
  7769. It returns 0 when the listener is associated with fixed priority.
  7770. </p>
  7771. !#zh 获取当前目标节点
  7772. */
  7773. getCurrentTarget(): Node;
  7774. /**
  7775. !#en Gets the event type.
  7776. !#zh 获取事件类型
  7777. */
  7778. getType(): string;
  7779. /** !#en Code for event without type.
  7780. !#zh 没有类型的事件 */
  7781. static NO_TYPE: string;
  7782. /** !#en The type code of Touch event.
  7783. !#zh 触摸事件类型 */
  7784. static TOUCH: string;
  7785. /** !#en The type code of Mouse event.
  7786. !#zh 鼠标事件类型 */
  7787. static MOUSE: string;
  7788. /** !#en The type code of Keyboard event.
  7789. !#zh 键盘事件类型 */
  7790. static KEYBOARD: string;
  7791. /** !#en The type code of Acceleration event.
  7792. !#zh 加速器事件类型 */
  7793. static ACCELERATION: string;
  7794. /** !#en Events not currently dispatched are in this phase
  7795. !#zh 尚未派发事件阶段 */
  7796. static NONE: number;
  7797. /** !#en
  7798. The capturing phase comprises the journey from the root to the last node before the event target's node
  7799. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7800. !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */
  7801. static CAPTURING_PHASE: number;
  7802. /** !#en
  7803. The target phase comprises only the event target node
  7804. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7805. !#zh 目标阶段仅包括事件目标节点。 */
  7806. static AT_TARGET: number;
  7807. /** !#en
  7808. The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy
  7809. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7810. !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */
  7811. static BUBBLING_PHASE: number;
  7812. }
  7813. /** !#en The System event, it currently supports the key events and accelerometer events
  7814. !#zh 系统事件,它目前支持按键事件和重力感应事件 */
  7815. export class SystemEvent extends EventTarget {
  7816. /**
  7817. !#en whether enable accelerometer event
  7818. !#zh 是否启用加速度计事件
  7819. @param isEnable isEnable
  7820. */
  7821. setAccelerometerEnabled(isEnable: boolean): void;
  7822. /**
  7823. !#en set accelerometer interval value
  7824. !#zh 设置加速度计间隔值
  7825. @param interval interval
  7826. */
  7827. setAccelerometerInterval(interval: number): void;
  7828. }
  7829. /** undefined */
  7830. export class Graphics extends _RendererUnderSG {
  7831. /** !#en
  7832. Current line width.
  7833. !#zh
  7834. 当前线条宽度 */
  7835. lineWidth: number;
  7836. /** !#en
  7837. lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together.
  7838. !#zh
  7839. lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */
  7840. lineJoin: Graphics.LineJoin;
  7841. /** !#en
  7842. lineCap determines how the end points of every line are drawn.
  7843. !#zh
  7844. lineCap 指定如何绘制每一条线段末端。 */
  7845. lineCap: Graphics.LineCap;
  7846. /** !#en
  7847. stroke color
  7848. !#zh
  7849. 线段颜色 */
  7850. strokeColor: Color;
  7851. /** !#en
  7852. fill color
  7853. !#zh
  7854. 填充颜色 */
  7855. fillColor: Color;
  7856. /** !#en
  7857. Sets the miter limit ratio
  7858. !#zh
  7859. 设置斜接面限制比例 */
  7860. miterLimit: number;
  7861. /**
  7862. !#en Move path start point to (x,y).
  7863. !#zh 移动路径起点到坐标(x, y)
  7864. @param x The x axis of the coordinate for the end point.
  7865. @param y The y axis of the coordinate for the end point.
  7866. */
  7867. moveTo(x?: number, y?: number): void;
  7868. /**
  7869. !#en Adds a straight line to the path
  7870. !#zh 绘制直线路径
  7871. @param x The x axis of the coordinate for the end point.
  7872. @param y The y axis of the coordinate for the end point.
  7873. */
  7874. lineTo(x?: number, y?: number): void;
  7875. /**
  7876. !#en Adds a cubic Bézier curve to the path
  7877. !#zh 绘制三次贝赛尔曲线路径
  7878. @param c1x The x axis of the coordinate for the first control point.
  7879. @param c1y The y axis of the coordinate for first control point.
  7880. @param c2x The x axis of the coordinate for the second control point.
  7881. @param c2y The y axis of the coordinate for the second control point.
  7882. @param x The x axis of the coordinate for the end point.
  7883. @param y The y axis of the coordinate for the end point.
  7884. */
  7885. bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void;
  7886. /**
  7887. !#en Adds a quadratic Bézier curve to the path
  7888. !#zh 绘制二次贝赛尔曲线路径
  7889. @param cx The x axis of the coordinate for the control point.
  7890. @param cy The y axis of the coordinate for the control point.
  7891. @param x The x axis of the coordinate for the end point.
  7892. @param y The y axis of the coordinate for the end point.
  7893. */
  7894. quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void;
  7895. /**
  7896. !#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).
  7897. !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。
  7898. @param cx The x axis of the coordinate for the center point.
  7899. @param cy The y axis of the coordinate for the center point.
  7900. @param r The arc's radius.
  7901. @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.
  7902. @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.
  7903. @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.
  7904. */
  7905. arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: number): void;
  7906. /**
  7907. !#en Adds an ellipse to the path.
  7908. !#zh 绘制椭圆路径。
  7909. @param cx The x axis of the coordinate for the center point.
  7910. @param cy The y axis of the coordinate for the center point.
  7911. @param rx The ellipse's x-axis radius.
  7912. @param ry The ellipse's y-axis radius.
  7913. */
  7914. ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void;
  7915. /**
  7916. !#en Adds an circle to the path.
  7917. !#zh 绘制圆形路径。
  7918. @param cx The x axis of the coordinate for the center point.
  7919. @param cy The y axis of the coordinate for the center point.
  7920. @param r The circle's radius.
  7921. */
  7922. circle(cx?: number, cy?: number, r?: number): void;
  7923. /**
  7924. !#en Adds an rectangle to the path.
  7925. !#zh 绘制矩形路径。
  7926. @param x The x axis of the coordinate for the rectangle starting point.
  7927. @param y The y axis of the coordinate for the rectangle starting point.
  7928. @param w The rectangle's width.
  7929. @param h The rectangle's height.
  7930. */
  7931. rect(x?: number, y?: number, w?: number, h?: number): void;
  7932. /**
  7933. !#en Adds an round corner rectangle to the path.
  7934. !#zh 绘制圆角矩形路径。
  7935. @param x The x axis of the coordinate for the rectangle starting point.
  7936. @param y The y axis of the coordinate for the rectangle starting point.
  7937. @param w The rectangles width.
  7938. @param h The rectangle's height.
  7939. @param r The radius of the rectangle.
  7940. */
  7941. roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void;
  7942. /**
  7943. !#en Draws a filled rectangle.
  7944. !#zh 绘制填充矩形。
  7945. @param x The x axis of the coordinate for the rectangle starting point.
  7946. @param y The y axis of the coordinate for the rectangle starting point.
  7947. @param w The rectangle's width.
  7948. @param h The rectangle's height.
  7949. */
  7950. fillRect(x?: number, y?: number, w?: number, h?: number): void;
  7951. /**
  7952. !#en Erasing any previously drawn content.
  7953. !#zh 擦除之前绘制的所有内容的方法。
  7954. @param clean Whether to clean the graphics inner cache.
  7955. */
  7956. clear(clean?: boolean): void;
  7957. /**
  7958. !#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.
  7959. !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。
  7960. */
  7961. close(): void;
  7962. /**
  7963. !#en Strokes the current or given path with the current stroke style.
  7964. !#zh 根据当前的画线样式,绘制当前或已经存在的路径。
  7965. */
  7966. stroke(): void;
  7967. /**
  7968. !#en Fills the current or given path with the current fill style.
  7969. !#zh 根据当前的画线样式,填充当前或已经存在的路径。
  7970. */
  7971. fill(): void;
  7972. }
  7973. /** !#en
  7974. <p>
  7975. The base class of event listener. <br/>
  7976. If you need custom listener which with different callback, you need to inherit this class. <br/>
  7977. For instance, you could refer to EventListenerAcceleration, EventListenerKeyboard, <br/>
  7978. EventListenerTouchOneByOne, EventListenerCustom.
  7979. </p>
  7980. !#zh
  7981. 封装用户的事件处理逻辑。
  7982. 注意:这是一个抽象类,开发者不应该直接实例化这个类,请参考 {{#crossLink "EventListener/create:method"}}cc.EventListener.create{{/crossLink}}。 */
  7983. export class EventListener {
  7984. /**
  7985. Constructor
  7986. @param type type
  7987. @param listenerID listenerID
  7988. @param callback callback
  7989. */
  7990. constructor(type: number, listenerID: number, callback: number);
  7991. /**
  7992. !#en Checks whether the listener is available.
  7993. !#zh 检测监听器是否有效
  7994. */
  7995. checkAvailable(): boolean;
  7996. /**
  7997. !#en Clones the listener, its subclasses have to override this method.
  7998. !#zh 克隆监听器,它的子类必须重写此方法。
  7999. */
  8000. clone(): EventListener;
  8001. /**
  8002. !#en Enables or disables the listener
  8003. !#zh 启用或禁用监听器。
  8004. @param enabled enabled
  8005. */
  8006. setEnabled(enabled: boolean): void;
  8007. /**
  8008. !#en Checks whether the listener is enabled
  8009. !#zh 检查监听器是否可用。
  8010. */
  8011. isEnabled(): boolean;
  8012. /** !#en The type code of unknown event listener.
  8013. !#zh 未知的事件监听器类型 */
  8014. static UNKNOWN: number;
  8015. /** !#en The type code of keyboard event listener.
  8016. !#zh 键盘事件监听器类型 */
  8017. static KEYBOARD: number;
  8018. /** !#en The type code of acceleration event listener.
  8019. !#zh 加速器事件监听器类型 */
  8020. static ACCELERATION: number;
  8021. /**
  8022. !#en
  8023. Create a EventListener object with configuration including the event type, handlers and other parameters.
  8024. In handlers, this refer to the event listener object itself.
  8025. You can also pass custom parameters in the configuration object,
  8026. all custom parameters will be polyfilled into the event listener object and can be accessed in handlers.
  8027. !#zh 通过指定不同的 Event 对象来设置想要创建的事件监听器。
  8028. @param argObj a json object
  8029. @example
  8030. ```js
  8031. // Create KEYBOARD EventListener.
  8032. cc.EventListener.create({
  8033. event: cc.EventListener.KEYBOARD,
  8034. onKeyPressed: function (keyCode, event) {
  8035. cc.log('pressed key: ' + keyCode);
  8036. },
  8037. onKeyReleased: function (keyCode, event) {
  8038. cc.log('released key: ' + keyCode);
  8039. }
  8040. });
  8041. // Create ACCELERATION EventListener.
  8042. cc.EventListener.create({
  8043. event: cc.EventListener.ACCELERATION,
  8044. callback: function (acc, event) {
  8045. cc.log('acc: ' + keyCode);
  8046. }
  8047. });
  8048. ```
  8049. */
  8050. static create(argObj: any): EventListener;
  8051. }
  8052. /** !#en
  8053. This class has been deprecated, please use cc.systemEvent or cc.EventTarget instead. See [Listen to and launch events](../../../manual/en/scripting/events.md) for details.<br>
  8054. <br>
  8055. cc.eventManager is a singleton object which manages event listener subscriptions and event dispatching.
  8056. The EventListener list is managed in such way so that event listeners can be added and removed
  8057. while events are being dispatched.
  8058. !#zh
  8059. 该类已废弃,请使用 cc.systemEvent 或 cc.EventTarget 代替,详见 [监听和发射事件](../../../manual/zh/scripting/events.md)。<br>
  8060. <br>
  8061. 事件管理器,它主要管理事件监听器注册和派发系统事件。 */
  8062. export class eventManager {
  8063. /**
  8064. !#en Pauses all listeners which are associated the specified target.
  8065. !#zh 暂停传入的 node 相关的所有监听器的事件响应。
  8066. @param node node
  8067. @param recursive recursive
  8068. */
  8069. static pauseTarget(node: Node, recursive?: boolean): void;
  8070. /**
  8071. !#en Resumes all listeners which are associated the specified target.
  8072. !#zh 恢复传入的 node 相关的所有监听器的事件响应。
  8073. @param node node
  8074. @param recursive recursive
  8075. */
  8076. static resumeTarget(node: Node, recursive?: boolean): void;
  8077. /**
  8078. !#en Query whether the specified event listener id has been added.
  8079. !#zh 查询指定的事件 ID 是否存在
  8080. @param listenerID The listener id.
  8081. */
  8082. static hasEventListener(listenerID: string|number): boolean;
  8083. /**
  8084. !#en
  8085. <p>
  8086. Adds a event listener for a specified event.<br/>
  8087. if the parameter "nodeOrPriority" is a node,
  8088. it means to add a event listener for a specified event with the priority of scene graph.<br/>
  8089. if the parameter "nodeOrPriority" is a Number,
  8090. it means to add a event listener for a specified event with the fixed priority.<br/>
  8091. </p>
  8092. !#zh
  8093. 将事件监听器添加到事件管理器中。<br/>
  8094. 如果参数 “nodeOrPriority” 是节点,优先级由 node 的渲染顺序决定,显示在上层的节点将优先收到事件。<br/>
  8095. 如果参数 “nodeOrPriority” 是数字,优先级则固定为该参数的数值,数字越小,优先级越高。<br/>
  8096. @param listener The listener of a specified event or a object of some event parameters.
  8097. @param nodeOrPriority The priority of the listener is based on the draw order of this node or fixedPriority The fixed priority of the listener.
  8098. */
  8099. static addListener(listener: EventListener|any, nodeOrPriority: Node|number): EventListener;
  8100. /**
  8101. !#en Remove a listener.
  8102. !#zh 移除一个已添加的监听器。
  8103. @param listener an event listener or a registered node target
  8104. @example
  8105. ```js
  8106. // 1. remove eventManager add Listener;
  8107. var mouseListener1 = cc.eventManager.addListener({
  8108. event: cc.EventListener.MOUSE,
  8109. onMouseDown: function(keyCode, event){ },
  8110. onMouseUp: function(keyCode, event){ },
  8111. onMouseMove: function () { },
  8112. onMouseScroll: function () { }
  8113. }, node);
  8114. cc.eventManager.removeListener(mouseListener1);
  8115. // 2. remove eventListener create Listener;
  8116. var mouseListener2 = cc.EventListener.create({
  8117. event: cc.EventListener.MOUSE,
  8118. onMouseDown: function(keyCode, event){ },
  8119. onMouseUp: function(keyCode, event){ },
  8120. onMouseMove: function () { },
  8121. onMouseScroll: function () { }
  8122. });
  8123. cc.eventManager.removeListener(mouseListener2);
  8124. ```
  8125. */
  8126. static removeListener(listener: EventListener): void;
  8127. /**
  8128. !#en Removes all listeners with the same event listener type or removes all listeners of a node.
  8129. !#zh
  8130. 移除注册到 eventManager 中指定类型的所有事件监听器。<br/>
  8131. 1. 如果传入的第一个参数类型是 Node,那么事件管理器将移除与该对象相关的所有事件监听器。
  8132. (如果第二参数 recursive 是 true 的话,就会连同该对象的子控件上所有的事件监听器也一并移除)<br/>
  8133. 2. 如果传入的第一个参数类型是 Number(该类型 EventListener 中定义的事件类型),
  8134. 那么事件管理器将移除该类型的所有事件监听器。<br/>
  8135. 下列是目前存在监听器类型: <br/>
  8136. cc.EventListener.UNKNOWN <br/>
  8137. cc.EventListener.KEYBOARD <br/>
  8138. cc.EventListener.ACCELERATION,<br/>
  8139. @param listenerType listenerType or a node
  8140. @param recursive recursive
  8141. */
  8142. static removeListeners(listenerType: number|Node, recursive?: boolean): void;
  8143. /**
  8144. !#en Removes all listeners
  8145. !#zh 移除所有事件监听器。
  8146. */
  8147. static removeAllListeners(): void;
  8148. /**
  8149. !#en Sets listener's priority with fixed value.
  8150. !#zh 设置 FixedPriority 类型监听器的优先级。
  8151. @param listener listener
  8152. @param fixedPriority fixedPriority
  8153. */
  8154. static setPriority(listener: EventListener, fixedPriority: number): void;
  8155. /**
  8156. !#en Whether to enable dispatching events
  8157. !#zh 启用或禁用事件管理器,禁用后不会分发任何事件。
  8158. @param enabled enabled
  8159. */
  8160. static setEnabled(enabled: boolean): void;
  8161. /**
  8162. !#en Checks whether dispatching events is enabled
  8163. !#zh 检测事件管理器是否启用。
  8164. */
  8165. static isEnabled(): boolean;
  8166. }
  8167. /** !#en The touch event class
  8168. !#zh 封装了触摸相关的信息。 */
  8169. export class Touch {
  8170. /**
  8171. !#en Returns the current touch location in OpenGL coordinates.、
  8172. !#zh 获取当前触点位置。
  8173. */
  8174. getLocation(): Vec2;
  8175. /**
  8176. !#en Returns X axis location value.
  8177. !#zh 获取当前触点 X 轴位置。
  8178. */
  8179. getLocationX(): number;
  8180. /**
  8181. !#en Returns Y axis location value.
  8182. !#zh 获取当前触点 Y 轴位置。
  8183. */
  8184. getLocationY(): number;
  8185. /**
  8186. !#en Returns the previous touch location in OpenGL coordinates.
  8187. !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
  8188. */
  8189. getPreviousLocation(): Vec2;
  8190. /**
  8191. !#en Returns the start touch location in OpenGL coordinates.
  8192. !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。
  8193. */
  8194. getStartLocation(): Vec2;
  8195. /**
  8196. !#en Returns the delta distance from the previous touche to the current one in screen coordinates.
  8197. !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  8198. */
  8199. getDelta(): Vec2;
  8200. /**
  8201. !#en Returns the current touch location in screen coordinates.
  8202. !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
  8203. */
  8204. getLocationInView(): Vec2;
  8205. /**
  8206. !#en Returns the previous touch location in screen coordinates.
  8207. !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
  8208. */
  8209. getPreviousLocationInView(): Vec2;
  8210. /**
  8211. !#en Returns the start touch location in screen coordinates.
  8212. !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
  8213. */
  8214. getStartLocationInView(): Vec2;
  8215. /**
  8216. !#en Returns the id of cc.Touch.
  8217. !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
  8218. */
  8219. getID(): number;
  8220. /**
  8221. !#en Sets information to touch.
  8222. !#zh 设置触摸相关的信息。用于监控触摸事件。
  8223. @param id id
  8224. @param x x
  8225. @param y y
  8226. */
  8227. setTouchInfo(id: number, x: number, y: number): void;
  8228. }
  8229. /** Loader for resource loading process. It's a singleton object. */
  8230. export class loader extends Pipeline {
  8231. /** The asset loader in cc.loader's pipeline, it's by default the first pipe.
  8232. It's used to identify an asset's type, and determine how to download it. */
  8233. static assetLoader: any;
  8234. /** The downloader in cc.loader's pipeline, it's by default the second pipe.
  8235. It's used to download files with several handlers: pure text, image, script, audio, font, uuid.
  8236. You can add your own download function with addDownloadHandlers */
  8237. static downloader: any;
  8238. /** The downloader in cc.loader's pipeline, it's by default the third pipe.
  8239. It's used to parse downloaded content with several handlers: JSON, image, plist, fnt, uuid.
  8240. You can add your own download function with addLoadHandlers */
  8241. static loader: any;
  8242. /**
  8243. Gets a new XMLHttpRequest instance.
  8244. */
  8245. static getXMLHttpRequest(): XMLHttpRequest;
  8246. /**
  8247. Add custom supported types handler or modify existing type handler for download process.
  8248. @param extMap Custom supported types with corresponded handler
  8249. @example
  8250. ```js
  8251. cc.loader.addDownloadHandlers({
  8252. // This will match all url with `.scene` extension or all url with `scene` type
  8253. 'scene' : function (url, callback) {}
  8254. });
  8255. ```
  8256. */
  8257. static addDownloadHandlers(extMap: any): void;
  8258. /**
  8259. Add custom supported types handler or modify existing type handler for load process.
  8260. @param extMap Custom supported types with corresponded handler
  8261. @example
  8262. ```js
  8263. cc.loader.addLoadHandlers({
  8264. // This will match all url with `.scene` extension or all url with `scene` type
  8265. 'scene' : function (url, callback) {}
  8266. });
  8267. ```
  8268. */
  8269. static addLoadHandlers(extMap: any): void;
  8270. /**
  8271. Load resources with a progression callback and a complete callback.
  8272. The progression callback is the same as Pipeline's {{#crossLink "LoadingItems/onProgress:method"}}onProgress{{/crossLink}}
  8273. The complete callback is almost the same as Pipeline's {{#crossLink "LoadingItems/onComplete:method"}}onComplete{{/crossLink}}
  8274. The only difference is when user pass a single url as resources, the complete callback will set its result directly as the second parameter.
  8275. @param resources Url list in an array
  8276. @param progressCallback Callback invoked when progression change
  8277. @param completeCallback Callback invoked when all resources loaded
  8278. @example
  8279. ```js
  8280. cc.loader.load('a.png', function (err, tex) {
  8281. cc.log('Result should be a texture: ' + (tex instanceof cc.Texture2D));
  8282. });
  8283. cc.loader.load('http://example.com/a.png', function (err, tex) {
  8284. cc.log('Should load a texture from external url: ' + (tex instanceof cc.Texture2D));
  8285. });
  8286. cc.loader.load({url: 'http://example.com/getImageREST?file=a.png', type: 'png'}, function (err, tex) {
  8287. cc.log('Should load a texture from RESTful API by specify the type: ' + (tex instanceof cc.Texture2D));
  8288. });
  8289. cc.loader.load(['a.png', 'b.json'], function (errors, results) {
  8290. if (errors) {
  8291. for (var i = 0; i < errors.length; i++) {
  8292. cc.log('Error url [' + errors[i] + ']: ' + results.getError(errors[i]));
  8293. }
  8294. }
  8295. var aTex = results.getContent('a.png');
  8296. var bJsonObj = results.getContent('b.json');
  8297. });
  8298. ```
  8299. */
  8300. static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void;
  8301. static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void;
  8302. /**
  8303. Load resources from the "resources" folder inside the "assets" folder of your project.<br>
  8304. <br>
  8305. Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work.
  8306. @param url Url of the target resource.
  8307. The url is relative to the "resources" folder, extensions must be omitted.
  8308. @param type Only asset of type will be loaded if this argument is supplied.
  8309. @param progressCallback Callback invoked when progression change.
  8310. @param completeCallback Callback invoked when the resource loaded.
  8311. @example
  8312. ```js
  8313. // load the prefab (project/assets/resources/misc/character/cocos) from resources folder
  8314. cc.loader.loadRes('misc/character/cocos', function (err, prefab) {
  8315. if (err) {
  8316. cc.error(err.message || err);
  8317. return;
  8318. }
  8319. cc.log('Result should be a prefab: ' + (prefab instanceof cc.Prefab));
  8320. });
  8321. // load the sprite frame of (project/assets/resources/imgs/cocos.png) from resources folder
  8322. cc.loader.loadRes('imgs/cocos', cc.SpriteFrame, function (err, spriteFrame) {
  8323. if (err) {
  8324. cc.error(err.message || err);
  8325. return;
  8326. }
  8327. cc.log('Result should be a sprite frame: ' + (spriteFrame instanceof cc.SpriteFrame));
  8328. });
  8329. ```
  8330. */
  8331. static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void;
  8332. static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void;
  8333. static loadRes(url: string, type: typeof cc.Asset): void;
  8334. static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void;
  8335. static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void;
  8336. static loadRes(url: string): void;
  8337. /**
  8338. This method is like {{#crossLink "loader/loadRes:method"}}{{/crossLink}} except that it accepts array of url.
  8339. @param urls Array of URLs of the target resource.
  8340. The url is relative to the "resources" folder, extensions must be omitted.
  8341. @param type Only asset of type will be loaded if this argument is supplied.
  8342. @param progressCallback Callback invoked when progression change.
  8343. @param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
  8344. @example
  8345. ```js
  8346. // load the SpriteFrames from resources folder
  8347. var spriteFrames;
  8348. var urls = ['misc/characters/character_01', 'misc/weapons/weapons_01'];
  8349. cc.loader.loadResArray(urls, cc.SpriteFrame, function (err, assets) {
  8350. if (err) {
  8351. cc.error(err);
  8352. return;
  8353. }
  8354. spriteFrames = assets;
  8355. // ...
  8356. });
  8357. ```
  8358. */
  8359. static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void;
  8360. static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void;
  8361. static loadResArray(url: string[], type: typeof cc.Asset): void;
  8362. static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void;
  8363. static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void;
  8364. static loadResArray(url: string[]): void;
  8365. /**
  8366. Load all assets in a folder inside the "assets/resources" folder of your project.<br>
  8367. <br>
  8368. Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work.
  8369. @param url Url of the target folder.
  8370. The url is relative to the "resources" folder, extensions must be omitted.
  8371. @param type Only asset of type will be loaded if this argument is supplied.
  8372. @param progressCallback Callback invoked when progression change.
  8373. @param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
  8374. @example
  8375. ```js
  8376. // load the texture (resources/imgs/cocos.png) and the corresponding sprite frame
  8377. cc.loader.loadResDir('imgs/cocos', function (err, assets) {
  8378. if (err) {
  8379. cc.error(err);
  8380. return;
  8381. }
  8382. var texture = assets[0];
  8383. var spriteFrame = assets[1];
  8384. });
  8385. // load all textures in "resources/imgs/"
  8386. cc.loader.loadResDir('imgs', cc.Texture2D, function (err, textures) {
  8387. var texture1 = textures[0];
  8388. var texture2 = textures[1];
  8389. });
  8390. // load all JSONs in "resources/data/"
  8391. cc.loader.loadResDir('data', function (err, objects, urls) {
  8392. var data = objects[0];
  8393. var url = urls[0];
  8394. });
  8395. ```
  8396. */
  8397. static loadResDir(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void;
  8398. static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void;
  8399. static loadResDir(url: string, type: typeof cc.Asset): void;
  8400. static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void;
  8401. static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void;
  8402. static loadResDir(url: string): void;
  8403. /**
  8404. Get resource data by id. <br>
  8405. When you load resources with {{#crossLink "loader/load:method"}}{{/crossLink}} or {{#crossLink "loader/loadRes:method"}}{{/crossLink}},
  8406. the url will be the unique identity of the resource.
  8407. After loaded, you can acquire them by passing the url to this API.
  8408. @param url url
  8409. @param type Only asset of type will be returned if this argument is supplied.
  8410. */
  8411. static getRes(url: string, type?: Function): any;
  8412. /**
  8413. !#en Get all resource dependencies of the requested asset in an array, including itself.
  8414. The owner parameter accept the following types: 1. The asset itself; 2. The resource url; 3. The asset's uuid.<br>
  8415. The returned array stores the dependencies with their uuids, after retrieve dependencies,
  8416. you can release them, access dependent assets by passing the uuid to {{#crossLink "loader/getRes:method"}}{{/crossLink}}, or other stuffs you want.<br>
  8417. For release all dependencies of an asset, please refer to {{#crossLink "loader/release:method"}}{{/crossLink}}
  8418. Here is some examples:
  8419. !#zh 获取一个指定资源的所有依赖资源,包含它自身,并保存在数组中返回。owner 参数接收以下几种类型:1. 资源 asset 对象;2. 资源目录下的 url;3. 资源的 uuid。<br>
  8420. 返回的数组将仅保存依赖资源的 uuid,获取这些 uuid 后,你可以从 loader 释放这些资源;通过 {{#crossLink "loader/getRes:method"}}{{/crossLink}} 获取某个资源或者进行其他你需要的操作。<br>
  8421. 想要释放一个资源及其依赖资源,可以参考 {{#crossLink "loader/release:method"}}{{/crossLink}}。下面是一些示例代码:
  8422. @param owner The owner asset or the resource url or the asset's uuid
  8423. @example
  8424. ```js
  8425. // Release all dependencies of a loaded prefab
  8426. var deps = cc.loader.getDependsRecursively(prefab);
  8427. cc.loader.release(deps);
  8428. // Retrieve all dependent textures
  8429. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  8430. var textures = [];
  8431. for (var i = 0; i < deps.length; ++i) {
  8432. var item = cc.loader.getRes(deps[i]);
  8433. if (item instanceof cc.Texture2D) {
  8434. textures.push(item);
  8435. }
  8436. }
  8437. ```
  8438. */
  8439. static getDependsRecursively(owner: Asset|RawAsset|string): any[];
  8440. /**
  8441. !#en
  8442. Release the content of an asset or an array of assets by uuid.
  8443. Start from v1.3, this method will not only remove the cache of the asset in loader, but also clean up its content.
  8444. For example, if you release a texture, the texture asset and its gl texture data will be freed up.
  8445. In complexe project, you can use this function with {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} to free up memory in critical circumstances.
  8446. Notice, this method may cause the texture to be unusable, if there are still other nodes use the same texture, they may turn to black and report gl errors.
  8447. If you only want to remove the cache of an asset, please use {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}}
  8448. !#zh
  8449. 通过 id(通常是资源 url)来释放一个资源或者一个资源数组。
  8450. 从 v1.3 开始,这个方法不仅会从 loader 中删除资源的缓存引用,还会清理它的资源内容。
  8451. 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。
  8452. 在复杂项目中,我们建议你结合 {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} 来使用,便于在设备内存告急的情况下更快地释放不再需要的资源的内存。
  8453. 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。
  8454. 如果你只想删除一个资源的缓存引用,请使用 {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}}
  8455. @param asset asset
  8456. @example
  8457. ```js
  8458. // Release a texture which is no longer need
  8459. cc.loader.release(texture);
  8460. // Release all dependencies of a loaded prefab
  8461. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  8462. cc.loader.release(deps);
  8463. // If there is no instance of this prefab in the scene, the prefab and its dependencies like textures, sprite frames, etc, will be freed up.
  8464. // If you have some other nodes share a texture in this prefab, you can skip it in two ways:
  8465. // 1. Forbid auto release a texture before release
  8466. cc.loader.setAutoRelease(texture2d, false);
  8467. // 2. Remove it from the dependencies array
  8468. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  8469. var index = deps.indexOf(texture2d._uuid);
  8470. if (index !== -1)
  8471. deps.splice(index, 1);
  8472. cc.loader.release(deps);
  8473. ```
  8474. */
  8475. static release(asset: Asset|RawAsset|string|any[]): void;
  8476. /**
  8477. !#en Release the asset by its object. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8478. !#zh 通过资源对象自身来释放资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8479. @param asset asset
  8480. */
  8481. static releaseAsset(asset: Asset): void;
  8482. /**
  8483. !#en Release the asset loaded by {{#crossLink "loader/loadRes:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8484. !#zh 释放通过 {{#crossLink "loader/loadRes:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8485. @param url url
  8486. @param type Only asset of type will be released if this argument is supplied.
  8487. */
  8488. static releaseRes(url: string, type?: Function): void;
  8489. /**
  8490. !#en Release the all assets loaded by {{#crossLink "loader/loadResDir:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8491. !#zh 释放通过 {{#crossLink "loader/loadResDir:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8492. @param url url
  8493. @param type Only asset of type will be released if this argument is supplied.
  8494. */
  8495. static releaseResDir(url: string, type?: Function): void;
  8496. /**
  8497. !#en Resource all assets. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8498. !#zh 释放所有资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8499. */
  8500. static releaseAll(): void;
  8501. /**
  8502. !#en
  8503. Indicates whether to release the asset when loading a new scene.<br>
  8504. By default, when loading a new scene, all assets in the previous scene will be released or preserved
  8505. according to whether the previous scene checked the "Auto Release Assets" option.
  8506. On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir`
  8507. will not be affected by that option, remain not released by default.<br>
  8508. Use this API to change the default behavior on a single asset, to force preserve or release specified asset when scene switching.<br>
  8509. <br>
  8510. See: {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8511. !#zh
  8512. 设置当场景切换时是否自动释放资源。<br>
  8513. 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。
  8514. 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。<br>
  8515. 使用这个 API 可以在单个资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。<br>
  8516. <br>
  8517. 参考:{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8518. @param assetOrUrlOrUuid asset object or the raw asset's url or uuid
  8519. @param autoRelease indicates whether should release automatically
  8520. @example
  8521. ```js
  8522. // auto release the texture event if "Auto Release Assets" disabled in current scene
  8523. cc.loader.setAutoRelease(texture2d, true);
  8524. // don't release the texture even if "Auto Release Assets" enabled in current scene
  8525. cc.loader.setAutoRelease(texture2d, false);
  8526. // first parameter can be url
  8527. cc.loader.setAutoRelease(audioUrl, false);
  8528. ```
  8529. */
  8530. static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void;
  8531. /**
  8532. !#en
  8533. Indicates whether to release the asset and its referenced other assets when loading a new scene.<br>
  8534. By default, when loading a new scene, all assets in the previous scene will be released or preserved
  8535. according to whether the previous scene checked the "Auto Release Assets" option.
  8536. On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir`
  8537. will not be affected by that option, remain not released by default.<br>
  8538. 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>
  8539. <br>
  8540. See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8541. !#zh
  8542. 设置当场景切换时是否自动释放资源及资源引用的其它资源。<br>
  8543. 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。
  8544. 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。<br>
  8545. 使用这个 API 可以在指定资源及资源递归引用到的所有资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。<br>
  8546. <br>
  8547. 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8548. @param assetOrUrlOrUuid asset object or the raw asset's url or uuid
  8549. @param autoRelease indicates whether should release automatically
  8550. @example
  8551. ```js
  8552. // auto release the SpriteFrame and its Texture event if "Auto Release Assets" disabled in current scene
  8553. cc.loader.setAutoReleaseRecursively(spriteFrame, true);
  8554. // don't release the SpriteFrame and its Texture even if "Auto Release Assets" enabled in current scene
  8555. cc.loader.setAutoReleaseRecursively(spriteFrame, false);
  8556. // don't release the Prefab and all the referenced assets
  8557. cc.loader.setAutoReleaseRecursively(prefab, false);
  8558. ```
  8559. */
  8560. static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void;
  8561. /**
  8562. !#en
  8563. Returns whether the asset is configured as auto released, despite how "Auto Release Assets" property is set on scene asset.<br>
  8564. <br>
  8565. See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}
  8566. !#zh
  8567. 返回指定的资源是否有被设置为自动释放,不论场景的“Auto Release Assets”如何设置。<br>
  8568. <br>
  8569. 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}
  8570. @param assetOrUrl asset object or the raw asset's url
  8571. */
  8572. static isAutoRelease(assetOrUrl: Asset|string): boolean;
  8573. }
  8574. /** !#en
  8575. LoadingItems is the queue of items which can flow them into the loading pipeline.</br>
  8576. Please don't construct it directly, use {{#crossLink "LoadingItems.create"}}LoadingItems.create{{/crossLink}} instead, because we use an internal pool to recycle the queues.</br>
  8577. It hold a map of items, each entry in the map is a url to object key value pair.</br>
  8578. Each item always contains the following property:</br>
  8579. - id: The identification of the item, usually it's identical to url</br>
  8580. - url: The url </br>
  8581. - type: The type, it's the extension name of the url by default, could be specified manually too.</br>
  8582. - error: The error happened in pipeline will be stored in this property.</br>
  8583. - content: The content processed by the pipeline, the final result will also be stored in this property.</br>
  8584. - complete: The flag indicate whether the item is completed by the pipeline.</br>
  8585. - 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>
  8586. </br>
  8587. Item can hold other custom properties.</br>
  8588. Each LoadingItems object will be destroyed for recycle after onComplete callback</br>
  8589. So please don't hold its reference for later usage, you can copy properties in it though.
  8590. !#zh
  8591. LoadingItems 是一个加载对象队列,可以用来输送加载对象到加载管线中。</br>
  8592. 请不要直接使用 new 构造这个类的对象,你可以使用 {{#crossLink "LoadingItems.create"}}LoadingItems.create{{/crossLink}} 来创建一个新的加载队列,这样可以允许我们的内部对象池回收并重利用加载队列。
  8593. 它有一个 map 属性用来存放加载项,在 map 对象中已 url 为 key 值。</br>
  8594. 每个对象都会包含下列属性:</br>
  8595. - id:该对象的标识,通常与 url 相同。</br>
  8596. - url:路径 </br>
  8597. - type: 类型,它这是默认的 URL 的扩展名,可以手动指定赋值。</br>
  8598. - error:pipeline 中发生的错误将被保存在这个属性中。</br>
  8599. - content: pipeline 中处理的临时结果,最终的结果也将被存储在这个属性中。</br>
  8600. - complete:该标志表明该对象是否通过 pipeline 完成。</br>
  8601. - states:该对象存储每个管道中对象经历的状态,状态可以是 Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE</br>
  8602. </br>
  8603. 对象可容纳其他自定义属性。</br>
  8604. 每个 LoadingItems 对象都会在 onComplete 回调之后被销毁,所以请不要持有它的引用并在结束回调之后依赖它的内容执行任何逻辑,有这种需求的话你可以提前复制它的内容。 */
  8605. export class LoadingItems extends CallbacksInvoker {
  8606. /**
  8607. !#en This is a callback which will be invoked while an item flow out the pipeline.
  8608. You can pass the callback function in LoadingItems.create or set it later.
  8609. !#zh 这个回调函数将在 item 加载结束后被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。
  8610. @param completedCount The number of the items that are already completed.
  8611. @param totalCount The total number of the items.
  8612. @param item The latest item which flow out the pipeline.
  8613. @example
  8614. ```js
  8615. loadingItems.onProgress = function (completedCount, totalCount, item) {
  8616. var progress = (100 * completedCount / totalCount).toFixed(2);
  8617. cc.log(progress + '%');
  8618. }
  8619. ```
  8620. */
  8621. onProgress(completedCount: number, totalCount: number, item: any): void;
  8622. /**
  8623. !#en This is a callback which will be invoked while all items is completed,
  8624. You can pass the callback function in LoadingItems.create or set it later.
  8625. !#zh 该函数将在加载队列全部完成时被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。
  8626. @param errors All errored urls will be stored in this array, if no error happened, then it will be null
  8627. @param items All items.
  8628. @example
  8629. ```js
  8630. loadingItems.onComplete = function (errors, items) {
  8631. if (error)
  8632. cc.log('Completed with ' + errors.length + ' errors');
  8633. else
  8634. cc.log('Completed ' + items.totalCount + ' items');
  8635. }
  8636. ```
  8637. */
  8638. onComplete(errors: any[], items: LoadingItems): void;
  8639. /** !#en The map of all items.
  8640. !#zh 存储所有加载项的对象。 */
  8641. map: any;
  8642. /** !#en The map of completed items.
  8643. !#zh 存储已经完成的加载项。 */
  8644. completed: any;
  8645. /** !#en Total count of all items.
  8646. !#zh 所有加载项的总数。 */
  8647. totalCount: number;
  8648. /** !#en Total count of completed items.
  8649. !#zh 所有完成加载项的总数。 */
  8650. completedCount: number;
  8651. /** !#en Activated or not.
  8652. !#zh 是否启用。 */
  8653. active: boolean;
  8654. /**
  8655. !#en The constructor function of LoadingItems, this will use recycled LoadingItems in the internal pool if possible.
  8656. You can pass onProgress and onComplete callbacks to visualize the loading process.
  8657. !#zh LoadingItems 的构造函数,这种构造方式会重用内部对象缓冲池中的 LoadingItems 队列,以尽量避免对象创建。
  8658. 你可以传递 onProgress 和 onComplete 回调函数来获知加载进度信息。
  8659. @param pipeline The pipeline to process the queue.
  8660. @param urlList The items array.
  8661. @param onProgress The progression callback, refer to {{#crossLink "LoadingItems.onProgress"}}{{/crossLink}}
  8662. @param onComplete The completion callback, refer to {{#crossLink "LoadingItems.onComplete"}}{{/crossLink}}
  8663. @example
  8664. ```js
  8665. LoadingItems.create(cc.loader, ['a.png', 'b.plist'], function (completedCount, totalCount, item) {
  8666. var progress = (100 * completedCount / totalCount).toFixed(2);
  8667. cc.log(progress + '%');
  8668. }, function (errors, items) {
  8669. if (errors) {
  8670. for (var i = 0; i < errors.length; ++i) {
  8671. cc.log('Error url: ' + errors[i] + ', error: ' + items.getError(errors[i]));
  8672. }
  8673. }
  8674. else {
  8675. var result_a = items.getContent('a.png');
  8676. // ...
  8677. }
  8678. })
  8679. ```
  8680. */
  8681. static create(pipeline: Pipeline, urlList: any[], onProgress: Function, onComplete: Function): LoadingItems;
  8682. /**
  8683. !#en Retrieve the LoadingItems queue object for an item.
  8684. !#zh 通过 item 对象获取它的 LoadingItems 队列。
  8685. @param item The item to query
  8686. */
  8687. static getQueue(item: any): LoadingItems;
  8688. /**
  8689. !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening.
  8690. !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。
  8691. @param item The item which has completed
  8692. */
  8693. static itemComplete(item: any): void;
  8694. /**
  8695. !#en Add urls to the LoadingItems queue.
  8696. !#zh 向一个 LoadingItems 队列添加加载项。
  8697. @param urlList The url list to be appended, the url can be object or string
  8698. */
  8699. append(urlList: any[]): any[];
  8700. /**
  8701. !#en Complete a LoadingItems queue, please do not call this method unless you know what's happening.
  8702. !#zh 完成一个 LoadingItems 队列,请不要调用这个函数,除非你知道自己在做什么。
  8703. */
  8704. allComplete(): void;
  8705. /**
  8706. !#en Check whether all items are completed.
  8707. !#zh 检查是否所有加载项都已经完成。
  8708. */
  8709. isCompleted(): boolean;
  8710. /**
  8711. !#en Check whether an item is completed.
  8712. !#zh 通过 id 检查指定加载项是否已经加载完成。
  8713. @param id The item's id.
  8714. */
  8715. isItemCompleted(id: string): boolean;
  8716. /**
  8717. !#en Check whether an item exists.
  8718. !#zh 通过 id 检查加载项是否存在。
  8719. @param id The item's id.
  8720. */
  8721. exists(id: string): boolean;
  8722. /**
  8723. !#en Returns the content of an internal item.
  8724. !#zh 通过 id 获取指定对象的内容。
  8725. @param id The item's id.
  8726. */
  8727. getContent(id: string): any;
  8728. /**
  8729. !#en Returns the error of an internal item.
  8730. !#zh 通过 id 获取指定对象的错误信息。
  8731. @param id The item's id.
  8732. */
  8733. getError(id: string): any;
  8734. /**
  8735. !#en Add a listener for an item, the callback will be invoked when the item is completed.
  8736. !#zh 监听加载项(通过 key 指定)的完成事件。
  8737. @param key key
  8738. @param callback can be null
  8739. @param target can be null
  8740. */
  8741. addListener(key: string, callback: Function, target: any): boolean;
  8742. /**
  8743. !#en
  8744. Check if the specified key has any registered callback. </br>
  8745. If a callback is also specified, it will only return true if the callback is registered.
  8746. !#zh
  8747. 检查指定的加载项是否有完成事件监听器。</br>
  8748. 如果同时还指定了一个回调方法,并且回调有注册,它只会返回 true。
  8749. @param key key
  8750. @param callback callback
  8751. @param target target
  8752. */
  8753. hasListener(key: string, callback?: Function, target?: any): boolean;
  8754. /**
  8755. !#en
  8756. Removes a listener. </br>
  8757. It will only remove when key, callback, target all match correctly.
  8758. !#zh
  8759. 移除指定加载项已经注册的完成事件监听器。</br>
  8760. 只会删除 key, callback, target 均匹配的监听器。
  8761. @param key key
  8762. @param callback callback
  8763. @param target target
  8764. */
  8765. remove(key: string, callback: Function, target: any): boolean;
  8766. /**
  8767. !#en
  8768. Removes all callbacks registered in a certain event
  8769. type or all callbacks registered with a certain target.
  8770. !#zh 删除指定目标的所有完成事件监听器。
  8771. @param key The event key to be removed or the target to be removed
  8772. */
  8773. removeAllListeners(key: string|any): void;
  8774. /**
  8775. !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening.
  8776. !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。
  8777. @param id The item url
  8778. */
  8779. itemComplete(id: string): void;
  8780. /**
  8781. !#en Destroy the LoadingItems queue, the queue object won't be garbage collected, it will be recycled, so every after destroy is not reliable.
  8782. !#zh 销毁一个 LoadingItems 队列,这个队列对象会被内部缓冲池回收,所以销毁后的所有内部信息都是不可依赖的。
  8783. */
  8784. destroy(): void;
  8785. }
  8786. /** !#en
  8787. A pipeline describes a sequence of manipulations, each manipulation is called a pipe.</br>
  8788. 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>
  8789. A list of items can flow in the pipeline and it will output the results of all pipes.</br>
  8790. They flow in the pipeline like water in tubes, they go through pipe by pipe separately.</br>
  8791. Finally all items will flow out the pipeline and the process is finished.
  8792. !#zh
  8793. pipeline 描述了一系列的操作,每个操作都被称为 pipe。</br>
  8794. 它被设计来做加载过程的流程管理。所以 item 应该是 url,并且该 url 将是在处理中的每个 item 的身份标识。</br>
  8795. 一个 item 列表可以在 pipeline 中流动,它将输出加载项经过所有 pipe 之后的结果。</br>
  8796. 它们穿过 pipeline 就像水在管子里流动,将会按顺序流过每个 pipe。</br>
  8797. 最后当所有加载项都流出 pipeline 时,整个加载流程就结束了。 */
  8798. export class Pipeline {
  8799. /**
  8800. !#en
  8801. Constructor, pass an array of pipes to construct a new Pipeline,
  8802. the pipes will be chained in the given order.</br>
  8803. A pipe is an object which must contain an `id` in string and a `handle` function,
  8804. the id must be unique in the pipeline.</br>
  8805. It can also include `async` property to identify whether it's an asynchronous process.
  8806. !#zh
  8807. 构造函数,通过一系列的 pipe 来构造一个新的 pipeline,pipes 将会在给定的顺序中被锁定。</br>
  8808. 一个 pipe 就是一个对象,它包含了字符串类型的 ‘id’ 和 ‘handle’ 函数,在 pipeline 中 id 必须是唯一的。</br>
  8809. 它还可以包括 ‘async’ 属性以确定它是否是一个异步过程。
  8810. @param pipes pipes
  8811. @example
  8812. ```js
  8813. var pipeline = new Pipeline([
  8814. {
  8815. id: 'Downloader',
  8816. handle: function (item, callback) {},
  8817. async: true
  8818. },
  8819. {id: 'Parser', handle: function (item) {}, async: false}
  8820. ]);
  8821. ```
  8822. */
  8823. constructor(pipes: any[]);
  8824. /**
  8825. !#en
  8826. Insert a new pipe at the given index of the pipeline. </br>
  8827. A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline.
  8828. !#zh
  8829. 在给定的索引位置插入一个新的 pipe。</br>
  8830. 一个 pipe 必须包含一个字符串类型的 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。
  8831. @param pipe The pipe to be inserted
  8832. @param index The index to insert
  8833. */
  8834. insertPipe(pipe: any, index: number): void;
  8835. /**
  8836. !en
  8837. Insert a pipe to the end of an existing pipe. The existing pipe must be a valid pipe in the pipeline.
  8838. !zh
  8839. 在当前 pipeline 的一个已知 pipe 后面插入一个新的 pipe。
  8840. @param refPipe An existing pipe in the pipeline.
  8841. @param newPipe The pipe to be inserted.
  8842. */
  8843. insertPipeAfter(refPipe: any, newPipe: any): void;
  8844. /**
  8845. !#en
  8846. Add a new pipe at the end of the pipeline. </br>
  8847. A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline.
  8848. !#zh
  8849. 添加一个新的 pipe 到 pipeline 尾部。 </br>
  8850. 该 pipe 必须包含一个字符串类型 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。
  8851. @param pipe The pipe to be appended
  8852. */
  8853. appendPipe(pipe: any): void;
  8854. /**
  8855. !#en
  8856. Let new items flow into the pipeline. </br>
  8857. Each item can be a simple url string or an object,
  8858. if it's an object, it must contain `id` property. </br>
  8859. You can specify its type by `type` property, by default, the type is the extension name in url. </br>
  8860. By adding a `skips` property including pipe ids, you can skip these pipe. </br>
  8861. The object can contain any supplementary property as you want. </br>
  8862. !#zh
  8863. 让新的 item 流入 pipeline 中。</br>
  8864. 这里的每个 item 可以是一个简单字符串类型的 url 或者是一个对象,
  8865. 如果它是一个对象的话,他必须要包含 ‘id’ 属性。</br>
  8866. 你也可以指定它的 ‘type’ 属性类型,默认情况下,该类型是 ‘url’ 的后缀名。</br>
  8867. 也通过添加一个 包含 ‘skips’ 属性的 item 对象,你就可以跳过 skips 中包含的 pipe。</br>
  8868. 该对象可以包含任何附加属性。
  8869. @param items items
  8870. @example
  8871. ```js
  8872. pipeline.flowIn([
  8873. 'res/Background.png',
  8874. {
  8875. id: 'res/scene.json',
  8876. type: 'scene',
  8877. name: 'scene',
  8878. skips: ['Downloader']
  8879. }
  8880. ]);
  8881. ```
  8882. */
  8883. flowIn(items: any[]): void;
  8884. /**
  8885. !#en
  8886. Let new items flow into the pipeline and give a callback when the list of items are all completed. </br>
  8887. This is for loading dependencies for an existing item in flow, usually used in a pipe logic. </br>
  8888. For example, we have a loader for scene configuration file in JSON, the scene will only be fully loaded </br>
  8889. after all its dependencies are loaded, then you will need to use function to flow in all dependencies </br>
  8890. found in the configuration file, and finish the loader pipe only after all dependencies are loaded (in the callback).
  8891. !#zh
  8892. 让新 items 流入 pipeline 并且当 item 列表完成时进行回调函数。</br>
  8893. 这个 API 的使用通常是为了加载依赖项。</br>
  8894. 例如:</br>
  8895. 我们需要加载一个场景配置的 JSON 文件,该场景会将所有的依赖项全部都加载完毕以后,进行回调表示加载完毕。
  8896. @param urlList urlList
  8897. @param callback callback
  8898. */
  8899. flowInDeps(urlList: any[], callback: Function): any[];
  8900. /**
  8901. !#en
  8902. Copy the item states from one source item to all destination items. </br>
  8903. It's quite useful when a pipe generate new items from one source item,</br>
  8904. then you should flowIn these generated items into pipeline, </br>
  8905. but you probably want them to skip all pipes the source item already go through,</br>
  8906. you can achieve it with this API. </br>
  8907. </br>
  8908. For example, an unzip pipe will generate more items, but you won't want them to pass unzip or download pipe again.
  8909. !#zh
  8910. 从一个源 item 向所有目标 item 复制它的 pipe 状态,用于避免重复通过部分 pipe。</br>
  8911. 当一个源 item 生成了一系列新的 items 时很有用,</br>
  8912. 你希望让这些新的依赖项进入 pipeline,但是又不希望它们通过源 item 已经经过的 pipe,</br>
  8913. 但是你可能希望他们源 item 已经通过并跳过所有 pipes,</br>
  8914. 这个时候就可以使用这个 API。
  8915. @param srcItem The source item
  8916. @param dstItems A single destination item or an array of destination items
  8917. */
  8918. copyItemStates(srcItem: any, dstItems: any[]|any): void;
  8919. /**
  8920. !#en Returns whether the pipeline is flowing (contains item) currently.
  8921. !#zh 获取 pipeline 当前是否正在处理中。
  8922. */
  8923. isFlowing(): boolean;
  8924. /**
  8925. !#en Returns all items in pipeline. Returns null, please use API of Loader or LoadingItems.
  8926. !#zh 获取 pipeline 中的所有 items。返回 null,请使用 Loader / LoadingItems API。
  8927. */
  8928. getItems(): LoadingItems;
  8929. /**
  8930. !#en Returns an item in pipeline.
  8931. !#zh 根据 id 获取一个 item
  8932. @param id The id of the item
  8933. */
  8934. getItem(id: any): any;
  8935. /**
  8936. !#en Removes an completed item in pipeline.
  8937. It will only remove the cache in the pipeline or loader, its dependencies won't be released.
  8938. cc.loader provided another method to completely cleanup the resource and its dependencies,
  8939. please refer to {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}}
  8940. !#zh 移除指定的已完成 item。
  8941. 这将仅仅从 pipeline 或者 loader 中删除其缓存,并不会释放它所依赖的资源。
  8942. cc.loader 中提供了另一种删除资源及其依赖的清理方法,请参考 {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}}
  8943. @param id The id of the item
  8944. */
  8945. removeItem(id: any): boolean;
  8946. /**
  8947. !#en Clear the current pipeline, this function will clean up the items.
  8948. !#zh 清空当前 pipeline,该函数将清理 items。
  8949. */
  8950. clear(): void;
  8951. }
  8952. /** !#en
  8953. A cc.SpriteFrame has:<br/>
  8954. - texture: A cc.Texture2D that will be used by the _ccsg.Sprite<br/>
  8955. - rectangle: A rectangle of the texture
  8956. !#zh
  8957. 一个 SpriteFrame 包含:<br/>
  8958. - 纹理:会被 Sprite 使用的 Texture2D 对象。<br/>
  8959. - 矩形:在纹理中的矩形区域。 */
  8960. export class SpriteFrame extends Asset implements EventTarget {
  8961. /**
  8962. !#en
  8963. Constructor of SpriteFrame class.
  8964. !#zh
  8965. SpriteFrame 类的构造函数。
  8966. @param filename filename
  8967. @param rect rect
  8968. @param rotated Whether the frame is rotated in the texture
  8969. @param offset The offset of the frame in the texture
  8970. @param originalSize The size of the frame in the texture
  8971. */
  8972. constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size);
  8973. /** !#en Top border of the sprite
  8974. !#zh sprite 的顶部边框 */
  8975. insetTop: number;
  8976. /** !#en Bottom border of the sprite
  8977. !#zh sprite 的底部边框 */
  8978. insetBottom: number;
  8979. /** !#en Left border of the sprite
  8980. !#zh sprite 的左边边框 */
  8981. insetLeft: number;
  8982. /** !#en Right border of the sprite
  8983. !#zh sprite 的左边边框 */
  8984. insetRight: number;
  8985. /**
  8986. !#en Returns whether the texture have been loaded
  8987. !#zh 返回是否已加载纹理
  8988. */
  8989. textureLoaded(): boolean;
  8990. /**
  8991. Add a event listener for texture loaded event.
  8992. @param callback callback
  8993. @param target target
  8994. */
  8995. addLoadedEventListener(callback: Function, target: any): void;
  8996. /**
  8997. !#en Returns whether the sprite frame is rotated in the texture.
  8998. !#zh 获取 SpriteFrame 是否旋转
  8999. */
  9000. isRotated(): boolean;
  9001. /**
  9002. !#en Set whether the sprite frame is rotated in the texture.
  9003. !#zh 设置 SpriteFrame 是否旋转
  9004. @param bRotated bRotated
  9005. */
  9006. setRotated(bRotated: boolean): void;
  9007. /**
  9008. !#en Returns the rect of the sprite frame in the texture.
  9009. !#zh 获取 SpriteFrame 的纹理矩形区域
  9010. */
  9011. getRect(): Rect;
  9012. /**
  9013. !#en Sets the rect of the sprite frame in the texture.
  9014. !#zh 设置 SpriteFrame 的纹理矩形区域
  9015. @param rect rect
  9016. */
  9017. setRect(rect: Rect): void;
  9018. /**
  9019. !#en Returns the original size of the trimmed image.
  9020. !#zh 获取修剪前的原始大小
  9021. */
  9022. getOriginalSize(): Size;
  9023. /**
  9024. !#en Sets the original size of the trimmed image.
  9025. !#zh 设置修剪前的原始大小
  9026. @param size size
  9027. */
  9028. setOriginalSize(size: Size): void;
  9029. /**
  9030. !#en Returns the texture of the frame.
  9031. !#zh 获取使用的纹理实例
  9032. */
  9033. getTexture(): Texture2D;
  9034. /**
  9035. !#en Returns the offset of the frame in the texture.
  9036. !#zh 获取偏移量
  9037. */
  9038. getOffset(): Vec2;
  9039. /**
  9040. !#en Sets the offset of the frame in the texture.
  9041. !#zh 设置偏移量
  9042. @param offsets offsets
  9043. */
  9044. setOffset(offsets: Vec2): void;
  9045. /**
  9046. !#en Clone the sprite frame.
  9047. !#zh 克隆 SpriteFrame
  9048. */
  9049. clone(): SpriteFrame;
  9050. /**
  9051. !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.<br/>
  9052. !#zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame
  9053. @param textureOrTextureFile textureOrTextureFile
  9054. @param rect rect
  9055. @param rotated rotated
  9056. @param offset offset
  9057. @param originalSize originalSize
  9058. */
  9059. setTexture(textureOrTextureFile: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean;
  9060. /**
  9061. !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which
  9062. associated by user's custom Components in the scene, will not preload automatically.
  9063. These textures will be load when Sprite component is going to render the SpriteFrames.
  9064. You can call this method if you want to load the texture early.
  9065. !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。
  9066. 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。
  9067. @example
  9068. ```js
  9069. if (spriteFrame.textureLoaded()) {
  9070. this._onSpriteFrameLoaded();
  9071. }
  9072. else {
  9073. spriteFrame.once('load', this._onSpriteFrameLoaded, this);
  9074. spriteFrame.ensureLoadTexture();
  9075. }
  9076. ```
  9077. */
  9078. ensureLoadTexture(): void;
  9079. /**
  9080. !#en
  9081. If you do not need to use the SpriteFrame temporarily, you can call this method so that its texture could be garbage collected. Then when you need to render the SpriteFrame, you should call `ensureLoadTexture` manually to reload texture.
  9082. !#zh
  9083. 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。
  9084. @example
  9085. ```js
  9086. spriteFrame.clearTexture();
  9087. // when you need the SpriteFrame again...
  9088. spriteFrame.once('load', onSpriteFrameLoaded);
  9089. spriteFrame.ensureLoadTexture();
  9090. ```
  9091. */
  9092. clearTexture(): void;
  9093. /**
  9094. !#en
  9095. Register an callback of a specific event type on the EventTarget.
  9096. !#zh
  9097. 注册事件目标的特定事件类型回调。
  9098. @param type A string representing the event type to listen for.
  9099. @param callback The callback that will be invoked when the event is dispatched.
  9100. The callback is ignored if it is a duplicate (the callbacks are unique).
  9101. @param target The target (this object) to invoke the callback, can be null
  9102. @param useCapture When set to true, the capture argument prevents callback
  9103. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  9104. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  9105. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  9106. @example
  9107. ```js
  9108. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  9109. cc.log("this is callback");
  9110. }, node);
  9111. ```
  9112. */
  9113. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  9114. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  9115. /**
  9116. !#en
  9117. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  9118. if only type is passed as parameter, all listeners registered with that type will be removed.
  9119. !#zh
  9120. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  9121. @param type A string representing the event type being removed.
  9122. @param callback The callback to remove.
  9123. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  9124. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  9125. If not specified, useCapture defaults to false. If a callback was registered twice,
  9126. one with capture and one without, each must be removed separately. Removal of a capturing callback
  9127. does not affect a non-capturing version of the same listener, and vice versa.
  9128. @example
  9129. ```js
  9130. // register touchEnd eventListener
  9131. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  9132. cc.log("this is callback");
  9133. }, node);
  9134. // remove touch end event listener
  9135. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  9136. // remove all touch end event listeners
  9137. node.off(cc.Node.EventType.TOUCH_END);
  9138. ```
  9139. */
  9140. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  9141. /**
  9142. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  9143. This is not for removing all listeners in the current event target,
  9144. and this is not for removing all listeners the target parameter have registered.
  9145. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  9146. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  9147. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  9148. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  9149. @param target The target to be searched for all related listeners
  9150. */
  9151. targetOff(target: any): void;
  9152. /**
  9153. !#en
  9154. Register an callback of a specific event type on the EventTarget,
  9155. the callback will remove itself after the first time it is triggered.
  9156. !#zh
  9157. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  9158. @param type A string representing the event type to listen for.
  9159. @param callback The callback that will be invoked when the event is dispatched.
  9160. The callback is ignored if it is a duplicate (the callbacks are unique).
  9161. @param target The target (this object) to invoke the callback, can be null
  9162. @param useCapture When set to true, the capture argument prevents callback
  9163. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  9164. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  9165. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  9166. @example
  9167. ```js
  9168. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  9169. cc.log("this is callback");
  9170. }, node);
  9171. ```
  9172. */
  9173. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  9174. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  9175. /**
  9176. !#en
  9177. Dispatches an event into the event flow.
  9178. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  9179. !#zh 分发事件到事件流中。
  9180. @param event The Event object that is dispatched into the event flow
  9181. */
  9182. dispatchEvent(event: Event): void;
  9183. /**
  9184. !#en
  9185. Send an event to this object directly, this method will not propagate the event to any other objects.
  9186. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  9187. !#zh
  9188. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  9189. @param message the message to send
  9190. @param detail whatever argument the message needs
  9191. */
  9192. emit(message: string, detail?: any): void;
  9193. }
  9194. /** undefined */
  9195. export class WorldManifold {
  9196. /** !#en
  9197. world contact point (point of intersection)
  9198. !#zh
  9199. 碰撞点集合 */
  9200. points: [Vec2];
  9201. /** !#en
  9202. world vector pointing from A to B
  9203. !#zh
  9204. 世界坐标系下由 A 指向 B 的向量 */
  9205. normal: Vec2;
  9206. }
  9207. /** !#en
  9208. A manifold point is a contact point belonging to a contact manifold.
  9209. It holds details related to the geometry and dynamics of the contact points.
  9210. Note: the impulses are used for internal caching and may not
  9211. provide reliable contact forces, especially for high speed collisions.
  9212. !#zh
  9213. ManifoldPoint 是接触信息中的接触点信息。它拥有关于几何和接触点的详细信息。
  9214. 注意:信息中的冲量用于系统内部缓存,提供的接触力可能不是很准确,特别是高速移动中的碰撞信息。 */
  9215. export class ManifoldPoint {
  9216. /** !#en
  9217. The local point usage depends on the manifold type:
  9218. -e_circles: the local center of circleB
  9219. -e_faceA: the local center of circleB or the clip point of polygonB
  9220. -e_faceB: the clip point of polygonA
  9221. !#zh
  9222. 本地坐标点的用途取决于 manifold 的类型
  9223. - e_circles: circleB 的本地中心点
  9224. - e_faceA: circleB 的本地中心点 或者是 polygonB 的截取点
  9225. - e_faceB: polygonB 的截取点 */
  9226. localPoint: Vec2;
  9227. /** !#en
  9228. Normal impulse.
  9229. !#zh
  9230. 法线冲量。 */
  9231. normalImpulse: number;
  9232. /** !#en
  9233. Tangent impulse.
  9234. !#zh
  9235. 切线冲量。 */
  9236. tangentImpulse: number;
  9237. }
  9238. /** undefined */
  9239. export class Manifold {
  9240. /** !#en
  9241. Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB
  9242. !#zh
  9243. Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */
  9244. type: number;
  9245. /** !#en
  9246. The local point usage depends on the manifold type:
  9247. -e_circles: the local center of circleA
  9248. -e_faceA: the center of faceA
  9249. -e_faceB: the center of faceB
  9250. !#zh
  9251. 用途取决于 manifold 类型
  9252. -e_circles: circleA 的本地中心点
  9253. -e_faceA: faceA 的本地中心点
  9254. -e_faceB: faceB 的本地中心点 */
  9255. localPoint: Vec2;
  9256. /** !#en
  9257. -e_circles: not used
  9258. -e_faceA: the normal on polygonA
  9259. -e_faceB: the normal on polygonB
  9260. !#zh
  9261. -e_circles: 没被使用到
  9262. -e_faceA: polygonA 的法向量
  9263. -e_faceB: polygonB 的法向量 */
  9264. localNormal: Vec2;
  9265. /** !#en
  9266. the points of contact.
  9267. !#zh
  9268. 接触点信息。 */
  9269. points: [ManifoldPoint];
  9270. }
  9271. /** !#en
  9272. Contact impulses for reporting.
  9273. !#zh
  9274. 用于返回给回调的接触冲量。 */
  9275. export class PhysicsImpulse {
  9276. /** !#en
  9277. Normal impulses.
  9278. !#zh
  9279. 法线方向的冲量 */
  9280. normalImpulses: void;
  9281. /** !#en
  9282. Tangent impulses
  9283. !#zh
  9284. 切线方向的冲量 */
  9285. tangentImpulses: void;
  9286. }
  9287. /** !#en
  9288. PhysicsContact will be generated during begin and end collision as a parameter of the collision callback.
  9289. Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact.
  9290. !#zh
  9291. 物理接触会在开始和结束碰撞之间生成,并作为参数传入到碰撞回调函数中。
  9292. 注意:传入的物理接触会被系统进行重用,所以不要在使用中缓存里面的任何信息。 */
  9293. export class PhysicsContact {
  9294. /**
  9295. !#en
  9296. Get the world manifold.
  9297. !#zh
  9298. 获取世界坐标系下的碰撞信息。
  9299. */
  9300. getWorldManifold(): WorldManifold;
  9301. /**
  9302. !#en
  9303. Get the manifold.
  9304. !#zh
  9305. 获取世界坐标系下的碰撞信息。
  9306. */
  9307. getManifold(): Manifold;
  9308. /**
  9309. !#en
  9310. Get the impulses.
  9311. Note: PhysicsImpulse can only used in onPostSolve callback.
  9312. !#zh
  9313. 获取冲量信息
  9314. 注意:这个信息只有在 onPostSolve 回调中才能获取到
  9315. */
  9316. getImpulse(): PhysicsImpulse;
  9317. colliderA: Collider;
  9318. colliderB: Collider;
  9319. /** !#en
  9320. If set disabled to true, the contact will be ignored until contact end.
  9321. If you just want to disabled contact for current time step or sub-step, please use disabledOnce.
  9322. !#zh
  9323. 如果 disabled 被设置为 true,那么直到接触结束此接触都将被忽略。
  9324. 如果只是希望在当前时间步或子步中忽略此接触,请使用 disabledOnce 。 */
  9325. disabled: boolean;
  9326. /** !#en
  9327. Disabled contact for current time step or sub-step.
  9328. !#zh
  9329. 在当前时间步或子步中忽略此接触。 */
  9330. disabledOnce: boolean;
  9331. /**
  9332. !#en
  9333. Is this contact touching?
  9334. !#zh
  9335. 返回碰撞体是否已经接触到。
  9336. */
  9337. isTouching(): boolean;
  9338. /**
  9339. !#en
  9340. Set the desired tangent speed for a conveyor belt behavior.
  9341. !#zh
  9342. 为传送带设置期望的切线速度
  9343. @param tangentSpeed tangentSpeed
  9344. */
  9345. setTangentSpeed(tangentSpeed: number): void;
  9346. /**
  9347. !#en
  9348. Get the desired tangent speed.
  9349. !#zh
  9350. 获取切线速度
  9351. */
  9352. getTangentSpeed(): number;
  9353. /**
  9354. !#en
  9355. Override the default friction mixture. You can call this in onPreSolve callback.
  9356. !#zh
  9357. 覆盖默认的摩擦力系数。你可以在 onPreSolve 回调中调用此函数。
  9358. @param friction friction
  9359. */
  9360. setFriction(friction: number): void;
  9361. /**
  9362. !#en
  9363. Get the friction.
  9364. !#zh
  9365. 获取当前摩擦力系数
  9366. */
  9367. getFriction(): number;
  9368. /**
  9369. !#en
  9370. Reset the friction mixture to the default value.
  9371. !#zh
  9372. 重置摩擦力系数到默认值
  9373. */
  9374. resetFriction(): void;
  9375. /**
  9376. !#en
  9377. Override the default restitution mixture. You can call this in onPreSolve callback.
  9378. !#zh
  9379. 覆盖默认的恢复系数。你可以在 onPreSolve 回调中调用此函数。
  9380. @param restitution restitution
  9381. */
  9382. setRestitution(restitution: number): void;
  9383. /**
  9384. !#en
  9385. Get the restitution.
  9386. !#zh
  9387. 获取当前恢复系数
  9388. */
  9389. getRestitution(): number;
  9390. /**
  9391. !#en
  9392. Reset the restitution mixture to the default value.
  9393. !#zh
  9394. 重置恢复系数到默认值
  9395. */
  9396. resetRestitution(): void;
  9397. }
  9398. /** !#en
  9399. Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node).
  9400. You can visit some common box2d function through physics manager(hit testing, raycast, debug info).
  9401. Physics manager distributes the collision information to each collision callback when collision is produced.
  9402. Note: You need first enable the collision listener in the rigidbody.
  9403. !#zh
  9404. 物理系统将 box2d 作为内部物理系统,并且隐藏了大部分 box2d 实现细节(比如创建刚体,同步刚体信息到节点中等)。
  9405. 你可以通过物理系统访问一些 box2d 常用的功能,比如点击测试,射线测试,设置测试信息等。
  9406. 物理系统还管理碰撞信息的分发,她会在产生碰撞时,将碰撞信息分发到各个碰撞回调中。
  9407. 注意:你需要先在刚体中开启碰撞接听才会产生相应的碰撞回调。 */
  9408. export class PhysicsManager implements EventTarget {
  9409. /** !#en
  9410. The draw bits for drawing physics debug information.
  9411. !#zh
  9412. 指定物理系统需要绘制哪些调试信息。 */
  9413. static DrawBits: DrawBits;
  9414. /** !#en
  9415. The ratio transform between physics unit and pixel unit, generally is 32.
  9416. !#zh
  9417. 物理单位与像素单位互相转换的比率,一般是 32。 */
  9418. static PTM_RATIO: number;
  9419. /** !#en
  9420. The velocity iterations for the velocity constraint solver.
  9421. !#zh
  9422. 速度更新迭代数 */
  9423. static VELOCITY_ITERATIONS: number;
  9424. /** !#en
  9425. The position Iterations for the position constraint solver.
  9426. !#zh
  9427. 位置迭代更新数 */
  9428. static POSITION_ITERATIONS: number;
  9429. /** !#en
  9430. Specify the fixed time step.
  9431. Need enabledAccumulator to make it work.
  9432. !#zh
  9433. 指定固定的物理更新间隔时间,需要开启 enabledAccumulator 才有效。 */
  9434. static FIXED_TIME_STEP: number;
  9435. /** !#en
  9436. Specify the max accumulator time.
  9437. Need enabledAccumulator to make it work.
  9438. !#zh
  9439. 每次可用于更新物理系统的最大时间,需要开启 enabledAccumulator 才有效。 */
  9440. static MAX_ACCUMULATOR: number;
  9441. /** !#en
  9442. If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP.
  9443. And if the update dt is bigger than the time step, then will call step function several times.
  9444. If disabled accumulator, then will call step function with a time step calculated with the frame rate.
  9445. !#zh
  9446. 如果开启此选项,那么将会以固定的间隔时间 FIXED_TIME_STEP 来更新物理引擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物理引擎进行多次更新。
  9447. 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个间隔时间来更新物理引擎。 */
  9448. enabledAccumulator: boolean;
  9449. /**
  9450. !#en
  9451. Test which collider contains the given world point
  9452. !#zh
  9453. 获取包含给定世界坐标系点的碰撞体
  9454. @param point the world point
  9455. */
  9456. testPoint(point: Vec2): PhysicsCollider;
  9457. /**
  9458. !#en
  9459. Test which colliders intersect the given world rect
  9460. !#zh
  9461. 获取与给定世界坐标系矩形相交的碰撞体
  9462. @param rect the world rect
  9463. */
  9464. testAABB(rect: Rect): [PhysicsCollider];
  9465. /**
  9466. !#en
  9467. Raycast the world for all colliders in the path of the ray.
  9468. The raycast ignores colliders that contain the starting point.
  9469. !#zh
  9470. 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。
  9471. @param p1 start point of the raycast
  9472. @param p2 end point of the raycast
  9473. @param type optional, default is RayCastType.Closest
  9474. */
  9475. rayCast(p1: Vec2, p2: Vec2, type: RayCastType): [PhysicsRayCastResult];
  9476. /**
  9477. !#en
  9478. Attach physics debug draw to camera
  9479. !#zh
  9480. 将物理的调试绘制信息附加到指定摄像机上
  9481. @param camera camera
  9482. */
  9483. attachDebugDrawToCamera(camera: Camera): void;
  9484. /**
  9485. !#en
  9486. Detach physics debug draw to camera
  9487. !#zh
  9488. 将物理的调试绘制信息从指定摄像机上移除
  9489. @param camera camera
  9490. */
  9491. detachDebugDrawFromCamera(camera: Camera): void;
  9492. /** !#en
  9493. Enabled the physics manager?
  9494. !#zh
  9495. 指定是否启用物理系统? */
  9496. enabled: boolean;
  9497. /** !#en
  9498. Debug draw flags.
  9499. !#zh
  9500. 设置调试绘制标志 */
  9501. debugDrawFlags: number;
  9502. /** !#en
  9503. The physics world gravity.
  9504. !#zh
  9505. 物理世界重力值 */
  9506. gravity: Vec2;
  9507. /**
  9508. !#en
  9509. Register an callback of a specific event type on the EventTarget.
  9510. !#zh
  9511. 注册事件目标的特定事件类型回调。
  9512. @param type A string representing the event type to listen for.
  9513. @param callback The callback that will be invoked when the event is dispatched.
  9514. The callback is ignored if it is a duplicate (the callbacks are unique).
  9515. @param target The target (this object) to invoke the callback, can be null
  9516. @param useCapture When set to true, the capture argument prevents callback
  9517. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  9518. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  9519. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  9520. @example
  9521. ```js
  9522. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  9523. cc.log("this is callback");
  9524. }, node);
  9525. ```
  9526. */
  9527. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  9528. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  9529. /**
  9530. !#en
  9531. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  9532. if only type is passed as parameter, all listeners registered with that type will be removed.
  9533. !#zh
  9534. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  9535. @param type A string representing the event type being removed.
  9536. @param callback The callback to remove.
  9537. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  9538. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  9539. If not specified, useCapture defaults to false. If a callback was registered twice,
  9540. one with capture and one without, each must be removed separately. Removal of a capturing callback
  9541. does not affect a non-capturing version of the same listener, and vice versa.
  9542. @example
  9543. ```js
  9544. // register touchEnd eventListener
  9545. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  9546. cc.log("this is callback");
  9547. }, node);
  9548. // remove touch end event listener
  9549. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  9550. // remove all touch end event listeners
  9551. node.off(cc.Node.EventType.TOUCH_END);
  9552. ```
  9553. */
  9554. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  9555. /**
  9556. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  9557. This is not for removing all listeners in the current event target,
  9558. and this is not for removing all listeners the target parameter have registered.
  9559. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  9560. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  9561. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  9562. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  9563. @param target The target to be searched for all related listeners
  9564. */
  9565. targetOff(target: any): void;
  9566. /**
  9567. !#en
  9568. Register an callback of a specific event type on the EventTarget,
  9569. the callback will remove itself after the first time it is triggered.
  9570. !#zh
  9571. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  9572. @param type A string representing the event type to listen for.
  9573. @param callback The callback that will be invoked when the event is dispatched.
  9574. The callback is ignored if it is a duplicate (the callbacks are unique).
  9575. @param target The target (this object) to invoke the callback, can be null
  9576. @param useCapture When set to true, the capture argument prevents callback
  9577. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  9578. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  9579. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  9580. @example
  9581. ```js
  9582. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  9583. cc.log("this is callback");
  9584. }, node);
  9585. ```
  9586. */
  9587. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  9588. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  9589. /**
  9590. !#en
  9591. Dispatches an event into the event flow.
  9592. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  9593. !#zh 分发事件到事件流中。
  9594. @param event The Event object that is dispatched into the event flow
  9595. */
  9596. dispatchEvent(event: Event): void;
  9597. /**
  9598. !#en
  9599. Send an event to this object directly, this method will not propagate the event to any other objects.
  9600. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  9601. !#zh
  9602. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  9603. @param message the message to send
  9604. @param detail whatever argument the message needs
  9605. */
  9606. emit(message: string, detail?: any): void;
  9607. }
  9608. /** undefined */
  9609. export enum DrawBits {
  9610. e_aabbBit = 0,
  9611. e_pairBit = 0,
  9612. e_centerOfMassBit = 0,
  9613. e_jointBit = 0,
  9614. e_shapeBit = 0,
  9615. }
  9616. /** undefined */
  9617. export class PhysicsRayCastResult {
  9618. /** !#en
  9619. The PhysicsCollider which intersects with the raycast
  9620. !#zh
  9621. 与射线相交的碰撞体 */
  9622. collider: PhysicsCollider;
  9623. /** !#en
  9624. The intersection point
  9625. !#zh
  9626. 射线与碰撞体相交的点 */
  9627. point: Vec2;
  9628. /** !#en
  9629. The normal vector at the point of intersection
  9630. !#zh
  9631. 射线与碰撞体相交的点的法向量 */
  9632. normal: Vec2;
  9633. /** !#en
  9634. The fraction of the raycast path at the point of intersection
  9635. !#zh
  9636. 射线与碰撞体相交的点占射线长度的分数 */
  9637. fraction: number;
  9638. }
  9639. /** !#en Enum for RigidBodyType.
  9640. !#zh 刚体类型 */
  9641. export enum RigidBodyType {
  9642. Static = 0,
  9643. Kinematic = 0,
  9644. Dynamic = 0,
  9645. Animated = 0,
  9646. }
  9647. /** !#en Enum for RayCastType.
  9648. !#zh 射线检测类型 */
  9649. export enum RayCastType {
  9650. Closest = 0,
  9651. Any = 0,
  9652. AllClosest = 0,
  9653. All = 0,
  9654. }
  9655. /** undefined */
  9656. export class RigidBody extends Component {
  9657. /** !#en
  9658. Should enabled contact listener?
  9659. When a collision is trigger, the collision callback will only be called when enabled contact listener.
  9660. !#zh
  9661. 是否启用接触接听器。
  9662. 当 collider 产生碰撞时,只有开启了接触接听器才会调用相应的回调函数 */
  9663. enabledContactListener: boolean;
  9664. /**
  9665. !#en
  9666. Collision callback.
  9667. Called when two collider begin to touch.
  9668. !#zh
  9669. 碰撞回调。
  9670. 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体开始接触时被调用。
  9671. @param contact contact information
  9672. @param selfCollider the collider belong to this rigidbody
  9673. @param otherCollider the collider belong to another rigidbody
  9674. */
  9675. onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9676. /**
  9677. !#en
  9678. Collision callback.
  9679. Called when two collider cease to touch.
  9680. !#zh
  9681. 碰撞回调。
  9682. 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体停止接触时被调用。
  9683. @param contact contact information
  9684. @param selfCollider the collider belong to this rigidbody
  9685. @param otherCollider the collider belong to another rigidbody
  9686. */
  9687. onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9688. /**
  9689. !#en
  9690. Collision callback.
  9691. This is called when a contact is updated.
  9692. This allows you to inspect a contact before it goes to the solver(e.g. disable contact).
  9693. Note: this is called only for awake bodies.
  9694. Note: this is called even when the number of contact points is zero.
  9695. Note: this is not called for sensors.
  9696. !#zh
  9697. 碰撞回调。
  9698. 如果你的脚本中实现了这个函数,那么它将会在接触更新时被调用。
  9699. 你可以在接触被处理前根据他包含的信息作出相应的处理,比如将这个接触禁用掉。
  9700. 注意:回调只会为醒着的刚体调用。
  9701. 注意:接触点为零的时候也有可能被调用。
  9702. 注意:感知体(sensor)的回调不会被调用。
  9703. @param contact contact information
  9704. @param selfCollider the collider belong to this rigidbody
  9705. @param otherCollider the collider belong to another rigidbody
  9706. */
  9707. onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9708. /**
  9709. !#en
  9710. Collision callback.
  9711. This is called after a contact is updated.
  9712. You can get the impulses from the contact in this callback.
  9713. !#zh
  9714. 碰撞回调。
  9715. 如果你的脚本中实现了这个函数,那么它将会在接触更新完后被调用。
  9716. 你可以在这个回调中从接触信息中获取到冲量信息。
  9717. @param contact contact information
  9718. @param selfCollider the collider belong to this rigidbody
  9719. @param otherCollider the collider belong to another rigidbody
  9720. */
  9721. onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9722. /** !#en
  9723. Is this a fast moving body that should be prevented from tunneling through
  9724. other moving bodies?
  9725. Note :
  9726. - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies.
  9727. - You should use this flag sparingly since it increases processing time.
  9728. !#zh
  9729. 这个刚体是否是一个快速移动的刚体,并且需要禁止穿过其他快速移动的刚体?
  9730. 需要注意的是 :
  9731. - 所有刚体都被禁止从 运动刚体 和 静态刚体 中穿过。此选项只关注于 动态刚体。
  9732. - 应该尽量少的使用此选项,因为它会增加程序处理时间。 */
  9733. bullet: boolean;
  9734. /** !#en
  9735. Rigidbody type : Static, Kinematic, Dynamic or Animated.
  9736. !#zh
  9737. 刚体类型: Static, Kinematic, Dynamic or Animated. */
  9738. type: RigidBodyType;
  9739. /** !#en
  9740. Set this flag to false if this body should never fall asleep.
  9741. Note that this increases CPU usage.
  9742. !#zh
  9743. 如果此刚体永远都不应该进入睡眠,那么设置这个属性为 false。
  9744. 需要注意这将使 CPU 占用率提高。 */
  9745. allowSleep: boolean;
  9746. /** !#en
  9747. Scale the gravity applied to this body.
  9748. !#zh
  9749. 缩放应用在此刚体上的重力值 */
  9750. gravityScale: number;
  9751. /** !#en
  9752. Linear damping is use to reduce the linear velocity.
  9753. The damping parameter can be larger than 1, but the damping effect becomes sensitive to the
  9754. time step when the damping parameter is large.
  9755. !#zh
  9756. Linear damping 用于衰减刚体的线性速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */
  9757. linearDamping: number;
  9758. /** !#en
  9759. Angular damping is use to reduce the angular velocity. The damping parameter
  9760. can be larger than 1 but the damping effect becomes sensitive to the
  9761. time step when the damping parameter is large.
  9762. !#zh
  9763. Angular damping 用于衰减刚体的角速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */
  9764. angularDamping: number;
  9765. /** !#en
  9766. The linear velocity of the body's origin in world co-ordinates.
  9767. !#zh
  9768. 刚体在世界坐标下的线性速度 */
  9769. linearVelocity: Vec2;
  9770. /** !#en
  9771. The angular velocity of the body.
  9772. !#zh
  9773. 刚体的角速度 */
  9774. angularVelocity: number;
  9775. /** !#en
  9776. Should this body be prevented from rotating?
  9777. !#zh
  9778. 是否禁止此刚体进行旋转 */
  9779. fixedRotation: boolean;
  9780. /** !#en
  9781. Is this body initially awake or sleeping?
  9782. !#zh
  9783. 是否立刻唤醒此刚体 */
  9784. awake: boolean;
  9785. /** !#en
  9786. Set the active state of the body. An inactive body is not
  9787. simulated and cannot be collided with or woken up.
  9788. If body is active, all fixtures will be added to the
  9789. broad-phase.
  9790. If body is inactive, all fixtures will be removed from
  9791. the broad-phase and all contacts will be destroyed.
  9792. Fixtures on an inactive body are implicitly inactive and will
  9793. not participate in collisions, ray-casts, or queries.
  9794. Joints connected to an inactive body are implicitly inactive.
  9795. !#zh
  9796. 设置刚体的激活状态。一个非激活状态下的刚体是不会被模拟和碰撞的,不管它是否处于睡眠状态下。
  9797. 如果刚体处于激活状态下,所有夹具会被添加到 粗测阶段(broad-phase)。
  9798. 如果刚体处于非激活状态下,所有夹具会被从 粗测阶段(broad-phase)中移除。
  9799. 在非激活状态下的夹具不会参与到碰撞,射线,或者查找中
  9800. 链接到非激活状态下刚体的关节也是非激活的。 */
  9801. active: boolean;
  9802. /**
  9803. !#en
  9804. Gets a local point relative to the body's origin given a world point.
  9805. !#zh
  9806. 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点
  9807. @param worldPoint a point in world coordinates.
  9808. @param out optional, the receiving point
  9809. */
  9810. getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2;
  9811. /**
  9812. !#en
  9813. Get the world coordinates of a point given the local coordinates.
  9814. !#zh
  9815. 将一个给定的刚体本地坐标系下的点转换为世界坐标系下的点
  9816. @param localPoint a point in local coordinates.
  9817. @param out optional, the receiving point
  9818. */
  9819. getWorldPoint(localPoint: Vec2, out: Vec2): Vec2;
  9820. /**
  9821. !#en
  9822. Get the world coordinates of a vector given the local coordinates.
  9823. !#zh
  9824. 将一个给定的世界坐标系下的向量转换为刚体本地坐标系下的向量
  9825. @param localVector a vector in world coordinates.
  9826. @param out optional, the receiving vector
  9827. */
  9828. getWorldVector(localVector: Vec2, out: Vec2): Vec2;
  9829. /**
  9830. !#en
  9831. Gets a local vector relative to the body's origin given a world vector.
  9832. !#zh
  9833. 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点
  9834. @param worldVector a vector in world coordinates.
  9835. @param out optional, the receiving vector
  9836. */
  9837. getLocalVector(worldVector: Vec2, out: Vec2): Vec2;
  9838. /**
  9839. !#en
  9840. Get the world body origin position.
  9841. !#zh
  9842. 获取刚体世界坐标系下的原点值
  9843. @param out optional, the receiving point
  9844. */
  9845. getWorldPosition(out: Vec2): Vec2;
  9846. /**
  9847. !#en
  9848. Get the world body rotation angle.
  9849. !#zh
  9850. 获取刚体世界坐标系下的旋转值。
  9851. */
  9852. getWorldRotation(): number;
  9853. /**
  9854. !#en
  9855. Get the local position of the center of mass.
  9856. !#zh
  9857. 获取刚体本地坐标系下的质心
  9858. */
  9859. getLocalCenter(): Vec2;
  9860. /**
  9861. !#en
  9862. Get the world position of the center of mass.
  9863. !#zh
  9864. 获取刚体世界坐标系下的质心
  9865. */
  9866. getWorldCenter(): Vec2;
  9867. /**
  9868. !#en
  9869. Get the world linear velocity of a world point attached to this body.
  9870. !#zh
  9871. 获取刚体上指定点的线性速度
  9872. @param worldPoint a point in world coordinates.
  9873. @param out optional, the receiving point
  9874. */
  9875. getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2;
  9876. /**
  9877. !#en
  9878. Get total mass of the body.
  9879. !#zh
  9880. 获取刚体的质量。
  9881. */
  9882. getMass(): number;
  9883. /**
  9884. !#en
  9885. Get the rotational inertia of the body about the local origin.
  9886. !#zh
  9887. 获取刚体本地坐标系下原点的旋转惯性
  9888. */
  9889. getInertia(): number;
  9890. /**
  9891. !#en
  9892. Get all the joints connect to the rigidbody.
  9893. !#zh
  9894. 获取链接到此刚体的所有关节
  9895. */
  9896. getJointList(): [Joint];
  9897. /**
  9898. !#en
  9899. Apply a force at a world point. If the force is not
  9900. applied at the center of mass, it will generate a torque and
  9901. affect the angular velocity.
  9902. !#zh
  9903. 施加一个力到刚体上的一个点。如果力没有施加到刚体的质心上,还会产生一个扭矩并且影响到角速度。
  9904. @param force the world force vector.
  9905. @param point the world position.
  9906. @param wake also wake up the body.
  9907. */
  9908. applyForce(force: Vec2, point: Vec2, wake: boolean): void;
  9909. /**
  9910. !#en
  9911. Apply a force to the center of mass.
  9912. !#zh
  9913. 施加一个力到刚体上的质心上。
  9914. @param force the world force vector.
  9915. @param wake also wake up the body.
  9916. */
  9917. applyForceToCenter(force: Vec2, wake: boolean): void;
  9918. /**
  9919. !#en
  9920. Apply a torque. This affects the angular velocity.
  9921. !#zh
  9922. 施加一个扭矩力,将影响刚体的角速度
  9923. @param torque about the z-axis (out of the screen), usually in N-m.
  9924. @param wake also wake up the body
  9925. */
  9926. applyTorque(torque: number, wake: boolean): void;
  9927. /**
  9928. !#en
  9929. Apply a impulse at a world point, This immediately modifies the velocity.
  9930. If the impulse is not applied at the center of mass, it will generate a torque and
  9931. affect the angular velocity.
  9932. !#zh
  9933. 施加冲量到刚体上的一个点,将立即改变刚体的线性速度。
  9934. 如果冲量施加到的点不是刚体的质心,那么将产生一个扭矩并影响刚体的角速度。
  9935. @param impulse the world impulse vector, usually in N-seconds or kg-m/s.
  9936. @param point the world position
  9937. @param wake alse wake up the body
  9938. */
  9939. applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void;
  9940. /**
  9941. !#en
  9942. Apply an angular impulse.
  9943. !#zh
  9944. 施加一个角速度冲量。
  9945. @param impulse the angular impulse in units of kg*m*m/s
  9946. @param wake also wake up the body
  9947. */
  9948. applyAngularImpulse(impulse: number, wake: boolean): void;
  9949. /**
  9950. !#en
  9951. Synchronize node's world position to box2d rigidbody's position.
  9952. If enableAnimated is true and rigidbody's type is Animated type,
  9953. will set linear velocity instead of directly set rigidbody's position.
  9954. !#zh
  9955. 同步节点的世界坐标到 box2d 刚体的坐标上。
  9956. 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度来代替直接设置刚体的位置。
  9957. @param enableAnimated enableAnimated
  9958. */
  9959. syncPosition(enableAnimated: boolean): void;
  9960. /**
  9961. !#en
  9962. Synchronize node's world angle to box2d rigidbody's angle.
  9963. If enableAnimated is true and rigidbody's type is Animated type,
  9964. will set angular velocity instead of directly set rigidbody's angle.
  9965. !#zh
  9966. 同步节点的世界旋转角度值到 box2d 刚体的旋转值上。
  9967. 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度来代替直接设置刚体的角度。
  9968. @param enableAnimated enableAnimated
  9969. */
  9970. syncRotation(enableAnimated: boolean): void;
  9971. }
  9972. /** !#en Key map for keyboard event
  9973. !#zh 键盘事件的按键值 */
  9974. export enum KEY {
  9975. none = 0,
  9976. back = 0,
  9977. menu = 0,
  9978. backspace = 0,
  9979. tab = 0,
  9980. enter = 0,
  9981. shift = 0,
  9982. ctrl = 0,
  9983. alt = 0,
  9984. pause = 0,
  9985. capslock = 0,
  9986. escape = 0,
  9987. space = 0,
  9988. pageup = 0,
  9989. pagedown = 0,
  9990. end = 0,
  9991. home = 0,
  9992. left = 0,
  9993. up = 0,
  9994. right = 0,
  9995. down = 0,
  9996. select = 0,
  9997. insert = 0,
  9998. Delete = 0,
  9999. a = 0,
  10000. b = 0,
  10001. c = 0,
  10002. d = 0,
  10003. e = 0,
  10004. f = 0,
  10005. g = 0,
  10006. h = 0,
  10007. i = 0,
  10008. j = 0,
  10009. k = 0,
  10010. l = 0,
  10011. m = 0,
  10012. n = 0,
  10013. o = 0,
  10014. p = 0,
  10015. q = 0,
  10016. r = 0,
  10017. s = 0,
  10018. t = 0,
  10019. u = 0,
  10020. v = 0,
  10021. w = 0,
  10022. x = 0,
  10023. y = 0,
  10024. z = 0,
  10025. num0 = 0,
  10026. num1 = 0,
  10027. num2 = 0,
  10028. num3 = 0,
  10029. num4 = 0,
  10030. num5 = 0,
  10031. num6 = 0,
  10032. num7 = 0,
  10033. num8 = 0,
  10034. num9 = 0,
  10035. '*' = 0,
  10036. '+' = 0,
  10037. '-' = 0,
  10038. numdel = 0,
  10039. '/' = 0,
  10040. f1 = 0,
  10041. f2 = 0,
  10042. f3 = 0,
  10043. f4 = 0,
  10044. f5 = 0,
  10045. f6 = 0,
  10046. f7 = 0,
  10047. f8 = 0,
  10048. f9 = 0,
  10049. f10 = 0,
  10050. f11 = 0,
  10051. f12 = 0,
  10052. numlock = 0,
  10053. scrolllock = 0,
  10054. ';' = 0,
  10055. semicolon = 0,
  10056. equal = 0,
  10057. '=' = 0,
  10058. ',' = 0,
  10059. comma = 0,
  10060. dash = 0,
  10061. '.' = 0,
  10062. period = 0,
  10063. forwardslash = 0,
  10064. grave = 0,
  10065. '[' = 0,
  10066. openbracket = 0,
  10067. backslash = 0,
  10068. ']' = 0,
  10069. closebracket = 0,
  10070. quote = 0,
  10071. dpadLeft = 0,
  10072. dpadRight = 0,
  10073. dpadUp = 0,
  10074. dpadDown = 0,
  10075. dpadCenter = 0,
  10076. }
  10077. /** Image formats */
  10078. export enum ImageFormat {
  10079. JPG = 0,
  10080. PNG = 0,
  10081. TIFF = 0,
  10082. WEBP = 0,
  10083. PVR = 0,
  10084. ETC = 0,
  10085. S3TC = 0,
  10086. ATITC = 0,
  10087. TGA = 0,
  10088. RAWDATA = 0,
  10089. UNKNOWN = 0,
  10090. getImageFormatByData = 0,
  10091. }
  10092. /** Predefined constants */
  10093. export enum macro {
  10094. INVALID_INDEX = 0,
  10095. NODE_TAG_INVALID = 0,
  10096. PI = 0,
  10097. PI2 = 0,
  10098. FLT_MAX = 0,
  10099. FLT_MIN = 0,
  10100. RAD = 0,
  10101. DEG = 0,
  10102. UINT_MAX = 0,
  10103. REPEAT_FOREVER = 0,
  10104. FLT_EPSILON = 0,
  10105. ONE = 0,
  10106. ZERO = 0,
  10107. SRC_ALPHA = 0,
  10108. SRC_ALPHA_SATURATE = 0,
  10109. SRC_COLOR = 0,
  10110. DST_ALPHA = 0,
  10111. DST_COLOR = 0,
  10112. ONE_MINUS_SRC_ALPHA = 0,
  10113. ONE_MINUS_SRC_COLOR = 0,
  10114. ONE_MINUS_DST_ALPHA = 0,
  10115. ONE_MINUS_DST_COLOR = 0,
  10116. ONE_MINUS_CONSTANT_ALPHA = 0,
  10117. ONE_MINUS_CONSTANT_COLOR = 0,
  10118. LINEAR = 0,
  10119. BLEND_DST = 0,
  10120. WEB_ORIENTATION_PORTRAIT = 0,
  10121. WEB_ORIENTATION_LANDSCAPE_LEFT = 0,
  10122. WEB_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 0,
  10123. WEB_ORIENTATION_LANDSCAPE_RIGHT = 0,
  10124. ORIENTATION_PORTRAIT = 0,
  10125. ORIENTATION_LANDSCAPE = 0,
  10126. ORIENTATION_AUTO = 0,
  10127. VERTEX_ATTRIB_FLAG_NONE = 0,
  10128. VERTEX_ATTRIB_FLAG_POSITION = 0,
  10129. VERTEX_ATTRIB_FLAG_COLOR = 0,
  10130. VERTEX_ATTRIB_FLAG_TEX_COORDS = 0,
  10131. VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0,
  10132. GL_ALL = 0,
  10133. VERTEX_ATTRIB_POSITION = 0,
  10134. VERTEX_ATTRIB_COLOR = 0,
  10135. VERTEX_ATTRIB_TEX_COORDS = 0,
  10136. VERTEX_ATTRIB_MAX = 0,
  10137. UNIFORM_PMATRIX = 0,
  10138. UNIFORM_MVMATRIX = 0,
  10139. UNIFORM_MVPMATRIX = 0,
  10140. UNIFORM_TIME = 0,
  10141. UNIFORM_SINTIME = 0,
  10142. UNIFORM_COSTIME = 0,
  10143. UNIFORM_RANDOM01 = 0,
  10144. UNIFORM_SAMPLER = 0,
  10145. UNIFORM_MAX = 0,
  10146. SHADER_POSITION_TEXTURECOLOR = 0,
  10147. SHADER_SPRITE_POSITION_TEXTURECOLOR = 0,
  10148. SHADER_POSITION_TEXTURECOLORALPHATEST = 0,
  10149. SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST = 0,
  10150. SHADER_POSITION_COLOR = 0,
  10151. SHADER_SPRITE_POSITION_COLOR = 0,
  10152. SHADER_POSITION_TEXTURE = 0,
  10153. SHADER_POSITION_TEXTURE_UCOLOR = 0,
  10154. SHADER_POSITION_TEXTUREA8COLOR = 0,
  10155. SHADER_POSITION_UCOLOR = 0,
  10156. SHADER_POSITION_LENGTHTEXTURECOLOR = 0,
  10157. UNIFORM_PMATRIX_S = 0,
  10158. UNIFORM_MVMATRIX_S = 0,
  10159. UNIFORM_MVPMATRIX_S = 0,
  10160. UNIFORM_TIME_S = 0,
  10161. UNIFORM_SINTIME_S = 0,
  10162. UNIFORM_COSTIME_S = 0,
  10163. UNIFORM_RANDOM01_S = 0,
  10164. UNIFORM_SAMPLER_S = 0,
  10165. UNIFORM_ALPHA_TEST_VALUE_S = 0,
  10166. ATTRIBUTE_NAME_COLOR = 0,
  10167. ATTRIBUTE_NAME_POSITION = 0,
  10168. ATTRIBUTE_NAME_TEX_COORD = 0,
  10169. ITEM_SIZE = 0,
  10170. CURRENT_ITEM = 0,
  10171. ZOOM_ACTION_TAG = 0,
  10172. NORMAL_TAG = 0,
  10173. SELECTED_TAG = 0,
  10174. DISABLE_TAG = 0,
  10175. FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0,
  10176. FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX = 0,
  10177. DIRECTOR_STATS_POSITION = 0,
  10178. DIRECTOR_FPS_INTERVAL = 0,
  10179. COCOSNODE_RENDER_SUBPIXEL = 0,
  10180. SPRITEBATCHNODE_RENDER_SUBPIXEL = 0,
  10181. AUTO_PREMULTIPLIED_ALPHA_FOR_PNG = 0,
  10182. OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0,
  10183. TEXTURE_NPOT_SUPPORT = 0,
  10184. USE_LA88_LABELS = 0,
  10185. SPRITE_DEBUG_DRAW = 0,
  10186. LABELBMFONT_DEBUG_DRAW = 0,
  10187. LABELATLAS_DEBUG_DRAW = 0,
  10188. ENABLE_STACKABLE_ACTIONS = 0,
  10189. ENABLE_GL_STATE_CACHE = 0,
  10190. TOUCH_TIMEOUT = 0,
  10191. BATCH_VERTEX_COUNT = 0,
  10192. ENABLE_GC_FOR_NATIVE_OBJECTS = 0,
  10193. ENABLE_TILEDMAP_CULLING = 0,
  10194. DOWNLOAD_MAX_CONCURRENT = 0,
  10195. ENABLE_TRANSPARENT_CANVAS = 0,
  10196. ENABLE_CULLING = 0,
  10197. BLEND_SRC = 0,
  10198. }
  10199. /** The base class of most of all the objects in Fireball. */
  10200. export class Object {
  10201. /** !#en The name of the object.
  10202. !#zh 该对象的名称。 */
  10203. name: string;
  10204. /** !#en Indicates whether the object is not yet destroyed.
  10205. !#zh 表示该对象是否可用(被销毁后将不可用)。 */
  10206. isValid: boolean;
  10207. /**
  10208. !#en
  10209. Destroy this Object, and release all its own references to other objects.<br/>
  10210. Actual object destruction will delayed until before rendering.
  10211. <br/>
  10212. After destroy, this CCObject is not usable any more.
  10213. You can use cc.isValid(obj) to check whether the object is destroyed before accessing it.
  10214. !#zh
  10215. 销毁该对象,并释放所有它对其它对象的引用。<br/>
  10216. 销毁后,CCObject 不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
  10217. 实际销毁操作会延迟到当前帧渲染前执行。
  10218. @example
  10219. ```js
  10220. obj.destroy();
  10221. ```
  10222. */
  10223. destroy(): boolean;
  10224. }
  10225. /** Bit mask that controls object states. */
  10226. export enum Flags {
  10227. DontSave = 0,
  10228. EditorOnly = 0,
  10229. }
  10230. /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen.
  10231. It's invalid on safari, QQbrowser and android browser */
  10232. export class screen {
  10233. /**
  10234. initialize
  10235. */
  10236. init(): void;
  10237. /**
  10238. return true if it's full now.
  10239. */
  10240. fullScreen(): boolean;
  10241. /**
  10242. change the screen to full mode.
  10243. @param element element
  10244. @param onFullScreenChange onFullScreenChange
  10245. */
  10246. requestFullScreen(element: Element, onFullScreenChange: Function): void;
  10247. /**
  10248. exit the full mode.
  10249. */
  10250. exitFullScreen(): boolean;
  10251. /**
  10252. Automatically request full screen with a touch/click event
  10253. @param element element
  10254. @param onFullScreenChange onFullScreenChange
  10255. */
  10256. autoFullScreen(element: Element, onFullScreenChange: Function): void;
  10257. }
  10258. /** System variables */
  10259. export class sys {
  10260. /** English language code */
  10261. static LANGUAGE_ENGLISH: string;
  10262. /** Chinese language code */
  10263. static LANGUAGE_CHINESE: string;
  10264. /** French language code */
  10265. static LANGUAGE_FRENCH: string;
  10266. /** Italian language code */
  10267. static LANGUAGE_ITALIAN: string;
  10268. /** German language code */
  10269. static LANGUAGE_GERMAN: string;
  10270. /** Spanish language code */
  10271. static LANGUAGE_SPANISH: string;
  10272. /** Spanish language code */
  10273. static LANGUAGE_DUTCH: string;
  10274. /** Russian language code */
  10275. static LANGUAGE_RUSSIAN: string;
  10276. /** Korean language code */
  10277. static LANGUAGE_KOREAN: string;
  10278. /** Japanese language code */
  10279. static LANGUAGE_JAPANESE: string;
  10280. /** Hungarian language code */
  10281. static LANGUAGE_HUNGARIAN: string;
  10282. /** Portuguese language code */
  10283. static LANGUAGE_PORTUGUESE: string;
  10284. /** Arabic language code */
  10285. static LANGUAGE_ARABIC: string;
  10286. /** Norwegian language code */
  10287. static LANGUAGE_NORWEGIAN: string;
  10288. /** Polish language code */
  10289. static LANGUAGE_POLISH: string;
  10290. /** Turkish language code */
  10291. static LANGUAGE_TURKISH: string;
  10292. /** Ukrainian language code */
  10293. static LANGUAGE_UKRAINIAN: string;
  10294. /** Romanian language code */
  10295. static LANGUAGE_ROMANIAN: string;
  10296. /** Bulgarian language code */
  10297. static LANGUAGE_BULGARIAN: string;
  10298. /** Unknown language code */
  10299. static LANGUAGE_UNKNOWN: string;
  10300. static OS_IOS: string;
  10301. static OS_ANDROID: string;
  10302. static OS_WINDOWS: string;
  10303. static OS_MARMALADE: string;
  10304. static OS_LINUX: string;
  10305. static OS_BADA: string;
  10306. static OS_BLACKBERRY: string;
  10307. static OS_OSX: string;
  10308. static OS_WP8: string;
  10309. static OS_WINRT: string;
  10310. static OS_UNKNOWN: string;
  10311. static UNKNOWN: number;
  10312. static WIN32: number;
  10313. static LINUX: number;
  10314. static MACOS: number;
  10315. static ANDROID: number;
  10316. static IPHONE: number;
  10317. static IPAD: number;
  10318. static BLACKBERRY: number;
  10319. static NACL: number;
  10320. static EMSCRIPTEN: number;
  10321. static TIZEN: number;
  10322. static WINRT: number;
  10323. static WP8: number;
  10324. static MOBILE_BROWSER: number;
  10325. static DESKTOP_BROWSER: number;
  10326. /** Indicates whether executes in editor's window process (Electron's renderer context) */
  10327. static EDITOR_PAGE: number;
  10328. /** Indicates whether executes in editor's main process (Electron's browser context) */
  10329. static EDITOR_CORE: number;
  10330. static WECHAT_GAME: number;
  10331. static QQ_PLAY: number;
  10332. /** BROWSER_TYPE_WECHAT */
  10333. static BROWSER_TYPE_WECHAT: string;
  10334. /** BROWSER_TYPE_WECHAT_GAME */
  10335. static BROWSER_TYPE_WECHAT_GAME: string;
  10336. /** BROWSER_TYPE_QQ_PLAY */
  10337. static BROWSER_TYPE_QQ_PLAY: string;
  10338. static BROWSER_TYPE_ANDROID: string;
  10339. static BROWSER_TYPE_IE: string;
  10340. static BROWSER_TYPE_QQ: string;
  10341. static BROWSER_TYPE_MOBILE_QQ: string;
  10342. static BROWSER_TYPE_UC: string;
  10343. static BROWSER_TYPE_360: string;
  10344. static BROWSER_TYPE_BAIDU_APP: string;
  10345. static BROWSER_TYPE_BAIDU: string;
  10346. static BROWSER_TYPE_MAXTHON: string;
  10347. static BROWSER_TYPE_OPERA: string;
  10348. static BROWSER_TYPE_OUPENG: string;
  10349. static BROWSER_TYPE_MIUI: string;
  10350. static BROWSER_TYPE_FIREFOX: string;
  10351. static BROWSER_TYPE_SAFARI: string;
  10352. static BROWSER_TYPE_CHROME: string;
  10353. static BROWSER_TYPE_LIEBAO: string;
  10354. static BROWSER_TYPE_QZONE: string;
  10355. static BROWSER_TYPE_SOUGOU: string;
  10356. static BROWSER_TYPE_UNKNOWN: string;
  10357. /** Is native ? This is set to be true in jsb auto. */
  10358. static isNative: boolean;
  10359. /** Is web browser ? */
  10360. static isBrowser: boolean;
  10361. /** Indicate whether system is mobile system */
  10362. static isMobile: boolean;
  10363. /** Indicate the running platform */
  10364. static platform: number;
  10365. /** Indicate the current language of the running system */
  10366. static language: string;
  10367. /** Indicate the running os name */
  10368. static os: string;
  10369. /** Indicate the running os version */
  10370. static osVersion: string;
  10371. /** Indicate the running os main version */
  10372. static osMainVersion: number;
  10373. /** Indicate the running browser type */
  10374. static browserType: string;
  10375. /** Indicate the running browser version */
  10376. static browserVersion: string;
  10377. /** Indicate the real pixel resolution of the whole game window */
  10378. static windowPixelResolution: Size;
  10379. /** cc.sys.localStorage is a local storage component. */
  10380. static localStorage: any;
  10381. /** The capabilities of the current platform */
  10382. static capabilities: any;
  10383. /**
  10384. Forces the garbage collection, only available in JSB
  10385. */
  10386. static garbageCollect(): void;
  10387. /**
  10388. Dumps rooted objects, only available in JSB
  10389. */
  10390. static dumpRoot(): void;
  10391. /**
  10392. Restart the JS VM, only available in JSB
  10393. */
  10394. static restartVM(): void;
  10395. /**
  10396. Clean a script in the JS VM, only available in JSB
  10397. @param jsfile jsfile
  10398. */
  10399. static cleanScript(jsfile: string): void;
  10400. /**
  10401. Check whether an object is valid,
  10402. In web engine, it will return true if the object exist
  10403. In native engine, it will return true if the JS object and the correspond native object are both valid
  10404. @param obj obj
  10405. */
  10406. static isObjectValid(obj: any): boolean;
  10407. /**
  10408. Dump system informations
  10409. */
  10410. static dump(): void;
  10411. /**
  10412. Open a url in browser
  10413. @param url url
  10414. */
  10415. static openURL(url: string): void;
  10416. /**
  10417. Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
  10418. */
  10419. static now(): number;
  10420. }
  10421. /** cc.view is the singleton object which represents the game window.<br/>
  10422. It's main task include: <br/>
  10423. - Apply the design resolution policy<br/>
  10424. - Provide interaction with the window, like resize event on web, retina display support, etc...<br/>
  10425. - Manage the game view port which can be different with the window<br/>
  10426. - Manage the content scale and translation<br/>
  10427. <br/>
  10428. Since the cc.view is a singleton, you don't need to call any constructor or create functions,<br/>
  10429. the standard way to use it is by calling:<br/>
  10430. - cc.view.methodName(); <br/> */
  10431. export class View {
  10432. /**
  10433. <p>
  10434. Sets view's target-densitydpi for android mobile browser. it can be set to: <br/>
  10435. 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi" <br/>
  10436. 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value) <br/>
  10437. 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value) <br/>
  10438. 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi" <br/>
  10439. 5. Custom value, e.g: "480" <br/>
  10440. </p>
  10441. @param densityDPI densityDPI
  10442. */
  10443. setTargetDensityDPI(densityDPI: string): void;
  10444. /**
  10445. Returns the current target-densitydpi value of cc.view.
  10446. */
  10447. getTargetDensityDPI(): string;
  10448. /**
  10449. Sets whether resize canvas automatically when browser's size changed.<br/>
  10450. Useful only on web.
  10451. @param enabled Whether enable automatic resize with browser's resize event
  10452. */
  10453. resizeWithBrowserSize(enabled: boolean): void;
  10454. /**
  10455. Sets the callback function for cc.view's resize action,<br/>
  10456. this callback will be invoked before applying resolution policy, <br/>
  10457. so you can do any additional modifications within the callback.<br/>
  10458. Useful only on web.
  10459. @param callback The callback function
  10460. */
  10461. setResizeCallback(callback: Function|void): void;
  10462. /**
  10463. Sets the orientation of the game, it can be landscape, portrait or auto.
  10464. When set it to landscape or portrait, and screen w/h ratio doesn't fit,
  10465. cc.view will automatically rotate the game canvas using CSS.
  10466. Note that this function doesn't have any effect in native,
  10467. in native, you need to set the application orientation in native project settings
  10468. @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO
  10469. */
  10470. setOrientation(orientation: number): void;
  10471. /**
  10472. Sets whether the engine modify the "viewport" meta in your web page.<br/>
  10473. It's enabled by default, we strongly suggest you not to disable it.<br/>
  10474. And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden<br/>
  10475. Only useful on web
  10476. @param enabled Enable automatic modification to "viewport" meta
  10477. */
  10478. adjustViewPort(enabled: boolean): void;
  10479. /**
  10480. Retina support is enabled by default for Apple device but disabled for other devices,<br/>
  10481. it takes effect only when you called setDesignResolutionPolicy<br/>
  10482. Only useful on web
  10483. @param enabled Enable or disable retina display
  10484. */
  10485. enableRetina(enabled: boolean): void;
  10486. /**
  10487. Check whether retina display is enabled.<br/>
  10488. Only useful on web
  10489. */
  10490. isRetinaEnabled(): boolean;
  10491. /**
  10492. !#en Whether to Enable on anti-alias
  10493. !#zh 控制抗锯齿是否开启
  10494. @param enabled Enable or not anti-alias
  10495. */
  10496. enableAntiAlias(enabled: boolean): void;
  10497. /**
  10498. !#en Returns whether the current enable on anti-alias
  10499. !#zh 返回当前是否抗锯齿
  10500. */
  10501. isAntiAliasEnabled(): boolean;
  10502. /**
  10503. If enabled, the application will try automatically to enter full screen mode on mobile devices<br/>
  10504. You can pass true as parameter to enable it and disable it by passing false.<br/>
  10505. Only useful on web
  10506. @param enabled Enable or disable auto full screen on mobile devices
  10507. */
  10508. enableAutoFullScreen(enabled: boolean): void;
  10509. /**
  10510. Check whether auto full screen is enabled.<br/>
  10511. Only useful on web
  10512. */
  10513. isAutoFullScreenEnabled(): boolean;
  10514. /**
  10515. Get whether render system is ready(no matter opengl or canvas),<br/>
  10516. this name is for the compatibility with cocos2d-x, subclass must implement this method.
  10517. */
  10518. isViewReady(): boolean;
  10519. /**
  10520. Sets the resolution translate on View.
  10521. @param offsetLeft offsetLeft
  10522. @param offsetTop offsetTop
  10523. */
  10524. setContentTranslateLeftTop(offsetLeft: number, offsetTop: number): void;
  10525. /**
  10526. Returns the resolution translate on View
  10527. */
  10528. getContentTranslateLeftTop(): Size;
  10529. /**
  10530. Returns the frame size of the view.<br/>
  10531. On native platforms, it returns the screen size since the view is a fullscreen view.<br/>
  10532. On web, it returns the size of the canvas's outer DOM element.
  10533. */
  10534. getFrameSize(): Size;
  10535. /**
  10536. On native, it sets the frame size of view.<br/>
  10537. On web, it sets the size of the canvas's outer DOM element.
  10538. @param width width
  10539. @param height height
  10540. */
  10541. setFrameSize(width: number, height: number): void;
  10542. /**
  10543. Returns the visible area size of the view port.
  10544. */
  10545. getVisibleSize(): Size;
  10546. /**
  10547. Returns the visible area size of the view port.
  10548. */
  10549. getVisibleSizeInPixel(): Size;
  10550. /**
  10551. Returns the visible origin of the view port.
  10552. */
  10553. getVisibleOrigin(): Vec2;
  10554. /**
  10555. Returns the visible origin of the view port.
  10556. */
  10557. getVisibleOriginInPixel(): Vec2;
  10558. /**
  10559. Returns whether developer can set content's scale factor.
  10560. */
  10561. canSetContentScaleFactor(): boolean;
  10562. /**
  10563. Returns the current resolution policy
  10564. */
  10565. getResolutionPolicy(): ResolutionPolicy;
  10566. /**
  10567. Sets the current resolution policy
  10568. @param resolutionPolicy resolutionPolicy
  10569. */
  10570. setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void;
  10571. /**
  10572. Sets the resolution policy with designed view size in points.<br/>
  10573. The resolution policy include: <br/>
  10574. [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/>
  10575. [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/>
  10576. [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/>
  10577. [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width<br/>
  10578. [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height<br/>
  10579. [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy<br/>
  10580. @param width Design resolution width.
  10581. @param height Design resolution height.
  10582. @param resolutionPolicy The resolution policy desired
  10583. */
  10584. setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void;
  10585. /**
  10586. Returns the designed size for the view.
  10587. Default resolution size is the same as 'getFrameSize'.
  10588. */
  10589. getDesignResolutionSize(): Size;
  10590. /**
  10591. Sets the container to desired pixel resolution and fit the game content to it.
  10592. This function is very useful for adaptation in mobile browsers.
  10593. In some HD android devices, the resolution is very high, but its browser performance may not be very good.
  10594. In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry.
  10595. But this API can be helpful to set a desired pixel resolution which is in between.
  10596. This API will do the following:
  10597. 1. Set viewport's width to the desired width in pixel
  10598. 2. Set body width to the exact pixel resolution
  10599. 3. The resolution policy will be reset with designed view size in points.
  10600. @param width Design resolution width.
  10601. @param height Design resolution height.
  10602. @param resolutionPolicy The resolution policy desired
  10603. */
  10604. setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void;
  10605. /**
  10606. Sets view port rectangle with points.
  10607. @param x x
  10608. @param y y
  10609. @param w width
  10610. @param h height
  10611. */
  10612. setViewPortInPoints(x: number, y: number, w: number, h: number): void;
  10613. /**
  10614. Sets Scissor rectangle with points.
  10615. @param x x
  10616. @param y y
  10617. @param w w
  10618. @param h h
  10619. */
  10620. setScissorInPoints(x: number, y: number, w: number, h: number): void;
  10621. /**
  10622. Returns whether GL_SCISSOR_TEST is enable
  10623. */
  10624. isScissorEnabled(): boolean;
  10625. /**
  10626. Returns the current scissor rectangle
  10627. */
  10628. getScissorRect(): Rect;
  10629. /**
  10630. Sets the name of the view
  10631. @param viewName viewName
  10632. */
  10633. setViewName(viewName: string): void;
  10634. /**
  10635. Returns the name of the view
  10636. */
  10637. getViewName(): string;
  10638. /**
  10639. Returns the view port rectangle.
  10640. */
  10641. getViewPortRect(): Rect;
  10642. /**
  10643. Returns scale factor of the horizontal direction (X axis).
  10644. */
  10645. getScaleX(): number;
  10646. /**
  10647. Returns scale factor of the vertical direction (Y axis).
  10648. */
  10649. getScaleY(): number;
  10650. /**
  10651. Returns device pixel ratio for retina display.
  10652. */
  10653. getDevicePixelRatio(): number;
  10654. /**
  10655. Returns the real location in view for a translation based on a related position
  10656. @param tx The X axis translation
  10657. @param ty The Y axis translation
  10658. @param relatedPos The related position object including "left", "top", "width", "height" informations
  10659. */
  10660. convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2;
  10661. }
  10662. /** <p>cc.ContainerStrategy class is the root strategy class of container's scale strategy,
  10663. it controls the behavior of how to scale the cc.container and cc.game.canvas object</p> */
  10664. export class ContainerStrategy {
  10665. /**
  10666. Manipulation before appling the strategy
  10667. @param view The target view
  10668. */
  10669. preApply(view: View): void;
  10670. /**
  10671. Function to apply this strategy
  10672. @param view view
  10673. @param designedResolution designedResolution
  10674. */
  10675. apply(view: View, designedResolution: Size): void;
  10676. /**
  10677. Manipulation after applying the strategy
  10678. @param view The target view
  10679. */
  10680. postApply(view: View): void;
  10681. }
  10682. /** <p>cc.ContentStrategy class is the root strategy class of content's scale strategy,
  10683. it controls the behavior of how to scale the scene and setup the viewport for the game</p> */
  10684. export class ContentStrategy {
  10685. /**
  10686. Manipulation before applying the strategy
  10687. @param view The target view
  10688. */
  10689. preApply(view: View): void;
  10690. /**
  10691. Function to apply this strategy
  10692. The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
  10693. The target view can then apply these value to itself, it's preferred not to modify directly its private variables
  10694. @param view view
  10695. @param designedResolution designedResolution
  10696. */
  10697. apply(view: View, designedResolution: Size): any;
  10698. /**
  10699. Manipulation after applying the strategy
  10700. @param view The target view
  10701. */
  10702. postApply(view: View): void;
  10703. }
  10704. /** undefined */
  10705. export class EqualToFrame extends ContainerStrategy {
  10706. }
  10707. /** undefined */
  10708. export class ProportionalToFrame extends ContainerStrategy {
  10709. }
  10710. /** undefined */
  10711. export class EqualToWindow extends EqualToFrame {
  10712. }
  10713. /** undefined */
  10714. export class ProportionalToWindow extends ProportionalToFrame {
  10715. }
  10716. /** undefined */
  10717. export class OriginalContainer extends ContainerStrategy {
  10718. }
  10719. /** <p>cc.ResolutionPolicy class is the root strategy class of scale strategy,
  10720. its main task is to maintain the compatibility with Cocos2d-x</p> */
  10721. export class ResolutionPolicy {
  10722. /**
  10723. @param containerStg The container strategy
  10724. @param contentStg The content strategy
  10725. */
  10726. constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy);
  10727. /**
  10728. Manipulation before applying the resolution policy
  10729. @param view The target view
  10730. */
  10731. preApply(view: View): void;
  10732. /**
  10733. Function to apply this resolution policy
  10734. The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
  10735. The target view can then apply these value to itself, it's preferred not to modify directly its private variables
  10736. @param view The target view
  10737. @param designedResolution The user defined design resolution
  10738. */
  10739. apply(view: View, designedResolution: Size): any;
  10740. /**
  10741. Manipulation after appyling the strategy
  10742. @param view The target view
  10743. */
  10744. postApply(view: View): void;
  10745. /**
  10746. Setup the container's scale strategy
  10747. @param containerStg containerStg
  10748. */
  10749. setContainerStrategy(containerStg: ContainerStrategy): void;
  10750. /**
  10751. Setup the content's scale strategy
  10752. @param contentStg contentStg
  10753. */
  10754. setContentStrategy(contentStg: ContentStrategy): void;
  10755. /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.<br/>
  10756. Distortion can occur, and the application may appear stretched or compressed. */
  10757. static EXACT_FIT: number;
  10758. /** The entire application fills the specified area, without distortion but possibly with some cropping,<br/>
  10759. while maintaining the original aspect ratio of the application. */
  10760. static NO_BORDER: number;
  10761. /** The entire application is visible in the specified area without distortion while maintaining the original<br/>
  10762. aspect ratio of the application. Borders can appear on two sides of the application. */
  10763. static SHOW_ALL: number;
  10764. /** The application takes the height of the design resolution size and modifies the width of the internal<br/>
  10765. canvas so that it fits the aspect ratio of the device<br/>
  10766. no distortion will occur however you must make sure your application works on different<br/>
  10767. aspect ratios */
  10768. static FIXED_HEIGHT: number;
  10769. /** The application takes the width of the design resolution size and modifies the height of the internal<br/>
  10770. canvas so that it fits the aspect ratio of the device<br/>
  10771. no distortion will occur however you must make sure your application works on different<br/>
  10772. aspect ratios */
  10773. static FIXED_WIDTH: number;
  10774. /** Unknow policy */
  10775. static UNKNOWN: number;
  10776. }
  10777. /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view,
  10778. it should represent the same rect as cc.view.getViewportRect() */
  10779. export class visibleRect {
  10780. /**
  10781. initialize
  10782. @param visibleRect visibleRect
  10783. */
  10784. init(visibleRect: Rect): void;
  10785. /** Top left coordinate of the screen related to the game scene. */
  10786. topLeft: Vec2;
  10787. /** Top right coordinate of the screen related to the game scene. */
  10788. topRight: Vec2;
  10789. /** Top center coordinate of the screen related to the game scene. */
  10790. top: Vec2;
  10791. /** Bottom left coordinate of the screen related to the game scene. */
  10792. bottomLeft: Vec2;
  10793. /** Bottom right coordinate of the screen related to the game scene. */
  10794. bottomRight: Vec2;
  10795. /** Bottom center coordinate of the screen related to the game scene. */
  10796. bottom: Vec2;
  10797. /** Center coordinate of the screen related to the game scene. */
  10798. center: Vec2;
  10799. /** Left center coordinate of the screen related to the game scene. */
  10800. left: Vec2;
  10801. /** Right center coordinate of the screen related to the game scene. */
  10802. right: Vec2;
  10803. /** Width of the screen. */
  10804. width: number;
  10805. /** Height of the screen. */
  10806. height: number;
  10807. }
  10808. /** The CallbacksHandler is an abstract class that can register and unregister callbacks by key.
  10809. Subclasses should implement their own methods about how to invoke the callbacks. */
  10810. export class _CallbacksHandler {
  10811. /**
  10812. @param key key
  10813. @param callback callback
  10814. @param target can be null
  10815. */
  10816. add(key: string, callback: Function, target?: any): void;
  10817. /**
  10818. Check if the specified key has any registered callback. If a callback is also specified,
  10819. it will only return true if the callback is registered.
  10820. @param key key
  10821. @param callback callback
  10822. @param target target
  10823. */
  10824. has(key: string, callback?: Function, target?: any): boolean;
  10825. /**
  10826. Removes all callbacks registered in a certain event type or all callbacks registered with a certain target
  10827. @param keyOrTarget The event key to be removed or the target to be removed
  10828. */
  10829. removeAll(keyOrTarget: string|any): void;
  10830. /**
  10831. @param key key
  10832. @param callback callback
  10833. @param target target
  10834. */
  10835. remove(key: string, callback: Function, target?: any): void;
  10836. }
  10837. /** !#en The callbacks invoker to handle and invoke callbacks by key.
  10838. !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */
  10839. export class CallbacksInvoker extends _CallbacksHandler {
  10840. /**
  10841. @param key key
  10842. @param p1 p1
  10843. @param p2 p2
  10844. @param p3 p3
  10845. @param p4 p4
  10846. @param p5 p5
  10847. */
  10848. invoke(key: string, p1?: any, p2?: any, p3?: any, p4?: any, p5?: any): void;
  10849. }
  10850. /** !#en Contains information collected during deserialization
  10851. !#zh 包含反序列化时的一些信息 */
  10852. export class Details {
  10853. /** list of the depends assets' uuid */
  10854. uuidList: string[];
  10855. /** the obj list whose field needs to load asset by uuid */
  10856. uuidObjList: any[];
  10857. /** the corresponding field name which referenced to the asset */
  10858. uuidPropList: string[];
  10859. /** the corresponding field name which referenced to the raw object */
  10860. rawProp: string;
  10861. reset(): void;
  10862. /**
  10863. @param obj obj
  10864. @param propName propName
  10865. */
  10866. getUuidOf(obj: any, propName: string): string;
  10867. /**
  10868. @param obj obj
  10869. @param propName propName
  10870. @param uuid uuid
  10871. */
  10872. push(obj: any, propName: string, uuid: string): void;
  10873. }
  10874. /** undefined */
  10875. export class url {
  10876. /**
  10877. Returns the url of raw assets, you will only need this if the raw asset is inside the "resources" folder.
  10878. @param url url
  10879. @example
  10880. ```js
  10881. ---
  10882. var url = cc.url.raw("textures/myTexture.png");
  10883. console.log(url); // "resources/raw/textures/myTexture.png"
  10884. ```
  10885. */
  10886. static raw(url: string): string;
  10887. /**
  10888. Returns the url of builtin raw assets. This method can only used in editor.
  10889. @param url url
  10890. @example
  10891. ```js
  10892. ---
  10893. var url = cc.url.builtinRaw("textures/myTexture.png");
  10894. console.log(url); // "resources/default-raw/textures/myTexture.png"
  10895. ```
  10896. */
  10897. static builtinRaw(url: string): string;
  10898. }
  10899. /** <p>
  10900. This class allows to easily create OpenGL or Canvas 2D textures from images, text or raw data. <br/>
  10901. The created cc.Texture2D object will always have power-of-two dimensions. <br/>
  10902. Depending on how you create the cc.Texture2D object, the actual image area of the texture might be smaller than the texture dimensions <br/>
  10903. i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0). <br/>
  10904. Be aware that the content of the generated textures will be upside-down! </p> */
  10905. export class Texture2D extends RawAsset implements EventTarget {
  10906. /** !#en
  10907. The url of the texture, this coule be empty if the texture wasn't created via a file.
  10908. !#zh
  10909. 贴图文件的 url,当贴图不是由文件创建时值可能为空 */
  10910. url: string;
  10911. /** !#en
  10912. Whether the texture is loaded or not
  10913. !#zh
  10914. 贴图是否已经成功加载 */
  10915. loaded: boolean;
  10916. /** !#en
  10917. Texture width in pixel
  10918. !#zh
  10919. 贴图像素宽度 */
  10920. width: number;
  10921. /** !#en
  10922. Texture height in pixel
  10923. !#zh
  10924. 贴图像素高度 */
  10925. height: number;
  10926. /**
  10927. Update texture options, not available in Canvas render mode.
  10928. image, format, premultiplyAlpha can not be updated in native.
  10929. @param options options
  10930. */
  10931. update(options: {image: DOMImageElement; mipmap: boolean; format: PixelFormat; minFilter: Filter; magFilter: Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void;
  10932. /**
  10933. Get width in pixels.
  10934. */
  10935. getPixelWidth(): number;
  10936. /**
  10937. Get height of in pixels.
  10938. */
  10939. getPixelHeight(): number;
  10940. /**
  10941. Get content size.
  10942. */
  10943. getContentSize(): Size;
  10944. /**
  10945. Get content size in pixels.
  10946. */
  10947. getContentSizeInPixels(): Size;
  10948. /**
  10949. Init with HTML element.
  10950. @param element element
  10951. @example
  10952. ```js
  10953. var img = new Image();
  10954. img.src = dataURL;
  10955. texture.initWithElement(img);
  10956. texture.handleLoadedTexture();
  10957. ```
  10958. */
  10959. initWithElement(element: HTMLImageElement|HTMLCanvasElement): void;
  10960. /**
  10961. Intializes with a texture2d with data.
  10962. @param data data
  10963. @param pixelFormat pixelFormat
  10964. @param pixelsWidth pixelsWidth
  10965. @param pixelsHeight pixelsHeight
  10966. @param contentSize contentSize is deprecated and ignored
  10967. */
  10968. initWithData(data: TypedArray, pixelFormat: number, pixelsWidth: number, pixelsHeight: number, contentSize: Size): boolean;
  10969. /**
  10970. Initializes a texture from a UIImage object.
  10971. Extensions to make it easy to create a CCTexture2D object from an image file.
  10972. Note that RGBA type textures will have their alpha premultiplied - use the blending mode (gl.ONE, gl.ONE_MINUS_SRC_ALPHA).
  10973. @param uiImage uiImage
  10974. */
  10975. initWithImage(uiImage: HTMLImageElement): boolean;
  10976. /**
  10977. HTMLElement Object getter, available only on web.
  10978. In most case, it will return null, because we are recycling the dom image element for better loading performance and lower image cache memory usage.
  10979. */
  10980. getHtmlElementObj(): HTMLImageElement;
  10981. /**
  10982. Check whether texture is loaded.
  10983. */
  10984. isLoaded(): boolean;
  10985. /**
  10986. Handler of texture loaded event.
  10987. @param premultiplied premultiplied
  10988. */
  10989. handleLoadedTexture(premultiplied?: boolean): void;
  10990. /**
  10991. Description of cc.Texture2D.
  10992. */
  10993. description(): string;
  10994. /**
  10995. Release texture.
  10996. */
  10997. releaseTexture(): void;
  10998. /**
  10999. Pixel format of the texture.
  11000. */
  11001. getPixelFormat(): number;
  11002. /**
  11003. Whether or not the texture has their Alpha premultiplied,
  11004. support only in WebGl rendering mode.
  11005. */
  11006. hasPremultipliedAlpha(): boolean;
  11007. /**
  11008. Whether or not use mipmap, support only in WebGl rendering mode.
  11009. */
  11010. hasMipmaps(): boolean;
  11011. /**
  11012. Sets the min filter, mag filter, wrap s and wrap t texture parameters. <br/>
  11013. 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}.
  11014. @param texParams texParams object or minFilter
  11015. @param magFilter magFilter
  11016. @param wrapS wrapS
  11017. @param wrapT wrapT
  11018. */
  11019. setTexParameters(texParams: any|number, magFilter?: number, wrapS?: Texture2D.WrapMode, wrapT?: Texture2D.WrapMode): void;
  11020. /**
  11021. sets antialias texture parameters: <br/>
  11022. - GL_TEXTURE_MIN_FILTER = GL_NEAREST <br/>
  11023. - GL_TEXTURE_MAG_FILTER = GL_NEAREST <br/>
  11024. supported only in native or WebGl rendering mode
  11025. */
  11026. setAntiAliasTexParameters(): void;
  11027. /**
  11028. Sets alias texture parameters: <br/>
  11029. GL_TEXTURE_MIN_FILTER = GL_NEAREST <br/>
  11030. GL_TEXTURE_MAG_FILTER = GL_NEAREST <br/>
  11031. supported only in native or WebGl rendering mode
  11032. */
  11033. setAliasTexParameters(): void;
  11034. /** Pixel format of the texture. */
  11035. pixelFormat: number;
  11036. /** Width in pixels. */
  11037. pixelWidth: number;
  11038. /** Height in pixels. */
  11039. pixelHeight: number;
  11040. /**
  11041. !#en
  11042. Register an callback of a specific event type on the EventTarget.
  11043. !#zh
  11044. 注册事件目标的特定事件类型回调。
  11045. @param type A string representing the event type to listen for.
  11046. @param callback The callback that will be invoked when the event is dispatched.
  11047. The callback is ignored if it is a duplicate (the callbacks are unique).
  11048. @param target The target (this object) to invoke the callback, can be null
  11049. @param useCapture When set to true, the capture argument prevents callback
  11050. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11051. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11052. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11053. @example
  11054. ```js
  11055. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11056. cc.log("this is callback");
  11057. }, node);
  11058. ```
  11059. */
  11060. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11061. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11062. /**
  11063. !#en
  11064. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  11065. if only type is passed as parameter, all listeners registered with that type will be removed.
  11066. !#zh
  11067. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  11068. @param type A string representing the event type being removed.
  11069. @param callback The callback to remove.
  11070. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  11071. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  11072. If not specified, useCapture defaults to false. If a callback was registered twice,
  11073. one with capture and one without, each must be removed separately. Removal of a capturing callback
  11074. does not affect a non-capturing version of the same listener, and vice versa.
  11075. @example
  11076. ```js
  11077. // register touchEnd eventListener
  11078. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11079. cc.log("this is callback");
  11080. }, node);
  11081. // remove touch end event listener
  11082. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  11083. // remove all touch end event listeners
  11084. node.off(cc.Node.EventType.TOUCH_END);
  11085. ```
  11086. */
  11087. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  11088. /**
  11089. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  11090. This is not for removing all listeners in the current event target,
  11091. and this is not for removing all listeners the target parameter have registered.
  11092. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  11093. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  11094. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  11095. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  11096. @param target The target to be searched for all related listeners
  11097. */
  11098. targetOff(target: any): void;
  11099. /**
  11100. !#en
  11101. Register an callback of a specific event type on the EventTarget,
  11102. the callback will remove itself after the first time it is triggered.
  11103. !#zh
  11104. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  11105. @param type A string representing the event type to listen for.
  11106. @param callback The callback that will be invoked when the event is dispatched.
  11107. The callback is ignored if it is a duplicate (the callbacks are unique).
  11108. @param target The target (this object) to invoke the callback, can be null
  11109. @param useCapture When set to true, the capture argument prevents callback
  11110. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11111. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11112. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11113. @example
  11114. ```js
  11115. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  11116. cc.log("this is callback");
  11117. }, node);
  11118. ```
  11119. */
  11120. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11121. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11122. /**
  11123. !#en
  11124. Dispatches an event into the event flow.
  11125. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  11126. !#zh 分发事件到事件流中。
  11127. @param event The Event object that is dispatched into the event flow
  11128. */
  11129. dispatchEvent(event: Event): void;
  11130. /**
  11131. !#en
  11132. Send an event to this object directly, this method will not propagate the event to any other objects.
  11133. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  11134. !#zh
  11135. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  11136. @param message the message to send
  11137. @param detail whatever argument the message needs
  11138. */
  11139. emit(message: string, detail?: any): void;
  11140. }
  11141. /** cc.textureCache is a singleton object, it's the global cache for cc.Texture2D */
  11142. export class textureCache {
  11143. /**
  11144. Description
  11145. */
  11146. static description(): string;
  11147. /**
  11148. Returns an already created texture. Returns null if the texture doesn't exist.
  11149. @param textureKeyName textureKeyName
  11150. @example
  11151. ```js
  11152. ------------------
  11153. var key = cc.textureCache.textureForKey("hello.png");
  11154. ```
  11155. */
  11156. static textureForKey(textureKeyName: string): Texture2D;
  11157. /**
  11158. Returns an already created texture. Returns null if the texture doesn't exist.
  11159. @param textureKeyName textureKeyName
  11160. @example
  11161. ```js
  11162. ------------------
  11163. var key = cc.textureCache.getTextureForKey("hello.png");
  11164. ```
  11165. */
  11166. static getTextureForKey(textureKeyName: string): Texture2D;
  11167. /**
  11168. @param texture texture
  11169. @example
  11170. ```js
  11171. ---------------
  11172. var cacheTextureForColor = cc.textureCache.getTextureColors(texture);
  11173. ```
  11174. */
  11175. static getTextureColors(texture: HTMLImageElement): any[];
  11176. /**
  11177. !#en get all textures
  11178. !#zh 获取所有贴图
  11179. */
  11180. static getAllTextures(): Texture2D[];
  11181. /**
  11182. <p>Purges the dictionary of loaded textures. <br />
  11183. Call this method if you receive the "Memory Warning" <br />
  11184. In the short term: it will free some resources preventing your app from being killed <br />
  11185. In the medium term: it will allocate more resources <br />
  11186. In the long term: it will be the same</p>
  11187. @example
  11188. ```js
  11189. --------
  11190. cc.textureCache.removeAllTextures();
  11191. ```
  11192. */
  11193. static removeAllTextures(): void;
  11194. /**
  11195. Deletes a texture from the cache given a texture.
  11196. @param texture texture
  11197. @example
  11198. ```js
  11199. -----
  11200. cc.textureCache.removeTexture(texture);
  11201. ```
  11202. */
  11203. static removeTexture(texture: HTMLImageElement): void;
  11204. /**
  11205. Deletes a texture from the cache given a its key name.
  11206. @param textureKeyName textureKeyName
  11207. @example
  11208. ```js
  11209. ------
  11210. cc.textureCache.removeTexture("hello.png");
  11211. ```
  11212. */
  11213. static removeTextureForKey(textureKeyName: string): void;
  11214. /**
  11215. <p>Returns a Texture2D object given an file image <br />
  11216. If the file image was not previously loaded, it will create a new Texture2D <br />
  11217. object and it will return it. It will use the filename as a key.<br />
  11218. Otherwise it will return a reference of a previously loaded image. <br />
  11219. Supported image extensions: .png, .jpg, .gif</p>
  11220. @param url url
  11221. @param cb cb
  11222. @param target target
  11223. @example
  11224. ```js
  11225. ----
  11226. cc.textureCache.addImage("hello.png");
  11227. ```
  11228. */
  11229. static addImage(url: string, cb: Function, target: any): Texture2D;
  11230. /**
  11231. Cache the image data.
  11232. @param path path
  11233. @param texture texture
  11234. */
  11235. static cacheImage(path: string, texture: HTMLImageElement|HTMLCanvasElement): void;
  11236. }
  11237. /** A base node for CCNode, it will:
  11238. - maintain scene hierarchy and active logic
  11239. - notifications if some properties changed
  11240. - define some interfaces shares between CCNode
  11241. - define machanisms for Enity Component Systems
  11242. - define prefab and serialize functions */
  11243. export class _BaseNode extends Object implements EventTarget {
  11244. /** !#en Name of node.
  11245. !#zh 该节点名称。 */
  11246. name: string;
  11247. /** !#en The uuid for editor, will be stripped before building project.
  11248. !#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */
  11249. uuid: string;
  11250. /** !#en All children nodes.
  11251. !#zh 节点的所有子节点。 */
  11252. children: Node[];
  11253. /** !#en All children nodes.
  11254. !#zh 节点的子节点数量。 */
  11255. childrenCount: number;
  11256. /** !#en
  11257. The local active state of this node.<br/>
  11258. Note that a Node may be inactive because a parent is not active, even if this returns true.<br/>
  11259. Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene.
  11260. !#zh
  11261. 当前节点的自身激活状态。<br/>
  11262. 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。<br/>
  11263. 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */
  11264. active: boolean;
  11265. /** !#en Indicates whether this node is active in the scene.
  11266. !#zh 表示此节点是否在场景中激活。 */
  11267. activeInHierarchy: boolean;
  11268. /** !#en Tag of node.
  11269. !#zh 节点标签。 */
  11270. tag: number;
  11271. /**
  11272. @param name name
  11273. */
  11274. constructor(name?: string);
  11275. /** !#en The parent of the node.
  11276. !#zh 该节点的父节点。 */
  11277. parent: Node;
  11278. /**
  11279. !#en
  11280. Properties configuration function </br>
  11281. All properties in attrs will be set to the node, </br>
  11282. when the setter of the node is available, </br>
  11283. the property will be set via setter function.</br>
  11284. !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。
  11285. @param attrs Properties to be set to node
  11286. @example
  11287. ```js
  11288. var attrs = { key: 0, num: 100 };
  11289. node.attr(attrs);
  11290. ```
  11291. */
  11292. attr(attrs: any): void;
  11293. /**
  11294. !#en Returns a child from the container given its tag.
  11295. !#zh 通过标签获取节点的子节点。
  11296. @param aTag An identifier to find the child node.
  11297. @example
  11298. ```js
  11299. var child = node.getChildByTag(1001);
  11300. ```
  11301. */
  11302. getChildByTag(aTag: number): Node;
  11303. /**
  11304. !#en Returns a child from the container given its uuid.
  11305. !#zh 通过 uuid 获取节点的子节点。
  11306. @param uuid The uuid to find the child node.
  11307. @example
  11308. ```js
  11309. var child = node.getChildByUuid(uuid);
  11310. ```
  11311. */
  11312. getChildByUuid(uuid: string): Node;
  11313. /**
  11314. !#en Returns a child from the container given its name.
  11315. !#zh 通过名称获取节点的子节点。
  11316. @param name A name to find the child node.
  11317. @example
  11318. ```js
  11319. var child = node.getChildByName("Test Node");
  11320. ```
  11321. */
  11322. getChildByName(name: string): Node;
  11323. /**
  11324. !#en
  11325. Inserts a child to the node at a specified index.
  11326. !#zh
  11327. 插入子节点到指定位置
  11328. @param child the child node to be inserted
  11329. @param siblingIndex the sibling index to place the child in
  11330. @example
  11331. ```js
  11332. node.insertChild(child, 2);
  11333. ```
  11334. */
  11335. insertChild(child: Node, siblingIndex: number): void;
  11336. /**
  11337. !#en Get the sibling index.
  11338. !#zh 获取同级索引。
  11339. @example
  11340. ```js
  11341. var index = node.getSiblingIndex();
  11342. ```
  11343. */
  11344. getSiblingIndex(): number;
  11345. /**
  11346. !#en Set the sibling index of this node.
  11347. !#zh 设置节点同级索引。
  11348. @param index index
  11349. @example
  11350. ```js
  11351. node.setSiblingIndex(1);
  11352. ```
  11353. */
  11354. setSiblingIndex(index: number): void;
  11355. /**
  11356. !#en
  11357. Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions. <br/>
  11358. If the cleanup parameter is not passed, it will force a cleanup, so it is recommended that you always pass in the `false` parameter when calling this API.<br/>
  11359. If the node orphan, then nothing happens.
  11360. !#zh
  11361. 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。<br/>
  11362. 因此建议调用这个 API 时总是传入 `false` 参数。<br/>
  11363. 如果这个节点是一个孤节点,那么什么都不会发生。
  11364. @param cleanup true if all actions and callbacks on this node should be removed, false otherwise.
  11365. @example
  11366. ```js
  11367. node.removeFromParent();
  11368. node.removeFromParent(false);
  11369. ```
  11370. */
  11371. removeFromParent(cleanup?: boolean): void;
  11372. /**
  11373. !#en
  11374. Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. </p>
  11375. If the cleanup parameter is not passed, it will force a cleanup. <br/>
  11376. "remove" logic MUST only be on this method <br/>
  11377. If a class wants to extend the 'removeChild' behavior it only needs <br/>
  11378. to override this method.
  11379. !#zh
  11380. 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11381. 如果 cleanup 参数不传入,默认为 true 表示清理。<br/>
  11382. @param child The child node which will be removed.
  11383. @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
  11384. @example
  11385. ```js
  11386. node.removeChild(newNode);
  11387. node.removeChild(newNode, false);
  11388. ```
  11389. */
  11390. removeChild(child: Node, cleanup?: boolean): void;
  11391. /**
  11392. !#en
  11393. Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter.
  11394. If the cleanup parameter is not passed, it will force a cleanup. <br/>
  11395. !#zh
  11396. 通过标签移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11397. 如果 cleanup 参数不传入,默认为 true 表示清理。
  11398. @param tag An integer number that identifies a child node
  11399. @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
  11400. @example
  11401. ```js
  11402. node.removeChildByTag(1001);
  11403. node.removeChildByTag(1001, false);
  11404. ```
  11405. */
  11406. removeChildByTag(tag: number, cleanup?: boolean): void;
  11407. /**
  11408. !#en
  11409. Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. <br/>
  11410. If the cleanup parameter is not passed, it will force a cleanup.
  11411. !#zh
  11412. 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11413. 如果 cleanup 参数不传入,默认为 true 表示清理。
  11414. @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise.
  11415. @example
  11416. ```js
  11417. node.removeAllChildren();
  11418. node.removeAllChildren(false);
  11419. ```
  11420. */
  11421. removeAllChildren(cleanup?: boolean): void;
  11422. /**
  11423. !#en Is this node a child of the given node?
  11424. !#zh 是否是指定节点的子节点?
  11425. @param parent parent
  11426. @example
  11427. ```js
  11428. node.isChildOf(newNode);
  11429. ```
  11430. */
  11431. isChildOf(parent: Node): boolean;
  11432. /**
  11433. !#en
  11434. Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
  11435. You can also get component in the node by passing in the name of the script.
  11436. !#zh
  11437. 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。<br/>
  11438. 传入参数也可以是脚本的名称。
  11439. @param typeOrClassName typeOrClassName
  11440. @example
  11441. ```js
  11442. // get sprite component.
  11443. var sprite = node.getComponent(cc.Sprite);
  11444. // get custom test calss.
  11445. var test = node.getComponent("Test");
  11446. ```
  11447. */
  11448. getComponent<T extends Component>(type: {prototype: T}): T;
  11449. getComponent(className: string): any;
  11450. /**
  11451. !#en Returns all components of supplied type in the node.
  11452. !#zh 返回节点上指定类型的所有组件。
  11453. @param typeOrClassName typeOrClassName
  11454. @example
  11455. ```js
  11456. var sprites = node.getComponents(cc.Sprite);
  11457. var tests = node.getComponents("Test");
  11458. ```
  11459. */
  11460. getComponents<T extends Component>(type: {prototype: T}): T[];
  11461. getComponents(className: string): any[];
  11462. /**
  11463. !#en Returns the component of supplied type in any of its children using depth first search.
  11464. !#zh 递归查找所有子节点中第一个匹配指定类型的组件。
  11465. @param typeOrClassName typeOrClassName
  11466. @example
  11467. ```js
  11468. var sprite = node.getComponentInChildren(cc.Sprite);
  11469. var Test = node.getComponentInChildren("Test");
  11470. ```
  11471. */
  11472. getComponentInChildren<T extends Component>(type: {prototype: T}): T;
  11473. getComponentInChildren(className: string): any;
  11474. /**
  11475. !#en Returns all components of supplied type in self or any of its children.
  11476. !#zh 递归查找自身或所有子节点中指定类型的组件
  11477. @param typeOrClassName typeOrClassName
  11478. @example
  11479. ```js
  11480. var sprites = node.getComponentsInChildren(cc.Sprite);
  11481. var tests = node.getComponentsInChildren("Test");
  11482. ```
  11483. */
  11484. getComponentsInChildren<T extends Component>(type: {prototype: T}): T[];
  11485. getComponentsInChildren(className: string): any[];
  11486. /**
  11487. !#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
  11488. !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。
  11489. @param typeOrClassName The constructor or the class name of the component to add
  11490. @example
  11491. ```js
  11492. var sprite = node.addComponent(cc.Sprite);
  11493. var test = node.addComponent("Test");
  11494. ```
  11495. */
  11496. addComponent<T extends Component>(type: {new(): T}): T;
  11497. addComponent(className: string): any;
  11498. /**
  11499. !#en
  11500. Removes a component identified by the given name or removes the component object given.
  11501. You can also use component.destroy() if you already have the reference.
  11502. !#zh
  11503. 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。
  11504. 如果你已经获得组件引用,你也可以直接调用 component.destroy()
  11505. @param component The need remove component.
  11506. @example
  11507. ```js
  11508. node.removeComponent(cc.Sprite);
  11509. var Test = require("Test");
  11510. node.removeComponent(Test);
  11511. ```
  11512. */
  11513. removeComponent(component: string|Function|Component): void;
  11514. /**
  11515. !#en
  11516. Destroy all children from the node, and release all their own references to other objects.<br/>
  11517. Actual destruct operation will delayed until before rendering.
  11518. !#zh
  11519. 销毁所有子节点,并释放所有它们对其它对象的引用。<br/>
  11520. 实际销毁操作会延迟到当前帧渲染前执行。
  11521. @example
  11522. ```js
  11523. node.destroyAllChildren();
  11524. ```
  11525. */
  11526. destroyAllChildren(): void;
  11527. /**
  11528. !#en
  11529. Register an callback of a specific event type on the EventTarget.
  11530. !#zh
  11531. 注册事件目标的特定事件类型回调。
  11532. @param type A string representing the event type to listen for.
  11533. @param callback The callback that will be invoked when the event is dispatched.
  11534. The callback is ignored if it is a duplicate (the callbacks are unique).
  11535. @param target The target (this object) to invoke the callback, can be null
  11536. @param useCapture When set to true, the capture argument prevents callback
  11537. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11538. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11539. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11540. @example
  11541. ```js
  11542. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11543. cc.log("this is callback");
  11544. }, node);
  11545. ```
  11546. */
  11547. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11548. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11549. /**
  11550. !#en
  11551. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  11552. if only type is passed as parameter, all listeners registered with that type will be removed.
  11553. !#zh
  11554. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  11555. @param type A string representing the event type being removed.
  11556. @param callback The callback to remove.
  11557. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  11558. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  11559. If not specified, useCapture defaults to false. If a callback was registered twice,
  11560. one with capture and one without, each must be removed separately. Removal of a capturing callback
  11561. does not affect a non-capturing version of the same listener, and vice versa.
  11562. @example
  11563. ```js
  11564. // register touchEnd eventListener
  11565. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11566. cc.log("this is callback");
  11567. }, node);
  11568. // remove touch end event listener
  11569. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  11570. // remove all touch end event listeners
  11571. node.off(cc.Node.EventType.TOUCH_END);
  11572. ```
  11573. */
  11574. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  11575. /**
  11576. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  11577. This is not for removing all listeners in the current event target,
  11578. and this is not for removing all listeners the target parameter have registered.
  11579. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  11580. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  11581. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  11582. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  11583. @param target The target to be searched for all related listeners
  11584. */
  11585. targetOff(target: any): void;
  11586. /**
  11587. !#en
  11588. Register an callback of a specific event type on the EventTarget,
  11589. the callback will remove itself after the first time it is triggered.
  11590. !#zh
  11591. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  11592. @param type A string representing the event type to listen for.
  11593. @param callback The callback that will be invoked when the event is dispatched.
  11594. The callback is ignored if it is a duplicate (the callbacks are unique).
  11595. @param target The target (this object) to invoke the callback, can be null
  11596. @param useCapture When set to true, the capture argument prevents callback
  11597. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11598. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11599. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11600. @example
  11601. ```js
  11602. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  11603. cc.log("this is callback");
  11604. }, node);
  11605. ```
  11606. */
  11607. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11608. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11609. /**
  11610. !#en
  11611. Dispatches an event into the event flow.
  11612. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  11613. !#zh 分发事件到事件流中。
  11614. @param event The Event object that is dispatched into the event flow
  11615. */
  11616. dispatchEvent(event: Event): void;
  11617. /**
  11618. !#en
  11619. Send an event to this object directly, this method will not propagate the event to any other objects.
  11620. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  11621. !#zh
  11622. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  11623. @param message the message to send
  11624. @param detail whatever argument the message needs
  11625. */
  11626. emit(message: string, detail?: any): void;
  11627. }
  11628. /** !#en
  11629. cc.AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.<br/>
  11630. Please do not use its constructor directly, use cc.affineTransformMake alias function instead.
  11631. !#zh
  11632. cc.AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。<br/>
  11633. 请不要直接使用它的构造,请使用 cc.affineTransformMake 函数代替。 */
  11634. export class AffineTransform {
  11635. /**
  11636. !#en Create a cc.AffineTransform object with all contents in the matrix.
  11637. !#zh 用在矩阵中的所有内容创建一个 cc.AffineTransform 对象。
  11638. @param a a
  11639. @param b b
  11640. @param c c
  11641. @param d d
  11642. @param tx tx
  11643. @param ty ty
  11644. */
  11645. affineTransformMake(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform;
  11646. /**
  11647. !#en Clone a cc.AffineTransform object from the specified transform.
  11648. !#zh 克隆指定的 cc.AffineTransform 对象。
  11649. @param t t
  11650. */
  11651. affineTransformClone(t: AffineTransform): AffineTransform;
  11652. /**
  11653. !#en Apply the affine transformation on a point.
  11654. !#zh 对一个点应用矩阵变换。
  11655. @param point or x.
  11656. @param transOrY transform matrix or y.
  11657. @param t transform matrix or y.
  11658. */
  11659. pointApplyAffineTransform(point: Vec2|number, transOrY: AffineTransform|number, t: AffineTransform): Vec2;
  11660. /**
  11661. !#en Apply the affine transformation on a size.
  11662. !#zh 应用 Size 到仿射变换矩阵上。
  11663. @param size size
  11664. @param t t
  11665. */
  11666. sizeApplyAffineTransform(size: Size, t: AffineTransform): Size;
  11667. /**
  11668. !#en
  11669. Create a identity transformation matrix: <br/>
  11670. [ 1, 0, 0, <br/>
  11671. 0, 1, 0 ]
  11672. !#zh
  11673. 单位矩阵:<br/>
  11674. [ 1, 0, 0, <br/>
  11675. 0, 1, 0 ]
  11676. */
  11677. affineTransformMakeIdentity(): AffineTransform;
  11678. /**
  11679. !#en Apply the affine transformation on a rect.
  11680. !#zh 应用 Rect 到仿射变换矩阵上。
  11681. @param rect rect
  11682. @param anAffineTransform anAffineTransform
  11683. */
  11684. rectApplyAffineTransform(rect: Rect, anAffineTransform: AffineTransform): Rect;
  11685. /**
  11686. !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box.
  11687. !#zh 应用 Rect 到仿射变换矩阵上, 并转换为有向包围盒
  11688. @param rect rect
  11689. @param anAffineTransform anAffineTransform
  11690. @param out_bl out_bl
  11691. @param out_tl out_tl
  11692. @param out_tr out_tr
  11693. @param out_br out_br
  11694. */
  11695. obbApplyAffineTransform(rect: Rect, anAffineTransform: AffineTransform, out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2): void;
  11696. /**
  11697. !#en Create a new affine transformation with a base transformation matrix and a translation based on it.
  11698. !#zh 基于一个基础矩阵加上一个平移操作来创建一个新的矩阵。
  11699. @param t The base affine transform object.
  11700. @param tx The translation on x axis.
  11701. @param ty The translation on y axis.
  11702. */
  11703. affineTransformTranslate(t: AffineTransform, tx: number, ty: number): AffineTransform;
  11704. /**
  11705. !#en Create a new affine transformation with a base transformation matrix and a scale based on it.
  11706. !#zh 创建一个基础变换矩阵,并在此基础上进行了 Scale 仿射变换。
  11707. @param t The base affine transform object.
  11708. @param sx The scale on x axis.
  11709. @param sy The scale on y axis.
  11710. */
  11711. affineTransformScale(t: AffineTransform, sx: number, sy: number): AffineTransform;
  11712. /**
  11713. !#en Create a new affine transformation with a base transformation matrix and a rotation based on it.
  11714. !#zh 创建一个基础变换矩阵,并在此基础上进行了 Rotation 仿射变换。
  11715. @param aTransform The base affine transform object.
  11716. @param anAngle The angle to rotate.
  11717. */
  11718. affineTransformRotate(aTransform: AffineTransform, anAngle: number): AffineTransform;
  11719. /**
  11720. !#en
  11721. Concatenate a transform matrix to another and return the result:<br/>
  11722. t' = t1 * t2
  11723. !#zh 拼接两个矩阵,并返回结果:<br/>
  11724. t' = t1 * t2
  11725. @param t1 The first transform object.
  11726. @param t2 The transform object to concatenate.
  11727. */
  11728. affineTransformConcat(t1: AffineTransform, t2: AffineTransform): AffineTransform;
  11729. /**
  11730. !#en
  11731. Concatenate a transform matrix to another<br/>
  11732. The results are reflected in the first matrix.<br/>
  11733. t' = t1 * t2
  11734. !#zh
  11735. 拼接两个矩阵,将结果保存到第一个矩阵。<br/>
  11736. t' = t1 * t2
  11737. @param t1 The first transform object.
  11738. @param t2 The transform object to concatenate.
  11739. */
  11740. affineTransformConcatIn(t1: AffineTransform, t2: AffineTransform): AffineTransform;
  11741. /**
  11742. !#en Return true if an affine transform equals to another, false otherwise.
  11743. !#zh 判断两个矩阵是否相等。
  11744. @param t1 t1
  11745. @param t2 t2
  11746. */
  11747. affineTransformEqualToTransform(t1: AffineTransform, t2: AffineTransform): boolean;
  11748. /**
  11749. !#en Get the invert transform of an AffineTransform object.
  11750. !#zh 求逆矩阵。
  11751. @param t t
  11752. */
  11753. affineTransformInvert(t: AffineTransform): AffineTransform;
  11754. /**
  11755. !#en Put the invert transform of an AffineTransform object into the out AffineTransform object.
  11756. !#zh 求逆矩阵并存入用户传入的矩阵对象参数。
  11757. @param t t
  11758. @param out out
  11759. */
  11760. affineTransformInvert(t: AffineTransform, out: AffineTransform): void;
  11761. }
  11762. /** !#en
  11763. Representation of RGBA colors.
  11764. Each color component is a floating point value with a range from 0 to 255.
  11765. You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color.
  11766. !#zh
  11767. cc.Color 用于表示颜色。
  11768. 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。
  11769. 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */
  11770. export class Color extends ValueType {
  11771. /**
  11772. @param r red component of the color, default value is 0.
  11773. @param g green component of the color, defualt value is 0.
  11774. @param b blue component of the color, default value is 0.
  11775. @param a alpha component of the color, default value is 255.
  11776. */
  11777. constructor(r?: number, g?: number, b?: number, a?: number);
  11778. /** !#en Solid white, RGBA is [255, 255, 255, 255].
  11779. !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */
  11780. static WHITE: Color;
  11781. /** !#en Solid black, RGBA is [0, 0, 0, 255].
  11782. !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */
  11783. static BLACK: Color;
  11784. /** !#en Transparent, RGBA is [0, 0, 0, 0].
  11785. !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */
  11786. static TRANSPARENT: Color;
  11787. /** !#en Grey, RGBA is [127.5, 127.5, 127.5].
  11788. !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */
  11789. static GRAY: Color;
  11790. /** !#en Solid red, RGBA is [255, 0, 0].
  11791. !#zh 纯红色,RGBA 是 [255, 0, 0]。 */
  11792. static RED: Color;
  11793. /** !#en Solid green, RGBA is [0, 255, 0].
  11794. !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */
  11795. static GREEN: Color;
  11796. /** !#en Solid blue, RGBA is [0, 0, 255].
  11797. !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */
  11798. static BLUE: Color;
  11799. /** !#en Yellow, RGBA is [255, 235, 4].
  11800. !#zh 黄色,RGBA 是 [255, 235, 4]。 */
  11801. static YELLOW: Color;
  11802. /** !#en Orange, RGBA is [255, 127, 0].
  11803. !#zh 橙色,RGBA 是 [255, 127, 0]。 */
  11804. static ORANGE: Color;
  11805. /** !#en Cyan, RGBA is [0, 255, 255].
  11806. !#zh 青色,RGBA 是 [0, 255, 255]。 */
  11807. static CYAN: Color;
  11808. /** !#en Magenta, RGBA is [255, 0, 255].
  11809. !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */
  11810. static MAGENTA: Color;
  11811. /**
  11812. !#en Clone a new color from the current color.
  11813. !#zh 克隆当前颜色。
  11814. @example
  11815. ```js
  11816. var color = new cc.Color();
  11817. var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255}
  11818. ```
  11819. */
  11820. clone(): Color;
  11821. /**
  11822. !#en TODO
  11823. !#zh 判断两个颜色是否相等。
  11824. @param other other
  11825. @example
  11826. ```js
  11827. var color1 = cc.Color.WHITE;
  11828. var color2 = new cc.Color(255, 255, 255);
  11829. cc.log(color1.equals(color2)); // true;
  11830. color2 = cc.Color.RED;
  11831. cc.log(color2.equals(color1)); // false;
  11832. ```
  11833. */
  11834. equals(other: Color): boolean;
  11835. /**
  11836. !#en TODO
  11837. !#zh 线性插值
  11838. @param to to
  11839. @param ratio the interpolation coefficient.
  11840. @param out optional, the receiving vector.
  11841. @example
  11842. ```js
  11843. // Converts a white color to a black one trough time.
  11844. update: function (dt) {
  11845. var color = this.node.color;
  11846. if (color.equals(cc.Color.BLACK)) {
  11847. return;
  11848. }
  11849. this.ratio += dt * 0.1;
  11850. this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio);
  11851. }
  11852. ```
  11853. */
  11854. lerp(to: Color, ratio: number, out?: Color): Color;
  11855. /**
  11856. !#en TODO
  11857. !#zh 转换为方便阅读的字符串。
  11858. @example
  11859. ```js
  11860. var color = cc.Color.WHITE;
  11861. color.toString(); // "rgba(255, 255, 255, 255)"
  11862. ```
  11863. */
  11864. toString(): string;
  11865. /**
  11866. !#en Gets red channel value
  11867. !#zh 获取当前颜色的红色值。
  11868. */
  11869. getR(): number;
  11870. /**
  11871. !#en Sets red value and return the current color object
  11872. !#zh 设置当前的红色值,并返回当前对象。
  11873. @param red the new Red component.
  11874. @example
  11875. ```js
  11876. var color = new cc.Color();
  11877. color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255}
  11878. ```
  11879. */
  11880. setR(red: number): Color;
  11881. /**
  11882. !#en Gets green channel value
  11883. !#zh 获取当前颜色的绿色值。
  11884. */
  11885. getG(): number;
  11886. /**
  11887. !#en Sets green value and return the current color object
  11888. !#zh 设置当前的绿色值,并返回当前对象。
  11889. @param green the new Green component.
  11890. @example
  11891. ```js
  11892. var color = new cc.Color();
  11893. color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255}
  11894. ```
  11895. */
  11896. setG(green: number): Color;
  11897. /**
  11898. !#en Gets blue channel value
  11899. !#zh 获取当前颜色的蓝色值。
  11900. */
  11901. getB(): number;
  11902. /**
  11903. !#en Sets blue value and return the current color object
  11904. !#zh 设置当前的蓝色值,并返回当前对象。
  11905. @param blue the new Blue component.
  11906. @example
  11907. ```js
  11908. var color = new cc.Color();
  11909. color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255}
  11910. ```
  11911. */
  11912. setB(blue: number): Color;
  11913. /**
  11914. !#en Gets alpha channel value
  11915. !#zh 获取当前颜色的透明度值。
  11916. */
  11917. getA(): number;
  11918. /**
  11919. !#en Sets alpha value and return the current color object
  11920. !#zh 设置当前的透明度,并返回当前对象。
  11921. @param alpha the new Alpha component.
  11922. @example
  11923. ```js
  11924. var color = new cc.Color();
  11925. color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0}
  11926. ```
  11927. */
  11928. setA(alpha: number): Color;
  11929. /**
  11930. !#en Convert color to css format.
  11931. !#zh 转换为 CSS 格式。
  11932. @param opt "rgba", "rgb", "#rgb" or "#rrggbb".
  11933. @example
  11934. ```js
  11935. var color = cc.Color.BLACK;
  11936. color.toCSS(); // "#000";
  11937. color.toCSS("rgba"); // "rgba(0,0,0,1.00)";
  11938. color.toCSS("rgb"); // "rgba(0,0,0)";
  11939. color.toCSS("#rgb"); // "#000";
  11940. color.toCSS("#rrggbb"); // "#000000";
  11941. ```
  11942. */
  11943. toCSS(opt: string): string;
  11944. /**
  11945. !#en Clamp this color to make all components between 0 to 255。
  11946. !#zh 限制颜色数值,在 0 到 255 之间。
  11947. @example
  11948. ```js
  11949. var color = new cc.Color(1000, 0, 0, 255);
  11950. color.clamp();
  11951. cc.log(color); // (255, 0, 0, 255)
  11952. ```
  11953. */
  11954. clamp(): void;
  11955. /**
  11956. !#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb.
  11957. !#zh 读取 16 进制颜色。
  11958. @param hexString hexString
  11959. @example
  11960. ```js
  11961. var color = cc.Color.BLACK;
  11962. color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
  11963. ```
  11964. */
  11965. fromHEX(hexString: string): Color;
  11966. /**
  11967. !#en TODO
  11968. !#zh 转换为 16 进制。
  11969. @param fmt "#rgb" or "#rrggbb".
  11970. @example
  11971. ```js
  11972. var color = cc.Color.BLACK;
  11973. color.toHEX("#rgb"); // "000";
  11974. color.toHEX("#rrggbb"); // "000000";
  11975. ```
  11976. */
  11977. toHEX(fmt: string): string;
  11978. /**
  11979. !#en Convert to 24bit rgb value.
  11980. !#zh 转换为 24bit 的 RGB 值。
  11981. @example
  11982. ```js
  11983. var color = cc.Color.YELLOW;
  11984. color.toRGBValue(); // 16771844;
  11985. ```
  11986. */
  11987. toRGBValue(): number;
  11988. /**
  11989. !#en TODO
  11990. !#zh 读取 HSV(色彩模型)格式。
  11991. @param h h
  11992. @param s s
  11993. @param v v
  11994. @example
  11995. ```js
  11996. var color = cc.Color.YELLOW;
  11997. color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255};
  11998. ```
  11999. */
  12000. fromHSV(h: number, s: number, v: number): Color;
  12001. /**
  12002. !#en TODO
  12003. !#zh 转换为 HSV(色彩模型)格式。
  12004. @example
  12005. ```js
  12006. var color = cc.Color.YELLOW;
  12007. color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1};
  12008. ```
  12009. */
  12010. toHSV(): any;
  12011. /**
  12012. !#en TODO
  12013. !#zh RGB 转换为 HSV。
  12014. @param r red, must be [0, 255].
  12015. @param g red, must be [0, 255].
  12016. @param b red, must be [0, 255].
  12017. @example
  12018. ```js
  12019. cc.Color.rgb2hsv(255, 255, 255); // Object {h: 0, s: 0, v: 1};
  12020. ```
  12021. */
  12022. static rgb2hsv(r: number, g: number, b: number): any;
  12023. /**
  12024. !#en TODO
  12025. !#zh HSV 转换为 RGB。
  12026. @param h h
  12027. @param s s
  12028. @param v v
  12029. @example
  12030. ```js
  12031. cc.Color.hsv2rgb(0, 0, 1); // Object {r: 255, g: 255, b: 255};
  12032. ```
  12033. */
  12034. static hsv2rgb(h: number, s: number, v: number): any;
  12035. }
  12036. /** !#en A 2D rectangle defined by x, y position and width, height.
  12037. !#zh 通过位置和宽高定义的 2D 矩形。 */
  12038. export class Rect extends ValueType {
  12039. /**
  12040. !#en
  12041. Constructor of cc.Rect class.
  12042. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  12043. !#zh
  12044. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  12045. @param x x
  12046. @param y y
  12047. @param w w
  12048. @param h h
  12049. */
  12050. constructor(x?: number, y?: number, w?: number, h?: number);
  12051. x: number;
  12052. y: number;
  12053. width: number;
  12054. height: number;
  12055. /**
  12056. !#en Creates a rectangle from two coordinate values.
  12057. !#zh 根据指定 2 个坐标创建出一个矩形区域。
  12058. @param v1 v1
  12059. @param v2 v2
  12060. @example
  12061. ```js
  12062. cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10};
  12063. ```
  12064. */
  12065. static fromMinMax(v1: Vec2, v2: Vec2): Rect;
  12066. /**
  12067. !#en Checks if rect contains.
  12068. !#zh
  12069. 判断 2 个矩形是否有包含。<br/>
  12070. 返回 1 为 a 包含 b,如果 -1 为 b 包含 a,
  12071. 0 这则都不包含。
  12072. @param a Rect a
  12073. @param b Rect b
  12074. @example
  12075. ```js
  12076. var a = new cc.Rect(0, 0, 10, 10);
  12077. var b = new cc.Rect(5, 5, 5, 5);
  12078. var c = new cc.Rect(20, 20, 10, 10);
  12079. cc.Rect.contain(a, b); // 1;
  12080. cc.Rect.contain(b, a); // -1;
  12081. cc.Rect.contain(a, c); // 0;
  12082. ```
  12083. */
  12084. static contain(a: Rect, b: Rect): number;
  12085. /**
  12086. !#en TODO
  12087. !#zh 克隆一个新的 Rect。
  12088. @example
  12089. ```js
  12090. var a = new cc.Rect(0, 0, 10, 10);
  12091. a.clone();// Rect {x: 0, y: 0, width: 10, height: 10}
  12092. ```
  12093. */
  12094. clone(): Rect;
  12095. /**
  12096. !#en TODO
  12097. !#zh 是否等于指定的矩形。
  12098. @param other other
  12099. @example
  12100. ```js
  12101. var a = new cc.Rect(0, 0, 10, 10);
  12102. var b = new cc.Rect(0, 0, 10, 10);
  12103. a.equals(b);// true;
  12104. ```
  12105. */
  12106. equals(other: Rect): boolean;
  12107. /**
  12108. !#en TODO
  12109. !#zh 线性插值
  12110. @param to to
  12111. @param ratio the interpolation coefficient.
  12112. @param out optional, the receiving vector.
  12113. @example
  12114. ```js
  12115. var a = new cc.Rect(0, 0, 10, 10);
  12116. var b = new cc.Rect(50, 50, 100, 100);
  12117. update (dt) {
  12118. // method 1;
  12119. var c = a.lerp(b, dt * 0.1);
  12120. // method 2;
  12121. a.lerp(b, dt * 0.1, c);
  12122. }
  12123. ```
  12124. */
  12125. lerp(to: Rect, ratio: number, out?: Rect): Rect;
  12126. /**
  12127. !#en TODO
  12128. !#zh 转换为方便阅读的字符串
  12129. @example
  12130. ```js
  12131. var a = new cc.Rect(0, 0, 10, 10);
  12132. a.toString();// "(0.00, 0.00, 10.00, 10.00)";
  12133. ```
  12134. */
  12135. toString(): string;
  12136. /** !#en TODO
  12137. !#zh 矩形 x 轴上的最小值。 */
  12138. xMin: number;
  12139. /** !#en TODO
  12140. !#zh 矩形 y 轴上的最小值。 */
  12141. yMin: number;
  12142. /** !#en TODO
  12143. !#zh 矩形 x 轴上的最大值。 */
  12144. xMax: number;
  12145. /** !#en TODO
  12146. !#zh 矩形 y 轴上的最大值。 */
  12147. yMax: number;
  12148. /** !#en The position of the center of the rectangle.
  12149. !#zh 矩形的中心点。 */
  12150. center: Vec2;
  12151. /** !#en The X and Y position of the rectangle.
  12152. !#zh 矩形的 x 和 y 坐标。 */
  12153. origin: Vec2;
  12154. /** !#en Width and height of the rectangle.
  12155. !#zh 矩形的大小。 */
  12156. size: Size;
  12157. /**
  12158. !#en TODO
  12159. !#zh 当前矩形与指定矩形是否相交。
  12160. @param rect rect
  12161. @example
  12162. ```js
  12163. var a = new cc.Rect(0, 0, 10, 10);
  12164. var b = new cc.Rect(0, 0, 20, 20);
  12165. a.intersects(b);// true
  12166. ```
  12167. */
  12168. intersects(rect: Rect): void;
  12169. /**
  12170. !#en TODO
  12171. !#zh 当前矩形是否包含指定坐标点。
  12172. Returns true if the point inside this rectangle.
  12173. @param point point
  12174. @example
  12175. ```js
  12176. var a = new cc.Rect(0, 0, 10, 10);
  12177. var b = new cc.Vec2(0, 5);
  12178. a.contains(b);// true
  12179. ```
  12180. */
  12181. contains(point: Vec2): void;
  12182. /**
  12183. !#en Returns true if the other rect totally inside this rectangle.
  12184. !#zh 当前矩形是否包含指定矩形。
  12185. @param rect rect
  12186. @example
  12187. ```js
  12188. var a = new cc.Rect(0, 0, 20, 20);
  12189. var b = new cc.Rect(0, 0, 10, 10);
  12190. a.containsRect(b);// true
  12191. ```
  12192. */
  12193. containsRect(rect: Rect): void;
  12194. }
  12195. /** !#en
  12196. cc.Size is the class for size object,<br/>
  12197. please do not use its constructor to create sizes,<br/>
  12198. use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.<br/>
  12199. It will be deprecated soon, please use cc.Vec2 instead.
  12200. !#zh
  12201. cc.Size 是 size 对象的类。<br/>
  12202. 请不要使用它的构造函数创建的 size,<br/>
  12203. 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。<br/>
  12204. 它不久将被取消,请使用cc.Vec2代替。 */
  12205. export class Size {
  12206. /**
  12207. @param width width
  12208. @param height height
  12209. */
  12210. constructor(width: number|Size, height?: number);
  12211. width: number;
  12212. height: number;
  12213. /** !#en return a Size object with width = 0 and height = 0.
  12214. !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */
  12215. static ZERO: Size;
  12216. /**
  12217. !#en TODO
  12218. !#zh 克隆 size 对象。
  12219. @example
  12220. ```js
  12221. var a = new cc.size(10, 10);
  12222. a.clone();// return Size {width: 0, height: 0};
  12223. ```
  12224. */
  12225. clone(): Size;
  12226. /**
  12227. !#en TODO
  12228. !#zh 当前 Size 对象是否等于指定 Size 对象。
  12229. @param other other
  12230. @example
  12231. ```js
  12232. var a = new cc.size(10, 10);
  12233. a.equals(new cc.size(10, 10));// return true;
  12234. ```
  12235. */
  12236. equals(other: Size): boolean;
  12237. /**
  12238. !#en TODO
  12239. !#zh 线性插值。
  12240. @param to to
  12241. @param ratio the interpolation coefficient.
  12242. @param out optional, the receiving vector.
  12243. @example
  12244. ```js
  12245. var a = new cc.size(10, 10);
  12246. var b = new cc.rect(50, 50, 100, 100);
  12247. update (dt) {
  12248. // method 1;
  12249. var c = a.lerp(b, dt * 0.1);
  12250. // method 2;
  12251. a.lerp(b, dt * 0.1, c);
  12252. }
  12253. ```
  12254. */
  12255. lerp(to: Rect, ratio: number, out?: Size): Size;
  12256. /**
  12257. !#en TODO
  12258. !#zh 转换为方便阅读的字符串。
  12259. @example
  12260. ```js
  12261. var a = new cc.size(10, 10);
  12262. a.toString();// return "(10.00, 10.00)";
  12263. ```
  12264. */
  12265. toString(): string;
  12266. }
  12267. /** !#en the device accelerometer reports values for each axis in units of g-force.
  12268. !#zh 设备重力传感器传递的各个轴的数据。 */
  12269. export class Acceleration {
  12270. /**
  12271. @param x x
  12272. @param y y
  12273. @param z z
  12274. @param timestamp timestamp
  12275. */
  12276. constructor(x: number, y: number, z: number, timestamp: number);
  12277. }
  12278. /** !#en Blend Function used for textures.
  12279. !#zh 图像的混合方式。 */
  12280. export class BlendFunc {
  12281. /**
  12282. @param src1 source blend function
  12283. @param dst1 destination blend function
  12284. */
  12285. constructor(src1: number, dst1: number);
  12286. }
  12287. /** !#en
  12288. Enum for blend factor
  12289. Refer to: http://www.andersriggelsen.dk/glblendfunc.php
  12290. !#zh
  12291. 混合因子
  12292. 可参考: http://www.andersriggelsen.dk/glblendfunc.php */
  12293. export enum BlendFactor {
  12294. ONE = 0,
  12295. ZERO = 0,
  12296. SRC_ALPHA = 0,
  12297. SRC_COLOR = 0,
  12298. DST_ALPHA = 0,
  12299. DST_COLOR = 0,
  12300. ONE_MINUS_SRC_ALPHA = 0,
  12301. ONE_MINUS_SRC_COLOR = 0,
  12302. ONE_MINUS_DST_ALPHA = 0,
  12303. ONE_MINUS_DST_COLOR = 0,
  12304. blendFuncDisable = 0,
  12305. }
  12306. /** undefined */
  12307. export enum TextAlignment {
  12308. LEFT = 0,
  12309. CENTER = 0,
  12310. RIGHT = 0,
  12311. }
  12312. /** undefined */
  12313. export class WebGLColor {
  12314. /**
  12315. @param r r
  12316. @param g g
  12317. @param b b
  12318. @param a a
  12319. @param arrayBuffer arrayBuffer
  12320. @param offset offset
  12321. */
  12322. constructor(r: number, g: number, b: number, a: number, arrayBuffer: any[], offset: number);
  12323. BYTES_PER_ELEMENT: number;
  12324. }
  12325. /** undefined */
  12326. export class Vertex2F {
  12327. /**
  12328. @param x x
  12329. @param y y
  12330. @param arrayBuffer arrayBuffer
  12331. @param offset offset
  12332. */
  12333. constructor(x: number, y: number, arrayBuffer: any[], offset: number);
  12334. BYTES_PER_ELEMENT: number;
  12335. }
  12336. /** undefined */
  12337. export class Vertex3F {
  12338. /**
  12339. @param x x
  12340. @param y y
  12341. @param z z
  12342. @param arrayBuffer arrayBuffer
  12343. @param offset offset
  12344. */
  12345. constructor(x: number, y: number, z: number, arrayBuffer: any[], offset: number);
  12346. BYTES_PER_ELEMENT: number;
  12347. }
  12348. /** undefined */
  12349. export class Tex2F {
  12350. /**
  12351. @param u u
  12352. @param v v
  12353. @param arrayBuffer arrayBuffer
  12354. @param offset offset
  12355. */
  12356. constructor(u: number, v: number, arrayBuffer: any[], offset: number);
  12357. BYTES_PER_ELEMENT: number;
  12358. }
  12359. /** undefined */
  12360. export class Quad2 {
  12361. /**
  12362. @param tl tl
  12363. @param tr tr
  12364. @param bl bl
  12365. @param br br
  12366. @param arrayBuffer arrayBuffer
  12367. @param offset offset
  12368. */
  12369. constructor(tl: Vertex2F, tr: Vertex2F, bl: Vertex2F, br: Vertex2F, arrayBuffer: any[], offset: number);
  12370. BYTES_PER_ELEMENT: number;
  12371. }
  12372. /** A 3D Quad. 4 * 3 floats */
  12373. export class Quad3 {
  12374. /**
  12375. @param bl1 bl1
  12376. @param br1 br1
  12377. @param tl1 tl1
  12378. @param tr1 tr1
  12379. @param arrayBuffer arrayBuffer
  12380. @param offset offset
  12381. */
  12382. constructor(bl1: Vertex3F, br1: Vertex3F, tl1: Vertex3F, tr1: Vertex3F, arrayBuffer: any[], offset: number);
  12383. }
  12384. /** undefined */
  12385. export class V3F_C4B_T2F {
  12386. /**
  12387. @param vertices vertices
  12388. @param colors colors
  12389. @param texCoords texCoords
  12390. @param arrayBuffer arrayBuffer
  12391. @param offset offset
  12392. */
  12393. constructor(vertices: Vertex3F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number);
  12394. BYTES_PER_ELEMENT(): void;
  12395. }
  12396. /** undefined */
  12397. export class V3F_C4B_T2F_Quad {
  12398. /**
  12399. @param tl tl
  12400. @param bl bl
  12401. @param tr tr
  12402. @param br br
  12403. @param arrayBuffer arrayBuffer
  12404. @param offset offset
  12405. */
  12406. constructor(tl: V3F_C4B_T2F, bl: V3F_C4B_T2F, tr: V3F_C4B_T2F, br: V3F_C4B_T2F, arrayBuffer: any[], offset: number);
  12407. BYTES_PER_ELEMENT: number;
  12408. }
  12409. /** undefined */
  12410. export class V2F_C4B_T2F {
  12411. /**
  12412. @param vertices vertices
  12413. @param colors colors
  12414. @param texCoords texCoords
  12415. @param arrayBuffer arrayBuffer
  12416. @param offset offset
  12417. */
  12418. constructor(vertices: Vertex2F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number);
  12419. BYTES_PER_ELEMENT: number;
  12420. }
  12421. /** undefined */
  12422. export class V2F_C4B_T2F_Triangle {
  12423. /**
  12424. @param a a
  12425. @param b b
  12426. @param c c
  12427. @param arrayBuffer arrayBuffer
  12428. @param offset offset
  12429. */
  12430. constructor(a: V2F_C4B_T2F, b: V2F_C4B_T2F, c: V2F_C4B_T2F, arrayBuffer: any[], offset: number);
  12431. }
  12432. /** !#en The base class of all value types.
  12433. !#zh 所有值类型的基类。 */
  12434. export class ValueType {
  12435. /**
  12436. !#en This method returns an exact copy of current value.
  12437. !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。
  12438. */
  12439. clone(): ValueType;
  12440. /**
  12441. !#en Compares this object with the other one.
  12442. !#zh 当前对象是否等于指定对象。
  12443. @param other other
  12444. */
  12445. equals(other: ValueType): boolean;
  12446. /**
  12447. !#en
  12448. Linearly interpolates between this value to to value by ratio which is in the range [0, 1].
  12449. When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to.
  12450. !#zh
  12451. 线性插值。<br/>
  12452. 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。
  12453. @param to the to value
  12454. @param ratio the interpolation coefficient
  12455. */
  12456. lerp(to: ValueType, ratio: number): ValueType;
  12457. /**
  12458. !#en TODO
  12459. !#zh 转换为方便阅读的字符串。
  12460. */
  12461. toString(): string;
  12462. }
  12463. /** !#en Representation of 2D vectors and points.
  12464. !#zh 表示 2D 向量和坐标 */
  12465. export class Vec2 extends ValueType {
  12466. /**
  12467. !#en
  12468. Constructor
  12469. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  12470. !#zh
  12471. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  12472. @param x x
  12473. @param y y
  12474. */
  12475. constructor(x?: number, y?: number);
  12476. x: number;
  12477. y: number;
  12478. /**
  12479. !#en clone a Vec2 value
  12480. !#zh 克隆一个 Vec2 值
  12481. */
  12482. clone(): Vec2;
  12483. /**
  12484. !#en TODO
  12485. !#zh 设置向量值。
  12486. @param newValue !#en new value to set. !#zh 要设置的新值
  12487. */
  12488. set(newValue: Vec2): Vec2;
  12489. /**
  12490. !#en TODO
  12491. !#zh 当前的向量是否与指定的向量相等。
  12492. @param other other
  12493. */
  12494. equals(other: Vec2): boolean;
  12495. /**
  12496. !#en TODO
  12497. !#zh 转换为方便阅读的字符串。
  12498. */
  12499. toString(): string;
  12500. /**
  12501. !#en TODO
  12502. !#zh 线性插值。
  12503. @param to to
  12504. @param ratio the interpolation coefficient
  12505. @param out optional, the receiving vector
  12506. */
  12507. lerp(to: Vec2, ratio: number, out?: Vec2): Vec2;
  12508. /**
  12509. !#en Adds this vector. If you want to save result to another vector, use add() instead.
  12510. !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。
  12511. @param vector vector
  12512. @example
  12513. ```js
  12514. var v = cc.v2(10, 10);
  12515. v.addSelf(cc.v2(5, 5));// return Vec2 {x: 15, y: 15};
  12516. ```
  12517. */
  12518. addSelf(vector: Vec2): Vec2;
  12519. /**
  12520. !#en Adds two vectors, and returns the new result.
  12521. !#zh 向量加法,并返回新结果。
  12522. @param vector vector
  12523. @param out optional, the receiving vector
  12524. @example
  12525. ```js
  12526. var v = cc.v2(10, 10);
  12527. v.add(cc.v2(5, 5)); // return Vec2 {x: 15, y: 15};
  12528. var v1;
  12529. v.add(cc.v2(5, 5), v1); // return Vec2 {x: 15, y: 15};
  12530. ```
  12531. */
  12532. add(vector: Vec2, out?: Vec2): Vec2;
  12533. /**
  12534. !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead.
  12535. !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。
  12536. @param vector vector
  12537. @example
  12538. ```js
  12539. var v = cc.v2(10, 10);
  12540. v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5};
  12541. ```
  12542. */
  12543. subSelf(vector: Vec2): Vec2;
  12544. /**
  12545. !#en Subtracts one vector from this, and returns the new result.
  12546. !#zh 向量减法,并返回新结果。
  12547. @param vector vector
  12548. @param out optional, the receiving vector
  12549. @example
  12550. ```js
  12551. var v = cc.v2(10, 10);
  12552. v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5};
  12553. var v1;
  12554. v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5};
  12555. ```
  12556. */
  12557. sub(vector: Vec2, out?: Vec2): Vec2;
  12558. /**
  12559. !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead.
  12560. !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。
  12561. @param num num
  12562. @example
  12563. ```js
  12564. var v = cc.v2(10, 10);
  12565. v.mulSelf(5);// return Vec2 {x: 50, y: 50};
  12566. ```
  12567. */
  12568. mulSelf(num: number): Vec2;
  12569. /**
  12570. !#en Multiplies by a number, and returns the new result.
  12571. !#zh 缩放当前向量,并返回新结果。
  12572. @param num num
  12573. @param out optional, the receiving vector
  12574. @example
  12575. ```js
  12576. var v = cc.v2(10, 10);
  12577. v.mul(5); // return Vec2 {x: 50, y: 50};
  12578. var v1;
  12579. v.mul(5, v1); // return Vec2 {x: 50, y: 50};
  12580. ```
  12581. */
  12582. mul(num: number, out?: Vec2): Vec2;
  12583. /**
  12584. !#en Multiplies two vectors.
  12585. !#zh 分量相乘。
  12586. @param vector vector
  12587. @example
  12588. ```js
  12589. var v = cc.v2(10, 10);
  12590. v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50};
  12591. ```
  12592. */
  12593. scaleSelf(vector: Vec2): Vec2;
  12594. /**
  12595. !#en Multiplies two vectors, and returns the new result.
  12596. !#zh 分量相乘,并返回新的结果。
  12597. @param vector vector
  12598. @param out optional, the receiving vector
  12599. @example
  12600. ```js
  12601. var v = cc.v2(10, 10);
  12602. v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50};
  12603. var v1;
  12604. v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50};
  12605. ```
  12606. */
  12607. scale(vector: Vec2, out?: Vec2): Vec2;
  12608. /**
  12609. !#en Divides by a number. If you want to save result to another vector, use div() instead.
  12610. !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。
  12611. @param vector vector
  12612. @example
  12613. ```js
  12614. var v = cc.v2(10, 10);
  12615. v.divSelf(5); // return Vec2 {x: 2, y: 2};
  12616. ```
  12617. */
  12618. divSelf(vector: Vec2): Vec2;
  12619. /**
  12620. !#en Divides by a number, and returns the new result.
  12621. !#zh 向量除法,并返回新的结果。
  12622. @param vector vector
  12623. @param out optional, the receiving vector
  12624. @example
  12625. ```js
  12626. var v = cc.v2(10, 10);
  12627. v.div(5); // return Vec2 {x: 2, y: 2};
  12628. var v1;
  12629. v.div(5, v1); // return Vec2 {x: 2, y: 2};
  12630. ```
  12631. */
  12632. div(vector: Vec2, out?: Vec2): Vec2;
  12633. /**
  12634. !#en Negates the components. If you want to save result to another vector, use neg() instead.
  12635. !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。
  12636. @example
  12637. ```js
  12638. var v = cc.v2(10, 10);
  12639. v.negSelf(); // return Vec2 {x: -10, y: -10};
  12640. ```
  12641. */
  12642. negSelf(): Vec2;
  12643. /**
  12644. !#en Negates the components, and returns the new result.
  12645. !#zh 返回取反后的新向量。
  12646. @param out optional, the receiving vector
  12647. @example
  12648. ```js
  12649. var v = cc.v2(10, 10);
  12650. var v1;
  12651. v.neg(v1); // return Vec2 {x: -10, y: -10};
  12652. ```
  12653. */
  12654. neg(out?: Vec2): Vec2;
  12655. /**
  12656. !#en Dot product
  12657. !#zh 当前向量与指定向量进行点乘。
  12658. @param vector vector
  12659. @example
  12660. ```js
  12661. var v = cc.v2(10, 10);
  12662. v.dot(cc.v2(5, 5)); // return 100;
  12663. ```
  12664. */
  12665. dot(vector?: Vec2): number;
  12666. /**
  12667. !#en Cross product
  12668. !#zh 当前向量与指定向量进行叉乘。
  12669. @param vector vector
  12670. @example
  12671. ```js
  12672. var v = cc.v2(10, 10);
  12673. v.cross(cc.v2(5, 5)); // return 0;
  12674. ```
  12675. */
  12676. cross(vector?: Vec2): number;
  12677. /**
  12678. !#en Returns the length of this vector.
  12679. !#zh 返回该向量的长度。
  12680. @example
  12681. ```js
  12682. var v = cc.v2(10, 10);
  12683. v.mag(); // return 14.142135623730951;
  12684. ```
  12685. */
  12686. mag(): number;
  12687. /**
  12688. !#en Returns the squared length of this vector.
  12689. !#zh 返回该向量的长度平方。
  12690. @example
  12691. ```js
  12692. var v = cc.v2(10, 10);
  12693. v.magSqr(); // return 200;
  12694. ```
  12695. */
  12696. magSqr(): number;
  12697. /**
  12698. !#en Make the length of this vector to 1.
  12699. !#zh 向量归一化,让这个向量的长度为 1。
  12700. @example
  12701. ```js
  12702. var v = cc.v2(10, 10);
  12703. v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
  12704. ```
  12705. */
  12706. normalizeSelf(): Vec2;
  12707. /**
  12708. !#en
  12709. Returns this vector with a magnitude of 1.<br/>
  12710. <br/>
  12711. 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.
  12712. !#zh
  12713. 返回归一化后的向量。<br/>
  12714. <br/>
  12715. 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。
  12716. @param out optional, the receiving vector
  12717. */
  12718. normalize(out?: Vec2): Vec2;
  12719. /**
  12720. !#en Get angle in radian between this and vector.
  12721. !#zh 夹角的弧度。
  12722. @param vector vector
  12723. */
  12724. angle(vector: Vec2): number;
  12725. /**
  12726. !#en Get angle in radian between this and vector with direction.
  12727. !#zh 带方向的夹角的弧度。
  12728. @param vector vector
  12729. */
  12730. signAngle(vector: Vec2): number;
  12731. /**
  12732. !#en rotate
  12733. !#zh 返回旋转给定弧度后的新向量。
  12734. @param radians radians
  12735. @param out optional, the receiving vector
  12736. */
  12737. rotate(radians: number, out?: Vec2): Vec2;
  12738. /**
  12739. !#en rotate self
  12740. !#zh 按指定弧度旋转向量。
  12741. @param radians radians
  12742. */
  12743. rotateSelf(radians: number): Vec2;
  12744. /** !#en return a Vec2 object with x = 1 and y = 1.
  12745. !#zh 新 Vec2 对象。 */
  12746. static ONE: Vec2;
  12747. /** !#en return a Vec2 object with x = 0 and y = 0.
  12748. !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */
  12749. static ZERO: Vec2;
  12750. /** !#en return a Vec2 object with x = 0 and y = 1.
  12751. !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */
  12752. static UP: Vec2;
  12753. /** !#en return a Vec2 object with x = 1 and y = 0.
  12754. !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */
  12755. static RIGHT: Vec2;
  12756. }
  12757. /** undefined */
  12758. export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box {
  12759. /** !#en Position offset
  12760. !#zh 位置偏移量 */
  12761. offset: Vec2;
  12762. /** !#en Box size
  12763. !#zh 包围盒大小 */
  12764. size: Size;
  12765. }
  12766. /** undefined */
  12767. export class PhysicsChainCollider extends PolygonCollider {
  12768. /** !#en Whether the chain is loop
  12769. !#zh 链条是否首尾相连 */
  12770. loop: boolean;
  12771. /** !#en Chain points
  12772. !#zh 链条顶点数组 */
  12773. points: [Vec2];
  12774. }
  12775. /** undefined */
  12776. export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle {
  12777. /** !#en Position offset
  12778. !#zh 位置偏移量 */
  12779. offset: Vec2;
  12780. /** !#en Circle radius
  12781. !#zh 圆形半径 */
  12782. radius: number;
  12783. }
  12784. /** undefined */
  12785. export class PhysicsCollider {
  12786. /** !#en
  12787. The density.
  12788. !#zh
  12789. 密度 */
  12790. density: number;
  12791. /** !#en
  12792. A sensor collider collects contact information but never generates a collision response
  12793. !#zh
  12794. 一个传感器类型的碰撞体会产生碰撞回调,但是不会发生物理碰撞效果。 */
  12795. sensor: boolean;
  12796. /** !#en
  12797. The friction coefficient, usually in the range [0,1].
  12798. !#zh
  12799. 摩擦系数,取值一般在 [0, 1] 之间 */
  12800. friction: number;
  12801. /** !#en
  12802. The restitution (elasticity) usually in the range [0,1].
  12803. !#zh
  12804. 弹性系数,取值一般在 [0, 1]之间 */
  12805. restitution: number;
  12806. /** !#en
  12807. Physics collider will find the rigidbody component on the node and set to this property.
  12808. !#zh
  12809. 碰撞体会在初始化时查找节点上是否存在刚体,如果查找成功则赋值到这个属性上。 */
  12810. body: RigidBody;
  12811. /**
  12812. !#en
  12813. Apply current changes to collider, this will regenerate inner box2d fixtures.
  12814. !#zh
  12815. 应用当前 collider 中的修改,调用此函数会重新生成内部 box2d 的夹具。
  12816. */
  12817. apply(): void;
  12818. /**
  12819. !#en
  12820. Get the world aabb of the collider
  12821. !#zh
  12822. 获取碰撞体的世界坐标系下的包围盒
  12823. */
  12824. getAABB(): void;
  12825. }
  12826. /** undefined */
  12827. export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon {
  12828. /** !#en Position offset
  12829. !#zh 位置偏移量 */
  12830. offset: Vec2;
  12831. /** !#en Polygon points
  12832. !#zh 多边形顶点数组 */
  12833. points: [Vec2];
  12834. }
  12835. /** !#en
  12836. A distance joint constrains two points on two bodies
  12837. to remain at a fixed distance from each other. You can view
  12838. this as a massless, rigid rod.
  12839. !#zh
  12840. 距离关节通过一个固定的长度来约束关节链接的两个刚体。你可以将它想象成一个无质量,坚固的木棍。 */
  12841. export class DistanceJoint extends Joint {
  12842. /** !#en
  12843. The distance separating the two ends of the joint.
  12844. !#zh
  12845. 关节两端的距离 */
  12846. distance: number;
  12847. /** !#en
  12848. The spring frequency.
  12849. !#zh
  12850. 弹性系数。 */
  12851. frequency: number;
  12852. /** !#en
  12853. The damping ratio.
  12854. !#zh
  12855. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  12856. 0: number;
  12857. }
  12858. /** !#en
  12859. Base class for joints to connect rigidbody.
  12860. !#zh
  12861. 关节类的基类 */
  12862. export class Joint extends Component {
  12863. /** !#en
  12864. The anchor of the rigidbody.
  12865. !#zh
  12866. 刚体的锚点。 */
  12867. anchor: Vec2;
  12868. /** !#en
  12869. The anchor of the connected rigidbody.
  12870. !#zh
  12871. 关节另一端刚体的锚点。 */
  12872. connectedAnchor: Vec2;
  12873. /** !#en
  12874. The rigidbody to which the other end of the joint is attached.
  12875. !#zh
  12876. 关节另一端链接的刚体 */
  12877. connectedBody: RigidBody;
  12878. /** !#en
  12879. Should the two rigid bodies connected with this joint collide with each other?
  12880. !#zh
  12881. 链接到关节上的两个刚体是否应该相互碰撞? */
  12882. collideConnected: boolean;
  12883. /**
  12884. !#en
  12885. Apply current changes to joint, this will regenerate inner box2d joint.
  12886. !#zh
  12887. 应用当前关节中的修改,调用此函数会重新生成内部 box2d 的关节。
  12888. */
  12889. apply(): void;
  12890. /**
  12891. !#en
  12892. Get the anchor point on rigidbody in world coordinates.
  12893. !#zh
  12894. 获取刚体世界坐标系下的锚点。
  12895. */
  12896. getWorldAnchor(): Vec2;
  12897. /**
  12898. !#en
  12899. Get the anchor point on connected rigidbody in world coordinates.
  12900. !#zh
  12901. 获取链接刚体世界坐标系下的锚点。
  12902. */
  12903. getWorldConnectedAnchor(): Vec2;
  12904. /**
  12905. !#en
  12906. Gets the reaction force of the joint.
  12907. !#zh
  12908. 获取关节的反作用力。
  12909. @param timeStep The time to calculate the reaction force for.
  12910. */
  12911. getReactionForce(timeStep: number): number;
  12912. /**
  12913. !#en
  12914. Gets the reaction torque of the joint.
  12915. !#zh
  12916. 获取关节的反扭矩。
  12917. @param timeStep The time to calculate the reaction torque for.
  12918. */
  12919. getReactionTorque(timeStep: number): number;
  12920. }
  12921. /** !#en
  12922. A motor joint is used to control the relative motion
  12923. between two bodies. A typical usage is to control the movement
  12924. of a dynamic body with respect to the ground.
  12925. !#zh
  12926. 马达关节被用来控制两个刚体间的相对运动。
  12927. 一个典型的例子是用来控制一个动态刚体相对于地面的运动。 */
  12928. export class MotorJoint extends Joint {
  12929. /** !#en
  12930. The anchor of the rigidbody.
  12931. !#zh
  12932. 刚体的锚点。 */
  12933. anchor: Vec2;
  12934. /** !#en
  12935. The anchor of the connected rigidbody.
  12936. !#zh
  12937. 关节另一端刚体的锚点。 */
  12938. connectedAnchor: Vec2;
  12939. /** !#en
  12940. The linear offset from connected rigidbody to rigidbody.
  12941. !#zh
  12942. 关节另一端的刚体相对于起始端刚体的位置偏移量 */
  12943. linearOffset: Vec2;
  12944. /** !#en
  12945. The angular offset from connected rigidbody to rigidbody.
  12946. !#zh
  12947. 关节另一端的刚体相对于起始端刚体的角度偏移量 */
  12948. angularOffset: number;
  12949. /** !#en
  12950. The maximum force can be applied to rigidbody.
  12951. !#zh
  12952. 可以应用于刚体的最大的力值 */
  12953. maxForce: number;
  12954. /** !#en
  12955. The maximum torque can be applied to rigidbody.
  12956. !#zh
  12957. 可以应用于刚体的最大扭矩值 */
  12958. maxTorque: number;
  12959. /** !#en
  12960. The position correction factor in the range [0,1].
  12961. !#zh
  12962. 位置矫正系数,范围为 [0, 1] */
  12963. correctionFactor: number;
  12964. }
  12965. /** !#en
  12966. A mouse joint is used to make a point on a body track a
  12967. specified world point. This a soft constraint with a maximum
  12968. force. This allows the constraint to stretch and without
  12969. applying huge forces.
  12970. Mouse Joint will auto register the touch event with the mouse region node,
  12971. and move the choosed rigidbody in touch move event.
  12972. Note : generally mouse joint only used in test bed.
  12973. !#zh
  12974. 鼠标关节用于使刚体上的一个点追踪一个指定的世界坐标系下的位置。
  12975. 鼠标关节可以指定一个最大的里来施加一个柔和的约束。
  12976. 鼠标关节会自动使用 mouse region 节点来注册鼠标事件,并且在触摸移动事件中移动选中的刚体。
  12977. 注意:一般鼠标关节只在测试环境中使用。 */
  12978. export class MouseJoint extends Joint {
  12979. /** !#en
  12980. The anchor of the rigidbody.
  12981. !#zh
  12982. 刚体的锚点。 */
  12983. anchor: Vec2;
  12984. /** !#en
  12985. The anchor of the connected rigidbody.
  12986. !#zh
  12987. 关节另一端刚体的锚点。 */
  12988. connectedAnchor: Vec2;
  12989. /** !#en
  12990. The node used to register touch evnet.
  12991. If this is null, it will be the joint's node.
  12992. !#zh
  12993. 用于注册触摸事件的节点。
  12994. 如果没有设置这个值,那么将会使用关节的节点来注册事件。 */
  12995. mouseRegion: Node;
  12996. /** !#en
  12997. The target point.
  12998. The mouse joint will move choosed rigidbody to target point.
  12999. !#zh
  13000. 目标点,鼠标关节将会移动选中的刚体到指定的目标点 */
  13001. target: Vec2;
  13002. /** !#en
  13003. The spring frequency.
  13004. !#zh
  13005. 弹簧系数。 */
  13006. frequency: number;
  13007. /** !#en
  13008. The damping ratio.
  13009. !#zh
  13010. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13011. 0: number;
  13012. /** !#en
  13013. The maximum force
  13014. !#zh
  13015. 最大阻力值 */
  13016. maxForce: number;
  13017. }
  13018. /** !#en
  13019. A prismatic joint. This joint provides one degree of freedom: translation
  13020. along an axis fixed in rigidbody. Relative rotation is prevented. You can
  13021. use a joint limit to restrict the range of motion and a joint motor to
  13022. drive the motion or to model joint friction.
  13023. !#zh
  13024. 移动关节指定了只能在一个方向上移动刚体。
  13025. 你可以开启关节限制来设置刚体运行移动的间距,也可以开启马达来使用关节马达驱动刚体的运行。 */
  13026. export class PrismaticJoint extends Joint {
  13027. /** !#en
  13028. The local joint axis relative to rigidbody.
  13029. !#zh
  13030. 指定刚体可以移动的方向。 */
  13031. localAxisA: Vec2;
  13032. /** !#en
  13033. The reference angle.
  13034. !#zh
  13035. 相对角度 */
  13036. referenceAngle: number;
  13037. /** !#en
  13038. Enable joint distance limit?
  13039. !#zh
  13040. 是否开启关节的距离限制? */
  13041. enableLimit: boolean;
  13042. /** !#en
  13043. Enable joint motor?
  13044. !#zh
  13045. 是否开启关节马达? */
  13046. enableMotor: boolean;
  13047. /** !#en
  13048. The lower joint limit.
  13049. !#zh
  13050. 刚体能够移动的最小值 */
  13051. lowerLimit: number;
  13052. /** !#en
  13053. The upper joint limit.
  13054. !#zh
  13055. 刚体能够移动的最大值 */
  13056. upperLimit: number;
  13057. /** !#en
  13058. The maxium force can be applied to rigidbody to rearch the target motor speed.
  13059. !#zh
  13060. 可以施加到刚体的最大力。 */
  13061. maxMotorForce: number;
  13062. /** !#en
  13063. The expected motor speed.
  13064. !#zh
  13065. 期望的马达速度。 */
  13066. motorSpeed: number;
  13067. }
  13068. /** !#en
  13069. A revolute joint constrains two bodies to share a common point while they
  13070. are free to rotate about the point. The relative rotation about the shared
  13071. point is the joint angle. You can limit the relative rotation with
  13072. a joint limit that specifies a lower and upper angle. You can use a motor
  13073. to drive the relative rotation about the shared point. A maximum motor torque
  13074. is provided so that infinite forces are not generated.
  13075. !#zh
  13076. 旋转关节可以约束两个刚体围绕一个点来进行旋转。
  13077. 你可以通过开启关节限制来限制旋转的最大角度和最小角度。
  13078. 你可以通过开启马达来施加一个扭矩力来驱动这两个刚体在这一点上的相对速度。 */
  13079. export class RevoluteJoint extends Joint {
  13080. /** !#en
  13081. The reference angle.
  13082. An angle between bodies considered to be zero for the joint angle.
  13083. !#zh
  13084. 相对角度。
  13085. 两个物体之间角度为零时可以看作相等于关节角度 */
  13086. referenceAngle: number;
  13087. /** !#en
  13088. The lower angle.
  13089. !#zh
  13090. 角度的最低限制。 */
  13091. lowerAngle: number;
  13092. /** !#en
  13093. The upper angle.
  13094. !#zh
  13095. 角度的最高限制。 */
  13096. upperAngle: number;
  13097. /** !#en
  13098. The maxium torque can be applied to rigidbody to rearch the target motor speed.
  13099. !#zh
  13100. 可以施加到刚体的最大扭矩。 */
  13101. maxMotorTorque: number;
  13102. /** !#en
  13103. The expected motor speed.
  13104. !#zh
  13105. 期望的马达速度。 */
  13106. motorSpeed: number;
  13107. /** !#en
  13108. Enable joint limit?
  13109. !#zh
  13110. 是否开启关节的限制? */
  13111. enableLimit: boolean;
  13112. /** !#en
  13113. Enable joint motor?
  13114. !#zh
  13115. 是否开启关节马达? */
  13116. enableMotor: boolean;
  13117. /**
  13118. !#en
  13119. Get the joint angle.
  13120. !#zh
  13121. 获取关节角度。
  13122. */
  13123. getJointAngle(): number;
  13124. }
  13125. /** !#en
  13126. A rope joint enforces a maximum distance between two points
  13127. on two bodies. It has no other effect.
  13128. Warning: if you attempt to change the maximum length during
  13129. the simulation you will get some non-physical behavior.
  13130. !#zh
  13131. 绳子关节只指定两个刚体间的最大距离,没有其他的效果。
  13132. 注意:如果你试图动态修改关节的长度,这有可能会得到一些意外的效果。 */
  13133. export class RopeJoint extends Joint {
  13134. /** !#en
  13135. The max length.
  13136. !#zh
  13137. 最大长度。 */
  13138. maxLength: number;
  13139. }
  13140. /** !#en
  13141. A weld joint essentially glues two bodies together. A weld joint may
  13142. distort somewhat because the island constraint solver is approximate.
  13143. !#zh
  13144. 熔接关节相当于将两个刚体粘在了一起。
  13145. 熔接关节可能会使某些东西失真,因为约束求解器算出的都是近似值。 */
  13146. export class WeldJoint extends Joint {
  13147. /** !#en
  13148. The reference angle.
  13149. !#zh
  13150. 相对角度。 */
  13151. referenceAngle: number;
  13152. /** !#en
  13153. The frequency.
  13154. !#zh
  13155. 弹性系数。 */
  13156. frequency: number;
  13157. /** !#en
  13158. The damping ratio.
  13159. !#zh
  13160. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13161. 0: number;
  13162. }
  13163. /** !#en
  13164. A wheel joint. This joint provides two degrees of freedom: translation
  13165. along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive
  13166. the rotation or to model rotational friction.
  13167. This joint is designed for vehicle suspensions.
  13168. !#zh
  13169. 轮子关节提供两个维度的自由度:旋转和沿着指定方向上位置的移动。
  13170. 你可以通过开启关节马达来使用马达驱动刚体的旋转。
  13171. 轮组关节是专门为机动车类型设计的。 */
  13172. export class WheelJoint extends Joint {
  13173. /** !#en
  13174. The local joint axis relative to rigidbody.
  13175. !#zh
  13176. 指定刚体可以移动的方向。 */
  13177. localAxisA: Vec2;
  13178. /** !#en
  13179. The maxium torque can be applied to rigidbody to rearch the target motor speed.
  13180. !#zh
  13181. 可以施加到刚体的最大扭矩。 */
  13182. maxMotorTorque: number;
  13183. /** !#en
  13184. The expected motor speed.
  13185. !#zh
  13186. 期望的马达速度。 */
  13187. motorSpeed: number;
  13188. /** !#en
  13189. Enable joint motor?
  13190. !#zh
  13191. 是否开启关节马达? */
  13192. enableMotor: boolean;
  13193. /** !#en
  13194. The spring frequency.
  13195. !#zh
  13196. 弹性系数。 */
  13197. frequency: number;
  13198. /** !#en
  13199. The damping ratio.
  13200. !#zh
  13201. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13202. dampingRatio: number;
  13203. }
  13204. /****************************************************
  13205. * audioEngine
  13206. *****************************************************/
  13207. export module audioEngine {
  13208. /** !#en Audio state.
  13209. !#zh 声音播放状态 */
  13210. export enum AudioState {
  13211. ERROR = 0,
  13212. INITIALZING = 0,
  13213. PLAYING = 0,
  13214. PAUSED = 0,
  13215. }
  13216. }
  13217. /****************************************************
  13218. * ParticleSystem
  13219. *****************************************************/
  13220. export module ParticleSystem {
  13221. /** !#en Enum for emitter modes
  13222. !#zh 发射模式 */
  13223. export enum EmitterMode {
  13224. GRAVITY = 0,
  13225. RADIUS = 0,
  13226. }
  13227. }
  13228. /****************************************************
  13229. * ParticleSystem
  13230. *****************************************************/
  13231. export module ParticleSystem {
  13232. /** !#en Enum for particles movement type.
  13233. !#zh 粒子位置类型 */
  13234. export enum PositionType {
  13235. FREE = 0,
  13236. RELATIVE = 0,
  13237. GROUPED = 0,
  13238. }
  13239. }
  13240. /****************************************************
  13241. * Node
  13242. *****************************************************/
  13243. export module Node {
  13244. /** !#en The event type supported by Node
  13245. !#zh Node 支持的事件类型 */
  13246. export class EventType {
  13247. /** !#en The event type for touch start event, you can use its value directly: 'touchstart'
  13248. !#zh 当手指触摸到屏幕时。 */
  13249. static TOUCH_START: string;
  13250. /** !#en The event type for touch move event, you can use its value directly: 'touchmove'
  13251. !#zh 当手指在屏幕上目标节点区域内移动时。 */
  13252. static TOUCH_MOVE: string;
  13253. /** !#en The event type for touch end event, you can use its value directly: 'touchend'
  13254. !#zh 当手指在目标节点区域内离开屏幕时。 */
  13255. static TOUCH_END: string;
  13256. /** !#en The event type for touch end event, you can use its value directly: 'touchcancel'
  13257. !#zh 当手指在目标节点区域外离开屏幕时。 */
  13258. static TOUCH_CANCEL: string;
  13259. /** !#en The event type for mouse down events, you can use its value directly: 'mousedown'
  13260. !#zh 当鼠标按下时触发一次。 */
  13261. static MOUSE_DOWN: string;
  13262. /** !#en The event type for mouse move events, you can use its value directly: 'mousemove'
  13263. !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。 */
  13264. static MOUSE_MOVE: string;
  13265. /** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter'
  13266. !#zh 当鼠标移入目标节点区域时,不论是否按下。 */
  13267. static MOUSE_ENTER: string;
  13268. /** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave'
  13269. !#zh 当鼠标移出目标节点区域时,不论是否按下。 */
  13270. static MOUSE_LEAVE: string;
  13271. /** !#en The event type for mouse up events, you can use its value directly: 'mouseup'
  13272. !#zh 当鼠标从按下状态松开时触发一次。 */
  13273. static MOUSE_UP: string;
  13274. /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel'
  13275. !#zh 当鼠标滚轮滚动时。 */
  13276. static MOUSE_WHEEL: string;
  13277. }
  13278. }
  13279. /****************************************************
  13280. * TiledMap
  13281. *****************************************************/
  13282. export module TiledMap {
  13283. /** !#en The orientation of tiled map.
  13284. !#zh Tiled Map 地图方向。 */
  13285. export enum Orientation {
  13286. ORTHO = 0,
  13287. HEX = 0,
  13288. ISO = 0,
  13289. NONE = 0,
  13290. MAP = 0,
  13291. LAYER = 0,
  13292. OBJECTGROUP = 0,
  13293. OBJECT = 0,
  13294. TILE = 0,
  13295. HORIZONTAL = 0,
  13296. VERTICAL = 0,
  13297. DIAGONAL = 0,
  13298. FLIPPED_ALL = 0,
  13299. FLIPPED_MASK = 0,
  13300. STAGGERAXIS_X = 0,
  13301. STAGGERAXIS_Y = 0,
  13302. STAGGERINDEX_ODD = 0,
  13303. STAGGERINDEX_EVEN = 0,
  13304. }
  13305. }
  13306. /****************************************************
  13307. * Collider
  13308. *****************************************************/
  13309. export module Collider {
  13310. /** !#en Defines a Box Collider .
  13311. !#zh 用来定义包围盒碰撞体 */
  13312. export class Box {
  13313. /** !#en Position offset
  13314. !#zh 位置偏移量 */
  13315. offset: Vec2;
  13316. /** !#en Box size
  13317. !#zh 包围盒大小 */
  13318. size: Size;
  13319. }
  13320. }
  13321. /****************************************************
  13322. * Collider
  13323. *****************************************************/
  13324. export module Collider {
  13325. /** !#en Defines a Circle Collider .
  13326. !#zh 用来定义圆形碰撞体 */
  13327. export class Circle {
  13328. /** !#en Position offset
  13329. !#zh 位置偏移量 */
  13330. offset: Vec2;
  13331. /** !#en Circle radius
  13332. !#zh 圆形半径 */
  13333. radius: number;
  13334. }
  13335. }
  13336. /****************************************************
  13337. * Collider
  13338. *****************************************************/
  13339. export module Collider {
  13340. /** !#en Defines a Polygon Collider .
  13341. !#zh 用来定义多边形碰撞体 */
  13342. export class Polygon {
  13343. /** !#en Position offset
  13344. !#zh 位置偏移量 */
  13345. offset: Vec2;
  13346. /** !#en Polygon points
  13347. !#zh 多边形顶点数组 */
  13348. points: [Vec2];
  13349. }
  13350. }
  13351. /****************************************************
  13352. * Button
  13353. *****************************************************/
  13354. export module Button {
  13355. /** !#en Enum for transition type.
  13356. !#zh 过渡类型 */
  13357. export enum Transition {
  13358. NONE = 0,
  13359. COLOR = 0,
  13360. SPRITE = 0,
  13361. SCALE = 0,
  13362. }
  13363. }
  13364. /****************************************************
  13365. * Component
  13366. *****************************************************/
  13367. export module Component {
  13368. /** !#en
  13369. Component will register a event to target component's handler.
  13370. And it will trigger the handler when a certain event occurs.
  13371. !@zh
  13372. “EventHandler” 类用来设置场景中的事件回调,
  13373. 该类允许用户设置回调目标节点,目标组件名,组件方法名,
  13374. 并可通过 emit 方法调用目标函数。 */
  13375. export class EventHandler {
  13376. /** !#en Event target
  13377. !#zh 目标节点 */
  13378. target: Node;
  13379. /** !#en Component name
  13380. !#zh 目标组件名 */
  13381. component: string;
  13382. /** !#en Event handler
  13383. !#zh 响应事件函数名 */
  13384. handler: string;
  13385. /** !#en Custom Event Data
  13386. !#zh 自定义事件数据 */
  13387. customEventData: string;
  13388. /**
  13389. @param events events
  13390. @param params params
  13391. */
  13392. static emitEvents(events: Component.EventHandler[], ...params: any[]): void;
  13393. /**
  13394. !#en Emit event with params
  13395. !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。
  13396. @param params params
  13397. @example
  13398. ```js
  13399. // Call Function
  13400. var eventHandler = new cc.Component.EventHandler();
  13401. eventHandler.target = newTarget;
  13402. eventHandler.component = "MainMenu";
  13403. eventHandler.handler = "OnClick"
  13404. eventHandler.emit(["param1", "param2", ....]);
  13405. ```
  13406. */
  13407. emit(params: any[]): void;
  13408. }
  13409. }
  13410. /****************************************************
  13411. * EditBox
  13412. *****************************************************/
  13413. export module EditBox {
  13414. /** !#en Enum for keyboard return types
  13415. !#zh 键盘的返回键类型 */
  13416. export enum KeyboardReturnType {
  13417. DEFAULT = 0,
  13418. DONE = 0,
  13419. SEND = 0,
  13420. SEARCH = 0,
  13421. GO = 0,
  13422. }
  13423. }
  13424. /****************************************************
  13425. * EditBox
  13426. *****************************************************/
  13427. export module EditBox {
  13428. /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter.
  13429. !#zh 输入模式 */
  13430. export enum InputMode {
  13431. ANY = 0,
  13432. EMAIL_ADDR = 0,
  13433. NUMERIC = 0,
  13434. PHONE_NUMBER = 0,
  13435. URL = 0,
  13436. DECIMAL = 0,
  13437. SINGLE_LINE = 0,
  13438. }
  13439. }
  13440. /****************************************************
  13441. * EditBox
  13442. *****************************************************/
  13443. export module EditBox {
  13444. /** !#en Enum for the EditBox's input flags
  13445. !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */
  13446. export enum InputFlag {
  13447. PASSWORD = 0,
  13448. SENSITIVE = 0,
  13449. INITIAL_CAPS_WORD = 0,
  13450. INITIAL_CAPS_SENTENCE = 0,
  13451. INITIAL_CAPS_ALL_CHARACTERS = 0,
  13452. }
  13453. }
  13454. /****************************************************
  13455. * Label
  13456. *****************************************************/
  13457. export module Label {
  13458. /** !#en Enum for text alignment.
  13459. !#zh 文本横向对齐类型 */
  13460. export enum HorizontalAlign {
  13461. LEFT = 0,
  13462. CENTER = 0,
  13463. RIGHT = 0,
  13464. }
  13465. }
  13466. /****************************************************
  13467. * Label
  13468. *****************************************************/
  13469. export module Label {
  13470. /** !#en Enum for vertical text alignment.
  13471. !#zh 文本垂直对齐类型 */
  13472. export enum VerticalAlign {
  13473. TOP = 0,
  13474. CENTER = 0,
  13475. BOTTOM = 0,
  13476. }
  13477. }
  13478. /****************************************************
  13479. * Label
  13480. *****************************************************/
  13481. export module Label {
  13482. /** !#en Enum for Overflow.
  13483. !#zh Overflow 类型 */
  13484. export enum Overflow {
  13485. NONE = 0,
  13486. CLAMP = 0,
  13487. SHRINK = 0,
  13488. RESIZE_HEIGHT = 0,
  13489. }
  13490. }
  13491. /****************************************************
  13492. * Label
  13493. *****************************************************/
  13494. export module Label {
  13495. /** !#en Enum for font type.
  13496. !#zh Type 类型 */
  13497. export enum Type {
  13498. TTF = 0,
  13499. BMFont = 0,
  13500. SystemFont = 0,
  13501. }
  13502. }
  13503. /****************************************************
  13504. * Layout
  13505. *****************************************************/
  13506. export module Layout {
  13507. /** !#en Enum for Layout type
  13508. !#zh 布局类型 */
  13509. export enum Type {
  13510. NONE = 0,
  13511. HORIZONTAL = 0,
  13512. VERTICAL = 0,
  13513. GRID = 0,
  13514. }
  13515. }
  13516. /****************************************************
  13517. * Layout
  13518. *****************************************************/
  13519. export module Layout {
  13520. /** !#en Enum for Layout Resize Mode
  13521. !#zh 缩放模式 */
  13522. export enum ResizeMode {
  13523. NONE = 0,
  13524. CONTAINER = 0,
  13525. CHILDREN = 0,
  13526. }
  13527. }
  13528. /****************************************************
  13529. * Layout
  13530. *****************************************************/
  13531. export module Layout {
  13532. /** !#en Enum for Grid Layout start axis direction.
  13533. The items in grid layout will be arranged in each axis at first.;
  13534. !#zh 布局轴向,只用于 GRID 布局。 */
  13535. export enum AxisDirection {
  13536. HORIZONTAL = 0,
  13537. VERTICAL = 0,
  13538. }
  13539. }
  13540. /****************************************************
  13541. * Layout
  13542. *****************************************************/
  13543. export module Layout {
  13544. /** !#en Enum for vertical layout direction.
  13545. Used in Grid Layout together with AxisDirection is VERTICAL
  13546. !#zh 垂直方向布局方式 */
  13547. export enum VerticalDirection {
  13548. BOTTOM_TO_TOP = 0,
  13549. TOP_TO_BOTTOM = 0,
  13550. }
  13551. }
  13552. /****************************************************
  13553. * Layout
  13554. *****************************************************/
  13555. export module Layout {
  13556. /** !#en Enum for horizontal layout direction.
  13557. Used in Grid Layout together with AxisDirection is HORIZONTAL
  13558. !#zh 水平方向布局方式 */
  13559. export enum HorizontalDirection {
  13560. LEFT_TO_RIGHT = 0,
  13561. RIGHT_TO_LEFT = 0,
  13562. }
  13563. }
  13564. /****************************************************
  13565. * Mask
  13566. *****************************************************/
  13567. export module Mask {
  13568. /** !#en the type for mask.
  13569. !#zh 遮罩组件类型 */
  13570. export enum Type {
  13571. RECT = 0,
  13572. ELLIPSE = 0,
  13573. IMAGE_STENCIL = 0,
  13574. }
  13575. }
  13576. /****************************************************
  13577. * PageView
  13578. *****************************************************/
  13579. export module PageView {
  13580. /** !#en The Page View Size Mode
  13581. !#zh 页面视图每个页面统一的大小类型 */
  13582. export enum SizeMode {
  13583. Unified = 0,
  13584. Free = 0,
  13585. }
  13586. }
  13587. /****************************************************
  13588. * PageView
  13589. *****************************************************/
  13590. export module PageView {
  13591. /** !#en The Page View Direction
  13592. !#zh 页面视图滚动类型 */
  13593. export enum Direction {
  13594. Horizontal = 0,
  13595. Vertical = 0,
  13596. }
  13597. }
  13598. /****************************************************
  13599. * PageView
  13600. *****************************************************/
  13601. export module PageView {
  13602. /** !#en Enum for ScrollView event type.
  13603. !#zh 滚动视图事件类型 */
  13604. export enum EventType {
  13605. PAGE_TURNING = 0,
  13606. }
  13607. }
  13608. /****************************************************
  13609. * PageViewIndicator
  13610. *****************************************************/
  13611. export module PageViewIndicator {
  13612. /** !#en Enum for PageView Indicator direction
  13613. !#zh 页面视图指示器的摆放方向 */
  13614. export enum Direction {
  13615. HORIZONTAL = 0,
  13616. VERTICAL = 0,
  13617. }
  13618. }
  13619. /****************************************************
  13620. * ProgressBar
  13621. *****************************************************/
  13622. export module ProgressBar {
  13623. /** !#en Enum for ProgressBar mode
  13624. !#zh 进度条模式 */
  13625. export enum Mode {
  13626. HORIZONTAL = 0,
  13627. VERTICAL = 0,
  13628. FILLED = 0,
  13629. }
  13630. }
  13631. /****************************************************
  13632. * Scrollbar
  13633. *****************************************************/
  13634. export module Scrollbar {
  13635. /** Enum for Scrollbar direction */
  13636. export enum Direction {
  13637. HORIZONTAL = 0,
  13638. VERTICAL = 0,
  13639. }
  13640. }
  13641. /****************************************************
  13642. * ScrollView
  13643. *****************************************************/
  13644. export module ScrollView {
  13645. /** !#en Enum for ScrollView event type.
  13646. !#zh 滚动视图事件类型 */
  13647. export enum EventType {
  13648. SCROLL_TO_TOP = 0,
  13649. SCROLL_TO_BOTTOM = 0,
  13650. SCROLL_TO_LEFT = 0,
  13651. SCROLL_TO_RIGHT = 0,
  13652. SCROLLING = 0,
  13653. BOUNCE_TOP = 0,
  13654. BOUNCE_BOTTOM = 0,
  13655. BOUNCE_LEFT = 0,
  13656. BOUNCE_RIGHT = 0,
  13657. SCROLL_ENDED = 0,
  13658. TOUCH_UP = 0,
  13659. AUTOSCROLL_ENDED_WITH_THRESHOLD = 0,
  13660. SCROLL_BEGAN = 0,
  13661. }
  13662. }
  13663. /****************************************************
  13664. * Slider
  13665. *****************************************************/
  13666. export module Slider {
  13667. /** !#en The Slider Direction
  13668. !#zh 滑动器方向 */
  13669. export enum Direction {
  13670. Horizontal = 0,
  13671. Vertical = 0,
  13672. }
  13673. }
  13674. /****************************************************
  13675. * Sprite
  13676. *****************************************************/
  13677. export module Sprite {
  13678. /** !#en Enum for sprite type.
  13679. !#zh Sprite 类型 */
  13680. export enum Type {
  13681. SIMPLE = 0,
  13682. SLICED = 0,
  13683. TILED = 0,
  13684. FILLED = 0,
  13685. }
  13686. }
  13687. /****************************************************
  13688. * Sprite
  13689. *****************************************************/
  13690. export module Sprite {
  13691. /** !#en Enum for fill type.
  13692. !#zh 填充类型 */
  13693. export enum FillType {
  13694. HORIZONTAL = 0,
  13695. VERTICAL = 0,
  13696. RADIAL = 0,
  13697. }
  13698. }
  13699. /****************************************************
  13700. * Sprite
  13701. *****************************************************/
  13702. export module Sprite {
  13703. /** !#en Sprite Size can track trimmed size, raw size or none.
  13704. !#zh 精灵尺寸调整模式 */
  13705. export enum SizeMode {
  13706. CUSTOM = 0,
  13707. TRIMMED = 0,
  13708. RAW = 0,
  13709. }
  13710. }
  13711. /****************************************************
  13712. * VideoPlayer
  13713. *****************************************************/
  13714. export module VideoPlayer {
  13715. /** !#en Video event type
  13716. !#zh 视频事件类型 */
  13717. export enum EventType {
  13718. PLAYING = 0,
  13719. PAUSED = 0,
  13720. STOPPED = 0,
  13721. COMPLETED = 0,
  13722. META_LOADED = 0,
  13723. CLICKED = 0,
  13724. READY_TO_PLAY = 0,
  13725. }
  13726. }
  13727. /****************************************************
  13728. * VideoPlayer
  13729. *****************************************************/
  13730. export module VideoPlayer {
  13731. /** !#en Enum for video resouce type type.
  13732. !#zh 视频来源 */
  13733. export enum ResourceType {
  13734. REMOTE = 0,
  13735. LOCAL = 0,
  13736. }
  13737. }
  13738. /****************************************************
  13739. * WebView
  13740. *****************************************************/
  13741. export module WebView {
  13742. /** !#en WebView event type
  13743. !#zh 网页视图事件类型 */
  13744. export enum EventType {
  13745. LOADED = 0,
  13746. LOADING = 0,
  13747. ERROR = 0,
  13748. }
  13749. }
  13750. /****************************************************
  13751. * Event
  13752. *****************************************************/
  13753. export module Event {
  13754. /** !#en The Custom event
  13755. !#zh 自定义事件 */
  13756. export class EventCustom extends Event {
  13757. /**
  13758. @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
  13759. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  13760. */
  13761. constructor(type: string, bubbles: boolean);
  13762. /** !#en A reference to the detailed data of the event
  13763. !#zh 事件的详细数据 */
  13764. detail: any;
  13765. /**
  13766. !#en Sets user data
  13767. !#zh 设置用户数据
  13768. @param data data
  13769. */
  13770. setUserData(data: any): void;
  13771. /**
  13772. !#en Gets user data
  13773. !#zh 获取用户数据
  13774. */
  13775. getUserData(): any;
  13776. /**
  13777. !#en Gets event name
  13778. !#zh 获取事件名称
  13779. */
  13780. getEventName(): string;
  13781. /** !#en
  13782. The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. </br>
  13783. This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key.</br>
  13784. If the key can't be identified, this value is 0.</br>
  13785. !#zh
  13786. keyCode 是只读属性它表示一个系统和依赖于实现的数字代码,可以识别按键的未修改值。</br>
  13787. 这通常是十进制 ASCII (RFC20) 或者 Windows 1252 代码,所对应的密钥。</br>
  13788. 如果无法识别该键,则该值为 0。 */
  13789. keyCode: number;
  13790. }
  13791. }
  13792. /****************************************************
  13793. * SystemEvent
  13794. *****************************************************/
  13795. export module SystemEvent {
  13796. /** !#en The event type supported by SystemEvent
  13797. !#zh SystemEvent 支持的事件类型 */
  13798. export class EventType {
  13799. /** !#en The event type for press the key down event, you can use its value directly: 'keydown'
  13800. !#zh 当按下按键时触发的事件 */
  13801. static KEY_DOWN: string;
  13802. /** !#en The event type for press the key up event, you can use its value directly: 'keyup'
  13803. !#zh 当松开按键时触发的事件 */
  13804. static KEY_UP: string;
  13805. /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion'
  13806. !#zh 重力感应 */
  13807. static DEVICEMOTION: string;
  13808. }
  13809. }
  13810. /****************************************************
  13811. * Graphics
  13812. *****************************************************/
  13813. export module Graphics {
  13814. /** !#en Enum for LineCap.
  13815. !#zh 线段末端属性 */
  13816. export enum LineCap {
  13817. BUTT = 0,
  13818. ROUND = 0,
  13819. SQUARE = 0,
  13820. }
  13821. }
  13822. /****************************************************
  13823. * Graphics
  13824. *****************************************************/
  13825. export module Graphics {
  13826. /** !#en Enum for LineJoin.
  13827. !#zh 线段拐角属性 */
  13828. export enum LineJoin {
  13829. BEVEL = 0,
  13830. ROUND = 0,
  13831. MITER = 0,
  13832. }
  13833. }
  13834. /****************************************************
  13835. * Event
  13836. *****************************************************/
  13837. export module Event {
  13838. /** !#en The mouse event
  13839. !#zh 鼠标事件类型 */
  13840. export class EventMouse extends Event {
  13841. /**
  13842. !#en Sets scroll data.
  13843. !#zh 设置鼠标的滚动数据。
  13844. @param scrollX scrollX
  13845. @param scrollY scrollY
  13846. */
  13847. setScrollData(scrollX: number, scrollY: number): void;
  13848. /**
  13849. !#en Returns the x axis scroll value.
  13850. !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。
  13851. */
  13852. getScrollX(): number;
  13853. /**
  13854. !#en Returns the y axis scroll value.
  13855. !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。
  13856. */
  13857. getScrollY(): number;
  13858. /**
  13859. !#en Sets cursor location.
  13860. !#zh 设置当前鼠标位置。
  13861. @param x x
  13862. @param y y
  13863. */
  13864. setLocation(x: number, y: number): void;
  13865. /**
  13866. !#en Returns cursor location.
  13867. !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。
  13868. */
  13869. getLocation(): Vec2;
  13870. /**
  13871. !#en Returns the current cursor location in screen coordinates.
  13872. !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
  13873. */
  13874. getLocationInView(): Vec2;
  13875. /**
  13876. !#en Returns the previous touch location.
  13877. !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。
  13878. */
  13879. getPreviousLocation(): Vec2;
  13880. /**
  13881. !#en Returns the delta distance from the previous location to current location.
  13882. !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  13883. */
  13884. getDelta(): Vec2;
  13885. /**
  13886. !#en Returns the X axis delta distance from the previous location to current location.
  13887. !#zh 获取鼠标距离上一次事件移动的 X 轴距离。
  13888. */
  13889. getDeltaX(): number;
  13890. /**
  13891. !#en Returns the Y axis delta distance from the previous location to current location.
  13892. !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。
  13893. */
  13894. getDeltaY(): number;
  13895. /**
  13896. !#en Sets mouse button.
  13897. !#zh 设置鼠标按键。
  13898. @param button button
  13899. */
  13900. setButton(button: number): void;
  13901. /**
  13902. !#en Returns mouse button.
  13903. !#zh 获取鼠标按键。
  13904. */
  13905. getButton(): number;
  13906. /**
  13907. !#en Returns location X axis data.
  13908. !#zh 获取鼠标当前位置 X 轴。
  13909. */
  13910. getLocationX(): number;
  13911. /**
  13912. !#en Returns location Y axis data.
  13913. !#zh 获取鼠标当前位置 Y 轴。
  13914. */
  13915. getLocationY(): number;
  13916. /** !#en The none event code of mouse event.
  13917. !#zh 无。 */
  13918. static NONE: number;
  13919. /** !#en The event type code of mouse down event.
  13920. !#zh 鼠标按下事件。 */
  13921. static DOWN: number;
  13922. /** !#en The event type code of mouse up event.
  13923. !#zh 鼠标按下后释放事件。 */
  13924. static UP: number;
  13925. /** !#en The event type code of mouse move event.
  13926. !#zh 鼠标移动事件。 */
  13927. static MOVE: number;
  13928. /** !#en The event type code of mouse scroll event.
  13929. !#zh 鼠标滚轮事件。 */
  13930. static SCROLL: number;
  13931. /** !#en The tag of Mouse left button.
  13932. !#zh 鼠标左键的标签。 */
  13933. static BUTTON_LEFT: number;
  13934. /** !#en The tag of Mouse right button (The right button number is 2 on browser).
  13935. !#zh 鼠标右键的标签。 */
  13936. static BUTTON_RIGHT: number;
  13937. /** !#en The tag of Mouse middle button (The right button number is 1 on browser).
  13938. !#zh 鼠标中键的标签。 */
  13939. static BUTTON_MIDDLE: number;
  13940. /** !#en The tag of Mouse button 4.
  13941. !#zh 鼠标按键 4 的标签。 */
  13942. static BUTTON_4: number;
  13943. /** !#en The tag of Mouse button 5.
  13944. !#zh 鼠标按键 5 的标签。 */
  13945. static BUTTON_5: number;
  13946. /** !#en The tag of Mouse button 6.
  13947. !#zh 鼠标按键 6 的标签。 */
  13948. static BUTTON_6: number;
  13949. /** !#en The tag of Mouse button 7.
  13950. !#zh 鼠标按键 7 的标签。 */
  13951. static BUTTON_7: number;
  13952. /** !#en The tag of Mouse button 8.
  13953. !#zh 鼠标按键 8 的标签。 */
  13954. static BUTTON_8: number;
  13955. }
  13956. }
  13957. /****************************************************
  13958. * Event
  13959. *****************************************************/
  13960. export module Event {
  13961. /** !#en The touch event
  13962. !#zh 触摸事件 */
  13963. export class EventTouch extends Event {
  13964. /**
  13965. @param touchArr The array of the touches
  13966. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  13967. */
  13968. constructor(touchArr: any[], bubbles: boolean);
  13969. /** !#en The current touch object
  13970. !#zh 当前触点对象 */
  13971. touch: Touch;
  13972. /**
  13973. !#en Returns event code.
  13974. !#zh 获取事件类型。
  13975. */
  13976. getEventCode(): number;
  13977. /**
  13978. !#en Returns touches of event.
  13979. !#zh 获取触摸点的列表。
  13980. */
  13981. getTouches(): any[];
  13982. /**
  13983. !#en Sets touch location.
  13984. !#zh 设置当前触点位置
  13985. @param x x
  13986. @param y y
  13987. */
  13988. setLocation(x: number, y: number): void;
  13989. /**
  13990. !#en Returns touch location.
  13991. !#zh 获取触点位置。
  13992. */
  13993. getLocation(): Vec2;
  13994. /**
  13995. !#en Returns the current touch location in screen coordinates.
  13996. !#zh 获取当前触点在游戏窗口中的位置。
  13997. */
  13998. getLocationInView(): Vec2;
  13999. /**
  14000. !#en Returns the previous touch location.
  14001. !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
  14002. */
  14003. getPreviousLocation(): Vec2;
  14004. /**
  14005. !#en Returns the start touch location.
  14006. !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。
  14007. */
  14008. getStartLocation(): Vec2;
  14009. /**
  14010. !#en Returns the id of cc.Touch.
  14011. !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
  14012. */
  14013. getID(): number;
  14014. /**
  14015. !#en Returns the delta distance from the previous location to current location.
  14016. !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  14017. */
  14018. getDelta(): Vec2;
  14019. /**
  14020. !#en Returns the X axis delta distance from the previous location to current location.
  14021. !#zh 获取触点距离上一次事件移动的 x 轴距离。
  14022. */
  14023. getDeltaX(): number;
  14024. /**
  14025. !#en Returns the Y axis delta distance from the previous location to current location.
  14026. !#zh 获取触点距离上一次事件移动的 y 轴距离。
  14027. */
  14028. getDeltaY(): number;
  14029. /**
  14030. !#en Returns location X axis data.
  14031. !#zh 获取当前触点 X 轴位置。
  14032. */
  14033. getLocationX(): number;
  14034. /**
  14035. !#en Returns location Y axis data.
  14036. !#zh 获取当前触点 Y 轴位置。
  14037. */
  14038. getLocationY(): number;
  14039. }
  14040. }
  14041. /****************************************************
  14042. * Event
  14043. *****************************************************/
  14044. export module Event {
  14045. /** !#en The acceleration event
  14046. !#zh 加速度事件 */
  14047. export class EventAcceleration extends Event {
  14048. }
  14049. }
  14050. /****************************************************
  14051. * Event
  14052. *****************************************************/
  14053. export module Event {
  14054. /** !#en The keyboard event
  14055. !#zh 键盘事件 */
  14056. export class EventKeyboard extends Event {
  14057. }
  14058. }
  14059. /****************************************************
  14060. * Pipeline
  14061. *****************************************************/
  14062. export module Pipeline {
  14063. /** The downloader pipe, it can download several types of files:
  14064. 1. Text
  14065. 2. Image
  14066. 3. Script
  14067. 4. Audio
  14068. 5. Assets
  14069. All unknown type will be downloaded as plain text.
  14070. You can pass custom supported types in the constructor. */
  14071. export class Downloader {
  14072. /**
  14073. Constructor of Downloader, you can pass custom supported types.
  14074. @param extMap Custom supported types with corresponded handler
  14075. @example
  14076. ```js
  14077. var downloader = new Downloader({
  14078. // This will match all url with `.scene` extension or all url with `scene` type
  14079. 'scene' : function (url, callback) {}
  14080. });
  14081. ```
  14082. */
  14083. constructor(extMap: any);
  14084. /**
  14085. Add custom supported types handler or modify existing type handler.
  14086. @param extMap Custom supported types with corresponded handler
  14087. */
  14088. addHandlers(extMap: any): void;
  14089. }
  14090. }
  14091. /****************************************************
  14092. * Pipeline
  14093. *****************************************************/
  14094. export module Pipeline {
  14095. /** The loader pipe, it can load several types of files:
  14096. 1. Images
  14097. 2. JSON
  14098. 3. Plist
  14099. 4. Audio
  14100. 5. Font
  14101. 6. Cocos Creator scene
  14102. It will not interfere with items of unknown type.
  14103. You can pass custom supported types in the constructor. */
  14104. export class Loader {
  14105. /**
  14106. Constructor of Loader, you can pass custom supported types.
  14107. @param extMap Custom supported types with corresponded handler
  14108. @example
  14109. ```js
  14110. var loader = new Loader({
  14111. // This will match all url with `.scene` extension or all url with `scene` type
  14112. 'scene' : function (url, callback) {}
  14113. });
  14114. ```
  14115. */
  14116. constructor(extMap: any);
  14117. /**
  14118. Add custom supported types handler or modify existing type handler.
  14119. @param extMap Custom supported types with corresponded handler
  14120. */
  14121. addHandlers(extMap: any): void;
  14122. }
  14123. }
  14124. /****************************************************
  14125. * LoadingItems
  14126. *****************************************************/
  14127. export module LoadingItems {
  14128. /** !#en The item states of the LoadingItems, its value could be LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR
  14129. !#zh LoadingItems 队列中的加载项状态,状态的值可能是 LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR */
  14130. export enum ItemState {
  14131. WORKING = 0,
  14132. COMPLETET = 0,
  14133. ERROR = 0,
  14134. }
  14135. }
  14136. /****************************************************
  14137. * Texture2D
  14138. *****************************************************/
  14139. export module Texture2D {
  14140. /** The texture pixel format, default value is RGBA8888 */
  14141. export enum PixelFormat {
  14142. RGB565 = 0,
  14143. RGB5A1 = 0,
  14144. RGBA4444 = 0,
  14145. RGB888 = 0,
  14146. RGBA8888 = 0,
  14147. A8 = 0,
  14148. I8 = 0,
  14149. AI88 = 0,
  14150. }
  14151. }
  14152. /****************************************************
  14153. * Texture2D
  14154. *****************************************************/
  14155. export module Texture2D {
  14156. /** The texture wrap mode */
  14157. export enum WrapMode {
  14158. REPEAT = 0,
  14159. CLAMP_TO_EDGE = 0,
  14160. MIRRORED_REPEAT = 0,
  14161. }
  14162. }
  14163. /****************************************************
  14164. * Texture2D
  14165. *****************************************************/
  14166. export module Texture2D {
  14167. /** The texture filter mode */
  14168. export enum Filter {
  14169. LINEAR = 0,
  14170. NEAREST = 0,
  14171. }
  14172. }
  14173. }
  14174. /** !#en
  14175. 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.
  14176. !#zh
  14177. AnySDK 为 CP 提供一套第三方 SDK 接入解决方案,整个接入过程,不改变任何 SDK 的功能、特性、参数等,对于最终玩家而言是完全透明无感知的。
  14178. 目的是让 CP 商能有更多时间更专注于游戏本身的品质,所有 SDK 的接入工作统统交给我们吧。第三方 SDK 包括了渠道SDK、用户系统、支付系统、广告系统、统计系统、分享系统等等。 */
  14179. declare module anysdk {
  14180. /** !#en
  14181. agent manager of plugin
  14182. !#zh
  14183. 插件管理对象 */
  14184. export var agentManager: anysdk.AgentManager;
  14185. /** !#en
  14186. agent manager of plugin
  14187. !#zh
  14188. 插件管理类 */
  14189. export class AgentManager {
  14190. /**
  14191. !#en
  14192. AppKey appSecret and privateKey are the only three parameters generated
  14193. after the packing tool client finishes creating the game.
  14194. The oauthLoginServer parameter is the API address provided by the game service
  14195. to login verification
  14196. !#zh
  14197. appKey、appSecret、privateKey是通过 AnySDK 客户端工具创建游戏后生成的。
  14198. oauthLoginServer参数是游戏服务提供的用来做登陆验证转发的接口地址。
  14199. @param appKey appKey
  14200. @param appSecret appSecret
  14201. @param privateKey privateKey
  14202. @param oauthLoginServer oauthLoginServer
  14203. */
  14204. init(appKey: string, appSecret: string, privateKey: string, oauthLoginServer: string): void;
  14205. /**
  14206. !#en
  14207. load all plugins, the operation includes SDK`s initialization
  14208. !#zh
  14209. 加载所有插件,该操作包含了 SDKs 初始化
  14210. @param callback callback
  14211. @param target The object to bind to.
  14212. */
  14213. loadAllPlugins(callback: Function, target: any): void;
  14214. /**
  14215. !#en
  14216. unload all plugins
  14217. !#zh
  14218. 卸载插件
  14219. */
  14220. unloadAllPlugins(): void;
  14221. /**
  14222. !#en
  14223. get user system plugin
  14224. !#zh
  14225. 获取用户系统插件
  14226. */
  14227. getUserPlugin(): anysdk.ProtocolUser;
  14228. /**
  14229. !#en
  14230. get IAP system plugins
  14231. !#zh
  14232. 获取支付系统插件
  14233. */
  14234. getIAPPlugins(): anysdk.ProtocolIAP[];
  14235. /**
  14236. !#en
  14237. get IAP system plugin
  14238. !#zh
  14239. 获取支付系统插件
  14240. */
  14241. getIAPPlugin(): anysdk.ProtocolIAP;
  14242. /**
  14243. !#en
  14244. get social system plugin
  14245. !#zh
  14246. 获取社交系统插件
  14247. */
  14248. getSocialPlugin(): anysdk.ProtocolSocial;
  14249. /**
  14250. !#en
  14251. get share system plugin
  14252. !#zh
  14253. 获取分享系统插件
  14254. */
  14255. getSharePlugin(): anysdk.ProtocolShare;
  14256. /**
  14257. !#en
  14258. get analytics system plugin
  14259. !#zh
  14260. 获取统计系统插件
  14261. */
  14262. getAnalyticsPlugin(): anysdk.ProtocolAnalytics;
  14263. /**
  14264. !#en
  14265. get ads system plugin
  14266. !#zh
  14267. 获取广告系统插件
  14268. */
  14269. getAdsPlugin(): anysdk.ProtocolAds;
  14270. /**
  14271. !#en
  14272. get push system plugin
  14273. !#zh
  14274. 获取推送系统插件
  14275. */
  14276. getPushPlugin(): anysdk.ProtocolPush;
  14277. /**
  14278. !#en
  14279. get REC system plugin
  14280. !#zh
  14281. 获取录屏系统插件
  14282. */
  14283. getRECPlugin(): anysdk.ProtocolREC;
  14284. /**
  14285. !#en
  14286. get crash system plugin
  14287. !#zh
  14288. 获取崩溃分析系统插件
  14289. */
  14290. getCrashPlugin(): anysdk.ProtocolCrash;
  14291. /**
  14292. !#en
  14293. get ad track system plugin
  14294. !#zh
  14295. 获取广告追踪系统插件
  14296. */
  14297. getAdTrackingPlugin(): anysdk.ProtocolAdTracking;
  14298. /**
  14299. !#en
  14300. get custom system plugin
  14301. !#zh
  14302. 获取自定义系统插件
  14303. */
  14304. getCustomPlugin(): anysdk.ProtocolCustom;
  14305. /**
  14306. !#en
  14307. get custom parameter
  14308. !#zh
  14309. 获取自定义参数
  14310. */
  14311. getCustomParam(): string;
  14312. /**
  14313. !#en
  14314. get channel id
  14315. !#zh
  14316. 获取渠道唯一表示符
  14317. */
  14318. getChannelId(): string;
  14319. /**
  14320. !#en
  14321. get status of analytics
  14322. !#zh
  14323. 获取统计状态
  14324. */
  14325. isAnaylticsEnabled(): boolean;
  14326. /**
  14327. !#en
  14328. set whether to analytics
  14329. !#zh
  14330. 设置是否统计
  14331. @param enabled enabled
  14332. */
  14333. setIsAnaylticsEnabled(enabled: boolean): void;
  14334. /**
  14335. !#en
  14336. destory instance
  14337. !#zh
  14338. 销毁单例
  14339. */
  14340. static end(): void;
  14341. /**
  14342. !#en
  14343. get instance
  14344. !#zh
  14345. 获取单例
  14346. */
  14347. static getInstance(): anysdk.AgentManager;
  14348. }
  14349. /** !#en
  14350. plugin protocol
  14351. !#zh
  14352. 插件协议 */
  14353. export class PluginProtocol {
  14354. /**
  14355. !#en
  14356. Check whether the function is supported
  14357. !#zh
  14358. 判断函数是否支持
  14359. @param functionName functionName
  14360. */
  14361. isFunctionSupported(functionName: string): boolean;
  14362. /**
  14363. !#en
  14364. get plugin name
  14365. !#zh
  14366. 获取插件名称
  14367. */
  14368. getPluginName(): string;
  14369. /**
  14370. !#en
  14371. get plugin version
  14372. !#zh
  14373. 获取插件版本
  14374. */
  14375. getPluginVersion(): string;
  14376. /**
  14377. !#en
  14378. get SDK version
  14379. !#zh
  14380. 获取 SDK 版本
  14381. */
  14382. getSDKVersion(): string;
  14383. /**
  14384. !#en
  14385. void methods for reflections with parameter
  14386. !#zh
  14387. 反射调用带参数的void方法
  14388. @param funName funName
  14389. @param args optional arguments
  14390. */
  14391. callFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): void;
  14392. /**
  14393. !#en
  14394. String methods for reflections with parameter
  14395. !#zh
  14396. 反射调用带参数的 String 方法
  14397. @param funName funName
  14398. @param args optional arguments
  14399. */
  14400. callStringFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): string;
  14401. /**
  14402. !#en
  14403. int methods for reflections with parameter
  14404. !#zh
  14405. 反射调用带参数的 Int 方法
  14406. @param funName funName
  14407. @param args optional arguments
  14408. */
  14409. callIntFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): number;
  14410. /**
  14411. !#en
  14412. boolean methods for reflections with parameter
  14413. !#zh
  14414. 反射调用带参数的 boolean 方法
  14415. @param funName funName
  14416. @param args optional arguments
  14417. */
  14418. callBoolFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): boolean;
  14419. /**
  14420. !#en
  14421. float methods for reflections with parameter
  14422. !#zh
  14423. 反射调用带参数的 float 方法
  14424. @param funName funName
  14425. @param args optional arguments
  14426. */
  14427. callFloatFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): number;
  14428. }
  14429. /** !#en
  14430. user protocol
  14431. !#zh
  14432. 用户系统协议接口 */
  14433. export class ProtocolUser extends PluginProtocol {
  14434. /**
  14435. !#en
  14436. login interface
  14437. !#zh
  14438. 登录接口
  14439. @param args optional arguments
  14440. */
  14441. login(...args: string|any[]): void;
  14442. /**
  14443. !#en
  14444. get status of login
  14445. !#zh
  14446. 获取登录状态
  14447. */
  14448. isLogined(): boolean;
  14449. /**
  14450. !#en
  14451. get user ID
  14452. !#zh
  14453. 获取用户唯一标示符
  14454. */
  14455. getUserID(): string;
  14456. /**
  14457. !#en
  14458. get plugin ID
  14459. !#zh
  14460. 获取插件ID
  14461. */
  14462. getPluginId(): string;
  14463. /**
  14464. !#en
  14465. set listener
  14466. !#zh
  14467. 设置用户系统的监听
  14468. @param listener listener
  14469. @param target target
  14470. */
  14471. setListener(listener: Function, target: any): void;
  14472. /**
  14473. !#en
  14474. get listener
  14475. !#zh
  14476. 获取用户系统的监听
  14477. */
  14478. getListener(): Function;
  14479. /**
  14480. !#en
  14481. logout
  14482. Before to invoke, you need to verdict whether this properties existed
  14483. !#zh
  14484. 登出,调用前需要判断属性是否存在
  14485. */
  14486. logout(): void;
  14487. /**
  14488. !#en
  14489. show toolbar
  14490. Before to invoke, you need to verdict whether this properties existed
  14491. !#zh
  14492. 显示悬浮窗,调用前需要判断属性是否存在
  14493. @param place place
  14494. */
  14495. showToolBar(place: anysdk.ToolBarPlace): void;
  14496. /**
  14497. !#en
  14498. hide toolbar
  14499. Before to invoke, you need to verdict whether this properties existed
  14500. !#zh
  14501. 隐藏悬浮窗,调用前需要判断属性是否存在
  14502. */
  14503. hideToolBar(): void;
  14504. /**
  14505. !#en
  14506. enter platform
  14507. Before to invoke, you need to verdict whether this properties existed
  14508. !#zh
  14509. 显示平台中心,调用前需要判断属性是否存在
  14510. */
  14511. enterPlatform(): void;
  14512. /**
  14513. !#en
  14514. show exit page
  14515. Before to invoke, you need to verdict whether this properties existed
  14516. !#zh
  14517. 显示退出界面,调用前需要判断属性是否存在
  14518. */
  14519. exit(): void;
  14520. /**
  14521. !#en
  14522. show pause page
  14523. Before to invoke, you need to verdict whether this properties existed
  14524. !#zh
  14525. 显示暂停界面,调用前需要判断属性是否存在
  14526. */
  14527. pause(): void;
  14528. /**
  14529. !#en
  14530. Real-name registration
  14531. Before to invoke, you need to verdict whether this properties existed
  14532. !#zh
  14533. 实名注册,调用前需要判断属性是否存在
  14534. */
  14535. realNameRegister(): void;
  14536. /**
  14537. !#en
  14538. Anti-addiction query
  14539. Before to invoke, you need to verdict whether this properties existed
  14540. !#zh
  14541. 防沉迷查询,调用前需要判断属性是否存在
  14542. */
  14543. antiAddictionQuery(): void;
  14544. /**
  14545. !#en
  14546. submit game role information
  14547. Before to invoke, you need to verdict whether this properties existed
  14548. !#zh
  14549. 提交角色信息,调用前需要判断属性是否存在
  14550. @param data data
  14551. */
  14552. submitLoginGameRole(data: any): void;
  14553. /**
  14554. !#en
  14555. get user information
  14556. Before to invoke, you need to verdict whether this properties existed
  14557. !#zh
  14558. 获取用户信息,调用前需要判断属性是否存在
  14559. @param info info
  14560. */
  14561. getUserInfo(info: any): void;
  14562. /**
  14563. !#en
  14564. set login type
  14565. Before to invoke, you need to verdict whether this properties existed
  14566. !#zh
  14567. 设置登录类型,调用前需要判断属性是否存在
  14568. @param info info
  14569. */
  14570. getAvailableLoginType(info: any): void;
  14571. /**
  14572. !#en
  14573. set login type
  14574. Before to invoke, you need to verdict whether this properties existed
  14575. !#zh
  14576. 设置登录类型,调用前需要判断属性是否存在
  14577. @param loginType loginType
  14578. */
  14579. setLoginType(loginType: string): void;
  14580. /**
  14581. !#en
  14582. send to desktop
  14583. Before to invoke, you need to verdict whether this properties existed
  14584. !#zh
  14585. 发送到桌面,调用前需要判断属性是否存在
  14586. */
  14587. sendToDesktop(): void;
  14588. /**
  14589. !#en
  14590. open bbs
  14591. Before to invoke, you need to verdict whether this properties existed
  14592. !#zh
  14593. 打开论坛,调用前需要判断属性是否存在
  14594. */
  14595. openBBS(): void;
  14596. }
  14597. /** !#en
  14598. IAP protocol
  14599. !#zh
  14600. 支付系统协议接口 */
  14601. export class ProtocolIAP extends PluginProtocol {
  14602. /**
  14603. !#en
  14604. pay interface
  14605. !#zh
  14606. 支付接口
  14607. @param info Type:map
  14608. */
  14609. payForProduct(info: any): void;
  14610. /**
  14611. !#en
  14612. get order ID
  14613. !#zh
  14614. 获取订单ID
  14615. */
  14616. getOrderId(): string;
  14617. /**
  14618. !#en
  14619. reset the pay status
  14620. !#zh
  14621. 重置支付状态
  14622. */
  14623. static resetPayState(): void;
  14624. /**
  14625. !#en
  14626. get plugin ID
  14627. !#zh
  14628. 获取插件ID
  14629. */
  14630. getPluginId(): string;
  14631. /**
  14632. !#en
  14633. set listener
  14634. !#zh
  14635. 设置支付系统的监听
  14636. @param listener listener
  14637. @param target target
  14638. */
  14639. setListener(listener: Function, target: any): void;
  14640. /**
  14641. !#en
  14642. get listener
  14643. !#zh
  14644. 获取支付系统的监听
  14645. */
  14646. getListener(): Function;
  14647. }
  14648. /** !#en
  14649. analytics protocol
  14650. !#zh
  14651. 统计系统协议接口 */
  14652. export class ProtocolAnalytics extends PluginProtocol {
  14653. /**
  14654. !#en
  14655. Start a new session.
  14656. !#zh
  14657. 启动会话
  14658. */
  14659. startSession(): void;
  14660. /**
  14661. !#en
  14662. Stop a session.
  14663. !#zh
  14664. 关闭会话
  14665. */
  14666. stopSession(): void;
  14667. /**
  14668. !#en
  14669. Set the timeout for expiring a session.
  14670. !#zh
  14671. 设置会话超时时间
  14672. @param millis Type: long
  14673. */
  14674. setSessionContinueMillis(millis: number): void;
  14675. /**
  14676. !#en
  14677. log an error
  14678. !#zh
  14679. 捕捉异常
  14680. @param errorId errorId
  14681. @param message message
  14682. */
  14683. logError(errorId: string, message: string): void;
  14684. /**
  14685. !#en
  14686. log an event.
  14687. !#zh
  14688. 捕捉事件
  14689. @param errorId errorId
  14690. @param args optional arguments Type: map
  14691. */
  14692. logEvent(errorId: string, ...args: any[]): void;
  14693. /**
  14694. !#en
  14695. Track an event begin.
  14696. !#zh
  14697. 统计事件开始
  14698. @param eventId eventId
  14699. */
  14700. logTimedEventBegin(eventId: string): void;
  14701. /**
  14702. !#en
  14703. Track an event end.
  14704. !#zh
  14705. 统计事件结束
  14706. @param eventId eventId
  14707. */
  14708. logTimedEventEnd(eventId: string): void;
  14709. /**
  14710. !#en
  14711. set Whether to catch uncaught exceptions to server.
  14712. !#zh
  14713. 设置是否开启自动异常捕捉
  14714. @param enabled enabled
  14715. */
  14716. setCaptureUncaughtException(enabled: boolean): void;
  14717. /**
  14718. !#en
  14719. analytics account information
  14720. !#zh
  14721. 统计玩家帐户信息
  14722. @param paramMap Type: map
  14723. */
  14724. setAccount(paramMap: any): void;
  14725. /**
  14726. !#en
  14727. track user to request payment
  14728. !#zh
  14729. 跟踪用户支付请求
  14730. @param paramMap Type: map
  14731. */
  14732. onChargeRequest(paramMap: any): void;
  14733. /**
  14734. !#en
  14735. track Successful payment
  14736. !#zh
  14737. 追踪用户支付成功
  14738. @param orderID orderID
  14739. */
  14740. onChargeSuccess(orderID: string): void;
  14741. /**
  14742. !#en
  14743. track failed payment
  14744. !#zh
  14745. 追踪用户支付失败
  14746. @param paramMap Type: map
  14747. */
  14748. onChargeFail(paramMap: any): void;
  14749. /**
  14750. !#en
  14751. track Successful payment
  14752. !#zh
  14753. 统计玩家支付成功
  14754. @param paramMap Type: map
  14755. */
  14756. onChargeOnlySuccess(paramMap: any): void;
  14757. /**
  14758. !#en
  14759. track user purchase
  14760. !#zh
  14761. 统计玩家消费
  14762. @param paramMap Type: map
  14763. */
  14764. onPurchase(paramMap: any): void;
  14765. /**
  14766. !#en
  14767. track user to use goods
  14768. !#zh
  14769. 统计玩家使用道具
  14770. @param paramMap Type: map
  14771. */
  14772. onUse(paramMap: any): void;
  14773. /**
  14774. !#en
  14775. track user to reward goods
  14776. !#zh
  14777. 统计玩家获取奖励
  14778. @param paramMap Type: map
  14779. */
  14780. onReward(paramMap: any): void;
  14781. /**
  14782. !#en
  14783. start level
  14784. !#zh
  14785. 开始关卡
  14786. @param paramMap Type: map
  14787. */
  14788. startLevel(paramMap: any): void;
  14789. /**
  14790. !#en
  14791. finish level
  14792. !#zh
  14793. 结束关卡
  14794. @param levelID levelID
  14795. */
  14796. finishLevel(levelID: string): void;
  14797. /**
  14798. !#en
  14799. failed level
  14800. !#zh
  14801. 关卡失败
  14802. @param paramMap Type: map
  14803. */
  14804. failLevel(paramMap: any): void;
  14805. /**
  14806. !#en
  14807. start task
  14808. !#zh
  14809. 开始任务
  14810. @param paramMap Type: map
  14811. */
  14812. startTask(paramMap: any): void;
  14813. /**
  14814. !#en
  14815. finish task
  14816. !#zh
  14817. 完成任务
  14818. @param taskID taskID
  14819. */
  14820. finishTask(taskID: string): void;
  14821. /**
  14822. !#en
  14823. failed task
  14824. !#zh
  14825. 任务失败
  14826. @param paramMap Type: map
  14827. */
  14828. failTask(paramMap: any): void;
  14829. }
  14830. /** !#en
  14831. share protocol
  14832. !#zh
  14833. 分享系统协议接口 */
  14834. export class ProtocolShare extends PluginProtocol {
  14835. /**
  14836. !#en
  14837. share interface
  14838. !#zh
  14839. 分享
  14840. @param info Type: map
  14841. */
  14842. share(info: any): void;
  14843. /**
  14844. !#en
  14845. set listener
  14846. !#zh
  14847. 设置分享系统的监听
  14848. @param listener listener
  14849. @param target target
  14850. */
  14851. setListener(listener: Function, target: any): void;
  14852. /**
  14853. !#en
  14854. get listener
  14855. !#zh
  14856. 获取分享系统的监听
  14857. */
  14858. getListener(): Function;
  14859. }
  14860. /** !#en
  14861. ads protocol
  14862. !#zh
  14863. 广告系统协议接口 */
  14864. export class ProtocolAds extends PluginProtocol {
  14865. /**
  14866. !#en
  14867. hide ads view
  14868. !#zh
  14869. 隐藏广告
  14870. @param adstype adstype
  14871. @param idx idx
  14872. */
  14873. hideAds(adstype: anysdk.AdsType, idx: number): void;
  14874. /**
  14875. !#en
  14876. preload ads view
  14877. !#zh
  14878. 预加载广告
  14879. @param adstype adstype
  14880. @param idx idx
  14881. */
  14882. preloadAds(adstype: anysdk.AdsType, idx: number): void;
  14883. /**
  14884. !#en
  14885. query points
  14886. !#zh
  14887. 查询分数
  14888. */
  14889. queryPoints(): number;
  14890. /**
  14891. !#en
  14892. get whether the ads type is supported
  14893. !#zh
  14894. 获取广告类型是否支持
  14895. @param arg0 arg0
  14896. */
  14897. isAdTypeSupported(arg0: anysdk.AdsType): boolean;
  14898. /**
  14899. !#en
  14900. spend point
  14901. !#zh
  14902. 消费分数
  14903. @param points points
  14904. */
  14905. spendPoints(points: number): void;
  14906. /**
  14907. !#en
  14908. set listener
  14909. !#zh
  14910. 设置广告系统的监听
  14911. @param listener listener
  14912. @param target target
  14913. */
  14914. setListener(listener: Function, target: any): void;
  14915. /**
  14916. !#en
  14917. get listener
  14918. !#zh
  14919. 获取广告系统的监听
  14920. */
  14921. getListener(): Function;
  14922. }
  14923. /** !#en
  14924. social protocol
  14925. !#zh
  14926. 社交系统协议接口 */
  14927. export class ProtocolSocial extends PluginProtocol {
  14928. /**
  14929. !#en
  14930. sign in
  14931. !#zh
  14932. 登录
  14933. */
  14934. signIn(): void;
  14935. /**
  14936. !#en
  14937. sign out
  14938. !#zh
  14939. 登出
  14940. */
  14941. signOut(): void;
  14942. /**
  14943. !#en
  14944. submit score
  14945. !#zh
  14946. 提交分数
  14947. @param leadboardID leadboardID
  14948. @param score Type: long
  14949. */
  14950. submitScore(leadboardID: string, score: number): void;
  14951. /**
  14952. !#en
  14953. show the id of Leaderboard page
  14954. !#zh
  14955. 根据唯一标识符显示排行榜
  14956. @param leaderboardID leaderboardID
  14957. */
  14958. showLeaderboard(leaderboardID: string): void;
  14959. /**
  14960. !#en
  14961. show the page of achievements
  14962. !#zh
  14963. 显示成就榜
  14964. */
  14965. showAchievements(): void;
  14966. /**
  14967. !#en
  14968. unlock achievement
  14969. !#zh
  14970. 解锁成就
  14971. @param info Type: map
  14972. */
  14973. share(info: any): void;
  14974. /**
  14975. !#en
  14976. set listener
  14977. !#zh
  14978. 设置社交系统的监听
  14979. @param listener listener
  14980. @param target target
  14981. */
  14982. setListener(listener: Function, target: any): void;
  14983. /**
  14984. !#en
  14985. get listener
  14986. !#zh
  14987. 获取社交系统的监听
  14988. */
  14989. getListener(): Function;
  14990. /**
  14991. !#en
  14992. get friends info
  14993. Before to invoke, you need to verdict whether this properties existed
  14994. !#zh
  14995. 获取好友信息,调用前需要判断属性是否存在
  14996. */
  14997. pauseRecording(): void;
  14998. /**
  14999. !#en
  15000. interact
  15001. Before to invoke, you need to verdict whether this properties existed
  15002. !#zh
  15003. 订阅,调用前需要判断属性是否存在
  15004. */
  15005. interact(): void;
  15006. /**
  15007. !#en
  15008. subscribe
  15009. Before to invoke, you need to verdict whether this properties existed
  15010. !#zh
  15011. 关注,调用前需要判断属性是否存在
  15012. */
  15013. subscribe(): void;
  15014. }
  15015. /** !#en
  15016. push protocol
  15017. !#zh
  15018. 推送系统协议接口 */
  15019. export class ProtocolPush extends PluginProtocol {
  15020. /**
  15021. !#en
  15022. start Push services
  15023. !#zh
  15024. 启动推送服务
  15025. */
  15026. startPush(): void;
  15027. /**
  15028. !#en
  15029. close Push services
  15030. !#zh
  15031. 暂停推送服务
  15032. */
  15033. closePush(): void;
  15034. /**
  15035. !#en
  15036. delete alias
  15037. !#zh
  15038. 删除别名
  15039. @param alias alias
  15040. */
  15041. delAlias(alias: string): void;
  15042. /**
  15043. !#en
  15044. set alias
  15045. !#zh
  15046. 设置别名
  15047. @param alias alias
  15048. */
  15049. setAlias(alias: string): void;
  15050. /**
  15051. !#en
  15052. delete tags
  15053. !#zh
  15054. 删除标签
  15055. @param tags Type: list
  15056. */
  15057. delTags(tags: any): void;
  15058. /**
  15059. !#en
  15060. set tags
  15061. !#zh
  15062. 设置标签
  15063. @param tags Type: list
  15064. */
  15065. setTags(tags: any): void;
  15066. /**
  15067. !#en
  15068. set listener
  15069. !#zh
  15070. 设置推送系统的监听
  15071. @param listener listener
  15072. @param target target
  15073. */
  15074. setListener(listener: Function, target: any): void;
  15075. /**
  15076. !#en
  15077. get listener
  15078. !#zh
  15079. 获取推送系统的监听
  15080. */
  15081. getListener(): Function;
  15082. }
  15083. /** !#en
  15084. crash protocol
  15085. !#zh
  15086. 崩溃分析系统协议接口 */
  15087. export class ProtocolCrash extends PluginProtocol {
  15088. /**
  15089. !#en
  15090. set user identifier
  15091. !#zh
  15092. 统计用户唯一标识符
  15093. @param identifier identifier
  15094. */
  15095. setUserIdentifier(identifier: string): void;
  15096. /**
  15097. !#en
  15098. The uploader captured in exception information
  15099. !#zh
  15100. 上报异常信息
  15101. @param message message
  15102. @param exception exception
  15103. */
  15104. reportException(message: string, exception: string): void;
  15105. /**
  15106. !#en
  15107. customize logging
  15108. !#zh
  15109. 自定义日志记录
  15110. @param breadcrumb breadcrumb
  15111. */
  15112. leaveBreadcrumb(breadcrumb: string): void;
  15113. }
  15114. /** !#en
  15115. REC protocol
  15116. !#zh
  15117. 录屏系统协议接口 */
  15118. export class ProtocolREC extends PluginProtocol {
  15119. /**
  15120. !#en
  15121. share video
  15122. !#zh
  15123. 分享视频
  15124. @param info Type: map
  15125. */
  15126. share(info: any): void;
  15127. /**
  15128. !#en
  15129. Start to record video
  15130. !#zh
  15131. 开始录制视频
  15132. */
  15133. startRecording(): void;
  15134. /**
  15135. !#en
  15136. Start to record video
  15137. !#zh
  15138. 结束录制视频
  15139. */
  15140. stopRecording(): void;
  15141. /**
  15142. !#en
  15143. set listener
  15144. !#zh
  15145. 设置录屏系统的监听
  15146. @param listener listener
  15147. @param target target
  15148. */
  15149. setListener(listener: Function, target: any): void;
  15150. /**
  15151. !#en
  15152. get listener
  15153. !#zh
  15154. 获取录屏系统的监听
  15155. */
  15156. getListener(): Function;
  15157. /**
  15158. !#en
  15159. pause to record video
  15160. Before to invoke, you need to verdict whether this properties existed
  15161. !#zh
  15162. 暂停录制视频,调用前需要判断属性是否存在
  15163. */
  15164. pauseRecording(): void;
  15165. /**
  15166. !#en
  15167. resume to record video
  15168. Before to invoke, you need to verdict whether this properties existed
  15169. !#zh
  15170. 恢复录制视频,调用前需要判断属性是否存在
  15171. */
  15172. resumeRecording(): void;
  15173. /**
  15174. !#en
  15175. get whether the device is isAvailable
  15176. Before to invoke, you need to verdict whether this properties existed
  15177. !#zh
  15178. 获取设备是否可用,调用前需要判断属性是否存在
  15179. */
  15180. isAvailable(): boolean;
  15181. /**
  15182. !#en
  15183. get status of recording
  15184. Before to invoke, you need to verdict whether this properties existed
  15185. !#zh
  15186. 获取录制状态,调用前需要判断属性是否存在
  15187. */
  15188. isRecording(): boolean;
  15189. /**
  15190. !#en
  15191. show toolbar
  15192. Before to invoke, you need to verdict whether this properties existed
  15193. !#zh
  15194. 显示悬浮窗,调用前需要判断属性是否存在
  15195. */
  15196. showToolBar(): void;
  15197. /**
  15198. !#en
  15199. hide toolbar
  15200. Before to invoke, you need to verdict whether this properties existed
  15201. !#zh
  15202. 隐藏悬浮窗,调用前需要判断属性是否存在
  15203. */
  15204. hideToolBar(): void;
  15205. /**
  15206. !#en
  15207. show video center
  15208. Before to invoke, you need to verdict whether this properties existed
  15209. !#zh
  15210. 显示视频中心,调用前需要判断属性是否存在
  15211. */
  15212. showVideoCenter(): void;
  15213. /**
  15214. !#en
  15215. enter platform
  15216. Before to invoke, you need to verdict whether this properties existed
  15217. !#zh
  15218. 显示平台中心,调用前需要判断属性是否存在
  15219. */
  15220. enterPlatform(): void;
  15221. /**
  15222. !#en
  15223. Set the video data, it is recommended to check whether are recorded firstly
  15224. Before to invoke, you need to verdict whether this properties existed
  15225. !#zh
  15226. 设置视频相关数据,建议先检查是否是正在录制,调用前需要判断属性是否存在
  15227. @param info Type: map
  15228. */
  15229. setMetaData(info: any): void;
  15230. }
  15231. /** !#en
  15232. ad tracking protocol
  15233. !#zh
  15234. 广告追踪系统协议接口 */
  15235. export class ProtocolAdTracking extends PluginProtocol {
  15236. /**
  15237. !#en
  15238. Call this method if you want to track register events as happening during a section.
  15239. !#zh
  15240. 统计用户注册信息
  15241. @param productInfo Type: map
  15242. */
  15243. onPay(productInfo: any): void;
  15244. /**
  15245. !#en
  15246. Call this method if you want to track register events as happening during a section.
  15247. !#zh
  15248. 统计用户注册信息
  15249. @param userInfo Type: map
  15250. */
  15251. onLogin(userInfo: any): void;
  15252. /**
  15253. !#en
  15254. Call this method if you want to track register events as happening during a section.
  15255. !#zh
  15256. 统计用户注册信息
  15257. @param userId userId
  15258. */
  15259. onRegister(userId: string): void;
  15260. /**
  15261. !#en
  15262. Call this method if you want to track custom events with parameters as happening during a section.
  15263. !#zh
  15264. 统计自定义事件
  15265. @param eventId eventId
  15266. @param paramMap Type: map
  15267. */
  15268. trackEvent(eventId: string, paramMap: any): void;
  15269. /**
  15270. !#en
  15271. Call this method with parameters if you want to create role as happening during a section.
  15272. !#zh
  15273. 统计创建角色事件,调用前需要判断属性是否存在
  15274. @param userInfo Type: map
  15275. */
  15276. onCreateRole(userInfo: any): void;
  15277. /**
  15278. !#en
  15279. Call this method if you want to track levelup events with parameters as happening during a section.
  15280. Before to invoke, you need to verdict whether this properties existed
  15281. !#zh
  15282. 统计角色升级事件,调用前需要判断属性是否存在
  15283. @param info Type: map
  15284. */
  15285. onLevelUp(info: any): void;
  15286. /**
  15287. !#en
  15288. Invoke this method with parameters if you want to start to pay as happening during a section.
  15289. Before to invoke, you need to verdict whether this properties existed
  15290. !#zh
  15291. 统计开始充值事件,调用前需要判断属性是否存在
  15292. @param info Type: map
  15293. */
  15294. onStartToPay(info: any): void;
  15295. }
  15296. /** !#en
  15297. custom protocol
  15298. !#zh
  15299. 自定义系统协议接口 */
  15300. export class ProtocolCustom extends PluginProtocol {
  15301. /**
  15302. !#en
  15303. set listener
  15304. !#zh
  15305. 设置自定义系统的监听
  15306. @param listener listener
  15307. @param target target
  15308. */
  15309. setListener(listener: Function, target: any): void;
  15310. /**
  15311. !#en
  15312. get listener
  15313. !#zh
  15314. 获取自定义系统的监听
  15315. */
  15316. getListener(): Function;
  15317. }
  15318. /** !#en
  15319. Data structure class
  15320. !#zh
  15321. 数据结构类 */
  15322. export class PluginParam {
  15323. /**
  15324. !#en
  15325. create plugin parameters
  15326. !#zh
  15327. 创建对象
  15328. @param parameters parameters
  15329. */
  15330. static create(parameters: number|string|any): anysdk.PluginParam;
  15331. }
  15332. /** !#en The callback of user system
  15333. !#zh 用户系统回调 */
  15334. export enum UserActionResultCode {
  15335. kInitSuccess = 0,
  15336. kInitFail = 0,
  15337. kLoginSuccess = 0,
  15338. kLoginNetworkError = 0,
  15339. kLoginNoNeed = 0,
  15340. kLoginFail = 0,
  15341. kLoginCancel = 0,
  15342. kLogoutSuccess = 0,
  15343. kLogoutFail = 0,
  15344. kPlatformEnter = 0,
  15345. kPlatformBack = 0,
  15346. kPausePage = 0,
  15347. kExitPage = 0,
  15348. kAntiAddictionQuery = 0,
  15349. kRealNameRegister = 0,
  15350. kAccountSwitchSuccess = 0,
  15351. kAccountSwitchFail = 0,
  15352. kOpenShop = 0,
  15353. kAccountSwitchCancel = 0,
  15354. kUserExtension = 0,
  15355. kSendToDesktopSuccess = 0,
  15356. kSendToDesktopFail = 0,
  15357. kGetAvailableLoginTypeSuccess = 0,
  15358. kGetAvailableLoginTypeFail = 0,
  15359. kGetUserInfoSuccess = 0,
  15360. kGetUserInfoFail = 0,
  15361. kOpenBBSSuccess = 0,
  15362. kOpenBBSFail = 0,
  15363. }
  15364. /** !#en The toolbar position of user type
  15365. !#zh 用户系统悬浮窗位置 */
  15366. export enum ToolBarPlace {
  15367. kToolBarTopLeft = 0,
  15368. kToolBarTopRight = 0,
  15369. kToolBarMidLeft = 0,
  15370. kToolBarMidRight = 0,
  15371. kToolBarBottomLeft = 0,
  15372. kToolBarBottomRight = 0,
  15373. }
  15374. /** !#en The callback of requesting reStringge
  15375. !#zh 支付系统支付请求回调 */
  15376. export enum PayResultCode {
  15377. kPaySuccess = 0,
  15378. kPayFail = 0,
  15379. kPayCancel = 0,
  15380. kPayNetworkError = 0,
  15381. kPayProductionInforIncomplete = 0,
  15382. kPayInitSuccess = 0,
  15383. kPayInitFail = 0,
  15384. kPayNowPaying = 0,
  15385. kPayReStringgeSuccess = 0,
  15386. kPayExtension = 0,
  15387. kPayNeedLoginAgain = 0,
  15388. kRequestSuccess = 0,
  15389. kRequestFail = 0,
  15390. }
  15391. /** !#en The enum of account type
  15392. !#zh 统计系统的账号类型 */
  15393. export enum AccountType {
  15394. ANONYMOUS = 0,
  15395. REGISTED = 0,
  15396. SINA_WEIBO = 0,
  15397. TENCENT_WEIBO = 0,
  15398. QQ = 0,
  15399. ND91 = 0,
  15400. }
  15401. /** !#en The enum of account operation
  15402. !#zh 统计系统的账号操作 */
  15403. export enum AccountOperate {
  15404. LOGIN = 0,
  15405. LOGOUT = 0,
  15406. REGISTER = 0,
  15407. }
  15408. /** !#en The enum of gender
  15409. !#zh 统计系统的账号性别 */
  15410. export enum AccountGender {
  15411. MALE = 0,
  15412. FEMALE = 0,
  15413. UNKNOWN = 0,
  15414. }
  15415. /** !#en The enum of task type
  15416. !#zh 统计系统的任务类型 */
  15417. export enum TaskType {
  15418. GUIDE_LINE = 0,
  15419. MAIN_LINE = 0,
  15420. BRANCH_LINE = 0,
  15421. DAILY = 0,
  15422. ACTIVITY = 0,
  15423. OTHER = 0,
  15424. }
  15425. /** !#en The callback of share system
  15426. !#zh 分享系统回调 */
  15427. export enum ShareResultCode {
  15428. kShareSuccess = 0,
  15429. kShareFail = 0,
  15430. kShareCancel = 0,
  15431. kShareNetworkError = 0,
  15432. kShareExtension = 0,
  15433. }
  15434. /** !#en The callback of social system
  15435. !#zh 社交系统回调 */
  15436. export enum SocialRetCode {
  15437. kScoreSubmitSucceed = 0,
  15438. kScoreSubmitfail = 0,
  15439. kAchUnlockSucceed = 0,
  15440. kAchUnlockFail = 0,
  15441. kSocialSignInSucceed = 0,
  15442. kSocialSignInFail = 0,
  15443. kSocialSignOutSucceed = 0,
  15444. kSocialSignOutFail = 0,
  15445. kSocialGetGameFriends = 0,
  15446. kSocialExtensionCode = 0,
  15447. kSocialGetFriendsInfoSuccess = 0,
  15448. kSocialGetFriendsInfoFail = 0,
  15449. kSocialAlreadySubscription = 0,
  15450. kSocialNoSubscription = 0,
  15451. kSocialSubscriptionFail = 0,
  15452. }
  15453. /** !#en The callback of ads system
  15454. !#zh 广告系统回调 */
  15455. export enum AdsResultCode {
  15456. kAdsReceived = 0,
  15457. kAdsShown = 0,
  15458. kAdsDismissed = 0,
  15459. kPointsSpendSucceed = 0,
  15460. kPointsSpendFailed = 0,
  15461. kNetworkError = 0,
  15462. kUnknownError = 0,
  15463. kOfferWallOnPointsChanged = 0,
  15464. kRewardedVideoWithReward = 0,
  15465. kInAppPurchaseFinished = 0,
  15466. kAdsClicked = 0,
  15467. kAdsExtension = 0,
  15468. }
  15469. /** !#en The enum of ads position
  15470. !#zh 广告位置 */
  15471. export enum AdsPos {
  15472. kPosCenter = 0,
  15473. kPosTop = 0,
  15474. kPosTopLeft = 0,
  15475. kPosTopRight = 0,
  15476. kPosBottom = 0,
  15477. kPosBottomLeft = 0,
  15478. kPosBottomRight = 0,
  15479. }
  15480. /** !#en The enum of ads type
  15481. !#zh 广告类型 */
  15482. export enum AdsType {
  15483. AD_TYPE_BANNER = 0,
  15484. AD_TYPE_FULLSCREEN = 0,
  15485. AD_TYPE_MOREAPP = 0,
  15486. AD_TYPE_OFFERWALL = 0,
  15487. AD_TYPE_REWARDEDVIDEO = 0,
  15488. AD_TYPE_NATIVEEXPRESS = 0,
  15489. AD_TYPE_NATIVEADVANCED = 0,
  15490. }
  15491. /** !#en The callback of push system
  15492. !#zh 推送系统回调 */
  15493. export enum PushActionResultCode {
  15494. kPushReceiveMessage = 0,
  15495. kPushExtensionCode = 0,
  15496. }
  15497. /** !#en The callback of custom system
  15498. !#zh 自定义系统回调 */
  15499. export enum CustomResultCode {
  15500. kCustomExtension = 0,
  15501. }
  15502. /** !#en The callback of REC system
  15503. !#zh 录屏系统回调 */
  15504. export enum RECResultCode {
  15505. kRECInitSuccess = 0,
  15506. kRECInitFail = 0,
  15507. kRECStartRecording = 0,
  15508. kRECStopRecording = 0,
  15509. kRECPauseRecording = 0,
  15510. kRECResumeRecording = 0,
  15511. kRECEnterSDKPage = 0,
  15512. kRECQuitSDKPage = 0,
  15513. kRECShareSuccess = 0,
  15514. kRECShareFail = 0,
  15515. kRECExtension = 0,
  15516. }
  15517. }
  15518. /** !#en
  15519. The global main namespace of DragonBones, all classes, functions,
  15520. properties and constants of DragonBones are defined in this namespace
  15521. !#zh
  15522. DragonBones 的全局的命名空间,
  15523. 与 DragonBones 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */
  15524. declare module dragonBones {
  15525. /** !#en
  15526. The Armature Display of DragonBones <br/>
  15527. <br/>
  15528. (Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance,
  15529. which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
  15530. Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments.) <br/>
  15531. !#zh
  15532. DragonBones 骨骼动画 <br/>
  15533. <br/>
  15534. (Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态,
  15535. 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。<br/>
  15536. 多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。)<br/> */
  15537. export class ArmatureDisplay extends cc._RendererUnderSG {
  15538. /** !#en
  15539. The DragonBones data contains the armatures information (bind pose bones, slots, draw order,
  15540. attachments, skins, etc) and animations but does not hold any state.<br/>
  15541. Multiple ArmatureDisplay can share the same DragonBones data.
  15542. !#zh
  15543. 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
  15544. attachments,皮肤等等)和动画但不持有任何状态。<br/>
  15545. 多个 ArmatureDisplay 可以共用相同的骨骼数据。 */
  15546. dragonAsset: DragonBonesAsset;
  15547. /** !#en
  15548. The atlas asset for the DragonBones.
  15549. !#zh
  15550. 骨骼数据所需的 Atlas Texture 数据。 */
  15551. dragonAtlasAsset: DragonBonesAtlasAsset;
  15552. /** !#en The name of current armature.
  15553. !#zh 当前的 Armature 名称。 */
  15554. armatureName: string;
  15555. /** !#en The name of current playing animation.
  15556. !#zh 当前播放的动画名称。 */
  15557. animationName: string;
  15558. _defaultArmatureIndex: number;
  15559. /** !#en The time scale of this armature.
  15560. !#zh 当前骨骼中所有动画的时间缩放率。 */
  15561. timeScale: number;
  15562. /** !#en The play times of the default animation.
  15563. -1 means using the value of config file;
  15564. 0 means repeat for ever
  15565. >0 means repeat times
  15566. !#zh 播放默认动画的循环次数
  15567. -1 表示使用配置文件中的默认值;
  15568. 0 表示无限循环
  15569. >0 表示循环次数 */
  15570. playTimes: number;
  15571. /** !#en Indicates whether open debug bones.
  15572. !#zh 是否显示 bone 的 debug 信息。 */
  15573. debugBones: boolean;
  15574. /**
  15575. !#en
  15576. Play the specified animation.
  15577. Parameter animName specify the animation name.
  15578. Parameter playTimes specify the repeat times of the animation.
  15579. -1 means use the value of the config file.
  15580. 0 means play the animation for ever.
  15581. >0 means repeat times.
  15582. !#zh
  15583. 播放指定的动画.
  15584. animName 指定播放动画的名称。
  15585. playTimes 指定播放动画的次数。
  15586. -1 为使用配置文件中的次数。
  15587. 0 为无限循环播放。
  15588. >0 为动画的重复次数。
  15589. @param animName animName
  15590. @param playTimes playTimes
  15591. */
  15592. playAnimation(animName: string, playTimes: number): dragonBones.AnimationState;
  15593. /**
  15594. !#en
  15595. Get the all armature names in the DragonBones Data.
  15596. !#zh
  15597. 获取 DragonBones 数据中所有的 armature 名称
  15598. */
  15599. getArmatureNames(): any[];
  15600. /**
  15601. !#en
  15602. Get the all animation names of specified armature.
  15603. !#zh
  15604. 获取指定的 armature 的所有动画名称。
  15605. @param armatureName armatureName
  15606. */
  15607. getAnimationNames(armatureName: string): any[];
  15608. /**
  15609. !#en
  15610. Add event listener for the DragonBones Event.
  15611. !#zh
  15612. 添加 DragonBones 事件监听器。
  15613. @param eventType eventType
  15614. @param listener listener
  15615. @param target target
  15616. */
  15617. addEventListener(eventType: dragonBones.EventObject, listener: Function, target: any): void;
  15618. /**
  15619. !#en
  15620. Remove the event listener for the DragonBones Event.
  15621. !#zh
  15622. 移除 DragonBones 事件监听器。
  15623. @param eventType eventType
  15624. @param listener listener
  15625. @param target target
  15626. */
  15627. removeEventListener(eventType: dragonBones.EventObject, listener: Function, target: any): void;
  15628. /**
  15629. !#en
  15630. Build the armature for specified name.
  15631. !#zh
  15632. 构建指定名称的 armature 对象
  15633. @param armatureName armatureName
  15634. */
  15635. buildArmature(armatureName: string): dragonBones.Armature;
  15636. /**
  15637. !#en
  15638. Get the current armature object of the ArmatureDisplay.
  15639. !#zh
  15640. 获取 ArmatureDisplay 当前使用的 Armature 对象
  15641. */
  15642. armature(): any;
  15643. }
  15644. /** !#en The skeleton data of dragonBones.
  15645. !#zh dragonBones 的 骨骼数据。 */
  15646. export class DragonBonesAsset extends cc.Asset {
  15647. /** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html
  15648. !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */
  15649. dragonBonesJson: string;
  15650. }
  15651. /** !#en The skeleton atlas data of dragonBones.
  15652. !#zh dragonBones 的骨骼纹理数据。 */
  15653. export class DragonBonesAtlasAsset extends cc.Asset {
  15654. atlasJson: string;
  15655. texture: cc.Texture2D;
  15656. }
  15657. }
  15658. /** !#en
  15659. The global main namespace of Spine, all classes, functions,
  15660. properties and constants of Spine are defined in this namespace
  15661. !#zh
  15662. Spine 的全局的命名空间,
  15663. 与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */
  15664. declare module sp {
  15665. /** !#en
  15666. The skeleton of Spine <br/>
  15667. <br/>
  15668. (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance,
  15669. which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
  15670. Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.) <br/>
  15671. !#zh
  15672. Spine 骨骼动画 <br/>
  15673. <br/>
  15674. (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态,
  15675. 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。<br/>
  15676. 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */
  15677. export class Skeleton extends cc._RendererUnderSG {
  15678. /** !#en The skeletal animation is paused?
  15679. !#zh 该骨骼动画是否暂停。 */
  15680. paused: boolean;
  15681. /** !#en
  15682. The skeleton data contains the skeleton information (bind pose bones, slots, draw order,
  15683. attachments, skins, etc) and animations but does not hold any state.<br/>
  15684. Multiple skeletons can share the same skeleton data.
  15685. !#zh
  15686. 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
  15687. attachments,皮肤等等)和动画但不持有任何状态。<br/>
  15688. 多个 Skeleton 可以共用相同的骨骼数据。 */
  15689. skeletonData: SkeletonData;
  15690. /** !#en The name of default skin.
  15691. !#zh 默认的皮肤名称。 */
  15692. defaultSkin: string;
  15693. /** !#en The name of default animation.
  15694. !#zh 默认的动画名称。 */
  15695. defaultAnimation: string;
  15696. /** !#en The name of current playing animation.
  15697. !#zh 当前播放的动画名称。 */
  15698. animation: string;
  15699. _defaultSkinIndex: number;
  15700. /** !#en TODO
  15701. !#zh 是否循环播放当前骨骼动画。 */
  15702. loop: boolean;
  15703. /** !#en Indicates whether to enable premultiplied alpha.
  15704. You should disable this option when image's transparent area appears to have opaque pixels,
  15705. or enable this option when image's half transparent area appears to be darken.
  15706. !#zh 是否启用贴图预乘。
  15707. 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */
  15708. premultipliedAlpha: boolean;
  15709. /** !#en The time scale of this skeleton.
  15710. !#zh 当前骨骼中所有动画的时间缩放率。 */
  15711. timeScale: number;
  15712. /** !#en Indicates whether open debug slots.
  15713. !#zh 是否显示 slot 的 debug 信息。 */
  15714. debugSlots: boolean;
  15715. /** !#en Indicates whether open debug bones.
  15716. !#zh 是否显示 bone 的 debug 信息。 */
  15717. debugBones: boolean;
  15718. /**
  15719. !#en Computes the world SRT from the local SRT for each bone.
  15720. !#zh 重新更新所有骨骼的世界 Transform,
  15721. 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。
  15722. @example
  15723. ```js
  15724. var bone = spine.findBone('head');
  15725. cc.log(bone.worldX); // return 0;
  15726. spine.updateWorldTransform();
  15727. bone = spine.findBone('head');
  15728. cc.log(bone.worldX); // return -23.12;
  15729. ```
  15730. */
  15731. updateWorldTransform(): void;
  15732. /**
  15733. !#en Sets the bones and slots to the setup pose.
  15734. !#zh 还原到起始动作
  15735. */
  15736. setToSetupPose(): void;
  15737. /**
  15738. !#en
  15739. Sets the bones to the setup pose,
  15740. using the values from the `BoneData` list in the `SkeletonData`.
  15741. !#zh
  15742. 设置 bone 到起始动作
  15743. 使用 SkeletonData 中的 BoneData 列表中的值。
  15744. */
  15745. setBonesToSetupPose(): void;
  15746. /**
  15747. !#en
  15748. Sets the slots to the setup pose,
  15749. using the values from the `SlotData` list in the `SkeletonData`.
  15750. !#zh
  15751. 设置 slot 到起始动作。
  15752. 使用 SkeletonData 中的 SlotData 列表中的值。
  15753. */
  15754. setSlotsToSetupPose(): void;
  15755. /**
  15756. !#en
  15757. Finds a bone by name.
  15758. This does a string comparison for every bone.<br>
  15759. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object.
  15760. !#zh
  15761. 通过名称查找 bone。
  15762. 这里对每个 bone 的名称进行了对比。<br>
  15763. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。
  15764. @param boneName boneName
  15765. */
  15766. findBone(boneName: string): sp.spine.Bone;
  15767. /**
  15768. !#en
  15769. Finds a slot by name. This does a string comparison for every slot.<br>
  15770. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object.
  15771. !#zh
  15772. 通过名称查找 slot。这里对每个 slot 的名称进行了比较。<br>
  15773. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。
  15774. @param slotName slotName
  15775. */
  15776. findSlot(slotName: string): sp.spine.Slot;
  15777. /**
  15778. !#en
  15779. Finds a skin by name and makes it the active skin.
  15780. This does a string comparison for every skin.<br>
  15781. Note that setting the skin does not change which attachments are visible.<br>
  15782. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object.
  15783. !#zh
  15784. 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。<br>
  15785. 注意:设置皮肤不会改变 attachment 的可见性。<br>
  15786. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。
  15787. @param skinName skinName
  15788. */
  15789. setSkin(skinName: string): sp.spine.Skin;
  15790. /**
  15791. !#en
  15792. Returns the attachment for the slot and attachment name.
  15793. The skeleton looks first in its skin, then in the skeleton data’s default skin.<br>
  15794. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object.
  15795. !#zh
  15796. 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。<br>
  15797. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。
  15798. @param slotName slotName
  15799. @param attachmentName attachmentName
  15800. */
  15801. getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment;
  15802. /**
  15803. !#en
  15804. Sets the attachment for the slot and attachment name.
  15805. The skeleton looks first in its skin, then in the skeleton data’s default skin.
  15806. !#zh
  15807. 通过 slot 和 attachment 的名字来设置 attachment。
  15808. Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
  15809. @param slotName slotName
  15810. @param attachmentName attachmentName
  15811. */
  15812. setAttachment(slotName: string, attachmentName: string): void;
  15813. /**
  15814. !#en
  15815. Sets runtime skeleton data to sp.Skeleton.<br>
  15816. This method is different from the `skeletonData` property. This method is passed in the raw data provided by the Spine runtime, and the skeletonData type is the asset type provided by Creator.
  15817. !#zh
  15818. 设置底层运行时用到的 SkeletonData。<br>
  15819. 这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。
  15820. @param skeletonData skeletonData
  15821. @param ownsSkeletonData ownsSkeletonData
  15822. */
  15823. setSkeletonData(skeletonData: sp.spine.SkeletonData, ownsSkeletonData: sp.spine.SkeletonData): void;
  15824. /**
  15825. !#en Sets animation state data.<br>
  15826. The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData.
  15827. !#zh 设置动画状态数据。<br>
  15828. 参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。
  15829. @param stateData stateData
  15830. */
  15831. setAnimationStateData(stateData: sp.spine.AnimationStateData): void;
  15832. /**
  15833. !#en
  15834. Mix applies all keyframe values,
  15835. interpolated for the specified time and mixed with the current values.
  15836. !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。
  15837. @param fromAnimation fromAnimation
  15838. @param toAnimation toAnimation
  15839. @param duration duration
  15840. */
  15841. setMix(fromAnimation: string, toAnimation: string, duration: number): void;
  15842. /**
  15843. !#en Sets event listener.
  15844. !#zh 设置动画事件监听器。
  15845. @param target target
  15846. @param callback callback
  15847. */
  15848. setAnimationListener(target: any, callback: Function): void;
  15849. /**
  15850. !#en Set the current animation. Any queued animations are cleared.<br>
  15851. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  15852. !#zh 设置当前动画。队列中的任何的动画将被清除。<br>
  15853. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  15854. @param trackIndex trackIndex
  15855. @param name name
  15856. @param loop loop
  15857. */
  15858. setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry;
  15859. /**
  15860. !#en Adds an animation to be played delay seconds after the current or last queued animation.<br>
  15861. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  15862. !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。<br>
  15863. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  15864. @param trackIndex trackIndex
  15865. @param name name
  15866. @param loop loop
  15867. @param delay delay
  15868. */
  15869. addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry;
  15870. /**
  15871. !#en Find animation with specified name.
  15872. !#zh 查找指定名称的动画
  15873. @param name name
  15874. */
  15875. findAnimation(name: string): sp.spine.Animation;
  15876. /**
  15877. !#en Returns track entry by trackIndex.<br>
  15878. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  15879. !#zh 通过 track 索引获取 TrackEntry。<br>
  15880. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  15881. @param trackIndex trackIndex
  15882. */
  15883. getCurrent(trackIndex: void): sp.spine.TrackEntry;
  15884. /**
  15885. !#en Clears all tracks of animation state.
  15886. !#zh 清除所有 track 的动画状态。
  15887. */
  15888. clearTracks(): void;
  15889. /**
  15890. !#en Clears track of animation state by trackIndex.
  15891. !#zh 清除出指定 track 的动画状态。
  15892. @param trackIndex trackIndex
  15893. */
  15894. clearTrack(trackIndex: number): void;
  15895. /**
  15896. !#en Set the start event listener.
  15897. !#zh 用来设置开始播放动画的事件监听。
  15898. @param listener listener
  15899. */
  15900. setStartListener(listener: Function): void;
  15901. /**
  15902. !#en Set the interrupt event listener.
  15903. !#zh 用来设置动画被打断的事件监听。
  15904. @param listener listener
  15905. */
  15906. setInterruptListener(listener: Function): void;
  15907. /**
  15908. !#en Set the end event listener.
  15909. !#zh 用来设置动画播放完后的事件监听。
  15910. @param listener listener
  15911. */
  15912. setEndListener(listener: Function): void;
  15913. /**
  15914. !#en Set the dispose event listener.
  15915. !#zh 用来设置动画将被销毁的事件监听。
  15916. @param listener listener
  15917. */
  15918. setDisposeListener(listener: Function): void;
  15919. /**
  15920. !#en Set the complete event listener.
  15921. !#zh 用来设置动画播放一次循环结束后的事件监听。
  15922. @param listener listener
  15923. */
  15924. setCompleteListener(listener: Function): void;
  15925. /**
  15926. !#en Set the animation event listener.
  15927. !#zh 用来设置动画播放过程中帧事件的监听。
  15928. @param listener listener
  15929. */
  15930. setEventListener(listener: Function): void;
  15931. /**
  15932. !#en Set the start event listener for specified TrackEntry (only supported on Web).
  15933. !#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。(只支持 Web 平台)
  15934. @param entry entry
  15935. @param listener listener
  15936. */
  15937. setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15938. /**
  15939. !#en Set the interrupt event listener for specified TrackEntry (only supported on Web).
  15940. !#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。(只支持 Web 平台)
  15941. @param entry entry
  15942. @param listener listener
  15943. */
  15944. setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15945. /**
  15946. !#en Set the end event listener for specified TrackEntry (only supported on Web).
  15947. !#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。(只支持 Web 平台)
  15948. @param entry entry
  15949. @param listener listener
  15950. */
  15951. setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15952. /**
  15953. !#en Set the dispose event listener for specified TrackEntry (only supported on Web).
  15954. !#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。(只支持 Web 平台)
  15955. @param entry entry
  15956. @param listener listener
  15957. */
  15958. setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15959. /**
  15960. !#en Set the complete event listener for specified TrackEntry (only supported on Web).
  15961. !#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。(只支持 Web 平台)
  15962. @param entry entry
  15963. @param listener listener
  15964. */
  15965. setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15966. /**
  15967. !#en Set the event listener for specified TrackEntry (only supported on Web).
  15968. !#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。(只支持 Web 平台)
  15969. @param entry entry
  15970. @param listener listener
  15971. */
  15972. setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15973. }
  15974. /** !#en The skeleton data of spine.
  15975. !#zh Spine 的 骨骼数据。 */
  15976. export class SkeletonData extends cc.Asset {
  15977. /** !#en See http://en.esotericsoftware.com/spine-json-format
  15978. !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */
  15979. skeletonJson: any;
  15980. atlasText: string;
  15981. textures: cc.Texture2D[];
  15982. /** !#en
  15983. A scale can be specified on the JSON or binary loader which will scale the bone positions,
  15984. image sizes, and animation translations.
  15985. This can be useful when using different sized images than were used when designing the skeleton
  15986. in Spine. For example, if using images that are half the size than were used in Spine,
  15987. a scale of 0.5 can be used. This is commonly used for games that can run with either low or high
  15988. resolution texture atlases.
  15989. see http://en.esotericsoftware.com/spine-using-runtimes#Scaling
  15990. !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */
  15991. scale: number;
  15992. /**
  15993. !#en Get the included SkeletonData used in spine runtime.<br>
  15994. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object.
  15995. !#zh 获取 Spine Runtime 使用的 SkeletonData。<br>
  15996. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData 对象。
  15997. @param quiet quiet
  15998. */
  15999. getRuntimeData(quiet?: boolean): sp.spine.SkeletonData;
  16000. }
  16001. /** !#en The event type of spine skeleton animation.
  16002. !#zh 骨骼动画事件类型。 */
  16003. export enum AnimationEventType {
  16004. START = 0,
  16005. END = 0,
  16006. COMPLETE = 0,
  16007. EVENT = 0,
  16008. }
  16009. }
  16010. /** !#en
  16011. `sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.<br>
  16012. Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes)
  16013. !#zh
  16014. sp.spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */
  16015. declare module sp.spine {
  16016. }
  16017. /** !#en Some JavaScript decorators which can be accessed with "cc._decorator".
  16018. !#zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。
  16019. (这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整) */
  16020. declare module cc._decorator {
  16021. /**
  16022. !#en
  16023. Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes)
  16024. as CCClass, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class/) for details.
  16025. !#zh
  16026. 将标准写法的 [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass,具体用法请参阅[类型定义](/docs/creator/scripting/class/)。
  16027. @param name The class name used for serialization.
  16028. @example
  16029. ```js
  16030. const {ccclass} = cc._decorator;
  16031. // define a CCClass, omit the name
  16032. &#64;ccclass
  16033. class NewScript extends cc.Component {
  16034. // ...
  16035. }
  16036. // define a CCClass with a name
  16037. &#64;ccclass('LoginData')
  16038. class LoginData {
  16039. // ...
  16040. }
  16041. ```
  16042. */
  16043. export function ccclass(name?: string): Function;
  16044. export function ccclass(_class?: Function): void;
  16045. /**
  16046. !#en
  16047. Declare property for [CCClass](/docs/editors_and_tools/creator-chapters/scripting/class/).
  16048. !#zh
  16049. 定义 [CCClass](/docs/creator/scripting/class/) 所用的属性。
  16050. @param options an object with some property attributes
  16051. @example
  16052. ```js
  16053. const {ccclass, property} = cc._decorator;
  16054. &#64;ccclass
  16055. class NewScript extends cc.Component {
  16056. &#64;property({
  16057. type: cc.Node
  16058. })
  16059. targetNode1 = null;
  16060. &#64;property(cc.Node)
  16061. targetNode2 = null;
  16062. &#64;property(cc.Button)
  16063. targetButton = null;
  16064. &#64;property
  16065. _width = 100;
  16066. &#64;property
  16067. get width () {
  16068. return this._width;
  16069. }
  16070. &#64;property
  16071. set width (value) {
  16072. this._width = value;
  16073. }
  16074. &#64;property
  16075. offset = new cc.Vec2(100, 100);
  16076. &#64;property(cc.Vec2)
  16077. offsets = [];
  16078. &#64;property(cc.Texture2D)
  16079. texture = "";
  16080. }
  16081. // above is equivalent to (上面的代码相当于):
  16082. var NewScript = cc.Class({
  16083. properties: {
  16084. targetNode1: {
  16085. default: null,
  16086. type: cc.Node
  16087. },
  16088. targetNode2: {
  16089. default: null,
  16090. type: cc.Node
  16091. },
  16092. targetButton: {
  16093. default: null,
  16094. type: cc.Button
  16095. },
  16096. _width: 100,
  16097. width: {
  16098. get () {
  16099. return this._width;
  16100. },
  16101. set (value) {
  16102. this._width = value;
  16103. }
  16104. },
  16105. offset: new cc.Vec2(100, 100)
  16106. offsets: {
  16107. default: [],
  16108. type: cc.Vec2
  16109. }
  16110. texture: {
  16111. default: "",
  16112. url: cc.Texture2D
  16113. },
  16114. }
  16115. });
  16116. ```
  16117. */
  16118. export function property(options?: {type?: any; url?: typeof cc.RawAsset; visible?: boolean|(() => boolean); displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; step?: number; range?: number[]; slide?: boolean; serializable?: boolean; formerlySerializedAs?: string; editorOnly?: boolean; override?: boolean; animatable?: boolean} | any[]|Function|cc.ValueType|number|string|boolean): Function;
  16119. export function property(_target: Object, _key: any, _desc?: any): void;
  16120. /**
  16121. !#en
  16122. Makes a CCClass that inherit from component execute in edit mode.<br>
  16123. By default, all components are only executed in play mode,
  16124. which means they will not have their callback functions executed while the Editor is in edit mode.
  16125. !#zh
  16126. 允许继承自 Component 的 CCClass 在编辑器里执行。<br>
  16127. 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。
  16128. @example
  16129. ```js
  16130. const {ccclass, executeInEditMode} = cc._decorator;
  16131. &#64;ccclass
  16132. &#64;executeInEditMode
  16133. class NewScript extends cc.Component {
  16134. // ...
  16135. }
  16136. ```
  16137. */
  16138. export function executeInEditMode(): Function;
  16139. export function executeInEditMode(_class: Function): void;
  16140. /**
  16141. !#en
  16142. Automatically add required component as a dependency for the CCClass that inherit from component.
  16143. !#zh
  16144. 为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。
  16145. @param requiredComponent requiredComponent
  16146. @example
  16147. ```js
  16148. const {ccclass, requireComponent} = cc._decorator;
  16149. &#64;ccclass
  16150. &#64;requireComponent(cc.Sprite)
  16151. class SpriteCtrl extends cc.Component {
  16152. // ...
  16153. }
  16154. ```
  16155. */
  16156. export function requireComponent(requiredComponent: typeof cc.Component): Function;
  16157. /**
  16158. !#en
  16159. The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl".
  16160. !#zh
  16161. 将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。
  16162. @param path The path is the menu represented like a pathname.
  16163. For example the menu could be "Rendering/CameraCtrl".
  16164. @example
  16165. ```js
  16166. const {ccclass, menu} = cc._decorator;
  16167. &#64;ccclass
  16168. &#64;menu("Rendering/CameraCtrl")
  16169. class NewScript extends cc.Component {
  16170. // ...
  16171. }
  16172. ```
  16173. */
  16174. export function menu(path: string): Function;
  16175. /**
  16176. !#en
  16177. The execution order of lifecycle methods for Component.
  16178. Those less than 0 will execute before while those greater than 0 will execute after.
  16179. The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected.
  16180. !#zh
  16181. 设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。
  16182. @param order The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after.
  16183. @example
  16184. ```js
  16185. const {ccclass, executionOrder} = cc._decorator;
  16186. &#64;ccclass
  16187. &#64;executionOrder(1)
  16188. class CameraCtrl extends cc.Component {
  16189. // ...
  16190. }
  16191. ```
  16192. */
  16193. export function executionOrder(order: number): Function;
  16194. /**
  16195. !#en
  16196. Prevents Component of the same type (or subtype) to be added more than once to a Node.
  16197. !#zh
  16198. 防止多个相同类型(或子类型)的组件被添加到同一个节点。
  16199. @example
  16200. ```js
  16201. const {ccclass, disallowMultiple} = cc._decorator;
  16202. &#64;ccclass
  16203. &#64;disallowMultiple
  16204. class CameraCtrl extends cc.Component {
  16205. // ...
  16206. }
  16207. ```
  16208. */
  16209. export function disallowMultiple(): Function;
  16210. export function disallowMultiple(_class: Function): void;
  16211. /**
  16212. !#en
  16213. If specified, the editor's scene view will keep updating this node in 60 fps when it is selected, otherwise, it will update only if necessary.<br>
  16214. This property is only available if executeInEditMode is true.
  16215. !#zh
  16216. 当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。
  16217. @example
  16218. ```js
  16219. const {ccclass, playOnFocus, executeInEditMode} = cc._decorator;
  16220. &#64;ccclass
  16221. &#64;executeInEditMode
  16222. &#64;playOnFocus
  16223. class CameraCtrl extends cc.Component {
  16224. // ...
  16225. }
  16226. ```
  16227. */
  16228. export function playOnFocus(): Function;
  16229. export function playOnFocus(_class: Function): void;
  16230. /**
  16231. !#en
  16232. Specifying the url of the custom html to draw the component in **Properties**.
  16233. !#zh
  16234. 自定义当前组件在 **属性检查器** 中渲染时所用的网页 url。
  16235. @param url url
  16236. @example
  16237. ```js
  16238. const {ccclass, inspector} = cc._decorator;
  16239. &#64;ccclass
  16240. &#64;inspector("packages://inspector/inspectors/comps/camera-ctrl.js")
  16241. class NewScript extends cc.Component {
  16242. // ...
  16243. }
  16244. ```
  16245. */
  16246. export function inspector(path: string): Function;
  16247. /**
  16248. !#en
  16249. The custom documentation URL.
  16250. !#zh
  16251. 指定当前组件的帮助文档的 url,设置过后,在 **属性检查器** 中就会出现一个帮助图标,用户点击将打开指定的网页。
  16252. @param url url
  16253. @example
  16254. ```js
  16255. const {ccclass, help} = cc._decorator;
  16256. &#64;ccclass
  16257. &#64;help("app://docs/html/components/spine.html")
  16258. class NewScript extends cc.Component {
  16259. // ...
  16260. }
  16261. ```
  16262. */
  16263. export function help(path: string): Function;
  16264. /**
  16265. NOTE:<br>
  16266. The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance.
  16267. But since ES6, class constructor can't be function-called and class methods become non-enumerable,
  16268. so we can not mix in ES6 Classes.<br>
  16269. See:<br>
  16270. [https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32](https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32)<br>
  16271. One possible solution (but IDE unfriendly):<br>
  16272. [http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)<br>
  16273. <br>
  16274. NOTE:<br>
  16275. You must manually call mixins constructor, this is different from cc.Class(ES5).
  16276. @param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`,
  16277. not support ES6 Classes.
  16278. @example
  16279. ```js
  16280. const {ccclass, mixins} = cc._decorator;
  16281. class Animal { ... }
  16282. const Fly = cc.Class({
  16283. constructor () { ... }
  16284. });
  16285. &#64;ccclass
  16286. &#64;mixins(cc.EventTarget, Fly)
  16287. class Bird extends Animal {
  16288. constructor () {
  16289. super();
  16290. // You must manually call mixins constructor, this is different from cc.Class(ES5)
  16291. cc.EventTarget.call(this);
  16292. Fly.call(this);
  16293. }
  16294. // ...
  16295. }
  16296. ```
  16297. */
  16298. export function mixins(ctor: Function, ...rest: Function[]): Function;
  16299. }
  16300. /** This module provides some JavaScript utilities.
  16301. All members can be accessed with "cc.js". */
  16302. declare module cc.js {
  16303. /**
  16304. Check the obj whether is number or not
  16305. If a number is created by using 'new Number(10086)', the typeof it will be "object"...
  16306. Then you can use this function if you care about this case.
  16307. @param obj obj
  16308. */
  16309. export function isNumber(obj: any): boolean;
  16310. /**
  16311. Check the obj whether is string or not.
  16312. If a string is created by using 'new String("blabla")', the typeof it will be "object"...
  16313. Then you can use this function if you care about this case.
  16314. @param obj obj
  16315. */
  16316. export function isString(obj: any): boolean;
  16317. /**
  16318. This method is deprecated, use cc.js.mixin please.<br>
  16319. Copy all properties not defined in obj from arguments[1...n]
  16320. @param obj object to extend its properties
  16321. @param sourceObj source object to copy properties from
  16322. */
  16323. export function addon(obj: any, ...sourceObj: any[]): any;
  16324. /**
  16325. copy all properties from arguments[1...n] to obj
  16326. @param obj obj
  16327. @param sourceObj sourceObj
  16328. */
  16329. export function mixin(obj: any, ...sourceObj: any[]): any;
  16330. /**
  16331. Derive the class from the supplied base class.
  16332. Both classes are just native javascript constructors, not created by cc.Class, so
  16333. usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead.
  16334. @param cls cls
  16335. @param base the baseclass to inherit
  16336. */
  16337. export function extend(cls: Function, base: Function): Function;
  16338. /**
  16339. Get super class
  16340. @param ctor the constructor of subclass
  16341. */
  16342. export function getSuper(ctor: Function): Function;
  16343. /**
  16344. Removes all enumerable properties from object
  16345. @param obj obj
  16346. */
  16347. export function clear(obj: any): void;
  16348. /**
  16349. Get property descriptor in object and all its ancestors
  16350. @param obj obj
  16351. @param name name
  16352. */
  16353. export function getPropertyDescriptor(obj: any, name: string): any;
  16354. /**
  16355. Define value, just help to call Object.defineProperty.<br>
  16356. The configurable will be true.
  16357. @param obj obj
  16358. @param prop prop
  16359. @param value value
  16360. @param writable writable
  16361. @param enumerable enumerable
  16362. */
  16363. export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void;
  16364. /**
  16365. Define get set accessor, just help to call Object.defineProperty(...)
  16366. @param obj obj
  16367. @param prop prop
  16368. @param getter getter
  16369. @param setter setter
  16370. @param enumerable enumerable
  16371. */
  16372. export function getset(obj: any, prop: string, getter: Function, setter: Function, enumerable?: boolean): void;
  16373. /**
  16374. Define get accessor, just help to call Object.defineProperty(...)
  16375. @param obj obj
  16376. @param prop prop
  16377. @param getter getter
  16378. @param enumerable enumerable
  16379. @param configurable configurable
  16380. */
  16381. export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void;
  16382. /**
  16383. Define set accessor, just help to call Object.defineProperty(...)
  16384. @param obj obj
  16385. @param prop prop
  16386. @param setter setter
  16387. @param enumerable enumerable
  16388. @param configurable configurable
  16389. */
  16390. export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void;
  16391. /**
  16392. Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "".
  16393. (modified from <a href="http://stackoverflow.com/questions/1249531/how-to-get-a-javascript-objects-class">the code from this stackoverflow post</a>)
  16394. @param objOrCtor instance or constructor
  16395. */
  16396. export function getClassName(objOrCtor: any|Function): string;
  16397. /**
  16398. Register the class by specified name manually
  16399. @param className className
  16400. @param constructor constructor
  16401. */
  16402. export function setClassName(className: string, constructor: Function): void;
  16403. /**
  16404. Unregister a class from fireball.
  16405. If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore.
  16406. Please note that its still your responsibility to free other references to the class.
  16407. @param constructor the class you will want to unregister, any number of classes can be added
  16408. */
  16409. export function unregisterClass(...constructor: Function[]): void;
  16410. /**
  16411. Get the registered class by name
  16412. @param classname classname
  16413. */
  16414. export function getClassByName(classname: string): Function;
  16415. /**
  16416. Defines a polyfill field for obsoleted codes.
  16417. @param obj YourObject or YourClass.prototype
  16418. @param obsoleted "OldParam" or "YourClass.OldParam"
  16419. @param newPropName "NewParam"
  16420. @param writable writable
  16421. */
  16422. export function obsolete(obj: any, obsoleted: string, newPropName: string, writable?: boolean): void;
  16423. /**
  16424. Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props.
  16425. @param obj YourObject or YourClass.prototype
  16426. @param objName "YourObject" or "YourClass"
  16427. @param props props
  16428. @param writable writable
  16429. */
  16430. export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void;
  16431. /**
  16432. A string tool to construct a string with format string.
  16433. @param msg A JavaScript string containing zero or more substitution strings (%s).
  16434. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  16435. @example
  16436. ```js
  16437. cc.js.formatStr("a: %s, b: %s", a, b);
  16438. cc.js.formatStr(a, b, c);
  16439. ```
  16440. */
  16441. export function formatStr(msg: string|any, ...subst: any[]): string;
  16442. /**
  16443. !#en
  16444. A simple wrapper of `Object.create(null)` which ensures the return object have no prototype (and thus no inherited members). So we can skip `hasOwnProperty` calls on property lookups. It is a worthwhile optimization than the `{}` literal when `hasOwnProperty` calls are necessary.
  16445. !#zh
  16446. 该方法是对 `Object.create(null)` 的简单封装。`Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断。在需要频繁判断 `hasOwnProperty` 时,使用这个方法性能会比 `{}` 更高。
  16447. @param forceDictMode Apply the delete operator to newly created map object. This causes V8 to put the object in "dictionary mode" and disables creation of hidden classes which are very expensive for objects that are constantly changing shape.
  16448. */
  16449. export function createMap(forceDictMode?: boolean): any;
  16450. /** undefined */
  16451. export class array {
  16452. /**
  16453. Removes the array item at the specified index.
  16454. @param array array
  16455. @param index index
  16456. */
  16457. static removeAt(array: any[], index: number): void;
  16458. /**
  16459. Removes the array item at the specified index.
  16460. It's faster but the order of the array will be changed.
  16461. @param array array
  16462. @param index index
  16463. */
  16464. static fastRemoveAt(array: any[], index: number): void;
  16465. /**
  16466. Removes the first occurrence of a specific object from the array.
  16467. @param array array
  16468. @param value value
  16469. */
  16470. static remove(array: any[], value: any): boolean;
  16471. /**
  16472. Removes the first occurrence of a specific object from the array.
  16473. It's faster but the order of the array will be changed.
  16474. @param array array
  16475. @param value value
  16476. */
  16477. static fastRemove(array: any[], value: number): void;
  16478. /**
  16479. Verify array's Type
  16480. @param array array
  16481. @param type type
  16482. */
  16483. static verifyType(array: any[], type: Function): boolean;
  16484. /**
  16485. Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed.
  16486. @param array Source Array
  16487. @param minusArr minus Array
  16488. */
  16489. static removeArray(array: any[], minusArr: any[]): void;
  16490. /**
  16491. Inserts some objects at index
  16492. @param array array
  16493. @param addObjs addObjs
  16494. @param index index
  16495. */
  16496. static appendObjectsAt(array: any[], addObjs: any[], index: number): any[];
  16497. /**
  16498. Exact same function as Array.prototype.indexOf.<br>
  16499. HACK: ugliy hack for Baidu mobile browser compatibility, stupid Baidu guys modify Array.prototype.indexOf for all pages loaded, their version changes strict comparison to non-strict comparison, it also ignores the second parameter of the original API, and this will cause event handler enter infinite loop.<br>
  16500. Baidu developers, if you ever see this documentation, here is the standard: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf, Seriously!
  16501. @param searchElement Element to locate in the array.
  16502. @param fromIndex The index to start the search at
  16503. */
  16504. static indexOf(searchElement: any, fromIndex?: number): number;
  16505. /**
  16506. Determines whether the array contains a specific value.
  16507. @param array array
  16508. @param value value
  16509. */
  16510. static contains(array: any[], value: any): boolean;
  16511. /**
  16512. Copy an array's item to a new array (its performance is better than Array.slice)
  16513. @param array array
  16514. */
  16515. static copy(array: any[]): any[];
  16516. }
  16517. /** !#en
  16518. A fixed-length object pool designed for general type.<br>
  16519. The implementation of this object pool is very simple,
  16520. it can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  16521. !#zh
  16522. 长度固定的对象缓存池,可以用来缓存各种对象类型。<br/>
  16523. 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 */
  16524. export class Pool {
  16525. /**
  16526. !#en
  16527. Constructor for creating an object pool for the specific object type.
  16528. You can pass a callback argument for process the cleanup logic when the object is recycled.
  16529. !#zh
  16530. 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。
  16531. @param cleanupFunc the callback method used to process the cleanup logic when the object is recycled.
  16532. @param size initializes the length of the array
  16533. */
  16534. constructor(cleanupFunc: (obj: any) => void, size: number);
  16535. constructor(size: number);
  16536. /**
  16537. !#en
  16538. Get and initialize an object from pool. This method defaults to null and requires the user to implement it.
  16539. !#zh
  16540. 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。
  16541. @param params parameters to used to initialize the object
  16542. */
  16543. get(...params: any[]): any;
  16544. /** !#en
  16545. The current number of available objects, the default is 0, it will gradually increase with the recycle of the object,
  16546. the maximum will not exceed the size specified when the constructor is called.
  16547. !#zh
  16548. 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 */
  16549. count: number;
  16550. /**
  16551. !#en
  16552. Get an object from pool, if no available object in the pool, null will be returned.
  16553. !#zh
  16554. 获取对象池中的对象,如果对象池没有可用对象,则返回空。
  16555. */
  16556. _get(): any;
  16557. /**
  16558. !#en Put an object into the pool.
  16559. !#zh 向对象池返还一个不再需要的对象。
  16560. */
  16561. put(): void;
  16562. /**
  16563. !#en Resize the pool.
  16564. !#zh 设置对象池容量。
  16565. */
  16566. resize(): void;
  16567. }
  16568. }
  16569. declare namespace dragonBones {
  16570. /**
  16571. * @private
  16572. */
  16573. const enum ArmatureType {
  16574. Armature = 0,
  16575. MovieClip = 1,
  16576. Stage = 2,
  16577. }
  16578. /**
  16579. * @private
  16580. */
  16581. const enum DisplayType {
  16582. Image = 0,
  16583. Armature = 1,
  16584. Mesh = 2,
  16585. }
  16586. /**
  16587. * @private
  16588. */
  16589. const enum ExtensionType {
  16590. FFD = 0,
  16591. AdjustColor = 10,
  16592. BevelFilter = 11,
  16593. BlurFilter = 12,
  16594. DropShadowFilter = 13,
  16595. GlowFilter = 14,
  16596. GradientBevelFilter = 15,
  16597. GradientGlowFilter = 16,
  16598. }
  16599. /**
  16600. * @private
  16601. */
  16602. const enum EventType {
  16603. Frame = 10,
  16604. Sound = 11,
  16605. }
  16606. /**
  16607. * @private
  16608. */
  16609. const enum ActionType {
  16610. Play = 0,
  16611. Stop = 1,
  16612. GotoAndPlay = 2,
  16613. GotoAndStop = 3,
  16614. FadeIn = 4,
  16615. FadeOut = 5,
  16616. }
  16617. /**
  16618. * @private
  16619. */
  16620. const enum BlendMode {
  16621. Normal = 0,
  16622. Add = 1,
  16623. Alpha = 2,
  16624. Darken = 3,
  16625. Difference = 4,
  16626. Erase = 5,
  16627. HardLight = 6,
  16628. Invert = 7,
  16629. Layer = 8,
  16630. Lighten = 9,
  16631. Multiply = 10,
  16632. Overlay = 11,
  16633. Screen = 12,
  16634. Subtract = 13,
  16635. }
  16636. /**
  16637. * @private
  16638. */
  16639. interface Map<T> {
  16640. [key: string]: T;
  16641. }
  16642. /**
  16643. * DragonBones
  16644. */
  16645. class DragonBones {
  16646. /**
  16647. * @private
  16648. */
  16649. static PI_D: number;
  16650. /**
  16651. * @private
  16652. */
  16653. static PI_H: number;
  16654. /**
  16655. * @private
  16656. */
  16657. static PI_Q: number;
  16658. /**
  16659. * @private
  16660. */
  16661. static ANGLE_TO_RADIAN: number;
  16662. /**
  16663. * @private
  16664. */
  16665. static RADIAN_TO_ANGLE: number;
  16666. /**
  16667. * @private
  16668. */
  16669. static SECOND_TO_MILLISECOND: number;
  16670. static VERSION: string;
  16671. /**
  16672. * @private
  16673. */
  16674. static debug: boolean;
  16675. /**
  16676. * @private
  16677. */
  16678. static debugDraw: boolean;
  16679. }
  16680. }
  16681. declare namespace dragonBones {
  16682. /**
  16683. * @language zh_CN
  16684. * 基础对象。
  16685. * @version DragonBones 4.5
  16686. */
  16687. abstract class BaseObject {
  16688. private static _hashCode;
  16689. private static _defaultMaxCount;
  16690. private static _maxCountMap;
  16691. private static _poolsMap;
  16692. private static _returnObject(object);
  16693. /**
  16694. * @language zh_CN
  16695. * 设置每种对象池的最大缓存数量。
  16696. * @param objectConstructor 对象类。
  16697. * @param maxCount 最大缓存数量。 (设置为 0 则不缓存)
  16698. * @version DragonBones 4.5
  16699. */
  16700. static setMaxCount(objectConstructor: typeof BaseObject, maxCount: number): void;
  16701. /**
  16702. * @language zh_CN
  16703. * 清除对象池缓存的对象。
  16704. * @param objectConstructor 对象类。 (不设置则清除所有缓存)
  16705. * @version DragonBones 4.5
  16706. */
  16707. static clearPool(objectConstructor?: typeof BaseObject): void;
  16708. /**
  16709. * @language zh_CN
  16710. * 从对象池中创建指定对象。
  16711. * @param objectConstructor 对象类。
  16712. * @version DragonBones 4.5
  16713. */
  16714. static borrowObject<T extends BaseObject>(objectConstructor: {
  16715. new (): T;
  16716. }): T;
  16717. /**
  16718. * @language zh_CN
  16719. * 对象的唯一标识。
  16720. * @version DragonBones 4.5
  16721. */
  16722. hashCode: number;
  16723. /**
  16724. * @private
  16725. */
  16726. protected abstract _onClear(): void;
  16727. /**
  16728. * @language zh_CN
  16729. * 清除数据并返还对象池。
  16730. * @version DragonBones 4.5
  16731. */
  16732. returnToPool(): void;
  16733. }
  16734. }
  16735. declare namespace dragonBones {
  16736. }
  16737. declare namespace dragonBones {
  16738. /**
  16739. * @language zh_CN
  16740. * 动画混合时,使用的淡出方式。
  16741. * @see dragonBones.Animation#fadeIn()
  16742. * @version DragonBones 4.5
  16743. */
  16744. const enum AnimationFadeOutMode {
  16745. /**
  16746. * @language zh_CN
  16747. * 不淡出动画。
  16748. * @version DragonBones 4.5
  16749. */
  16750. None = 0,
  16751. /**
  16752. * @language zh_CN
  16753. * 淡出同层的动画。
  16754. * @version DragonBones 4.5
  16755. */
  16756. SameLayer = 1,
  16757. /**
  16758. * @language zh_CN
  16759. * 淡出同组的动画。
  16760. * @version DragonBones 4.5
  16761. */
  16762. SameGroup = 2,
  16763. /**
  16764. * @language zh_CN
  16765. * 淡出同层并且同组的动画。
  16766. * @version DragonBones 4.5
  16767. */
  16768. SameLayerAndGroup = 3,
  16769. /**
  16770. * @language zh_CN
  16771. * 淡出所有动画。
  16772. * @version DragonBones 4.5
  16773. */
  16774. All = 4,
  16775. }
  16776. /**
  16777. * @language zh_CN
  16778. * 播放动画组件接口。 (Armature 和 WordClock 都实现了该接口)
  16779. * 任何实现了此接口的实例都可以加到 WorldClock 时钟中,由时钟统一控制动画的播放。
  16780. * @see dragonBones.WorldClock
  16781. * @see dragonBones.Armature
  16782. * @version DragonBones 3.0
  16783. */
  16784. interface IAnimateble {
  16785. /**
  16786. * @language zh_CN
  16787. * 更新一个指定的时间。
  16788. * @param passedTime 前进的时间。 (以秒为单位)
  16789. * @version DragonBones 3.0
  16790. */
  16791. advanceTime(passedTime: number): void;
  16792. }
  16793. /**
  16794. * @language zh_CN
  16795. * 动画控制器,用来播放动画数据,管理动画状态。
  16796. * @see dragonBones.AnimationData
  16797. * @see dragonBones.AnimationState
  16798. * @version DragonBones 3.0
  16799. */
  16800. class Animation extends BaseObject {
  16801. /**
  16802. * @private
  16803. */
  16804. private static _sortAnimationState(a, b);
  16805. /**
  16806. * @private
  16807. */
  16808. static toString(): string;
  16809. /**
  16810. * @language zh_CN
  16811. * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  16812. * @default 1
  16813. * @version DragonBones 3.0
  16814. */
  16815. timeScale: number;
  16816. /**
  16817. * @private
  16818. */
  16819. _armature: Armature;
  16820. private _isPlaying;
  16821. private _time;
  16822. private _duration;
  16823. private _lastAnimationState;
  16824. private _animations;
  16825. private _animationNames;
  16826. private _animationStates;
  16827. /**
  16828. * @inheritDoc
  16829. */
  16830. protected _onClear(): void;
  16831. private _fadeOut(fadeOutTime, layer, group, fadeOutMode, pauseFadeOut);
  16832. /**
  16833. * @language zh_CN
  16834. * 清除所有正在播放的动画状态。
  16835. * @version DragonBones 4.5
  16836. */
  16837. reset(): void;
  16838. /**
  16839. * @language zh_CN
  16840. * 暂停播放动画。
  16841. * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。
  16842. * @see dragonBones.AnimationState
  16843. * @version DragonBones 3.0
  16844. */
  16845. stop(animationName?: string): void;
  16846. /**
  16847. * @language zh_CN
  16848. * 播放动画。
  16849. * @param animationName 动画数据的名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。
  16850. * @param playTimes 动画需要播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16851. * @returns 返回控制这个动画数据的动画状态。
  16852. * @see dragonBones.AnimationState
  16853. * @version DragonBones 3.0
  16854. */
  16855. play(animationName?: string, playTimes?: number): AnimationState;
  16856. /**
  16857. * @language zh_CN
  16858. * 淡入播放指定名称的动画。
  16859. * @param animationName 动画数据的名称。
  16860. * @param playTimes 循环播放的次数。 [-1: 使用数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16861. * @param fadeInTime 淡入的时间。 [-1: 使用数据默认值, [0~N]: N 秒淡入完毕] (以秒为单位)
  16862. * @param layer 混合的图层,图层高会优先获取混合权重。
  16863. * @param group 混合的组,用于给动画状态编组,方便混合淡出控制。
  16864. * @param fadeOutMode 淡出的模式。
  16865. * @param additiveBlending 以叠加的形式混合。
  16866. * @param displayControl 是否对显示对象属性可控。
  16867. * @param pauseFadeOut 暂停需要淡出的动画。
  16868. * @param pauseFadeIn 暂停需要淡入的动画,直到淡入结束才开始播放。
  16869. * @returns 返回控制这个动画数据的动画状态。
  16870. * @see dragonBones.AnimationFadeOutMode
  16871. * @see dragonBones.AnimationState
  16872. * @version DragonBones 4.5
  16873. */
  16874. fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, additiveBlending?: boolean, displayControl?: boolean, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState;
  16875. /**
  16876. * @language zh_CN
  16877. * 指定名称的动画从指定时间开始播放。
  16878. * @param animationName 动画数据的名称。
  16879. * @param time 时间。 (以秒为单位)
  16880. * @param playTimes 动画循环播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16881. * @param toTime 播放到指定的时间,如果未设置则播放整个动画。
  16882. * @returns 返回控制这个动画数据的动画状态。
  16883. * @see dragonBones.AnimationState
  16884. * @version DragonBones 4.5
  16885. */
  16886. gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number, toTime?: number): AnimationState;
  16887. /**
  16888. * @language zh_CN
  16889. * 指定名称的动画从指定帧开始播放。
  16890. * @param animationName 动画数据的名称。
  16891. * @param frame 帧。
  16892. * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16893. * @param toFrame 播放到指定的帧,如果未设置则播放整个动画。
  16894. * @returns 返回控制这个动画数据的动画状态。
  16895. * @see dragonBones.AnimationState
  16896. * @version DragonBones 4.5
  16897. */
  16898. gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number, toFrame?: number): AnimationState;
  16899. /**
  16900. * @language zh_CN
  16901. * 指定名称的动画从指定进度开始播放。
  16902. * @param animationName 动画数据的名称。
  16903. * @param progress 进度。 [0~1]
  16904. * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16905. * @param toProgress 播放到指定的进度,如果未设置则播放整个动画。
  16906. * @returns 返回控制这个动画数据的动画状态。
  16907. * @see dragonBones.AnimationState
  16908. * @version DragonBones 4.5
  16909. */
  16910. gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number, toProgress?: number): AnimationState;
  16911. /**
  16912. * @language zh_CN
  16913. * 播放指定名称的动画到指定的时间并停止。
  16914. * @param animationName 动画数据的名称。
  16915. * @param time 时间。 (以秒为单位)
  16916. * @returns 返回控制这个动画数据的动画状态。
  16917. * @see dragonBones.AnimationState
  16918. * @version DragonBones 4.5
  16919. */
  16920. gotoAndStopByTime(animationName: string, time?: number): AnimationState;
  16921. /**
  16922. * @language zh_CN
  16923. * 播放指定名称的动画到指定的帧并停止。
  16924. * @param animationName 动画数据的名称。
  16925. * @param frame 帧。
  16926. * @returns 返回控制这个动画数据的动画状态。
  16927. * @see dragonBones.AnimationState
  16928. * @version DragonBones 4.5
  16929. */
  16930. gotoAndStopByFrame(animationName: string, frame?: number): AnimationState;
  16931. /**
  16932. * @language zh_CN
  16933. * 播放指定名称的动画到指定的进度并停止。
  16934. * @param animationName 动画数据的名称。
  16935. * @param progress 进度。 [0~1]
  16936. * @returns 返回控制这个动画数据的动画状态。
  16937. * @see dragonBones.AnimationState
  16938. * @version DragonBones 4.5
  16939. */
  16940. gotoAndStopByProgress(animationName: string, progress?: number): AnimationState;
  16941. /**
  16942. * @language zh_CN
  16943. * 获取指定名称的动画状态。
  16944. * @param animationName 动画状态的名称。
  16945. * @see dragonBones.AnimationState
  16946. * @version DragonBones 3.0
  16947. */
  16948. getState(animationName: string): AnimationState;
  16949. /**
  16950. * @language zh_CN
  16951. * 是否包含指定名称的动画数据。
  16952. * @param animationName 动画数据的名称。
  16953. * @see dragonBones.AnimationData
  16954. * @version DragonBones 3.0
  16955. */
  16956. hasAnimation(animationName: string): boolean;
  16957. /**
  16958. * @language zh_CN
  16959. * 动画是否处于播放状态。
  16960. * @version DragonBones 3.0
  16961. */
  16962. isPlaying: boolean;
  16963. /**
  16964. * @language zh_CN
  16965. * 所有动画状态是否均已播放完毕。
  16966. * @see dragonBones.AnimationState
  16967. * @version DragonBones 3.0
  16968. */
  16969. isCompleted: boolean;
  16970. /**
  16971. * @language zh_CN
  16972. * 上一个正在播放的动画状态的名称。
  16973. * @see #lastAnimationState
  16974. * @version DragonBones 3.0
  16975. */
  16976. lastAnimationName: string;
  16977. /**
  16978. * @language zh_CN
  16979. * 上一个正在播放的动画状态。
  16980. * @see dragonBones.AnimationState
  16981. * @version DragonBones 3.0
  16982. */
  16983. lastAnimationState: AnimationState;
  16984. /**
  16985. * @language zh_CN
  16986. * 所有动画数据名称。
  16987. * @see #animations
  16988. * @version DragonBones 4.5
  16989. */
  16990. animationNames: Array<string>;
  16991. /**
  16992. * @language zh_CN
  16993. * 所有的动画数据。
  16994. * @see dragonBones.AnimationData
  16995. * @version DragonBones 4.5
  16996. */
  16997. animations: Map<AnimationData>;
  16998. /**
  16999. * @deprecated
  17000. * @see #play()
  17001. * @see #fadeIn()
  17002. * @see #gotoAndPlayByTime()
  17003. * @see #gotoAndPlayByFrame()
  17004. * @see #gotoAndPlayByProgress()
  17005. */
  17006. gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState;
  17007. /**
  17008. * @deprecated
  17009. * @see #gotoAndStopByTime()
  17010. * @see #gotoAndStopByFrame()
  17011. * @see #gotoAndStopByProgress()
  17012. */
  17013. gotoAndStop(animationName: string, time?: number): AnimationState;
  17014. /**
  17015. * @deprecated
  17016. * @see #animationNames
  17017. * @see #animations
  17018. */
  17019. animationList: Array<string>;
  17020. /**
  17021. * @language zh_CN
  17022. * @deprecated
  17023. * @see #animationNames
  17024. * @see #animations
  17025. */
  17026. animationDataList: Array<AnimationData>;
  17027. }
  17028. }
  17029. declare namespace dragonBones {
  17030. /**
  17031. * @language zh_CN
  17032. * 动画状态,播放动画时产生,可以对单个动画的播放进行更细致的控制和调节。
  17033. * @see dragonBones.Animation
  17034. * @see dragonBones.AnimationData
  17035. * @version DragonBones 3.0
  17036. */
  17037. class AnimationState extends BaseObject {
  17038. /**
  17039. * @private
  17040. */
  17041. static stateActionEnabled: boolean;
  17042. /**
  17043. * @private
  17044. */
  17045. static toString(): string;
  17046. /**
  17047. * @language zh_CN
  17048. * 是否对插槽的颜色,显示序列索引,深度排序,行为等拥有控制的权限。
  17049. * @see dragonBones.Slot#displayController
  17050. * @version DragonBones 3.0
  17051. */
  17052. displayControl: boolean;
  17053. /**
  17054. * @language zh_CN
  17055. * 是否以叠加的方式混合动画。
  17056. * @version DragonBones 3.0
  17057. */
  17058. additiveBlending: boolean;
  17059. /**
  17060. * @private
  17061. */
  17062. actionEnabled: boolean;
  17063. /**
  17064. * @language zh_CN
  17065. * 需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次]
  17066. * @version DragonBones 3.0
  17067. */
  17068. playTimes: number;
  17069. /**
  17070. * @language zh_CN
  17071. * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  17072. * @default 1
  17073. * @version DragonBones 3.0
  17074. */
  17075. timeScale: number;
  17076. /**
  17077. * @language zh_CN
  17078. * 进行动画混合时的权重。
  17079. * @default 1
  17080. * @version DragonBones 3.0
  17081. */
  17082. weight: number;
  17083. /**
  17084. * @language zh_CN
  17085. * 自动淡出时需要的时间,当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 (以秒为单位)
  17086. * @default -1
  17087. * @version DragonBones 3.0
  17088. */
  17089. autoFadeOutTime: number;
  17090. /**
  17091. * @private
  17092. */
  17093. fadeTotalTime: number;
  17094. /**
  17095. * @private
  17096. */
  17097. private _isPlaying;
  17098. /**
  17099. * @private
  17100. */
  17101. private _isPausePlayhead;
  17102. /**
  17103. * @private
  17104. */
  17105. private _fadeTime;
  17106. /**
  17107. * @private
  17108. */
  17109. private _time;
  17110. /**
  17111. * @private
  17112. */
  17113. private _name;
  17114. /**
  17115. * @private
  17116. */
  17117. private _armature;
  17118. /**
  17119. * @private
  17120. */
  17121. private _animationData;
  17122. /**
  17123. * @private
  17124. */
  17125. private _zOrderTimeline;
  17126. /**
  17127. * @private
  17128. */
  17129. private _boneMask;
  17130. /**
  17131. * @private
  17132. */
  17133. private _boneTimelines;
  17134. /**
  17135. * @private
  17136. */
  17137. private _slotTimelines;
  17138. /**
  17139. * @private
  17140. */
  17141. private _ffdTimelines;
  17142. /**
  17143. * @inheritDoc
  17144. */
  17145. protected _onClear(): void;
  17146. private _updateTimelineStates();
  17147. private _advanceFadeTime(passedTime);
  17148. /**
  17149. * @language zh_CN
  17150. * 继续播放。
  17151. * @version DragonBones 3.0
  17152. */
  17153. play(): void;
  17154. /**
  17155. * @language zh_CN
  17156. * 暂停播放。
  17157. * @version DragonBones 3.0
  17158. */
  17159. stop(): void;
  17160. /**
  17161. * @language zh_CN
  17162. * 淡出动画。
  17163. * @param fadeOutTime 淡出时间。 (以秒为单位)
  17164. * @param pausePlayhead 淡出时是否暂停动画。 [true: 暂停, false: 不暂停]
  17165. * @version DragonBones 3.0
  17166. */
  17167. fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void;
  17168. /**
  17169. * @language zh_CN
  17170. * 是否包含指定的骨骼遮罩。
  17171. * @param name 指定的骨骼名称。
  17172. * @version DragonBones 3.0
  17173. */
  17174. containsBoneMask(name: string): boolean;
  17175. /**
  17176. * @language zh_CN
  17177. * 添加指定的骨骼遮罩。
  17178. * @param boneName 指定的骨骼名称。
  17179. * @param recursive 是否为该骨骼的子骨骼添加遮罩。
  17180. * @version DragonBones 3.0
  17181. */
  17182. addBoneMask(name: string, recursive?: boolean): void;
  17183. /**
  17184. * @language zh_CN
  17185. * 删除指定的骨骼遮罩。
  17186. * @param boneName 指定的骨骼名称。
  17187. * @param recursive 是否删除该骨骼的子骨骼遮罩。
  17188. * @version DragonBones 3.0
  17189. */
  17190. removeBoneMask(name: string, recursive?: boolean): void;
  17191. /**
  17192. * @language zh_CN
  17193. * 删除所有骨骼遮罩。
  17194. * @version DragonBones 3.0
  17195. */
  17196. removeAllBoneMask(): void;
  17197. /**
  17198. * @language zh_CN
  17199. * 动画图层。
  17200. * @see dragonBones.Animation#fadeIn()
  17201. * @version DragonBones 3.0
  17202. */
  17203. layer: number;
  17204. /**
  17205. * @language zh_CN
  17206. * 动画组。
  17207. * @see dragonBones.Animation#fadeIn()
  17208. * @version DragonBones 3.0
  17209. */
  17210. group: string;
  17211. /**
  17212. * @language zh_CN
  17213. * 动画名称。
  17214. * @see dragonBones.AnimationData#name
  17215. * @version DragonBones 3.0
  17216. */
  17217. name: string;
  17218. /**
  17219. * @language zh_CN
  17220. * 动画数据。
  17221. * @see dragonBones.AnimationData
  17222. * @version DragonBones 3.0
  17223. */
  17224. animationData: AnimationData;
  17225. /**
  17226. * @language zh_CN
  17227. * 是否播放完毕。
  17228. * @version DragonBones 3.0
  17229. */
  17230. isCompleted: boolean;
  17231. /**
  17232. * @language zh_CN
  17233. * 是否正在播放。
  17234. * @version DragonBones 3.0
  17235. */
  17236. isPlaying: boolean;
  17237. /**
  17238. * @language zh_CN
  17239. * 当前动画的播放次数。
  17240. * @version DragonBones 3.0
  17241. */
  17242. currentPlayTimes: number;
  17243. /**
  17244. * @language zh_CN
  17245. * 当前动画的总时间。 (以秒为单位)
  17246. * @version DragonBones 3.0
  17247. */
  17248. totalTime: number;
  17249. /**
  17250. * @language zh_CN
  17251. * 当前动画的播放时间。 (以秒为单位)
  17252. * @version DragonBones 3.0
  17253. */
  17254. currentTime: number;
  17255. /**
  17256. * @deprecated
  17257. */
  17258. autoTween: boolean;
  17259. /**
  17260. * @deprecated
  17261. * @see #animationData
  17262. */
  17263. clip: AnimationData;
  17264. }
  17265. }
  17266. declare namespace dragonBones {
  17267. }
  17268. declare namespace dragonBones {
  17269. /**
  17270. * @language zh_CN
  17271. * WorldClock 提供时钟的支持,为每个加入到时钟的 IAnimatable 对象更新时间。
  17272. * @see dragonBones.IAnimatable
  17273. * @see dragonBones.Armature
  17274. * @version DragonBones 3.0
  17275. */
  17276. class WorldClock implements IAnimateble {
  17277. private static _clock;
  17278. /**
  17279. * @language zh_CN
  17280. * 一个可以直接使用的全局 WorldClock 实例.
  17281. * @version DragonBones 3.0
  17282. */
  17283. static clock: WorldClock;
  17284. /**
  17285. * @language zh_CN
  17286. * 当前的时间。 (以秒为单位)
  17287. * @version DragonBones 3.0
  17288. */
  17289. time: number;
  17290. /**
  17291. * @language zh_CN
  17292. * 时间流逝的速度,用于实现动画的变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  17293. * @default 1
  17294. * @version DragonBones 3.0
  17295. */
  17296. timeScale: number;
  17297. private _animatebles;
  17298. /**
  17299. * @language zh_CN
  17300. * 创建一个新的 WorldClock 实例。
  17301. * 通常并不需要单独创建 WorldClock 的实例,可以直接使用 WorldClock.clock 静态实例。
  17302. * (创建更多独立的 WorldClock 可以更灵活的为需要更新的 IAnimateble 实例分组,实现不同组不同速度的动画播放)
  17303. * @version DragonBones 3.0
  17304. */
  17305. constructor();
  17306. /**
  17307. * @language zh_CN
  17308. * 为所有的 IAnimatable 实例向前播放一个指定的时间。 (通常这个方法需要在 ENTER_FRAME 事件的响应函数中被调用)
  17309. * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差)
  17310. * @version DragonBones 3.0
  17311. */
  17312. advanceTime(passedTime: number): void;
  17313. /**
  17314. * 是否包含指定的 IAnimatable 实例
  17315. * @param value 指定的 IAnimatable 实例。
  17316. * @returns [true: 包含,false: 不包含]。
  17317. * @version DragonBones 3.0
  17318. */
  17319. contains(value: IAnimateble): boolean;
  17320. /**
  17321. * @language zh_CN
  17322. * 添加指定的 IAnimatable 实例。
  17323. * @param value IAnimatable 实例。
  17324. * @version DragonBones 3.0
  17325. */
  17326. add(value: IAnimateble): void;
  17327. /**
  17328. * @language zh_CN
  17329. * 移除指定的 IAnimatable 实例。
  17330. * @param value IAnimatable 实例。
  17331. * @version DragonBones 3.0
  17332. */
  17333. remove(value: IAnimateble): void;
  17334. /**
  17335. * @language zh_CN
  17336. * 清除所有的 IAnimatable 实例。
  17337. * @version DragonBones 3.0
  17338. */
  17339. clear(): void;
  17340. }
  17341. }
  17342. declare namespace dragonBones {
  17343. /**
  17344. * @language zh_CN
  17345. * 基础变换对象。
  17346. * @version DragonBones 4.5
  17347. */
  17348. abstract class TransformObject extends BaseObject {
  17349. /**
  17350. * @language zh_CN
  17351. * 可以用于存储临时数据。
  17352. * @version DragonBones 3.0
  17353. */
  17354. userData: any;
  17355. /**
  17356. * @language zh_CN
  17357. * 对象的名称。
  17358. * @version DragonBones 3.0
  17359. */
  17360. name: string;
  17361. /**
  17362. * @language zh_CN
  17363. * 相对于骨架坐标系的矩阵。
  17364. * @version DragonBones 3.0
  17365. */
  17366. globalTransformMatrix: Matrix;
  17367. /**
  17368. * @language zh_CN
  17369. * 相对于骨架坐标系的变换。
  17370. * @see dragonBones.Transform
  17371. * @version DragonBones 3.0
  17372. */
  17373. global: Transform;
  17374. /**
  17375. * @language zh_CN
  17376. * 相对于骨架或父骨骼坐标系的绑定变换。
  17377. * @see dragonBones.Transform
  17378. * @version DragonBones 3.0
  17379. */
  17380. origin: Transform;
  17381. /**
  17382. * @language zh_CN
  17383. * 相对于骨架或父骨骼坐标系的偏移变换。
  17384. * @see dragonBones.Transform
  17385. * @version DragonBones 3.0
  17386. */
  17387. offset: Transform;
  17388. /**
  17389. * @private
  17390. */
  17391. _armature: Armature;
  17392. /**
  17393. * @private
  17394. */
  17395. _parent: Bone;
  17396. /**
  17397. * @private
  17398. */
  17399. protected _globalTransformMatrix: Matrix;
  17400. /**
  17401. * @inheritDoc
  17402. */
  17403. protected _onClear(): void;
  17404. /**
  17405. * @language zh_CN
  17406. * 所属的骨架。
  17407. * @see dragonBones.Armature
  17408. * @version DragonBones 3.0
  17409. */
  17410. armature: Armature;
  17411. /**
  17412. * @language zh_CN
  17413. * 所属的父骨骼。
  17414. * @see dragonBones.Bone
  17415. * @version DragonBones 3.0
  17416. */
  17417. parent: Bone;
  17418. }
  17419. }
  17420. declare namespace dragonBones {
  17421. /**
  17422. * @language zh_CN
  17423. * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。
  17424. * @see dragonBones.ArmatureData
  17425. * @see dragonBones.Bone
  17426. * @see dragonBones.Slot
  17427. * @see dragonBones.Animation
  17428. * @see dragonBones.IArmatureDisplay
  17429. * @version DragonBones 3.0
  17430. */
  17431. class Armature extends BaseObject implements IAnimateble {
  17432. /**
  17433. * @private
  17434. */
  17435. static toString(): string;
  17436. private static _onSortSlots(a, b);
  17437. /**
  17438. * @language zh_CN
  17439. * 可以用于存储临时数据。
  17440. * @version DragonBones 3.0
  17441. */
  17442. userData: any;
  17443. /**
  17444. * @private
  17445. */
  17446. _cacheFrameIndex: number;
  17447. /**
  17448. * @private
  17449. */
  17450. _armatureData: ArmatureData;
  17451. /**
  17452. * @private
  17453. */
  17454. _skinData: SkinData;
  17455. /**
  17456. * @private
  17457. */
  17458. _animation: Animation;
  17459. /**
  17460. * @private
  17461. */
  17462. _display: IArmatureDisplay;
  17463. /**
  17464. * @private
  17465. */
  17466. _eventManager: IEventDispatcher;
  17467. private _delayDispose;
  17468. private _lockDispose;
  17469. private _slotsDirty;
  17470. private _replacedTexture;
  17471. private _bones;
  17472. private _slots;
  17473. private _actions;
  17474. private _events;
  17475. /**
  17476. * @inheritDoc
  17477. */
  17478. protected _onClear(): void;
  17479. private _sortBones();
  17480. private _sortSlots();
  17481. private _doAction(value);
  17482. /**
  17483. * @private
  17484. */
  17485. _sortZOrder(slotIndices: Array<number>): void;
  17486. /**
  17487. * @private
  17488. */
  17489. _bufferAction(value: ActionData): void;
  17490. /**
  17491. * @language zh_CN
  17492. * 释放骨架。 (会回收到内存池)
  17493. * @version DragonBones 3.0
  17494. */
  17495. dispose(): void;
  17496. /**
  17497. * @language zh_CN
  17498. * 更新骨架和动画。 (可以使用时钟实例或显示容器来更新)
  17499. * @param passedTime 两帧之前的时间间隔。 (以秒为单位)
  17500. * @see dragonBones.IAnimateble
  17501. * @see dragonBones.WorldClock
  17502. * @see dragonBones.IArmatureDisplay
  17503. * @version DragonBones 3.0
  17504. */
  17505. advanceTime(passedTime: number): void;
  17506. /**
  17507. * @language zh_CN
  17508. * 更新骨骼和插槽的变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新)
  17509. * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。
  17510. * @param updateSlotDisplay 是否更新插槽的显示对象。
  17511. * @see dragonBones.Bone
  17512. * @see dragonBones.Slot
  17513. * @version DragonBones 3.0
  17514. */
  17515. invalidUpdate(boneName?: string, updateSlotDisplay?: boolean): void;
  17516. /**
  17517. * @language zh_CN
  17518. * 获取指定名称的骨骼。
  17519. * @param name 骨骼的名称。
  17520. * @returns 骨骼。
  17521. * @see dragonBones.Bone
  17522. * @version DragonBones 3.0
  17523. */
  17524. getBone(name: string): Bone;
  17525. /**
  17526. * @language zh_CN
  17527. * 通过显示对象获取骨骼。
  17528. * @param display 显示对象。
  17529. * @returns 包含这个显示对象的骨骼。
  17530. * @see dragonBones.Bone
  17531. * @version DragonBones 3.0
  17532. */
  17533. getBoneByDisplay(display: any): Bone;
  17534. /**
  17535. * @language zh_CN
  17536. * 获取指定名称的插槽。
  17537. * @param name 插槽的名称。
  17538. * @returns 插槽。
  17539. * @see dragonBones.Slot
  17540. * @version DragonBones 3.0
  17541. */
  17542. getSlot(name: string): Slot;
  17543. /**
  17544. * @language zh_CN
  17545. * 通过显示对象获取插槽。
  17546. * @param display 显示对象。
  17547. * @returns 包含这个显示对象的插槽。
  17548. * @see dragonBones.Slot
  17549. * @version DragonBones 3.0
  17550. */
  17551. getSlotByDisplay(display: any): Slot;
  17552. /**
  17553. * @language zh_CN
  17554. * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。
  17555. * @param texture 贴图。
  17556. * @version DragonBones 4.5
  17557. */
  17558. replaceTexture(texture: any): void;
  17559. /**
  17560. * @language zh_CN
  17561. * 获取所有骨骼。
  17562. * @see dragonBones.Bone
  17563. * @version DragonBones 3.0
  17564. */
  17565. getBones(): Array<Bone>;
  17566. /**
  17567. * @language zh_CN
  17568. * 获取所有插槽。
  17569. * @see dragonBones.Slot
  17570. * @version DragonBones 3.0
  17571. */
  17572. getSlots(): Array<Slot>;
  17573. /**
  17574. * @language zh_CN
  17575. * 骨架名称。
  17576. * @see dragonBones.ArmatureData#name
  17577. * @version DragonBones 3.0
  17578. */
  17579. name: string;
  17580. /**
  17581. * @language zh_CN
  17582. * 获取骨架数据。
  17583. * @see dragonBones.ArmatureData
  17584. * @version DragonBones 4.5
  17585. */
  17586. armatureData: ArmatureData;
  17587. /**
  17588. * @language zh_CN
  17589. * 获得动画控制器。
  17590. * @see dragonBones.Animation
  17591. * @version DragonBones 3.0
  17592. */
  17593. animation: Animation;
  17594. /**
  17595. * @language zh_CN
  17596. * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。
  17597. * @version DragonBones 3.0
  17598. */
  17599. display: IArmatureDisplay | any;
  17600. /**
  17601. * @language zh_CN
  17602. * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系)
  17603. * @see dragonBones.Slot
  17604. * @version DragonBones 4.5
  17605. */
  17606. parent: Slot;
  17607. /**
  17608. * @language zh_CN
  17609. * 动画缓存的帧率,当设置一个大于 0 的帧率时,将会开启动画缓存。
  17610. * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。
  17611. * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。
  17612. * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。
  17613. * @see dragonBones.DragonBonesData#frameRate
  17614. * @see dragonBones.ArmatureData#frameRate
  17615. * @version DragonBones 4.5
  17616. */
  17617. cacheFrameRate: number;
  17618. /**
  17619. * @language zh_CN
  17620. * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。
  17621. * @version DragonBones 4.5
  17622. */
  17623. replacedTexture: any;
  17624. /**
  17625. * @language zh_CN
  17626. * 开启动画缓存。
  17627. * @param frameRate 动画缓存的帧率
  17628. * @see #cacheFrameRate
  17629. * @version DragonBones 4.5
  17630. */
  17631. enableAnimationCache(frameRate: number): void;
  17632. /**
  17633. * @language zh_CN
  17634. * 是否包含指定类型的事件。
  17635. * @param type 事件类型。
  17636. * @returns [true: 包含, false: 不包含]
  17637. * @version DragonBones 3.0
  17638. */
  17639. hasEventListener(type: EventStringType): void;
  17640. /**
  17641. * @language zh_CN
  17642. * 添加事件。
  17643. * @param type 事件类型。
  17644. * @param listener 事件回调。
  17645. * @version DragonBones 3.0
  17646. */
  17647. addEventListener(type: EventStringType, listener: Function, target: any): void;
  17648. /**
  17649. * @language zh_CN
  17650. * 移除事件。
  17651. * @param type 事件类型。
  17652. * @param listener 事件回调。
  17653. * @version DragonBones 3.0
  17654. */
  17655. removeEventListener(type: EventStringType, listener: Function, target: any): void;
  17656. /**
  17657. * @deprecated
  17658. */
  17659. addBone(value: Bone, parentName?: string): void;
  17660. /**
  17661. * @deprecated
  17662. */
  17663. addSlot(value: Slot, parentName: string): void;
  17664. /**
  17665. * @deprecated
  17666. */
  17667. removeBone(value: Bone): void;
  17668. /**
  17669. * @deprecated
  17670. */
  17671. removeSlot(value: Slot): void;
  17672. /**
  17673. * @deprecated
  17674. * @see #display
  17675. */
  17676. getDisplay(): any;
  17677. /**
  17678. * @deprecated
  17679. * @see #cacheFrameRate
  17680. */
  17681. enableCache: boolean;
  17682. }
  17683. }
  17684. declare namespace dragonBones {
  17685. /**
  17686. * @language zh_CN
  17687. * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。
  17688. * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。
  17689. * @see dragonBones.BoneData
  17690. * @see dragonBones.Armature
  17691. * @see dragonBones.Slot
  17692. * @version DragonBones 3.0
  17693. */
  17694. class Bone extends TransformObject {
  17695. /**
  17696. * @private
  17697. */
  17698. static toString(): string;
  17699. /**
  17700. * @language zh_CN
  17701. * 是否继承父骨骼的平移。 [true: 继承, false: 不继承]
  17702. * @version DragonBones 3.0
  17703. */
  17704. inheritTranslation: boolean;
  17705. /**
  17706. * @language zh_CN
  17707. * 是否继承父骨骼的旋转。 [true: 继承, false: 不继承]
  17708. * @version DragonBones 3.0
  17709. */
  17710. inheritRotation: boolean;
  17711. /**
  17712. * @language zh_CN
  17713. * 是否继承父骨骼的缩放。 [true: 继承, false: 不继承]
  17714. * @version DragonBones 4.5
  17715. */
  17716. inheritScale: boolean;
  17717. /**
  17718. * @language zh_CN
  17719. * IK 约束时骨骼方向是否为顺时针方向。 [true: 顺时针, false: 逆时针]
  17720. * @version DragonBones 4.5
  17721. */
  17722. ikBendPositive: boolean;
  17723. /**
  17724. * @language zh_CN
  17725. * IK 约束的权重。
  17726. * @version DragonBones 4.5
  17727. */
  17728. ikWeight: number;
  17729. /**
  17730. * @language zh_CN
  17731. * 骨骼长度。
  17732. * @version DragonBones 4.5
  17733. */
  17734. length: number;
  17735. /**
  17736. * @private
  17737. */
  17738. private _visible;
  17739. /**
  17740. * @private
  17741. */
  17742. private _ikChain;
  17743. /**
  17744. * @private
  17745. */
  17746. private _ikChainIndex;
  17747. /**
  17748. * @private
  17749. */
  17750. private _ik;
  17751. /**
  17752. * @private
  17753. */
  17754. private _bones;
  17755. /**
  17756. * @private
  17757. */
  17758. private _slots;
  17759. /**
  17760. * @inheritDoc
  17761. */
  17762. protected _onClear(): void;
  17763. /**
  17764. * @private
  17765. */
  17766. private _updateGlobalTransformMatrix();
  17767. /**
  17768. * @private
  17769. */
  17770. private _computeIKA();
  17771. /**
  17772. * @private
  17773. */
  17774. private _computeIKB();
  17775. /**
  17776. * @inheritDoc
  17777. */
  17778. _setArmature(value: Armature): void;
  17779. /**
  17780. * @language zh_CN
  17781. * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新)
  17782. * @version DragonBones 3.0
  17783. */
  17784. invalidUpdate(): void;
  17785. /**
  17786. * @language zh_CN
  17787. * 是否包含某个指定的骨骼或插槽。
  17788. * @returns [true: 包含,false: 不包含]
  17789. * @see dragonBones.TransformObject
  17790. * @version DragonBones 3.0
  17791. */
  17792. contains(child: TransformObject): boolean;
  17793. /**
  17794. * @language zh_CN
  17795. * 所有的子骨骼。
  17796. * @version DragonBones 3.0
  17797. */
  17798. getBones(): Array<Bone>;
  17799. /**
  17800. * @language zh_CN
  17801. * 所有的插槽。
  17802. * @see dragonBones.Slot
  17803. * @version DragonBones 3.0
  17804. */
  17805. getSlots(): Array<Slot>;
  17806. /**
  17807. * @private
  17808. */
  17809. ikChain: number;
  17810. /**
  17811. * @private
  17812. */
  17813. ikChainIndex: number;
  17814. /**
  17815. * @language zh_CN
  17816. * 当前的 IK 约束目标。
  17817. * @version DragonBones 4.5
  17818. */
  17819. ik: Bone;
  17820. /**
  17821. * @language zh_CN
  17822. * 控制此骨骼所有插槽的显示。
  17823. * @default true
  17824. * @see dragonBones.Slot
  17825. * @version DragonBones 3.0
  17826. */
  17827. visible: boolean;
  17828. /**
  17829. * @deprecated
  17830. * @see dragonBones.Armature#getSlot()
  17831. */
  17832. slot: Slot;
  17833. }
  17834. }
  17835. declare namespace dragonBones {
  17836. /**
  17837. * @language zh_CN
  17838. * 骨架显示容器和事件的接口。
  17839. * @see dragonBones.Armature#display
  17840. * @version DragonBones 4.5
  17841. */
  17842. interface IArmatureDisplay extends IEventDispatcher {
  17843. /**
  17844. * @language zh_CN
  17845. * 释放显示对象和骨架。
  17846. * @version DragonBones 4.5
  17847. */
  17848. dispose(): void;
  17849. /**
  17850. * @language zh_CN
  17851. * 获取使用这个显示容器的骨架。
  17852. * @readOnly
  17853. * @see dragonBones.Armature
  17854. * @version DragonBones 4.5
  17855. */
  17856. armature: Armature;
  17857. /**
  17858. * @language zh_CN
  17859. * 获取使用骨架的动画控制器。
  17860. * @readOnly
  17861. * @see dragonBones.Animation
  17862. * @version DragonBones 4.5
  17863. */
  17864. animation: Animation;
  17865. /**
  17866. * @language zh_CN
  17867. * 由显示容器来更新骨架和动画。
  17868. * @param on 开启或关闭显示容器对骨架与动画的更新。
  17869. * @version DragonBones 4.5
  17870. */
  17871. advanceTimeBySelf(on: boolean): void;
  17872. }
  17873. }
  17874. declare namespace dragonBones {
  17875. /**
  17876. * @language zh_CN
  17877. * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。
  17878. * 一个骨骼上可以包含多个插槽。
  17879. * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。
  17880. * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。
  17881. * @see dragonBones.Armature
  17882. * @see dragonBones.Bone
  17883. * @see dragonBones.SlotData
  17884. * @version DragonBones 3.0
  17885. */
  17886. abstract class Slot extends TransformObject {
  17887. private static _helpPoint;
  17888. private static _helpMatrix;
  17889. /**
  17890. * @language zh_CN
  17891. * 子骨架是否继承父骨架的动画。 [true: 继承, false: 不继承]
  17892. * @default true
  17893. * @version DragonBones 4.5
  17894. */
  17895. inheritAnimation: boolean;
  17896. /**
  17897. * @language zh_CN
  17898. * 显示对象受到控制的对象,应设置为动画状态的名称或组名称,设置为 null 则表示受所有的动画状态控制。
  17899. * @default null
  17900. * @see dragonBones.AnimationState#displayControl
  17901. * @see dragonBones.AnimationState#name
  17902. * @see dragonBones.AnimationState#group
  17903. * @version DragonBones 4.5
  17904. */
  17905. displayController: string;
  17906. /**
  17907. * @private
  17908. */
  17909. _zOrder: number;
  17910. /**
  17911. * @private
  17912. */
  17913. _pivotX: number;
  17914. /**
  17915. * @private
  17916. */
  17917. _pivotY: number;
  17918. /**
  17919. * @private
  17920. */
  17921. _displayDataSet: SlotDisplayDataSet;
  17922. /**
  17923. * @private
  17924. */
  17925. _meshData: MeshData;
  17926. /**
  17927. * @private
  17928. */
  17929. _childArmature: Armature;
  17930. /**
  17931. * @private
  17932. */
  17933. _rawDisplay: any;
  17934. /**
  17935. * @private
  17936. */
  17937. _meshDisplay: any;
  17938. /**
  17939. * @private
  17940. */
  17941. _cacheFrames: Array<Matrix>;
  17942. /**
  17943. * @private
  17944. */
  17945. _colorTransform: ColorTransform;
  17946. /**
  17947. * @private
  17948. */
  17949. _ffdVertices: Array<number>;
  17950. /**
  17951. * @private
  17952. */
  17953. _replacedDisplayDataSet: Array<DisplayData>;
  17954. /**
  17955. * @private
  17956. */
  17957. protected _displayDirty: boolean;
  17958. /**
  17959. * @private
  17960. */
  17961. protected _blendModeDirty: boolean;
  17962. /**
  17963. * @private
  17964. */
  17965. protected _originDirty: boolean;
  17966. /**
  17967. * @private
  17968. */
  17969. protected _transformDirty: boolean;
  17970. /**
  17971. * @private
  17972. */
  17973. protected _displayIndex: number;
  17974. /**
  17975. * @private
  17976. */
  17977. protected _blendMode: BlendMode;
  17978. /**
  17979. * @private
  17980. */
  17981. protected _display: any;
  17982. /**
  17983. * @private
  17984. */
  17985. protected _localMatrix: Matrix;
  17986. /**
  17987. * @private
  17988. */
  17989. protected _displayList: Array<any | Armature>;
  17990. /**
  17991. * @private
  17992. */
  17993. protected _meshBones: Array<Bone>;
  17994. /**
  17995. * @inheritDoc
  17996. */
  17997. protected _onClear(): void;
  17998. /**
  17999. * @private
  18000. */
  18001. protected abstract _initDisplay(value: any): void;
  18002. /**
  18003. * @private
  18004. */
  18005. protected abstract _disposeDisplay(value: any): void;
  18006. /**
  18007. * @private
  18008. */
  18009. protected abstract _onUpdateDisplay(): void;
  18010. /**
  18011. * @private
  18012. */
  18013. protected abstract _addDisplay(): void;
  18014. /**
  18015. * @private
  18016. */
  18017. protected abstract _replaceDisplay(value: any): void;
  18018. /**
  18019. * @private
  18020. */
  18021. protected abstract _removeDisplay(): void;
  18022. /**
  18023. * @private
  18024. */
  18025. protected abstract _updateZOrder(): void;
  18026. /**
  18027. * @private
  18028. */
  18029. protected abstract _updateBlendMode(): void;
  18030. /**
  18031. * @private
  18032. */
  18033. protected abstract _updateColor(): void;
  18034. /**
  18035. * @private
  18036. */
  18037. protected abstract _updateFilters(): void;
  18038. /**
  18039. * @private
  18040. */
  18041. protected abstract _updateFrame(): void;
  18042. /**
  18043. * @private
  18044. */
  18045. protected abstract _updateMesh(): void;
  18046. /**
  18047. * @private
  18048. */
  18049. protected abstract _updateTransform(): void;
  18050. private _isMeshBonesUpdate();
  18051. /**
  18052. * @private
  18053. */
  18054. protected _updatePivot(rawDisplayData: DisplayData, currentDisplayData: DisplayData, currentTextureData: TextureData): void;
  18055. /**
  18056. * @private
  18057. */
  18058. protected _updateDisplay(): void;
  18059. /**
  18060. * @private
  18061. */
  18062. protected _updateLocalTransformMatrix(): void;
  18063. /**
  18064. * @private
  18065. */
  18066. protected _updateGlobalTransformMatrix(): void;
  18067. /**
  18068. * @private Factory
  18069. */
  18070. _setDisplayList(value: Array<any>): boolean;
  18071. /**
  18072. * @language zh_CN
  18073. * 在下一帧更新显示对象的状态。
  18074. * @version DragonBones 4.5
  18075. */
  18076. invalidUpdate(): void;
  18077. /**
  18078. * @private
  18079. */
  18080. rawDisplay: any;
  18081. /**
  18082. * @private
  18083. */
  18084. MeshDisplay: any;
  18085. /**
  18086. * @language zh_CN
  18087. * 此时显示的显示对象在显示列表中的索引。
  18088. * @version DragonBones 4.5
  18089. */
  18090. displayIndex: number;
  18091. /**
  18092. * @language zh_CN
  18093. * 包含显示对象或子骨架的显示列表。
  18094. * @version DragonBones 3.0
  18095. */
  18096. displayList: Array<any>;
  18097. /**
  18098. * @language zh_CN
  18099. * 此时显示的显示对象。
  18100. * @version DragonBones 3.0
  18101. */
  18102. display: any;
  18103. /**
  18104. * @language zh_CN
  18105. * 此时显示的子骨架。
  18106. * @see dragonBones.Armature
  18107. * @version DragonBones 3.0
  18108. */
  18109. childArmature: Armature;
  18110. /**
  18111. * @deprecated
  18112. * @see #display
  18113. */
  18114. getDisplay(): any;
  18115. /**
  18116. * @deprecated
  18117. * @see #display
  18118. */
  18119. setDisplay(value: any): void;
  18120. }
  18121. }
  18122. declare namespace dragonBones {
  18123. /**
  18124. * @private
  18125. */
  18126. type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent";
  18127. /**
  18128. * @language zh_CN
  18129. * 事件接口。
  18130. * @version DragonBones 4.5
  18131. */
  18132. interface IEventDispatcher {
  18133. /**
  18134. * @language zh_CN
  18135. * 是否包含指定类型的事件。
  18136. * @param type 事件类型。
  18137. * @returns [true: 包含, false: 不包含]
  18138. * @version DragonBones 4.5
  18139. */
  18140. hasEvent(type: EventStringType): boolean;
  18141. /**
  18142. * @language zh_CN
  18143. * 添加事件。
  18144. * @param type 事件类型。
  18145. * @param listener 事件回调。
  18146. * @version DragonBones 4.5
  18147. */
  18148. addEvent(type: EventStringType, listener: Function, target: any): void;
  18149. /**
  18150. * @language zh_CN
  18151. * 移除事件。
  18152. * @param type 事件类型。
  18153. * @param listener 事件回调。
  18154. * @version DragonBones 4.5
  18155. */
  18156. removeEvent(type: EventStringType, listener: Function, target: any): void;
  18157. }
  18158. /**
  18159. * @language zh_CN
  18160. * 事件数据。
  18161. * @version DragonBones 4.5
  18162. */
  18163. class EventObject extends BaseObject {
  18164. /**
  18165. * @language zh_CN
  18166. * 动画开始。
  18167. * @version DragonBones 4.5
  18168. */
  18169. static START: string;
  18170. /**
  18171. * @language zh_CN
  18172. * 动画循环播放一次完成。
  18173. * @version DragonBones 4.5
  18174. */
  18175. static LOOP_COMPLETE: string;
  18176. /**
  18177. * @language zh_CN
  18178. * 动画播放完成。
  18179. * @version DragonBones 4.5
  18180. */
  18181. static COMPLETE: string;
  18182. /**
  18183. * @language zh_CN
  18184. * 动画淡入开始。
  18185. * @version DragonBones 4.5
  18186. */
  18187. static FADE_IN: string;
  18188. /**
  18189. * @language zh_CN
  18190. * 动画淡入完成。
  18191. * @version DragonBones 4.5
  18192. */
  18193. static FADE_IN_COMPLETE: string;
  18194. /**
  18195. * @language zh_CN
  18196. * 动画淡出开始。
  18197. * @version DragonBones 4.5
  18198. */
  18199. static FADE_OUT: string;
  18200. /**
  18201. * @language zh_CN
  18202. * 动画淡出完成。
  18203. * @version DragonBones 4.5
  18204. */
  18205. static FADE_OUT_COMPLETE: string;
  18206. /**
  18207. * @language zh_CN
  18208. * 动画帧事件。
  18209. * @version DragonBones 4.5
  18210. */
  18211. static FRAME_EVENT: string;
  18212. /**
  18213. * @language zh_CN
  18214. * 动画声音事件。
  18215. * @version DragonBones 4.5
  18216. */
  18217. static SOUND_EVENT: string;
  18218. /**
  18219. * @private
  18220. */
  18221. static toString(): string;
  18222. /**
  18223. * @language zh_CN
  18224. * 事件类型。
  18225. * @version DragonBones 4.5
  18226. */
  18227. type: EventStringType;
  18228. /**
  18229. * @language zh_CN
  18230. * 事件名称。 (帧标签的名称或声音的名称)
  18231. * @version DragonBones 4.5
  18232. */
  18233. name: string;
  18234. /**
  18235. * @language zh_CN
  18236. * 扩展的数据。
  18237. * @version DragonBones 4.5
  18238. */
  18239. data: any;
  18240. /**
  18241. * @language zh_CN
  18242. * 发出事件的骨架。
  18243. * @version DragonBones 4.5
  18244. */
  18245. armature: Armature;
  18246. /**
  18247. * @language zh_CN
  18248. * 发出事件的骨骼。
  18249. * @version DragonBones 4.5
  18250. */
  18251. bone: Bone;
  18252. /**
  18253. * @language zh_CN
  18254. * 发出事件的插槽。
  18255. * @version DragonBones 4.5
  18256. */
  18257. slot: Slot;
  18258. /**
  18259. * @language zh_CN
  18260. * 发出事件的动画状态。
  18261. * @version DragonBones 4.5
  18262. */
  18263. animationState: AnimationState;
  18264. /**
  18265. * @private
  18266. */
  18267. frame: AnimationFrameData;
  18268. /**
  18269. * @language zh_CN
  18270. * 用户数据。
  18271. * @version DragonBones 4.5
  18272. */
  18273. userData: any;
  18274. /**
  18275. * @inheritDoc
  18276. */
  18277. protected _onClear(): void;
  18278. }
  18279. }
  18280. declare namespace dragonBones {
  18281. /**
  18282. * @private
  18283. */
  18284. class ColorTransform {
  18285. alphaMultiplier: number;
  18286. redMultiplier: number;
  18287. greenMultiplier: number;
  18288. blueMultiplier: number;
  18289. alphaOffset: number;
  18290. redOffset: number;
  18291. greenOffset: number;
  18292. blueOffset: number;
  18293. constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number);
  18294. copyFrom(value: ColorTransform): void;
  18295. identity(): void;
  18296. }
  18297. }
  18298. declare namespace dragonBones {
  18299. /**
  18300. * @language zh_CN
  18301. * 2D 矩阵。
  18302. * @version DragonBones 3.0
  18303. */
  18304. class Matrix {
  18305. a: number;
  18306. b: number;
  18307. c: number;
  18308. d: number;
  18309. tx: number;
  18310. ty: number;
  18311. constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number);
  18312. /**
  18313. * @private
  18314. */
  18315. toString(): string;
  18316. /**
  18317. * @language zh_CN
  18318. * 复制矩阵。
  18319. * @param value 需要复制的矩阵。
  18320. * @version DragonBones 3.0
  18321. */
  18322. copyFrom(value: Matrix): void;
  18323. /**
  18324. * @language zh_CN
  18325. * 转换为恒等矩阵。
  18326. * @version DragonBones 3.0
  18327. */
  18328. identity(): void;
  18329. /**
  18330. * @language zh_CN
  18331. * 将当前矩阵与另一个矩阵相乘。
  18332. * @param value 需要相乘的矩阵。
  18333. * @version DragonBones 3.0
  18334. */
  18335. concat(value: Matrix): void;
  18336. /**
  18337. * @language zh_CN
  18338. * 转换为逆矩阵。
  18339. * @version DragonBones 3.0
  18340. */
  18341. invert(): void;
  18342. /**
  18343. * @language zh_CN
  18344. * 将矩阵转换应用于指定点。
  18345. * @param x 横坐标。
  18346. * @param y 纵坐标。
  18347. * @param result 应用转换之后的坐标。
  18348. * @params delta 是否忽略 tx,ty 对坐标的转换。
  18349. * @version DragonBones 3.0
  18350. */
  18351. transformPoint(x: number, y: number, result: {
  18352. x: number;
  18353. y: number;
  18354. }, delta?: boolean): void;
  18355. }
  18356. }
  18357. declare namespace dragonBones {
  18358. /**
  18359. * @private
  18360. */
  18361. class Point {
  18362. x: number;
  18363. y: number;
  18364. constructor(x?: number, y?: number);
  18365. copyFrom(value: Point): void;
  18366. clear(): void;
  18367. }
  18368. }
  18369. declare namespace dragonBones {
  18370. /**
  18371. * @private
  18372. */
  18373. class Rectangle {
  18374. x: number;
  18375. y: number;
  18376. width: number;
  18377. height: number;
  18378. constructor(x?: number, y?: number, width?: number, height?: number);
  18379. copyFrom(value: Rectangle): void;
  18380. clear(): void;
  18381. }
  18382. }
  18383. declare namespace dragonBones {
  18384. /**
  18385. * @language zh_CN
  18386. * 2D 变换。
  18387. * @version DragonBones 3.0
  18388. */
  18389. class Transform {
  18390. /**
  18391. * @language zh_CN
  18392. * 水平位移。
  18393. * @version DragonBones 3.0
  18394. */
  18395. x: number;
  18396. /**
  18397. * @language zh_CN
  18398. * 垂直位移。
  18399. * @version DragonBones 3.0
  18400. */
  18401. y: number;
  18402. /**
  18403. * @language zh_CN
  18404. * 水平倾斜。 (以弧度为单位)
  18405. * @version DragonBones 3.0
  18406. */
  18407. skewX: number;
  18408. /**
  18409. * @language zh_CN
  18410. * 垂直倾斜。 (以弧度为单位)
  18411. * @version DragonBones 3.0
  18412. */
  18413. skewY: number;
  18414. /**
  18415. * @language zh_CN
  18416. * 水平缩放。
  18417. * @version DragonBones 3.0
  18418. */
  18419. scaleX: number;
  18420. /**
  18421. * @language zh_CN
  18422. * 垂直缩放。
  18423. * @version DragonBones 3.0
  18424. */
  18425. scaleY: number;
  18426. /**
  18427. * @private
  18428. */
  18429. static normalizeRadian(value: number): number;
  18430. /**
  18431. * @private
  18432. */
  18433. constructor(
  18434. /**
  18435. * @language zh_CN
  18436. * 水平位移。
  18437. * @version DragonBones 3.0
  18438. */
  18439. x?: number,
  18440. /**
  18441. * @language zh_CN
  18442. * 垂直位移。
  18443. * @version DragonBones 3.0
  18444. */
  18445. y?: number,
  18446. /**
  18447. * @language zh_CN
  18448. * 水平倾斜。 (以弧度为单位)
  18449. * @version DragonBones 3.0
  18450. */
  18451. skewX?: number,
  18452. /**
  18453. * @language zh_CN
  18454. * 垂直倾斜。 (以弧度为单位)
  18455. * @version DragonBones 3.0
  18456. */
  18457. skewY?: number,
  18458. /**
  18459. * @language zh_CN
  18460. * 水平缩放。
  18461. * @version DragonBones 3.0
  18462. */
  18463. scaleX?: number,
  18464. /**
  18465. * @language zh_CN
  18466. * 垂直缩放。
  18467. * @version DragonBones 3.0
  18468. */
  18469. scaleY?: number);
  18470. /**
  18471. * @private
  18472. */
  18473. toString(): string;
  18474. /**
  18475. * @private
  18476. */
  18477. copyFrom(value: Transform): Transform;
  18478. /**
  18479. * @private
  18480. */
  18481. identity(): Transform;
  18482. /**
  18483. * @private
  18484. */
  18485. add(value: Transform): Transform;
  18486. /**
  18487. * @private
  18488. */
  18489. minus(value: Transform): Transform;
  18490. /**
  18491. * @private
  18492. */
  18493. fromMatrix(matrix: Matrix): Transform;
  18494. /**
  18495. * @language zh_CN
  18496. * 转换为矩阵。
  18497. * @param 矩阵。
  18498. * @version DragonBones 3.0
  18499. */
  18500. toMatrix(matrix: Matrix): Transform;
  18501. /**
  18502. * @language zh_CN
  18503. * 旋转。 (以弧度为单位)
  18504. * @version DragonBones 3.0
  18505. */
  18506. rotation: number;
  18507. }
  18508. }
  18509. declare namespace dragonBones {
  18510. /**
  18511. * @private
  18512. */
  18513. abstract class TimelineData<T extends FrameData<T>> extends BaseObject {
  18514. /**
  18515. * @private
  18516. */
  18517. static toString(): string;
  18518. scale: number;
  18519. /**
  18520. * @private
  18521. */
  18522. offset: number;
  18523. /**
  18524. * @private
  18525. */
  18526. frames: Array<T>;
  18527. constructor();
  18528. /**
  18529. * @inheritDoc
  18530. */
  18531. protected _onClear(): void;
  18532. }
  18533. /**
  18534. * @private
  18535. */
  18536. class ZOrderTimelineData extends TimelineData<ZOrderFrameData> {
  18537. static toString(): string;
  18538. }
  18539. /**
  18540. * @private
  18541. */
  18542. class BoneTimelineData extends TimelineData<BoneFrameData> {
  18543. static cacheFrame(cacheFrames: Array<Matrix>, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix;
  18544. static toString(): string;
  18545. bone: BoneData;
  18546. originalTransform: Transform;
  18547. cachedFrames: Array<Matrix>;
  18548. constructor();
  18549. /**
  18550. * @inheritDoc
  18551. */
  18552. protected _onClear(): void;
  18553. cacheFrames(cacheFrameCount: number): void;
  18554. }
  18555. /**
  18556. * @private
  18557. */
  18558. class SlotTimelineData extends TimelineData<SlotFrameData> {
  18559. static cacheFrame(cacheFrames: Array<Matrix>, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix;
  18560. static toString(): string;
  18561. slot: SlotData;
  18562. cachedFrames: Array<Matrix>;
  18563. constructor();
  18564. /**
  18565. * @inheritDoc
  18566. */
  18567. protected _onClear(): void;
  18568. cacheFrames(cacheFrameCount: number): void;
  18569. }
  18570. /**
  18571. * @private
  18572. */
  18573. class FFDTimelineData extends TimelineData<ExtensionFrameData> {
  18574. static toString(): string;
  18575. displayIndex: number;
  18576. skin: SkinData;
  18577. slot: SlotDisplayDataSet;
  18578. constructor();
  18579. /**
  18580. * @inheritDoc
  18581. */
  18582. protected _onClear(): void;
  18583. }
  18584. }
  18585. declare namespace dragonBones {
  18586. /**
  18587. * @language zh_CN
  18588. * 动画数据。
  18589. * @version DragonBones 3.0
  18590. */
  18591. class AnimationData extends TimelineData<AnimationFrameData> {
  18592. /**
  18593. * @private
  18594. */
  18595. static toString(): string;
  18596. /**
  18597. * @private
  18598. */
  18599. hasAsynchronyTimeline: boolean;
  18600. /**
  18601. * @language zh_CN
  18602. * 持续的帧数。
  18603. * @version DragonBones 3.0
  18604. */
  18605. frameCount: number;
  18606. /**
  18607. * @language zh_CN
  18608. * 循环播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次]
  18609. * @version DragonBones 3.0
  18610. */
  18611. playTimes: number;
  18612. /**
  18613. * @language zh_CN
  18614. * 开始的时间。 (以秒为单位)
  18615. * @version DragonBones 3.0
  18616. */
  18617. position: number;
  18618. /**
  18619. * @language zh_CN
  18620. * 持续的时间。 (以秒为单位)
  18621. * @version DragonBones 3.0
  18622. */
  18623. duration: number;
  18624. /**
  18625. * @language zh_CN
  18626. * 淡入混合的时间。 (以秒为单位)
  18627. * @version DragonBones 3.0
  18628. */
  18629. fadeInTime: number;
  18630. /**
  18631. * @private
  18632. */
  18633. cacheTimeToFrameScale: number;
  18634. /**
  18635. * @language zh_CN
  18636. * 数据名称。
  18637. * @version DragonBones 3.0
  18638. */
  18639. name: string;
  18640. /**
  18641. * @private
  18642. */
  18643. animation: AnimationData;
  18644. /**
  18645. * @private
  18646. */
  18647. zOrderTimeline: TimelineData<ZOrderFrameData>;
  18648. /**
  18649. * @private
  18650. */
  18651. boneTimelines: Map<BoneTimelineData>;
  18652. /**
  18653. * @private
  18654. */
  18655. slotTimelines: Map<SlotTimelineData>;
  18656. /**
  18657. * @private
  18658. */
  18659. ffdTimelines: Map<Map<Map<FFDTimelineData>>>;
  18660. /**
  18661. * @private
  18662. */
  18663. cachedFrames: Array<boolean>;
  18664. /**
  18665. * @private
  18666. */
  18667. constructor();
  18668. /**
  18669. * @inheritDoc
  18670. */
  18671. protected _onClear(): void;
  18672. /**
  18673. * @private
  18674. */
  18675. cacheFrames(value: number): void;
  18676. /**
  18677. * @private
  18678. */
  18679. addBoneTimeline(value: BoneTimelineData): void;
  18680. /**
  18681. * @private
  18682. */
  18683. addSlotTimeline(value: SlotTimelineData): void;
  18684. /**
  18685. * @private
  18686. */
  18687. addFFDTimeline(value: FFDTimelineData): void;
  18688. /**
  18689. * @private
  18690. */
  18691. getBoneTimeline(name: string): BoneTimelineData;
  18692. /**
  18693. * @private
  18694. */
  18695. getSlotTimeline(name: string): SlotTimelineData;
  18696. /**
  18697. * @private
  18698. */
  18699. getFFDTimeline(skinName: string, slotName: string, displayIndex: number): FFDTimelineData;
  18700. }
  18701. }
  18702. declare namespace dragonBones {
  18703. /**
  18704. * @language zh_CN
  18705. * 骨架数据。
  18706. * @see dragonBones.Armature
  18707. * @version DragonBones 3.0
  18708. */
  18709. class ArmatureData extends BaseObject {
  18710. private static _onSortSlots(a, b);
  18711. /**
  18712. * @private
  18713. */
  18714. static toString(): string;
  18715. /**
  18716. * @language zh_CN
  18717. * 动画帧率。
  18718. * @version DragonBones 3.0
  18719. */
  18720. frameRate: number;
  18721. /**
  18722. * @language zh_CN
  18723. * 骨架类型。
  18724. * @see dragonBones.ArmatureType
  18725. * @version DragonBones 3.0
  18726. */
  18727. type: ArmatureType;
  18728. /**
  18729. * @language zh_CN
  18730. * 数据名称。
  18731. * @version DragonBones 3.0
  18732. */
  18733. name: string;
  18734. /**
  18735. * @private
  18736. */
  18737. parent: DragonBonesData;
  18738. /**
  18739. * @private
  18740. */
  18741. userData: any;
  18742. /**
  18743. * @private
  18744. */
  18745. aabb: Rectangle;
  18746. /**
  18747. * @language zh_CN
  18748. * 所有的骨骼数据。
  18749. * @see dragonBones.BoneData
  18750. * @version DragonBones 3.0
  18751. */
  18752. bones: Map<BoneData>;
  18753. /**
  18754. * @language zh_CN
  18755. * 所有的插槽数据。
  18756. * @see dragonBones.SlotData
  18757. * @version DragonBones 3.0
  18758. */
  18759. slots: Map<SlotData>;
  18760. /**
  18761. * @language zh_CN
  18762. * 所有的皮肤数据。
  18763. * @see dragonBones.SkinData
  18764. * @version DragonBones 3.0
  18765. */
  18766. skins: Map<SkinData>;
  18767. /**
  18768. * @language zh_CN
  18769. * 所有的动画数据。
  18770. * @see dragonBones.AnimationData
  18771. * @version DragonBones 3.0
  18772. */
  18773. animations: Map<AnimationData>;
  18774. /**
  18775. * @private
  18776. */
  18777. actions: Array<ActionData>;
  18778. /**
  18779. * @private
  18780. */
  18781. cacheFrameRate: number;
  18782. /**
  18783. * @private
  18784. */
  18785. scale: number;
  18786. private _boneDirty;
  18787. private _slotDirty;
  18788. private _defaultSkin;
  18789. private _defaultAnimation;
  18790. private _sortedBones;
  18791. private _sortedSlots;
  18792. private _bonesChildren;
  18793. /**
  18794. * @private
  18795. */
  18796. constructor();
  18797. /**
  18798. * @inheritDoc
  18799. */
  18800. protected _onClear(): void;
  18801. private _sortBones();
  18802. private _sortSlots();
  18803. /**
  18804. * @private
  18805. */
  18806. cacheFrames(value: number): void;
  18807. /**
  18808. * @private
  18809. */
  18810. addBone(value: BoneData, parentName: string): void;
  18811. /**
  18812. * @private
  18813. */
  18814. addSlot(value: SlotData): void;
  18815. /**
  18816. * @private
  18817. */
  18818. addSkin(value: SkinData): void;
  18819. /**
  18820. * @private
  18821. */
  18822. addAnimation(value: AnimationData): void;
  18823. /**
  18824. * @language zh_CN
  18825. * 获取指定名称的骨骼数据。
  18826. * @param name 骨骼数据名称。
  18827. * @see dragonBones.BoneData
  18828. * @version DragonBones 3.0
  18829. */
  18830. getBone(name: string): BoneData;
  18831. /**
  18832. * @language zh_CN
  18833. * 获取指定名称的插槽数据。
  18834. * @param name 插槽数据名称。
  18835. * @see dragonBones.SlotData
  18836. * @version DragonBones 3.0
  18837. */
  18838. getSlot(name: string): SlotData;
  18839. /**
  18840. * @language zh_CN
  18841. * 获取指定名称的皮肤数据。
  18842. * @param name 皮肤数据名称。
  18843. * @see dragonBones.SkinData
  18844. * @version DragonBones 3.0
  18845. */
  18846. getSkin(name: string): SkinData;
  18847. /**
  18848. * @language zh_CN
  18849. * 获取指定名称的动画数据。
  18850. * @param name 动画数据名称。
  18851. * @see dragonBones.AnimationData
  18852. * @version DragonBones 3.0
  18853. */
  18854. getAnimation(name: string): AnimationData;
  18855. /**
  18856. * @private
  18857. */
  18858. sortedBones: Array<BoneData>;
  18859. /**
  18860. * @private
  18861. */
  18862. sortedSlots: Array<SlotData>;
  18863. /**
  18864. * @language zh_CN
  18865. * 获取默认的皮肤数据。
  18866. * @see dragonBones.SkinData
  18867. * @version DragonBones 4.5
  18868. */
  18869. defaultSkin: SkinData;
  18870. /**
  18871. * @language zh_CN
  18872. * 获取默认的动画数据。
  18873. * @see dragonBones.AnimationData
  18874. * @version DragonBones 4.5
  18875. */
  18876. defaultAnimation: AnimationData;
  18877. }
  18878. /**
  18879. * @language zh_CN
  18880. * 骨骼数据。
  18881. * @see dragonBones.Bone
  18882. * @version DragonBones 3.0
  18883. */
  18884. class BoneData extends BaseObject {
  18885. /**
  18886. * @private
  18887. */
  18888. static toString(): string;
  18889. /**
  18890. * @private
  18891. */
  18892. inheritTranslation: boolean;
  18893. /**
  18894. * @private
  18895. */
  18896. inheritRotation: boolean;
  18897. /**
  18898. * @private
  18899. */
  18900. inheritScale: boolean;
  18901. /**
  18902. * @private
  18903. */
  18904. bendPositive: boolean;
  18905. /**
  18906. * @private
  18907. */
  18908. chain: number;
  18909. /**
  18910. * @private
  18911. */
  18912. chainIndex: number;
  18913. /**
  18914. * @private
  18915. */
  18916. weight: number;
  18917. /**
  18918. * @private
  18919. */
  18920. length: number;
  18921. /**
  18922. * @language zh_CN
  18923. * 数据名称。
  18924. * @version DragonBones 3.0
  18925. */
  18926. name: string;
  18927. /**
  18928. * @language zh_CN
  18929. * 所属的父骨骼数据。
  18930. * @version DragonBones 3.0
  18931. */
  18932. parent: BoneData;
  18933. /**
  18934. * @private
  18935. */
  18936. ik: BoneData;
  18937. /**
  18938. * @private
  18939. */
  18940. transform: Transform;
  18941. /**
  18942. * @private
  18943. */
  18944. constructor();
  18945. /**
  18946. * @inheritDoc
  18947. */
  18948. protected _onClear(): void;
  18949. }
  18950. /**
  18951. * @language zh_CN
  18952. * 插槽数据。
  18953. * @see dragonBones.Slot
  18954. * @version DragonBones 3.0
  18955. */
  18956. class SlotData extends BaseObject {
  18957. /**
  18958. * @private
  18959. */
  18960. static DEFAULT_COLOR: ColorTransform;
  18961. /**
  18962. * @private
  18963. */
  18964. static generateColor(): ColorTransform;
  18965. /**
  18966. * @private
  18967. */
  18968. static toString(): string;
  18969. /**
  18970. * @private
  18971. */
  18972. displayIndex: number;
  18973. /**
  18974. * @private
  18975. */
  18976. zOrder: number;
  18977. /**
  18978. * @private
  18979. */
  18980. blendMode: BlendMode;
  18981. /**
  18982. * @language zh_CN
  18983. * 数据名称。
  18984. * @version DragonBones 3.0
  18985. */
  18986. name: string;
  18987. /**
  18988. * @language zh_CN
  18989. * 所属的父骨骼数据。
  18990. * @see dragonBones.BoneData
  18991. * @version DragonBones 3.0
  18992. */
  18993. parent: BoneData;
  18994. /**
  18995. * @private
  18996. */
  18997. color: ColorTransform;
  18998. /**
  18999. * @private
  19000. */
  19001. actions: Array<ActionData>;
  19002. /**
  19003. * @private
  19004. */
  19005. constructor();
  19006. /**
  19007. * @inheritDoc
  19008. */
  19009. protected _onClear(): void;
  19010. }
  19011. /**
  19012. * @language zh_CN
  19013. * 皮肤数据。
  19014. * @version DragonBones 3.0
  19015. */
  19016. class SkinData extends BaseObject {
  19017. /**
  19018. * @private
  19019. */
  19020. static toString(): string;
  19021. /**
  19022. * @language zh_CN
  19023. * 数据名称。
  19024. * @version DragonBones 3.0
  19025. */
  19026. name: string;
  19027. /**
  19028. * @private
  19029. */
  19030. slots: Map<SlotDisplayDataSet>;
  19031. /**
  19032. * @private
  19033. */
  19034. constructor();
  19035. /**
  19036. * @inheritDoc
  19037. */
  19038. protected _onClear(): void;
  19039. /**
  19040. * @private
  19041. */
  19042. addSlot(value: SlotDisplayDataSet): void;
  19043. /**
  19044. * @private
  19045. */
  19046. getSlot(name: string): SlotDisplayDataSet;
  19047. }
  19048. /**
  19049. * @private
  19050. */
  19051. class SlotDisplayDataSet extends BaseObject {
  19052. static toString(): string;
  19053. slot: SlotData;
  19054. displays: Array<DisplayData>;
  19055. constructor();
  19056. /**
  19057. * @inheritDoc
  19058. */
  19059. protected _onClear(): void;
  19060. }
  19061. /**
  19062. * @private
  19063. */
  19064. class DisplayData extends BaseObject {
  19065. static toString(): string;
  19066. isRelativePivot: boolean;
  19067. type: DisplayType;
  19068. name: string;
  19069. texture: TextureData;
  19070. armature: ArmatureData;
  19071. mesh: MeshData;
  19072. pivot: Point;
  19073. transform: Transform;
  19074. constructor();
  19075. /**
  19076. * @inheritDoc
  19077. */
  19078. protected _onClear(): void;
  19079. }
  19080. /**
  19081. * @private
  19082. */
  19083. class MeshData extends BaseObject {
  19084. static toString(): string;
  19085. skinned: boolean;
  19086. slotPose: Matrix;
  19087. uvs: Array<number>;
  19088. vertices: Array<number>;
  19089. vertexIndices: Array<number>;
  19090. boneIndices: Array<Array<number>>;
  19091. weights: Array<Array<number>>;
  19092. boneVertices: Array<Array<number>>;
  19093. bones: Array<BoneData>;
  19094. inverseBindPose: Array<Matrix>;
  19095. constructor();
  19096. /**
  19097. * @inheritDoc
  19098. */
  19099. protected _onClear(): void;
  19100. }
  19101. }
  19102. declare namespace dragonBones {
  19103. /**
  19104. * @language zh_CN
  19105. * 龙骨数据,包含多个骨架数据。
  19106. * @see dragonBones.ArmatureData
  19107. * @version DragonBones 3.0
  19108. */
  19109. class DragonBonesData extends BaseObject {
  19110. /**
  19111. * @private
  19112. */
  19113. static toString(): string;
  19114. /**
  19115. * @language zh_CN
  19116. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19117. * @default false
  19118. * @see dragonBones.ArmatureData
  19119. * @version DragonBones 4.5
  19120. */
  19121. autoSearch: boolean;
  19122. /**
  19123. * @language zh_CN
  19124. * 动画帧频。
  19125. * @version DragonBones 3.0
  19126. */
  19127. frameRate: number;
  19128. /**
  19129. * @language zh_CN
  19130. * 数据名称。
  19131. * @version DragonBones 3.0
  19132. */
  19133. name: string;
  19134. /**
  19135. * @language zh_CN
  19136. * 所有的骨架数据。
  19137. * @see dragonBones.ArmatureData
  19138. * @version DragonBones 3.0
  19139. */
  19140. armatures: Map<ArmatureData>;
  19141. private _armatureNames;
  19142. /**
  19143. * @inheritDoc
  19144. */
  19145. protected _onClear(): void;
  19146. /**
  19147. * @language zh_CN
  19148. * 获取指定名称的骨架。
  19149. * @param name 骨架数据骨架名称。
  19150. * @see dragonBones.ArmatureData
  19151. * @version DragonBones 3.0
  19152. */
  19153. getArmature(name: string): ArmatureData;
  19154. /**
  19155. * @language zh_CN
  19156. * 所有的骨架数据名称。
  19157. * @see #armatures
  19158. * @version DragonBones 3.0
  19159. */
  19160. armatureNames: Array<string>;
  19161. /**
  19162. * @deprecated
  19163. * @see dragonBones.BaseFactory#removeDragonBonesData()
  19164. */
  19165. dispose(): void;
  19166. }
  19167. }
  19168. declare namespace dragonBones {
  19169. /**
  19170. * @private
  19171. */
  19172. class ActionData extends BaseObject {
  19173. static toString(): string;
  19174. type: ActionType;
  19175. bone: BoneData;
  19176. slot: SlotData;
  19177. data: Array<any>;
  19178. constructor();
  19179. protected _onClear(): void;
  19180. }
  19181. /**
  19182. * @private
  19183. */
  19184. class EventData extends BaseObject {
  19185. static toString(): string;
  19186. type: EventType;
  19187. name: string;
  19188. data: any;
  19189. bone: BoneData;
  19190. slot: SlotData;
  19191. constructor();
  19192. protected _onClear(): void;
  19193. }
  19194. /**
  19195. * @private
  19196. */
  19197. abstract class FrameData<T> extends BaseObject {
  19198. position: number;
  19199. duration: number;
  19200. prev: T;
  19201. next: T;
  19202. constructor();
  19203. /**
  19204. * @inheritDoc
  19205. */
  19206. protected _onClear(): void;
  19207. }
  19208. /**
  19209. * @private
  19210. */
  19211. abstract class TweenFrameData<T> extends FrameData<T> {
  19212. static samplingCurve(curve: Array<number>, frameCount: number): Array<number>;
  19213. tweenEasing: number;
  19214. curve: Array<number>;
  19215. constructor();
  19216. /**
  19217. * @inheritDoc
  19218. */
  19219. protected _onClear(): void;
  19220. }
  19221. /**
  19222. * @private
  19223. */
  19224. class AnimationFrameData extends FrameData<AnimationFrameData> {
  19225. static toString(): string;
  19226. actions: Array<ActionData>;
  19227. events: Array<EventData>;
  19228. constructor();
  19229. /**
  19230. * @inheritDoc
  19231. */
  19232. protected _onClear(): void;
  19233. }
  19234. /**
  19235. * @private
  19236. */
  19237. class ZOrderFrameData extends FrameData<ZOrderFrameData> {
  19238. zOrder: Array<number>;
  19239. constructor();
  19240. /**
  19241. * @inheritDoc
  19242. */
  19243. protected _onClear(): void;
  19244. }
  19245. /**
  19246. * @private
  19247. */
  19248. class BoneFrameData extends TweenFrameData<BoneFrameData> {
  19249. static toString(): string;
  19250. tweenScale: boolean;
  19251. tweenRotate: number;
  19252. guideCurve: Array<number>;
  19253. transform: Transform;
  19254. constructor();
  19255. /**
  19256. * @inheritDoc
  19257. */
  19258. protected _onClear(): void;
  19259. }
  19260. /**
  19261. * @private
  19262. */
  19263. class SlotFrameData extends TweenFrameData<SlotFrameData> {
  19264. static DEFAULT_COLOR: ColorTransform;
  19265. static generateColor(): ColorTransform;
  19266. static toString(): string;
  19267. displayIndex: number;
  19268. color: ColorTransform;
  19269. constructor();
  19270. /**
  19271. * @inheritDoc
  19272. */
  19273. protected _onClear(): void;
  19274. }
  19275. /**
  19276. * @private
  19277. */
  19278. class ExtensionFrameData extends TweenFrameData<ExtensionFrameData> {
  19279. static toString(): string;
  19280. type: ExtensionType;
  19281. tweens: Array<number>;
  19282. keys: Array<number>;
  19283. constructor();
  19284. /**
  19285. * @inheritDoc
  19286. */
  19287. protected _onClear(): void;
  19288. }
  19289. }
  19290. declare namespace dragonBones {
  19291. /**
  19292. * @private
  19293. */
  19294. abstract class DataParser {
  19295. protected static DATA_VERSION_2_3: string;
  19296. protected static DATA_VERSION_3_0: string;
  19297. protected static DATA_VERSION_4_0: string;
  19298. protected static DATA_VERSION: string;
  19299. protected static TEXTURE_ATLAS: string;
  19300. protected static SUB_TEXTURE: string;
  19301. protected static FORMAT: string;
  19302. protected static IMAGE_PATH: string;
  19303. protected static WIDTH: string;
  19304. protected static HEIGHT: string;
  19305. protected static ROTATED: string;
  19306. protected static FRAME_X: string;
  19307. protected static FRAME_Y: string;
  19308. protected static FRAME_WIDTH: string;
  19309. protected static FRAME_HEIGHT: string;
  19310. protected static DRADON_BONES: string;
  19311. protected static ARMATURE: string;
  19312. protected static BONE: string;
  19313. protected static IK: string;
  19314. protected static SLOT: string;
  19315. protected static SKIN: string;
  19316. protected static DISPLAY: string;
  19317. protected static ANIMATION: string;
  19318. protected static Z_ORDER: string;
  19319. protected static FFD: string;
  19320. protected static FRAME: string;
  19321. protected static PIVOT: string;
  19322. protected static TRANSFORM: string;
  19323. protected static AABB: string;
  19324. protected static COLOR: string;
  19325. protected static FILTER: string;
  19326. protected static VERSION: string;
  19327. protected static IS_GLOBAL: string;
  19328. protected static FRAME_RATE: string;
  19329. protected static TYPE: string;
  19330. protected static NAME: string;
  19331. protected static PARENT: string;
  19332. protected static LENGTH: string;
  19333. protected static DATA: string;
  19334. protected static DISPLAY_INDEX: string;
  19335. protected static BLEND_MODE: string;
  19336. protected static INHERIT_TRANSLATION: string;
  19337. protected static INHERIT_ROTATION: string;
  19338. protected static INHERIT_SCALE: string;
  19339. protected static TARGET: string;
  19340. protected static BEND_POSITIVE: string;
  19341. protected static CHAIN: string;
  19342. protected static WEIGHT: string;
  19343. protected static FADE_IN_TIME: string;
  19344. protected static PLAY_TIMES: string;
  19345. protected static SCALE: string;
  19346. protected static OFFSET: string;
  19347. protected static POSITION: string;
  19348. protected static DURATION: string;
  19349. protected static TWEEN_EASING: string;
  19350. protected static TWEEN_ROTATE: string;
  19351. protected static TWEEN_SCALE: string;
  19352. protected static CURVE: string;
  19353. protected static GUIDE_CURVE: string;
  19354. protected static EVENT: string;
  19355. protected static SOUND: string;
  19356. protected static ACTION: string;
  19357. protected static ACTIONS: string;
  19358. protected static DEFAULT_ACTIONS: string;
  19359. protected static X: string;
  19360. protected static Y: string;
  19361. protected static SKEW_X: string;
  19362. protected static SKEW_Y: string;
  19363. protected static SCALE_X: string;
  19364. protected static SCALE_Y: string;
  19365. protected static ALPHA_OFFSET: string;
  19366. protected static RED_OFFSET: string;
  19367. protected static GREEN_OFFSET: string;
  19368. protected static BLUE_OFFSET: string;
  19369. protected static ALPHA_MULTIPLIER: string;
  19370. protected static RED_MULTIPLIER: string;
  19371. protected static GREEN_MULTIPLIER: string;
  19372. protected static BLUE_MULTIPLIER: string;
  19373. protected static UVS: string;
  19374. protected static VERTICES: string;
  19375. protected static TRIANGLES: string;
  19376. protected static WEIGHTS: string;
  19377. protected static SLOT_POSE: string;
  19378. protected static BONE_POSE: string;
  19379. protected static TWEEN: string;
  19380. protected static KEY: string;
  19381. protected static COLOR_TRANSFORM: string;
  19382. protected static TIMELINE: string;
  19383. protected static PIVOT_X: string;
  19384. protected static PIVOT_Y: string;
  19385. protected static Z: string;
  19386. protected static LOOP: string;
  19387. protected static AUTO_TWEEN: string;
  19388. protected static HIDE: string;
  19389. protected static _getArmatureType(value: string): ArmatureType;
  19390. protected static _getDisplayType(value: string): DisplayType;
  19391. protected static _getBlendMode(value: string): BlendMode;
  19392. protected static _getActionType(value: string): ActionType;
  19393. protected _data: DragonBonesData;
  19394. protected _armature: ArmatureData;
  19395. protected _skin: SkinData;
  19396. protected _slotDisplayDataSet: SlotDisplayDataSet;
  19397. protected _mesh: MeshData;
  19398. protected _animation: AnimationData;
  19399. protected _timeline: any;
  19400. protected _isOldData: boolean;
  19401. protected _isGlobalTransform: boolean;
  19402. protected _isAutoTween: boolean;
  19403. protected _animationTweenEasing: number;
  19404. protected _timelinePivot: Point;
  19405. protected _helpPoint: Point;
  19406. protected _helpTransformA: Transform;
  19407. protected _helpTransformB: Transform;
  19408. protected _helpMatrix: Matrix;
  19409. protected _rawBones: Array<BoneData>;
  19410. constructor();
  19411. /**
  19412. * @private
  19413. */
  19414. abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData;
  19415. /**
  19416. * @private
  19417. */
  19418. abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): void;
  19419. private _getTimelineFrameMatrix(animation, timeline, position, transform);
  19420. protected _globalToLocal(armature: ArmatureData): void;
  19421. protected _mergeFrameToAnimationTimeline(framePostion: number, actions: Array<ActionData>, events: Array<EventData>): void;
  19422. /**
  19423. * @deprecated
  19424. * @see dragonBones.BaseFactory#parseDragonBonesData()
  19425. */
  19426. static parseDragonBonesData(rawData: any): DragonBonesData;
  19427. /**
  19428. * @deprecated
  19429. * @see dragonBones.BaseFactory#parsetTextureAtlasData()
  19430. */
  19431. static parseTextureAtlasData(rawData: any, scale?: number): any;
  19432. }
  19433. }
  19434. declare namespace dragonBones {
  19435. /**
  19436. * @private
  19437. */
  19438. class ObjectDataParser extends DataParser {
  19439. /**
  19440. * @private
  19441. */
  19442. protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean;
  19443. /**
  19444. * @private
  19445. */
  19446. protected static _getNumber(rawData: any, key: string, defaultValue: number): number;
  19447. /**
  19448. * @private
  19449. */
  19450. protected static _getString(rawData: any, key: string, defaultValue: string): string;
  19451. /**
  19452. * @private
  19453. */
  19454. protected static _getParameter(rawData: Array<any>, index: number, defaultValue: any): any;
  19455. /**
  19456. * @private
  19457. */
  19458. constructor();
  19459. /**
  19460. * @private
  19461. */
  19462. protected _parseArmature(rawData: any, scale: number): ArmatureData;
  19463. /**
  19464. * @private
  19465. */
  19466. protected _parseBone(rawData: any): BoneData;
  19467. /**
  19468. * @private
  19469. */
  19470. protected _parseIK(rawData: any): void;
  19471. /**
  19472. * @private
  19473. */
  19474. protected _parseSlot(rawData: any, zOrder: number): SlotData;
  19475. /**
  19476. * @private
  19477. */
  19478. protected _parseSkin(rawData: any): SkinData;
  19479. /**
  19480. * @private
  19481. */
  19482. protected _parseSlotDisplaySet(rawData: any): SlotDisplayDataSet;
  19483. /**
  19484. * @private
  19485. */
  19486. protected _parseDisplay(rawData: any): DisplayData;
  19487. /**
  19488. * @private
  19489. */
  19490. protected _parseMesh(rawData: any): MeshData;
  19491. /**
  19492. * @private
  19493. */
  19494. protected _parseAnimation(rawData: any): AnimationData;
  19495. /**
  19496. * @private
  19497. */
  19498. protected _parseBoneTimeline(rawData: any): BoneTimelineData;
  19499. /**
  19500. * @private
  19501. */
  19502. protected _parseSlotTimeline(rawData: any): SlotTimelineData;
  19503. /**
  19504. * @private
  19505. */
  19506. protected _parseFFDTimeline(rawData: any): FFDTimelineData;
  19507. /**
  19508. * @private
  19509. */
  19510. protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): AnimationFrameData;
  19511. /**
  19512. * @private
  19513. */
  19514. protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): ZOrderFrameData;
  19515. /**
  19516. * @private
  19517. */
  19518. protected _parseBoneFrame(rawData: Object, frameStart: number, frameCount: number): BoneFrameData;
  19519. /**
  19520. * @private
  19521. */
  19522. protected _parseSlotFrame(rawData: any, frameStart: number, frameCount: number): SlotFrameData;
  19523. /**
  19524. * @private
  19525. */
  19526. protected _parseFFDFrame(rawData: any, frameStart: number, frameCount: number): ExtensionFrameData;
  19527. /**
  19528. * @private
  19529. */
  19530. protected _parseTweenFrame<T extends TweenFrameData<T>>(rawData: any, frame: T, frameStart: number, frameCount: number): void;
  19531. /**
  19532. * @private
  19533. */
  19534. protected _parseFrame<T extends FrameData<T>>(rawData: any, frame: T, frameStart: number, frameCount: number): void;
  19535. /**
  19536. * @private
  19537. */
  19538. protected _parseTimeline<T extends FrameData<T>>(rawData: Object, timeline: TimelineData<T>, frameParser: (rawData: any, frameStart: number, frameCount: number) => T): void;
  19539. /**
  19540. * @private
  19541. */
  19542. protected _parseActionData(rawData: any, actions: Array<ActionData>, bone: BoneData, slot: SlotData): void;
  19543. /**
  19544. * @private
  19545. */
  19546. protected _parseEventData(rawData: any, events: Array<EventData>, bone: BoneData, slot: SlotData): void;
  19547. /**
  19548. * @private
  19549. */
  19550. protected _parseTransform(rawData: Object, transform: Transform): void;
  19551. /**
  19552. * @private
  19553. */
  19554. protected _parseColorTransform(rawData: Object, color: ColorTransform): void;
  19555. /**
  19556. * @inheritDoc
  19557. */
  19558. parseDragonBonesData(rawData: any, scale?: number): DragonBonesData;
  19559. /**
  19560. * @inheritDoc
  19561. */
  19562. parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): void;
  19563. /**
  19564. * @private
  19565. */
  19566. private static _instance;
  19567. /**
  19568. * @deprecated
  19569. * @see dragonBones.BaseFactory#parseDragonBonesData()
  19570. */
  19571. static getInstance(): ObjectDataParser;
  19572. }
  19573. }
  19574. declare namespace dragonBones {
  19575. /**
  19576. * @language zh_CN
  19577. * 贴图集数据。
  19578. * @version DragonBones 3.0
  19579. */
  19580. abstract class TextureAtlasData extends BaseObject {
  19581. /**
  19582. * @language zh_CN
  19583. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19584. * @default false
  19585. * @version DragonBones 4.5
  19586. */
  19587. autoSearch: boolean;
  19588. /**
  19589. * @language zh_CN
  19590. * 贴图集缩放系数。
  19591. * @version DragonBones 3.0
  19592. */
  19593. scale: number;
  19594. /**
  19595. * @language zh_CN
  19596. * 贴图集名称。
  19597. * @version DragonBones 3.0
  19598. */
  19599. name: string;
  19600. /**
  19601. * @language zh_CN
  19602. * 贴图集图片路径。
  19603. * @version DragonBones 3.0
  19604. */
  19605. imagePath: string;
  19606. /**
  19607. * @inheritDoc
  19608. */
  19609. protected _onClear(): void;
  19610. /**
  19611. * @private
  19612. */
  19613. getTexture(name: string): TextureData;
  19614. }
  19615. /**
  19616. * @private
  19617. */
  19618. abstract class TextureData extends BaseObject {
  19619. static generateRectangle(): Rectangle;
  19620. rotated: boolean;
  19621. name: string;
  19622. frame: Rectangle;
  19623. parent: TextureAtlasData;
  19624. region: Rectangle;
  19625. constructor();
  19626. /**
  19627. * @inheritDoc
  19628. */
  19629. protected _onClear(): void;
  19630. }
  19631. }
  19632. declare namespace dragonBones {
  19633. /**
  19634. * @private
  19635. */
  19636. type BuildArmaturePackage = {
  19637. dataName?: string;
  19638. textureAtlasName?: string;
  19639. data?: DragonBonesData;
  19640. armature?: ArmatureData;
  19641. skin?: SkinData;
  19642. };
  19643. /**
  19644. * @language zh_CN
  19645. * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例)
  19646. * @see dragonBones.DragonBonesData
  19647. * @see dragonBones.TextureAtlasData
  19648. * @see dragonBones.ArmatureData
  19649. * @see dragonBones.Armature
  19650. * @version DragonBones 3.0
  19651. */
  19652. abstract class BaseFactory {
  19653. protected static _defaultParser: ObjectDataParser;
  19654. /**
  19655. * @language zh_CN
  19656. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19657. * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启)
  19658. * @see dragonBones.DragonBonesData#autoSearch
  19659. * @see dragonBones.TextureAtlasData#autoSearch
  19660. * @version DragonBones 4.5
  19661. */
  19662. autoSearch: boolean;
  19663. /**
  19664. * @private
  19665. */
  19666. protected _dataParser: DataParser;
  19667. /**
  19668. * @private
  19669. */
  19670. protected _dragonBonesDataMap: Map<DragonBonesData>;
  19671. /**
  19672. * @private
  19673. */
  19674. protected _textureAtlasDataMap: Map<Array<TextureAtlasData>>;
  19675. /**
  19676. * @private
  19677. */
  19678. constructor(dataParser?: DataParser);
  19679. /**
  19680. * @private
  19681. */
  19682. protected _getTextureData(textureAtlasName: string, textureName: string): TextureData;
  19683. /**
  19684. * @private
  19685. */
  19686. protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean;
  19687. /**
  19688. * @private
  19689. */
  19690. protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void;
  19691. /**
  19692. * @private
  19693. */
  19694. protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void;
  19695. /**
  19696. * @private
  19697. */
  19698. protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData, slot: Slot, displayIndex: number): void;
  19699. /**
  19700. * @private
  19701. */
  19702. protected abstract _generateTextureAtlasData(textureAtlasData: TextureAtlasData, textureAtlas: any): TextureAtlasData;
  19703. /**
  19704. * @private
  19705. */
  19706. protected abstract _generateArmature(dataPackage: BuildArmaturePackage): Armature;
  19707. /**
  19708. * @private
  19709. */
  19710. protected abstract _generateSlot(dataPackage: BuildArmaturePackage, slotDisplayDataSet: SlotDisplayDataSet, armature: Armature): Slot;
  19711. /**
  19712. * @language zh_CN
  19713. * 解析并添加龙骨数据。
  19714. * @param rawData 需要解析的原始数据。 (JSON)
  19715. * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  19716. * @returns DragonBonesData
  19717. * @see #getDragonBonesData()
  19718. * @see #addDragonBonesData()
  19719. * @see #removeDragonBonesData()
  19720. * @see dragonBones.DragonBonesData
  19721. * @version DragonBones 4.5
  19722. */
  19723. parseDragonBonesData(rawData: any, name?: string, scale?: number): DragonBonesData;
  19724. /**
  19725. * @language zh_CN
  19726. * 解析并添加贴图集数据。
  19727. * @param rawData 需要解析的原始数据。 (JSON)
  19728. * @param textureAtlas 贴图集数据。 (JSON)
  19729. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  19730. * @param scale 为贴图集设置一个缩放值。
  19731. * @returns 贴图集数据
  19732. * @see #getTextureAtlasData()
  19733. * @see #addTextureAtlasData()
  19734. * @see #removeTextureAtlasData()
  19735. * @see dragonBones.TextureAtlasData
  19736. * @version DragonBones 4.5
  19737. */
  19738. parseTextureAtlasData(rawData: any, textureAtlas: Object, name?: string, scale?: number): TextureAtlasData;
  19739. /**
  19740. * @language zh_CN
  19741. * 获取指定名称的龙骨数据。
  19742. * @param name 数据名称。
  19743. * @returns DragonBonesData
  19744. * @see #parseDragonBonesData()
  19745. * @see #addDragonBonesData()
  19746. * @see #removeDragonBonesData()
  19747. * @see dragonBones.DragonBonesData
  19748. * @version DragonBones 3.0
  19749. */
  19750. getDragonBonesData(name: string): DragonBonesData;
  19751. /**
  19752. * @language zh_CN
  19753. * 添加龙骨数据。
  19754. * @param data 龙骨数据。
  19755. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  19756. * @see #parseDragonBonesData()
  19757. * @see #getDragonBonesData()
  19758. * @see #removeDragonBonesData()
  19759. * @see dragonBones.DragonBonesData
  19760. * @version DragonBones 3.0
  19761. */
  19762. addDragonBonesData(data: DragonBonesData, name?: string): void;
  19763. /**
  19764. * @language zh_CN
  19765. * 移除龙骨数据。
  19766. * @param name 数据名称。
  19767. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  19768. * @see #parseDragonBonesData()
  19769. * @see #getDragonBonesData()
  19770. * @see #addDragonBonesData()
  19771. * @see dragonBones.DragonBonesData
  19772. * @version DragonBones 3.0
  19773. */
  19774. removeDragonBonesData(name: string, disposeData?: boolean): void;
  19775. /**
  19776. * @language zh_CN
  19777. * 获取指定名称的贴图集数据列表。
  19778. * @param name 数据名称。
  19779. * @returns 贴图集数据列表。
  19780. * @see #parseTextureAtlasData()
  19781. * @see #addTextureAtlasData()
  19782. * @see #removeTextureAtlasData()
  19783. * @see dragonBones.textures.TextureAtlasData
  19784. * @version DragonBones 3.0
  19785. */
  19786. getTextureAtlasData(name: string): Array<TextureAtlasData>;
  19787. /**
  19788. * @language zh_CN
  19789. * 添加贴图集数据。
  19790. * @param data 贴图集数据。
  19791. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  19792. * @see #parseTextureAtlasData()
  19793. * @see #getTextureAtlasData()
  19794. * @see #removeTextureAtlasData()
  19795. * @see dragonBones.textures.TextureAtlasData
  19796. * @version DragonBones 3.0
  19797. */
  19798. addTextureAtlasData(data: TextureAtlasData, name?: string): void;
  19799. /**
  19800. * @language zh_CN
  19801. * 移除贴图集数据。
  19802. * @param name 数据名称。
  19803. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  19804. * @see #parseTextureAtlasData()
  19805. * @see #getTextureAtlasData()
  19806. * @see #addTextureAtlasData()
  19807. * @see dragonBones.textures.TextureAtlasData
  19808. * @version DragonBones 3.0
  19809. */
  19810. removeTextureAtlasData(name: string, disposeData?: boolean): void;
  19811. /**
  19812. * @language zh_CN
  19813. * 清除所有的数据。
  19814. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  19815. * @version DragonBones 4.5
  19816. */
  19817. clear(disposeData?: boolean): void;
  19818. /**
  19819. * @language zh_CN
  19820. * 创建一个指定名称的骨架。
  19821. * @param armatureName 骨架数据名称。
  19822. * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。
  19823. * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。
  19824. * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。
  19825. * @returns 骨架
  19826. * @see dragonBones.Armature
  19827. * @version DragonBones 3.0
  19828. */
  19829. buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature;
  19830. /**
  19831. * @language zh_CN
  19832. * 将指定骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构)
  19833. * @param toArmature 指定的骨架。
  19834. * @param fromArmatreName 其他骨架的名称。
  19835. * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。
  19836. * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。
  19837. * @param ifRemoveOriginalAnimationList 是否移除原有的动画。 [true: 移除, false: 不移除]
  19838. * @returns 是否替换成功。 [true: 成功, false: 不成功]
  19839. * @see dragonBones.Armature
  19840. * @version DragonBones 4.5
  19841. */
  19842. copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, ifRemoveOriginalAnimationList?: boolean): boolean;
  19843. /**
  19844. * @language zh_CN
  19845. * 将指定插槽的显示对象替换为指定资源创造出的显示对象。
  19846. * @param dragonBonesName 指定的龙骨数据名称。
  19847. * @param armatureName 指定的骨架名称。
  19848. * @param slotName 指定的插槽名称。
  19849. * @param displayName 指定的显示对象名称。
  19850. * @param slot 指定的插槽实例。
  19851. * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。
  19852. * @version DragonBones 4.5
  19853. */
  19854. replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void;
  19855. /**
  19856. * @language zh_CN
  19857. * 将指定插槽的显示对象列表替换为指定资源创造出的显示对象列表。
  19858. * @param dragonBonesName 指定的 DragonBonesData 名称。
  19859. * @param armatureName 指定的骨架名称。
  19860. * @param slotName 指定的插槽名称。
  19861. * @param slot 指定的插槽实例。
  19862. * @version DragonBones 4.5
  19863. */
  19864. replaceSlotDisplayList(dragonBonesName: string, armatureName: string, slotName: string, slot: Slot): void;
  19865. /**
  19866. * @private
  19867. */
  19868. getAllDragonBonesData(): Map<DragonBonesData>;
  19869. /**
  19870. * @private
  19871. */
  19872. getAllTextureAtlasData(): Map<Array<TextureAtlasData>>;
  19873. }
  19874. }
  19875. declare let jsb: any;
  19876. /** Running in the editor. */
  19877. declare let CC_EDITOR: boolean;
  19878. /** Preview in browser or simulator. */
  19879. declare let CC_PREVIEW: boolean;
  19880. /** Running in the editor or preview. */
  19881. declare let CC_DEV: boolean;
  19882. /** Running in the editor or preview, or build in debug mode. */
  19883. declare let CC_DEBUG: boolean;
  19884. /** Running in published project. */
  19885. declare let CC_BUILD: boolean;
  19886. /** Running in native platform (mobile app, desktop app, or simulator). */
  19887. declare let CC_JSB: boolean;
  19888. /** Running in the engine's unit test. */
  19889. declare let CC_TEST: boolean;