creator.d.ts 1.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210
  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 namespace 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. /**
  11. !#en
  12. Creates the speed action which changes the speed of an action, making it take longer (speed > 1)
  13. or less (speed < 1) time. <br/>
  14. Useful to simulate 'slow motion' or 'fast forward' effect.
  15. !#zh 修改目标动作的速率。
  16. @param action action
  17. @param speed speed
  18. @example
  19. ```js
  20. // change the target action speed;
  21. var action = cc.scaleTo(0.2, 1, 0.6);
  22. var newAction = cc.speed(action, 0.5);
  23. ```
  24. */
  25. export function speed(action: ActionInterval, speed: number): Action;
  26. /**
  27. !#en Create a follow action which makes its target follows another node.
  28. !#zh 追踪目标节点的位置。
  29. @param followedNode followedNode
  30. @param rect rect
  31. @example
  32. ```js
  33. // example
  34. // creates the action with a set boundary
  35. var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight));
  36. node.runAction(followAction);
  37. // creates the action with no boundary set
  38. var followAction = cc.follow(targetNode);
  39. node.runAction(followAction);
  40. ```
  41. */
  42. export function follow(followedNode: Node, rect: Rect): Action;
  43. /**
  44. Points setter
  45. @param points points
  46. */
  47. export function setPoints(points: any[]): void;
  48. /**
  49. !#en Creates an action with a Cardinal Spline array of points and tension.
  50. !#zh 按基数样条曲线轨迹移动到目标位置。
  51. @param duration duration
  52. @param points array of control points
  53. @param tension tension
  54. @example
  55. ```js
  56. //create a cc.CardinalSplineTo
  57. var action1 = cc.cardinalSplineTo(3, array, 0);
  58. ```
  59. */
  60. export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval;
  61. /**
  62. update position of target
  63. @param newPos newPos
  64. */
  65. export function updatePosition(newPos: Vec2): void;
  66. /**
  67. !#en Creates an action with a Cardinal Spline array of points and tension.
  68. !#zh 按基数样条曲线轨迹移动指定的距离。
  69. @param duration duration
  70. @param points points
  71. @param tension tension
  72. */
  73. export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval;
  74. /**
  75. !#en Creates an action with a Cardinal Spline array of points and tension.
  76. !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。
  77. @param dt dt
  78. @param points points
  79. @example
  80. ```js
  81. var action1 = cc.catmullRomTo(3, array);
  82. ```
  83. */
  84. export function catmullRomTo(dt: number, points: any[]): ActionInterval;
  85. /**
  86. !#en Creates an action with a Cardinal Spline array of points and tension.
  87. !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。
  88. @param dt dt
  89. @param points points
  90. @example
  91. ```js
  92. var action1 = cc.catmullRomBy(3, array);
  93. ```
  94. */
  95. export function catmullRomBy(dt: number, points: any[]): ActionInterval;
  96. /**
  97. !#en
  98. Creates the action easing object with the rate parameter. <br />
  99. From slow to fast.
  100. !#zh 创建 easeIn 缓动对象,由慢到快。
  101. @param rate rate
  102. @example
  103. ```js
  104. action.easing(cc.easeIn(3.0));
  105. ```
  106. */
  107. export function easeIn(rate: number): any;
  108. /**
  109. !#en
  110. Creates the action easing object with the rate parameter. <br />
  111. From fast to slow.
  112. !#zh 创建 easeOut 缓动对象,由快到慢。
  113. @param rate rate
  114. @example
  115. ```js
  116. action.easing(cc.easeOut(3.0));
  117. ```
  118. */
  119. export function easeOut(rate: number): any;
  120. /**
  121. !#en
  122. Creates the action easing object with the rate parameter. <br />
  123. Slow to fast then to slow.
  124. !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。
  125. @param rate rate
  126. @example
  127. ```js
  128. action.easing(cc.easeInOut(3.0));
  129. ```
  130. */
  131. export function easeInOut(rate: number): any;
  132. /**
  133. !#en
  134. Creates the action easing object with the rate parameter. <br />
  135. Reference easeInExpo: <br />
  136. http://www.zhihu.com/question/21981571/answer/19925418
  137. !#zh
  138. 创建 easeExponentialIn 缓动对象。<br />
  139. EaseExponentialIn 是按指数函数缓动进入的动作。<br />
  140. 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418
  141. @example
  142. ```js
  143. action.easing(cc.easeExponentialIn());
  144. ```
  145. */
  146. export function easeExponentialIn(): any;
  147. /**
  148. !#en
  149. Creates the action easing object. <br />
  150. Reference easeOutExpo: <br />
  151. http://www.zhihu.com/question/21981571/answer/19925418
  152. !#zh
  153. 创建 easeExponentialOut 缓动对象。<br />
  154. EaseExponentialOut 是按指数函数缓动退出的动作。<br />
  155. 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
  156. @example
  157. ```js
  158. action.easing(cc.easeExponentialOut());
  159. ```
  160. */
  161. export function easeExponentialOut(): any;
  162. /**
  163. !#en
  164. Creates an EaseExponentialInOut action easing object. <br />
  165. Reference easeInOutExpo: <br />
  166. http://www.zhihu.com/question/21981571/answer/19925418
  167. !#zh
  168. 创建 easeExponentialInOut 缓动对象。<br />
  169. EaseExponentialInOut 是按指数函数缓动进入并退出的动作。<br />
  170. 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
  171. @example
  172. ```js
  173. action.easing(cc.easeExponentialInOut());
  174. ```
  175. */
  176. export function easeExponentialInOut(): any;
  177. /**
  178. !#en
  179. Creates an EaseSineIn action. <br />
  180. Reference easeInSine: <br />
  181. http://www.zhihu.com/question/21981571/answer/19925418
  182. !#zh
  183. 创建 EaseSineIn 缓动对象。<br />
  184. EaseSineIn 是按正弦函数缓动进入的动作。<br />
  185. 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418
  186. @example
  187. ```js
  188. action.easing(cc.easeSineIn());
  189. ```
  190. */
  191. export function easeSineIn(): any;
  192. /**
  193. !#en
  194. Creates an EaseSineOut action easing object. <br />
  195. Reference easeOutSine: <br />
  196. http://www.zhihu.com/question/21981571/answer/19925418
  197. !#zh
  198. 创建 EaseSineOut 缓动对象。<br />
  199. EaseSineIn 是按正弦函数缓动退出的动作。<br />
  200. 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418
  201. @example
  202. ```js
  203. action.easing(cc.easeSineOut());
  204. ```
  205. */
  206. export function easeSineOut(): any;
  207. /**
  208. !#en
  209. Creates the action easing object. <br />
  210. Reference easeInOutSine: <br />
  211. http://www.zhihu.com/question/21981571/answer/19925418
  212. !#zh
  213. 创建 easeSineInOut 缓动对象。<br />
  214. EaseSineIn 是按正弦函数缓动进入并退出的动作。<br />
  215. 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418
  216. @example
  217. ```js
  218. action.easing(cc.easeSineInOut());
  219. ```
  220. */
  221. export function easeSineInOut(): any;
  222. /**
  223. !#en
  224. Creates the action easing object with the period in radians (default is 0.3). <br />
  225. Reference easeInElastic: <br />
  226. http://www.zhihu.com/question/21981571/answer/19925418
  227. !#zh
  228. 创建 easeElasticIn 缓动对象。<br />
  229. EaseElasticIn 是按弹性曲线缓动进入的动作。<br />
  230. 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418
  231. @param period period
  232. @example
  233. ```js
  234. // example
  235. action.easing(cc.easeElasticIn(3.0));
  236. ```
  237. */
  238. export function easeElasticIn(period: number): any;
  239. /**
  240. !#en
  241. Creates the action easing object with the period in radians (default is 0.3). <br />
  242. Reference easeOutElastic: <br />
  243. http://www.zhihu.com/question/21981571/answer/19925418
  244. !#zh
  245. 创建 easeElasticOut 缓动对象。<br />
  246. EaseElasticOut 是按弹性曲线缓动退出的动作。<br />
  247. 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
  248. @param period period
  249. @example
  250. ```js
  251. // example
  252. action.easing(cc.easeElasticOut(3.0));
  253. ```
  254. */
  255. export function easeElasticOut(period: number): any;
  256. /**
  257. !#en
  258. Creates the action easing object with the period in radians (default is 0.3). <br />
  259. Reference easeInOutElastic: <br />
  260. http://www.zhihu.com/question/21981571/answer/19925418
  261. !#zh
  262. 创建 easeElasticInOut 缓动对象。<br />
  263. EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。<br />
  264. 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
  265. @param period period
  266. @example
  267. ```js
  268. // example
  269. action.easing(cc.easeElasticInOut(3.0));
  270. ```
  271. */
  272. export function easeElasticInOut(period: number): any;
  273. /**
  274. !#en
  275. Creates the action easing object. <br />
  276. Eased bounce effect at the beginning.
  277. !#zh
  278. 创建 easeBounceIn 缓动对象。<br />
  279. EaseBounceIn 是按弹跳动作缓动进入的动作。
  280. @example
  281. ```js
  282. // example
  283. action.easing(cc.easeBounceIn());
  284. ```
  285. */
  286. export function easeBounceIn(): any;
  287. /**
  288. !#en
  289. Creates the action easing object. <br />
  290. Eased bounce effect at the ending.
  291. !#zh
  292. 创建 easeBounceOut 缓动对象。<br />
  293. EaseBounceOut 是按弹跳动作缓动退出的动作。
  294. @example
  295. ```js
  296. // example
  297. action.easing(cc.easeBounceOut());
  298. ```
  299. */
  300. export function easeBounceOut(): any;
  301. /**
  302. !#en
  303. Creates the action easing object. <br />
  304. Eased bounce effect at the begining and ending.
  305. !#zh
  306. 创建 easeBounceInOut 缓动对象。<br />
  307. EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。
  308. @example
  309. ```js
  310. // example
  311. action.easing(cc.easeBounceInOut());
  312. ```
  313. */
  314. export function easeBounceInOut(): any;
  315. /**
  316. !#en
  317. Creates the action easing object. <br />
  318. In the opposite direction to move slowly, and then accelerated to the right direction.
  319. !#zh
  320. 创建 easeBackIn 缓动对象。<br />
  321. easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。<br />
  322. @example
  323. ```js
  324. // example
  325. action.easing(cc.easeBackIn());
  326. ```
  327. */
  328. export function easeBackIn(): any;
  329. /**
  330. !#en
  331. Creates the action easing object. <br />
  332. Fast moving more than the finish, and then slowly back to the finish.
  333. !#zh
  334. 创建 easeBackOut 缓动对象。<br />
  335. easeBackOut 快速移动超出目标,然后慢慢回到目标点。
  336. @example
  337. ```js
  338. // example
  339. action.easing(cc.easeBackOut());
  340. ```
  341. */
  342. export function easeBackOut(): any;
  343. /**
  344. !#en
  345. Creates the action easing object. <br />
  346. Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.
  347. !#zh
  348. 创建 easeBackInOut 缓动对象。<br />
  349. @example
  350. ```js
  351. // example
  352. action.easing(cc.easeBackInOut());
  353. ```
  354. */
  355. export function easeBackInOut(): any;
  356. /**
  357. !#en
  358. Creates the action easing object. <br />
  359. Into the 4 reference point. <br />
  360. To calculate the motion curve.
  361. !#zh
  362. 创建 easeBezierAction 缓动对象。<br />
  363. EaseBezierAction 是按贝塞尔曲线缓动的动作。
  364. @param p0 The first bezier parameter
  365. @param p1 The second bezier parameter
  366. @param p2 The third bezier parameter
  367. @param p3 The fourth bezier parameter
  368. @example
  369. ```js
  370. // example
  371. action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
  372. ```
  373. */
  374. export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any;
  375. /**
  376. !#en
  377. Creates the action easing object. <br />
  378. Reference easeInQuad: <br />
  379. http://www.zhihu.com/question/21981571/answer/19925418
  380. !#zh
  381. 创建 easeQuadraticActionIn 缓动对象。<br />
  382. EaseQuadraticIn是按二次函数缓动进入的动作。<br />
  383. 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418
  384. @example
  385. ```js
  386. //example
  387. action.easing(cc.easeQuadraticActionIn());
  388. ```
  389. */
  390. export function easeQuadraticActionIn(): any;
  391. /**
  392. !#en
  393. Creates the action easing object. <br />
  394. Reference easeOutQuad: <br />
  395. http://www.zhihu.com/question/21981571/answer/19925418
  396. !#zh
  397. 创建 easeQuadraticActionOut 缓动对象。<br />
  398. EaseQuadraticOut 是按二次函数缓动退出的动作。<br />
  399. 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
  400. @example
  401. ```js
  402. //example
  403. action.easing(cc.easeQuadraticActionOut());
  404. ```
  405. */
  406. export function easeQuadraticActionOut(): any;
  407. /**
  408. !#en
  409. Creates the action easing object. <br />
  410. Reference easeInOutQuad: <br />
  411. http://www.zhihu.com/question/21981571/answer/19925418
  412. !#zh
  413. 创建 easeQuadraticActionInOut 缓动对象。<br />
  414. EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。<br />
  415. 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
  416. @example
  417. ```js
  418. //example
  419. action.easing(cc.easeQuadraticActionInOut());
  420. ```
  421. */
  422. export function easeQuadraticActionInOut(): any;
  423. /**
  424. !#en
  425. Creates the action easing object. <br />
  426. Reference easeIntQuart: <br />
  427. http://www.zhihu.com/question/21981571/answer/19925418
  428. !#zh
  429. 创建 easeQuarticActionIn 缓动对象。<br />
  430. EaseQuarticIn 是按四次函数缓动进入的动作。<br />
  431. 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418
  432. @example
  433. ```js
  434. //example
  435. action.easing(cc.easeQuarticActionIn());
  436. ```
  437. */
  438. export function easeQuarticActionIn(): any;
  439. /**
  440. !#en
  441. Creates the action easing object. <br />
  442. Reference easeOutQuart: <br />
  443. http://www.zhihu.com/question/21981571/answer/19925418
  444. !#zh
  445. 创建 easeQuarticActionOut 缓动对象。<br />
  446. EaseQuarticOut 是按四次函数缓动退出的动作。<br />
  447. 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
  448. @example
  449. ```js
  450. //example
  451. action.easing(cc.QuarticActionOut());
  452. ```
  453. */
  454. export function easeQuarticActionOut(): any;
  455. /**
  456. !#en
  457. Creates the action easing object. <br />
  458. Reference easeInOutQuart: <br />
  459. http://www.zhihu.com/question/21981571/answer/19925418
  460. !#zh
  461. 创建 easeQuarticActionInOut 缓动对象。<br />
  462. EaseQuarticInOut 是按四次函数缓动进入并退出的动作。<br />
  463. 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
  464. */
  465. export function easeQuarticActionInOut(): any;
  466. /**
  467. !#en
  468. Creates the action easing object. <br />
  469. Reference easeInQuint: <br />
  470. http://www.zhihu.com/question/21981571/answer/19925418
  471. !#zh
  472. 创建 easeQuinticActionIn 缓动对象。<br />
  473. EaseQuinticIn 是按五次函数缓动进的动作。<br />
  474. 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418
  475. @example
  476. ```js
  477. //example
  478. action.easing(cc.easeQuinticActionIn());
  479. ```
  480. */
  481. export function easeQuinticActionIn(): any;
  482. /**
  483. !#en
  484. Creates the action easing object. <br />
  485. Reference easeOutQuint: <br />
  486. http://www.zhihu.com/question/21981571/answer/19925418
  487. !#zh
  488. 创建 easeQuinticActionOut 缓动对象。<br />
  489. EaseQuinticOut 是按五次函数缓动退出的动作
  490. 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
  491. @example
  492. ```js
  493. //example
  494. action.easing(cc.easeQuadraticActionOut());
  495. ```
  496. */
  497. export function easeQuinticActionOut(): any;
  498. /**
  499. !#en
  500. Creates the action easing object. <br />
  501. Reference easeInOutQuint: <br />
  502. http://www.zhihu.com/question/21981571/answer/19925418
  503. !#zh
  504. 创建 easeQuinticActionInOut 缓动对象。<br />
  505. EaseQuinticInOut是按五次函数缓动进入并退出的动作。<br />
  506. 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
  507. @example
  508. ```js
  509. //example
  510. action.easing(cc.easeQuinticActionInOut());
  511. ```
  512. */
  513. export function easeQuinticActionInOut(): any;
  514. /**
  515. !#en
  516. Creates the action easing object. <br />
  517. Reference easeInCirc: <br />
  518. http://www.zhihu.com/question/21981571/answer/19925418
  519. !#zh
  520. 创建 easeCircleActionIn 缓动对象。<br />
  521. EaseCircleIn是按圆形曲线缓动进入的动作。<br />
  522. 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418
  523. @example
  524. ```js
  525. //example
  526. action.easing(cc.easeCircleActionIn());
  527. ```
  528. */
  529. export function easeCircleActionIn(): any;
  530. /**
  531. !#en
  532. Creates the action easing object. <br />
  533. Reference easeOutCirc: <br />
  534. http://www.zhihu.com/question/21981571/answer/19925418
  535. !#zh
  536. 创建 easeCircleActionOut 缓动对象。<br />
  537. EaseCircleOut是按圆形曲线缓动退出的动作。<br />
  538. 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
  539. @example
  540. ```js
  541. //example
  542. actioneasing(cc.easeCircleActionOut());
  543. ```
  544. */
  545. export function easeCircleActionOut(): any;
  546. /**
  547. !#en
  548. Creates the action easing object. <br />
  549. Reference easeInOutCirc: <br />
  550. http://www.zhihu.com/question/21981571/answer/19925418
  551. !#zh
  552. 创建 easeCircleActionInOut 缓动对象。<br />
  553. EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。<br />
  554. 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
  555. @example
  556. ```js
  557. //example
  558. action.easing(cc.easeCircleActionInOut());
  559. ```
  560. */
  561. export function easeCircleActionInOut(): any;
  562. /**
  563. !#en
  564. Creates the action easing object. <br />
  565. Reference easeInCubic: <br />
  566. http://www.zhihu.com/question/21981571/answer/19925418
  567. !#zh
  568. 创建 easeCubicActionIn 缓动对象。<br />
  569. EaseCubicIn 是按三次函数缓动进入的动作。<br />
  570. 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418
  571. @example
  572. ```js
  573. //example
  574. action.easing(cc.easeCubicActionIn());
  575. ```
  576. */
  577. export function easeCubicActionIn(): any;
  578. /**
  579. !#en
  580. Creates the action easing object. <br />
  581. Reference easeOutCubic: <br />
  582. http://www.zhihu.com/question/21981571/answer/19925418
  583. !#zh
  584. 创建 easeCubicActionOut 缓动对象。<br />
  585. EaseCubicOut 是按三次函数缓动退出的动作。<br />
  586. 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
  587. @example
  588. ```js
  589. //example
  590. action.easing(cc.easeCubicActionOut());
  591. ```
  592. */
  593. export function easeCubicActionOut(): any;
  594. /**
  595. !#en
  596. Creates the action easing object. <br />
  597. Reference easeInOutCubic: <br />
  598. http://www.zhihu.com/question/21981571/answer/19925418
  599. !#zh
  600. 创建 easeCubicActionInOut 缓动对象。<br />
  601. EaseCubicInOut是按三次函数缓动进入并退出的动作。<br />
  602. 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
  603. */
  604. export function easeCubicActionInOut(): any;
  605. /**
  606. !#en
  607. Helper constructor to create an array of sequenceable actions
  608. The created action will run actions sequentially, one after another.
  609. !#zh 顺序执行动作,创建的动作将按顺序依次运行。
  610. @param actionOrActionArray actionOrActionArray
  611. @param tempArray tempArray
  612. @example
  613. ```js
  614. // example
  615. // create sequence with actions
  616. var seq = cc.sequence(act1, act2);
  617. // create sequence with array
  618. var seq = cc.sequence(actArray);
  619. ```
  620. */
  621. export function sequence(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval;
  622. /**
  623. !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30)
  624. !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。
  625. @param action action
  626. @param times times
  627. @example
  628. ```js
  629. // example
  630. var rep = cc.repeat(cc.sequence(jump2, jump1), 5);
  631. ```
  632. */
  633. export function repeat(action: FiniteTimeAction, times: number): ActionInterval;
  634. /**
  635. !#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn.
  636. !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。
  637. @param action action
  638. @example
  639. ```js
  640. // example
  641. var repeat = cc.repeatForever(cc.rotateBy(1.0, 360));
  642. ```
  643. */
  644. export function repeatForever(action: FiniteTimeAction): ActionInterval;
  645. /**
  646. !#en Create a spawn action which runs several actions in parallel.
  647. !#zh 同步执行动作,同步执行一组动作。
  648. @param actionOrActionArray actionOrActionArray
  649. @param tempArray tempArray
  650. @example
  651. ```js
  652. // example
  653. var action = cc.spawn(cc.jumpBy(2, cc.v2(300, 0), 50, 4), cc.rotateBy(2, 720));
  654. todo: It should be the direct use new
  655. ```
  656. */
  657. export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction;
  658. /**
  659. !#en
  660. Rotates a Node object to a certain angle by modifying its angle property. <br/>
  661. The direction will be decided by the shortest angle.
  662. !#zh 旋转到目标角度,通过逐帧修改它的 angle 属性,旋转方向将由最短的角度决定。
  663. @param duration duration in seconds
  664. @param dstAngle dstAngle in degrees.
  665. @example
  666. ```js
  667. // example
  668. var rotateTo = cc.rotateTo(2, 61.0);
  669. ```
  670. */
  671. export function rotateTo(duration: number, dstAngle: number): ActionInterval;
  672. /**
  673. !#en
  674. Rotates a Node object clockwise a number of degrees by modifying its angle property.
  675. Relative to its properties to modify.
  676. !#zh 旋转指定的角度。
  677. @param duration duration in seconds
  678. @param deltaAngle deltaAngle in degrees
  679. @example
  680. ```js
  681. // example
  682. var actionBy = cc.rotateBy(2, 360);
  683. ```
  684. */
  685. export function rotateBy(duration: number, deltaAngle: number): ActionInterval;
  686. /**
  687. !#en
  688. Moves a Node object x,y pixels by modifying its position property. <br/>
  689. x and y are relative to the position of the object. <br/>
  690. Several MoveBy actions can be concurrently called, and the resulting <br/>
  691. movement will be the sum of individual movements.
  692. !#zh 移动指定的距离。
  693. @param duration duration in seconds
  694. @param deltaPos deltaPos
  695. @param deltaY deltaY
  696. @example
  697. ```js
  698. // example
  699. var actionTo = cc.moveBy(2, cc.v2(windowSize.width - 40, windowSize.height - 40));
  700. ```
  701. */
  702. export function moveBy(duration: number, deltaPos: Vec2|number, deltaY?: number): ActionInterval;
  703. /**
  704. !#en
  705. Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property. <br/>
  706. Several MoveTo actions can be concurrently called, and the resulting <br/>
  707. movement will be the sum of individual movements.
  708. !#zh 移动到目标位置。
  709. @param duration duration in seconds
  710. @param position position
  711. @param y y
  712. @example
  713. ```js
  714. // example
  715. var actionBy = cc.moveTo(2, cc.v2(80, 80));
  716. ```
  717. */
  718. export function moveTo(duration: number, position: Vec2|number, y?: number): ActionInterval;
  719. /**
  720. !#en
  721. Create a action which skews a Node object to given angles by modifying its skewX and skewY properties.
  722. Changes to the specified value.
  723. !#zh 偏斜到目标角度。
  724. @param t time in seconds
  725. @param sx sx
  726. @param sy sy
  727. @example
  728. ```js
  729. // example
  730. var actionTo = cc.skewTo(2, 37.2, -37.2);
  731. ```
  732. */
  733. export function skewTo(t: number, sx: number, sy: number): ActionInterval;
  734. /**
  735. !#en
  736. Skews a Node object by skewX and skewY degrees. <br />
  737. Relative to its property modification.
  738. !#zh 偏斜指定的角度。
  739. @param t time in seconds
  740. @param sx sx skew in degrees for X axis
  741. @param sy sy skew in degrees for Y axis
  742. @example
  743. ```js
  744. // example
  745. var actionBy = cc.skewBy(2, 0, -90);
  746. ```
  747. */
  748. export function skewBy(t: number, sx: number, sy: number): ActionInterval;
  749. /**
  750. !#en
  751. Moves a Node object simulating a parabolic jump movement by modifying it's position property.
  752. Relative to its movement.
  753. !#zh 用跳跃的方式移动指定的距离。
  754. @param duration duration
  755. @param position position
  756. @param y y
  757. @param height height
  758. @param jumps jumps
  759. @example
  760. ```js
  761. // example
  762. var actionBy = cc.jumpBy(2, cc.v2(300, 0), 50, 4);
  763. var actionBy = cc.jumpBy(2, 300, 0, 50, 4);
  764. ```
  765. */
  766. export function jumpBy(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval;
  767. /**
  768. !#en
  769. Moves a Node object to a parabolic position simulating a jump movement by modifying its position property. <br />
  770. Jump to the specified location.
  771. !#zh 用跳跃的方式移动到目标位置。
  772. @param duration duration
  773. @param position position
  774. @param y y
  775. @param height height
  776. @param jumps jumps
  777. @example
  778. ```js
  779. // example
  780. var actionTo = cc.jumpTo(2, cc.v2(300, 300), 50, 4);
  781. var actionTo = cc.jumpTo(2, 300, 300, 50, 4);
  782. ```
  783. */
  784. export function jumpTo(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval;
  785. /**
  786. !#en
  787. An action that moves the target with a cubic Bezier curve by a certain distance.
  788. Relative to its movement.
  789. !#zh 按贝赛尔曲线轨迹移动指定的距离。
  790. @param t time in seconds
  791. @param c Array of points
  792. @example
  793. ```js
  794. // example
  795. var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)];
  796. var bezierForward = cc.bezierBy(3, bezier);
  797. ```
  798. */
  799. export function bezierBy(t: number, c: Vec2[]): ActionInterval;
  800. /**
  801. !#en An action that moves the target with a cubic Bezier curve to a destination point.
  802. !#zh 按贝赛尔曲线轨迹移动到目标位置。
  803. @param t t
  804. @param c Array of points
  805. @example
  806. ```js
  807. // example
  808. var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)];
  809. var bezierTo = cc.bezierTo(2, bezier);
  810. ```
  811. */
  812. export function bezierTo(t: number, c: Vec2[]): ActionInterval;
  813. /**
  814. !#en Scales a Node object to a zoom factor by modifying it's scale property.
  815. !#zh 将节点大小缩放到指定的倍数。
  816. @param duration duration
  817. @param sx scale parameter in X
  818. @param sy scale parameter in Y, if Null equal to sx
  819. @example
  820. ```js
  821. // example
  822. // It scales to 0.5 in both X and Y.
  823. var actionTo = cc.scaleTo(2, 0.5);
  824. // It scales to 0.5 in x and 2 in Y
  825. var actionTo = cc.scaleTo(2, 0.5, 2);
  826. ```
  827. */
  828. export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval;
  829. /**
  830. !#en
  831. Scales a Node object a zoom factor by modifying it's scale property.
  832. Relative to its changes.
  833. !#zh 按指定的倍数缩放节点大小。
  834. @param duration duration in seconds
  835. @param sx sx scale parameter in X
  836. @param sy sy scale parameter in Y, if Null equal to sx
  837. @example
  838. ```js
  839. // example without sy, it scales by 2 both in X and Y
  840. var actionBy = cc.scaleBy(2, 2);
  841. //example with sy, it scales by 0.25 in X and 4.5 in Y
  842. var actionBy2 = cc.scaleBy(2, 0.25, 4.5);
  843. ```
  844. */
  845. export function scaleBy(duration: number, sx: number, sy?: number|void): ActionInterval;
  846. /**
  847. !#en Blinks a Node object by modifying it's visible property.
  848. !#zh 闪烁(基于透明度)。
  849. @param duration duration in seconds
  850. @param blinks blinks in times
  851. @example
  852. ```js
  853. // example
  854. var action = cc.blink(2, 10);
  855. ```
  856. */
  857. export function blink(duration: number, blinks: number): ActionInterval;
  858. /**
  859. !#en
  860. Fades an object that implements the cc.RGBAProtocol protocol.
  861. It modifies the opacity from the current value to a custom one.
  862. !#zh 修改透明度到指定值。
  863. @param duration duration
  864. @param opacity 0-255, 0 is transparent
  865. @example
  866. ```js
  867. // example
  868. var action = cc.fadeTo(1.0, 0);
  869. ```
  870. */
  871. export function fadeTo(duration: number, opacity: number): ActionInterval;
  872. /**
  873. !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.
  874. !#zh 渐显效果。
  875. @param duration duration in seconds
  876. @example
  877. ```js
  878. //example
  879. var action = cc.fadeIn(1.0);
  880. ```
  881. */
  882. export function fadeIn(duration: number): ActionInterval;
  883. /**
  884. !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0.
  885. !#zh 渐隐效果。
  886. @param d duration in seconds
  887. @example
  888. ```js
  889. // example
  890. var action = cc.fadeOut(1.0);
  891. ```
  892. */
  893. export function fadeOut(d: number): ActionInterval;
  894. /**
  895. !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
  896. !#zh 修改颜色到指定值。
  897. @param duration duration
  898. @param red 0-255
  899. @param green 0-255
  900. @param blue 0-255
  901. @example
  902. ```js
  903. // example
  904. var action = cc.tintTo(2, 255, 0, 255);
  905. ```
  906. */
  907. export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval;
  908. /**
  909. !#en
  910. Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
  911. Relative to their own color change.
  912. !#zh 按照指定的增量修改颜色。
  913. @param duration duration in seconds
  914. @param deltaRed deltaRed
  915. @param deltaGreen deltaGreen
  916. @param deltaBlue deltaBlue
  917. @example
  918. ```js
  919. // example
  920. var action = cc.tintBy(2, -127, -255, -127);
  921. ```
  922. */
  923. export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval;
  924. /**
  925. !#en Delays the action a certain amount of seconds.
  926. !#zh 延迟指定的时间量。
  927. @param d duration in seconds
  928. @example
  929. ```js
  930. // example
  931. var delay = cc.delayTime(1);
  932. ```
  933. */
  934. export function delayTime(d: number): ActionInterval;
  935. /**
  936. !#en Executes an action in reverse order, from time=duration to time=0.
  937. !#zh 反转目标动作的时间轴。
  938. @param action action
  939. @example
  940. ```js
  941. // example
  942. var reverse = cc.reverseTime(this);
  943. ```
  944. */
  945. export function reverseTime(action: FiniteTimeAction): ActionInterval;
  946. /**
  947. !#en Create an action with the specified action and forced target.
  948. !#zh 用已有动作和一个新的目标节点创建动作。
  949. @param target target
  950. @param action action
  951. */
  952. export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval;
  953. /**
  954. !#en Show the Node.
  955. !#zh 立即显示。
  956. @example
  957. ```js
  958. // example
  959. var showAction = cc.show();
  960. ```
  961. */
  962. export function show(): ActionInstant;
  963. /**
  964. !#en Hide the node.
  965. !#zh 立即隐藏。
  966. @example
  967. ```js
  968. // example
  969. var hideAction = cc.hide();
  970. ```
  971. */
  972. export function hide(): ActionInstant;
  973. /**
  974. !#en Toggles the visibility of a node.
  975. !#zh 显隐状态切换。
  976. @example
  977. ```js
  978. // example
  979. var toggleVisibilityAction = cc.toggleVisibility();
  980. ```
  981. */
  982. export function toggleVisibility(): ActionInstant;
  983. /**
  984. !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.
  985. !#zh 从父节点移除自身。
  986. @param isNeedCleanUp isNeedCleanUp
  987. @example
  988. ```js
  989. // example
  990. var removeSelfAction = cc.removeSelf();
  991. ```
  992. */
  993. export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant;
  994. /**
  995. !#en Destroy self
  996. !#zh 创建一个销毁自身的动作。
  997. @example
  998. ```js
  999. var destroySelfAction = cc.destroySelf();
  1000. ```
  1001. */
  1002. export function destroySelf(): ActionInstant;
  1003. /**
  1004. !#en Create a FlipX action to flip or unflip the target.
  1005. !#zh X轴翻转。
  1006. @param flip Indicate whether the target should be flipped or not
  1007. @example
  1008. ```js
  1009. var flipXAction = cc.flipX(true);
  1010. ```
  1011. */
  1012. export function flipX(flip: boolean): ActionInstant;
  1013. /**
  1014. !#en Create a FlipY action to flip or unflip the target.
  1015. !#zh Y轴翻转。
  1016. @param flip flip
  1017. @example
  1018. ```js
  1019. var flipYAction = cc.flipY(true);
  1020. ```
  1021. */
  1022. export function flipY(flip: boolean): ActionInstant;
  1023. /**
  1024. !#en Creates a Place action with a position.
  1025. !#zh 放置在目标位置。
  1026. @param pos pos
  1027. @param y y
  1028. @example
  1029. ```js
  1030. // example
  1031. var placeAction = cc.place(cc.v2(200, 200));
  1032. var placeAction = cc.place(200, 200);
  1033. ```
  1034. */
  1035. export function place(pos: Vec2|number, y?: number): ActionInstant;
  1036. /**
  1037. !#en Creates the action with the callback.
  1038. !#zh 执行回调函数。
  1039. @param selector selector
  1040. @param selectorTarget selectorTarget
  1041. @param data data for function, it accepts all data types.
  1042. @example
  1043. ```js
  1044. // example
  1045. // CallFunc without data
  1046. var finish = cc.callFunc(this.removeSprite, this);
  1047. // CallFunc with data
  1048. var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true);
  1049. ```
  1050. */
  1051. export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant;
  1052. /**
  1053. @param target the target to animate
  1054. */
  1055. export function tween<T> (target?: T) : Tween<T>;
  1056. /**
  1057. !#en
  1058. Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).<br/>
  1059. - In Cocos Creator, error is red.<br/>
  1060. - In Chrome, error have a red icon along with red message text.<br/>
  1061. !#zh
  1062. 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。<br/>
  1063. - 在 Cocos Creator 中,错误信息显示是红色的。<br/>
  1064. - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。<br/>
  1065. @param msg A JavaScript string containing zero or more substitution strings.
  1066. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  1067. */
  1068. export function error(msg: any, ...subst: any[]): void;
  1069. /**
  1070. !#en
  1071. Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime).
  1072. - In Cocos Creator, warning is yellow.
  1073. - In Chrome, warning have a yellow warning icon with the message text.
  1074. !#zh
  1075. 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。<br/>
  1076. - 在 Cocos Creator 中,警告信息显示是黄色的。<br/>
  1077. - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。<br/>
  1078. @param msg A JavaScript string containing zero or more substitution strings.
  1079. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  1080. */
  1081. export function warn(msg: any, ...subst: any[]): void;
  1082. /**
  1083. !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime).
  1084. !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
  1085. @param msg A JavaScript string containing zero or more substitution strings.
  1086. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  1087. */
  1088. export function log(msg: string|any, ...subst: any[]): void;
  1089. /** !#en Director
  1090. !#zh 导演类。 */
  1091. export var director: Director;
  1092. /** !#en This is a Game instance.
  1093. !#zh 这是一个 Game 类的实例,包含游戏主体信息并负责驱动游戏的游戏对象。。 */
  1094. export var game: Game;
  1095. /** !#en This is a Easing instance.
  1096. !#zh 这是一个 Easing 类实例。 */
  1097. export var easing: Easing;
  1098. /**
  1099. !#en
  1100. Rotates a Node object to a certain angle by modifying its quternion property. <br/>
  1101. The direction will be decided by the shortest angle.
  1102. !#zh 旋转到目标角度,通过逐帧修改它的 quternion 属性,旋转方向将由最短的角度决定。
  1103. @param duration duration in seconds
  1104. @param dstAngleX dstAngleX in degrees.
  1105. @param dstAngleY dstAngleY in degrees.
  1106. @param dstAngleZ dstAngleZ in degrees.
  1107. @example
  1108. ```js
  1109. // example
  1110. var rotate3DTo = cc.rotate3DTo(2, cc.v3(0, 180, 0));
  1111. ```
  1112. */
  1113. export function rotate3DTo(duration: number, dstAngleX: number|Vec3|Quat, dstAngleY?: number, dstAngleZ?: number): ActionInterval;
  1114. /**
  1115. !#en
  1116. Rotates a Node object counter clockwise a number of degrees by modifying its quaternion property.
  1117. Relative to its properties to modify.
  1118. !#zh 旋转指定的 3D 角度。
  1119. @param duration duration in seconds
  1120. @param deltaAngleX deltaAngleX in degrees
  1121. @param deltaAngleY deltaAngleY in degrees
  1122. @param deltaAngleZ deltaAngleZ in degrees
  1123. @example
  1124. ```js
  1125. // example
  1126. var actionBy = cc.rotate3DBy(2, cc.v3(0, 360, 0));
  1127. ```
  1128. */
  1129. export function rotate3DBy(duration: number, deltaAngleX: number|Vec3, deltaAngleY?: number, deltaAngleZ?: number): ActionInterval;
  1130. /** !#en The System event singleton for global usage
  1131. !#zh 系统事件单例,方便全局使用 */
  1132. export var systemEvent: SystemEvent;
  1133. export var assetManager: AssetManager;
  1134. /** !#en
  1135. cc.resources is a bundle and controls all asset under assets/resources
  1136. !#zh
  1137. cc.resources 是一个 bundle,用于管理所有在 assets/resources 下的资源 */
  1138. export var resources: AssetManager.Bundle;
  1139. /**
  1140. !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details.
  1141. !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。
  1142. @param options options
  1143. @example
  1144. ```js
  1145. // define base class
  1146. var Node = cc.Class();
  1147. // define sub class
  1148. var Sprite = cc.Class({
  1149. name: 'Sprite',
  1150. extends: Node,
  1151. ctor: function () {
  1152. this.url = "";
  1153. this.id = 0;
  1154. },
  1155. statics: {
  1156. // define static members
  1157. count: 0,
  1158. getBounds: function (spriteList) {
  1159. // compute bounds...
  1160. }
  1161. },
  1162. properties {
  1163. width: {
  1164. default: 128,
  1165. type: cc.Integer,
  1166. tooltip: 'The width of sprite'
  1167. },
  1168. height: 128,
  1169. size: {
  1170. get: function () {
  1171. return cc.v2(this.width, this.height);
  1172. }
  1173. }
  1174. },
  1175. load: function () {
  1176. // load this.url...
  1177. };
  1178. });
  1179. // instantiate
  1180. var obj = new Sprite();
  1181. obj.url = 'sprite.png';
  1182. obj.load();
  1183. ```
  1184. */
  1185. 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;
  1186. /**
  1187. !#en
  1188. Define an enum type. <br/>
  1189. 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/>
  1190. Otherwise it will use the value specified by user who writes the enum definition.
  1191. !#zh
  1192. 定义一个枚举类型。<br/>
  1193. 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。
  1194. @param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type
  1195. @example
  1196. ```js
  1197. // JavaScript:
  1198. var WrapMode = cc.Enum({
  1199. Repeat: -1,
  1200. Clamp: -1
  1201. });
  1202. // Texture.WrapMode.Repeat == 0
  1203. // Texture.WrapMode.Clamp == 1
  1204. // Texture.WrapMode[0] == "Repeat"
  1205. // Texture.WrapMode[1] == "Clamp"
  1206. var FlagType = cc.Enum({
  1207. Flag1: 1,
  1208. Flag2: 2,
  1209. Flag3: 4,
  1210. Flag4: 8,
  1211. });
  1212. var AtlasSizeList = cc.Enum({
  1213. 128: 128,
  1214. 256: 256,
  1215. 512: 512,
  1216. 1024: 1024,
  1217. });
  1218. // TypeScript:
  1219. // If used in TypeScript, just define a TypeScript enum:
  1220. enum Direction {
  1221. Up,
  1222. Down,
  1223. Left,
  1224. Right
  1225. }
  1226. // If you need to inspect the enum in Properties panel, you can call cc.Enum:
  1227. const {ccclass, property} = cc._decorator;
  1228. @ccclass
  1229. class NewScript extends cc.Component {
  1230. @property({
  1231. type: cc.Enum(Direction) // call cc.Enum
  1232. })
  1233. direction: Direction = Direction.Up;
  1234. }
  1235. ```
  1236. */
  1237. export function Enum<T>(obj: T): T;
  1238. /**
  1239. @param touches touches
  1240. */
  1241. export function handleTouchesBegin(touches: any[]): void;
  1242. /**
  1243. @param touches touches
  1244. */
  1245. export function handleTouchesMove(touches: any[]): void;
  1246. /**
  1247. @param touches touches
  1248. */
  1249. export function handleTouchesEnd(touches: any[]): void;
  1250. /**
  1251. @param touches touches
  1252. */
  1253. export function handleTouchesCancel(touches: any[]): void;
  1254. /**
  1255. @param touches touches
  1256. */
  1257. export function getSetOfTouchesEndOrCancel(touches: any[]): any[];
  1258. /**
  1259. Gets the count of all currently valid touches.
  1260. */
  1261. export function getGlobalTouchCount(): any;
  1262. /**
  1263. Gets global touches map, please do not modify the touches, otherwise all event listener will be affected
  1264. */
  1265. export function getGlobalTouches(): any;
  1266. /**
  1267. @param touch touch
  1268. */
  1269. export function getPreTouch(touch: Touch): Touch;
  1270. /**
  1271. @param touch touch
  1272. */
  1273. export function setPreTouch(touch: Touch): void;
  1274. /**
  1275. @param tx tx
  1276. @param ty ty
  1277. @param pos pos
  1278. */
  1279. export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch;
  1280. /**
  1281. @param location location
  1282. @param pos pos
  1283. @param eventType eventType
  1284. */
  1285. export function getMouseEvent(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse;
  1286. /**
  1287. @param event event
  1288. @param pos pos
  1289. */
  1290. export function getPointByEvent(event: Touch, pos: Vec2): Vec2;
  1291. /**
  1292. @param event event
  1293. @param pos pos
  1294. */
  1295. export function getTouchesByEvent(event: Touch, pos: Vec2): any[];
  1296. /**
  1297. @param element element
  1298. */
  1299. export function registerSystemEvent(element: HTMLElement): void;
  1300. /**
  1301. @param dt dt
  1302. */
  1303. export function update(dt: number): void;
  1304. /**
  1305. !#en
  1306. Checks whether the object is non-nil and not yet destroyed.<br>
  1307. When an object's `destroy` is called, it is actually destroyed after the end of this frame.
  1308. So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true.
  1309. If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`,
  1310. but this is often caused by a particular logical requirements, which is not normally required.
  1311. !#zh
  1312. 检查该对象是否不为 null 并且尚未销毁。<br>
  1313. 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。
  1314. @param value value
  1315. @param strictMode If true, Object called destroy() in this frame will also treated as invalid.
  1316. @example
  1317. ```js
  1318. var node = new cc.Node();
  1319. cc.log(cc.isValid(node)); // true
  1320. node.destroy();
  1321. cc.log(cc.isValid(node)); // true, still valid in this frame
  1322. // after a frame...
  1323. cc.log(cc.isValid(node)); // false, destroyed in the end of last frame
  1324. ```
  1325. */
  1326. export function isValid(value: any, strictMode?: boolean): boolean;
  1327. /** !#en cc.view is the shared view object.
  1328. !#zh cc.view 是全局的视图对象。 */
  1329. export var view: View;
  1330. /** !#en cc.winSize is the alias object for the size of the current game window.
  1331. !#zh cc.winSize 为当前的游戏窗口的大小。 */
  1332. export var winSize: Size;
  1333. /** Specify that the input value must be integer in Inspector.
  1334. Also used to indicates that the elements in array should be type integer. */
  1335. export var Integer: string;
  1336. /** Indicates that the elements in array should be type double. */
  1337. export var Float: string;
  1338. /** Indicates that the elements in array should be type boolean. */
  1339. export var Boolean: string;
  1340. /** Indicates that the elements in array should be type string. */
  1341. export var String: string;
  1342. /**
  1343. !#en Deserialize json to cc.Asset
  1344. !#zh 将 JSON 反序列化为对象实例。
  1345. @param data the serialized cc.Asset json string or json object.
  1346. @param details additional loading result
  1347. @param options options
  1348. */
  1349. export function deserialize(data: string|any, details?: Details, options?: any): any;
  1350. /**
  1351. !#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab.
  1352. !#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。
  1353. (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。)
  1354. @param original An existing object that you want to make a copy of.
  1355. @example
  1356. ```js
  1357. // instantiate node from prefab
  1358. var scene = cc.director.getScene();
  1359. var node = cc.instantiate(prefabAsset);
  1360. node.parent = scene;
  1361. // clone node
  1362. var scene = cc.director.getScene();
  1363. var node = cc.instantiate(targetNode);
  1364. node.parent = scene;
  1365. ```
  1366. */
  1367. export function instantiate(original: Prefab): Node;
  1368. export function instantiate<T>(original: T): T;
  1369. /**
  1370. !#en
  1371. The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}}
  1372. Alpha channel is optional. Default value is 255.
  1373. !#zh
  1374. 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。
  1375. Alpha 通道是可选的。默认值是 255。
  1376. @param r r
  1377. @param g g
  1378. @param b b
  1379. @param a a
  1380. @example
  1381. ```js
  1382. -----------------------
  1383. // 1. All channels seperately as parameters
  1384. var color1 = new cc.Color(255, 255, 255, 255);
  1385. // 2. Convert a hex string to a color
  1386. var color2 = new cc.Color("#000000");
  1387. // 3. An color object as parameter
  1388. var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255});
  1389. ```
  1390. */
  1391. export function color(r?: number, g?: number, b?: number, a?: number): Color;
  1392. /**
  1393. !#en The convenience method to create a new {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}}.
  1394. !#zh 通过该简便的函数进行创建 {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}} 对象。
  1395. @param m00 Component in column 0, row 0 position (index 0)
  1396. @param m01 Component in column 0, row 1 position (index 1)
  1397. @param m02 Component in column 0, row 2 position (index 2)
  1398. @param m03 Component in column 0, row 3 position (index 3)
  1399. @param m10 Component in column 1, row 0 position (index 4)
  1400. @param m11 Component in column 1, row 1 position (index 5)
  1401. @param m12 Component in column 1, row 2 position (index 6)
  1402. @param m13 Component in column 1, row 3 position (index 7)
  1403. @param m20 Component in column 2, row 0 position (index 8)
  1404. @param m21 Component in column 2, row 1 position (index 9)
  1405. @param m22 Component in column 2, row 2 position (index 10)
  1406. @param m23 Component in column 2, row 3 position (index 11)
  1407. @param m30 Component in column 3, row 0 position (index 12)
  1408. @param m31 Component in column 3, row 1 position (index 13)
  1409. @param m32 Component in column 3, row 2 position (index 14)
  1410. @param m33 Component in column 3, row 3 position (index 15)
  1411. */
  1412. export function mat4(m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number): Mat4;
  1413. /**
  1414. !#en The convenience method to create a new {{#crossLink "Quat"}}cc.Quat{{/crossLink}}.
  1415. !#zh 通过该简便的函数进行创建 {{#crossLink "Quat"}}cc.Quat{{/crossLink}} 对象。
  1416. @param x x
  1417. @param y y
  1418. @param z z
  1419. @param w w
  1420. */
  1421. export function quat(x?: number|any, y?: number, z?: number, w?: number): Quat;
  1422. /**
  1423. !#en
  1424. The convenience method to create a new Rect.
  1425. see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
  1426. !#zh
  1427. 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
  1428. @param x x
  1429. @param y y
  1430. @param w w
  1431. @param h h
  1432. @example
  1433. ```js
  1434. var a = new cc.Rect(0 , 0, 10, 0);
  1435. ```
  1436. */
  1437. export function rect(x?: number, y?: number, w?: number, h?: number): Rect;
  1438. /**
  1439. !#en
  1440. Helper function that creates a cc.Size.<br/>
  1441. Please use cc.p or cc.v2 instead, it will soon replace cc.Size.
  1442. !#zh
  1443. 创建一个 cc.Size 对象的帮助函数。<br/>
  1444. 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。
  1445. @param w width or a size object
  1446. @param h height
  1447. @example
  1448. ```js
  1449. var size1 = cc.size();
  1450. var size2 = cc.size(100,100);
  1451. var size3 = cc.size(size2);
  1452. var size4 = cc.size({width: 100, height: 100});
  1453. ```
  1454. */
  1455. export function size(w: number|Size, h?: number): Size;
  1456. export var EPSILON: number;
  1457. /**
  1458. Clamps a value between a minimum float and maximum float value.
  1459. @param val val
  1460. @param min min
  1461. @param max max
  1462. */
  1463. export function clamp(val: number, min: number, max: number): number;
  1464. /**
  1465. Clamps a value between 0 and 1.
  1466. @param val val
  1467. */
  1468. export function clamp01(val: number): number;
  1469. /**
  1470. @param from from
  1471. @param to to
  1472. @param ratio the interpolation coefficient
  1473. */
  1474. export function lerp(from: number, to: number, ratio: number): number;
  1475. export function random(): void;
  1476. /**
  1477. Returns a floating-point random number between min (inclusive) and max (exclusive).
  1478. @param min min
  1479. @param max max
  1480. */
  1481. export function randomRange(min: number, max: number): number;
  1482. /**
  1483. Returns a random integer between min (inclusive) and max (exclusive).
  1484. @param min min
  1485. @param max max
  1486. */
  1487. export function randomRangeInt(min: number, max: number): number;
  1488. /**
  1489. Linear congruential generator using Hull-Dobell Theorem.
  1490. @param seed the random seed
  1491. */
  1492. export function pseudoRandom(seed: number): number;
  1493. /**
  1494. Returns a floating-point pseudo-random number between min (inclusive) and max (exclusive).
  1495. @param seed seed
  1496. @param min min
  1497. @param max max
  1498. */
  1499. export function pseudoRandomRange(seed: number, min: number, max: number): number;
  1500. /**
  1501. Returns a pseudo-random integer between min (inclusive) and max (exclusive).
  1502. @param seed seed
  1503. @param min min
  1504. @param max max
  1505. */
  1506. export function pseudoRandomRangeInt(seed: number, min: number, max: number): number;
  1507. /**
  1508. Returns the next power of two for the value
  1509. @param val val
  1510. */
  1511. export function nextPow2(val: number): number;
  1512. /**
  1513. Returns float remainder for t / length
  1514. @param t time start at 0
  1515. @param length time of one cycle
  1516. */
  1517. export function repeat(t: number, length: number): number;
  1518. /**
  1519. Returns time wrapped in ping-pong mode
  1520. @param t time start at 0
  1521. @param length time of one cycle
  1522. */
  1523. export function repeat(t: number, length: number): number;
  1524. /**
  1525. Returns ratio of a value within a given range
  1526. @param from start value
  1527. @param to end value
  1528. @param value given value
  1529. */
  1530. export function repeat(from: number, to: number, value: number): number;
  1531. /**
  1532. Returns -1, 0, +1 depending on sign of x.
  1533. @param v v
  1534. */
  1535. export function sign(v: number): void;
  1536. /**
  1537. !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}.
  1538. !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。
  1539. @param x x
  1540. @param y y
  1541. @example
  1542. ```js
  1543. var v1 = cc.v2();
  1544. var v2 = cc.v2(0, 0);
  1545. var v3 = cc.v2(v2);
  1546. var v4 = cc.v2({x: 100, y: 100});
  1547. ```
  1548. */
  1549. export function v2(x?: number|any, y?: number): Vec2;
  1550. /**
  1551. !#en The convenience method to create a new {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}}.
  1552. !#zh 通过该简便的函数进行创建 {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}} 对象。
  1553. @param x x
  1554. @param y y
  1555. @param z z
  1556. @example
  1557. ```js
  1558. var v1 = cc.v3();
  1559. var v2 = cc.v3(0, 0, 0);
  1560. var v3 = cc.v3(v2);
  1561. var v4 = cc.v3({x: 100, y: 100, z: 0});
  1562. ```
  1563. */
  1564. export function v3(x?: number|any, y?: number, z?: number): Vec3;
  1565. /**
  1566. Finds a node by hierarchy path, the path is case-sensitive.
  1567. It will traverse the hierarchy by splitting the path using '/' character.
  1568. This function will still returns the node even if it is inactive.
  1569. It is recommended to not use this function every frame instead cache the result at startup.
  1570. @param path path
  1571. @param referenceNode referenceNode
  1572. */
  1573. export function find(path: string, referenceNode?: Node): Node;
  1574. export var dynamicAtlasManager: DynamicAtlasManager;
  1575. /** !#en The matrix storage */
  1576. export var matrix: any[];
  1577. /**
  1578. !#en Get an element
  1579. @param i i
  1580. @param j j
  1581. */
  1582. export function get(i: number, j: number): number;
  1583. /**
  1584. !#en Set an element
  1585. @param i i
  1586. @param j j
  1587. @param value value
  1588. */
  1589. export function set(i: number, j: number, value: boolean): void;
  1590. /**
  1591. !#en Sets all elements to zero
  1592. */
  1593. export function reset(): void;
  1594. /** !#en
  1595. cc.NodePool is the cache pool designed for node type.<br/>
  1596. It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  1597. It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class,
  1598. for example, a prefab is a specific node type. <br/>
  1599. When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.<br/>
  1600. Some common use case is :<br/>
  1601. 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)<br/>
  1602. 2. Blocks in candy crash (massive creation and recreation)<br/>
  1603. etc...
  1604. !#zh
  1605. cc.NodePool 是用于管理节点对象的对象缓存池。<br/>
  1606. 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁<br/>
  1607. 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。
  1608. 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。<br/>
  1609. 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。<br/>
  1610. 一些常见的用例是:<br/>
  1611. 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)<br/>
  1612. 2.糖果粉碎传奇中的木块(频繁创建)。
  1613. 等等.... */
  1614. export class NodePool {
  1615. /**
  1616. !#en
  1617. 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.
  1618. !#zh
  1619. 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。
  1620. @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。
  1621. @example
  1622. ```js
  1623. properties: {
  1624. template: cc.Prefab
  1625. },
  1626. onLoad () {
  1627. // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled.
  1628. this.myPool = new cc.NodePool('MyTemplateHandler');
  1629. }
  1630. ```
  1631. */
  1632. constructor(poolHandlerComp?: {prototype: Component}|string);
  1633. /** !#en The pool handler component, it could be the class name or the constructor.
  1634. !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */
  1635. poolHandlerComp: Function|string;
  1636. /**
  1637. !#en The current available size in the pool
  1638. !#zh 获取当前缓冲池的可用对象数量
  1639. */
  1640. size(): number;
  1641. /**
  1642. !#en Destroy all cached nodes in the pool
  1643. !#zh 销毁对象池中缓存的所有节点
  1644. */
  1645. clear(): void;
  1646. /**
  1647. !#en Put a new Node into the pool.
  1648. It will automatically remove the node from its parent without cleanup.
  1649. It will also invoke unuse method of the poolHandlerComp if exist.
  1650. !#zh 向缓冲池中存入一个不再需要的节点对象。
  1651. 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。
  1652. 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。
  1653. @param obj obj
  1654. @example
  1655. ```js
  1656. let myNode = cc.instantiate(this.template);
  1657. this.myPool.put(myNode);
  1658. ```
  1659. */
  1660. put(obj: Node): void;
  1661. /**
  1662. !#en Get a obj from pool, if no available object in pool, null will be returned.
  1663. This function will invoke the reuse function of poolHandlerComp if exist.
  1664. !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。
  1665. 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。
  1666. @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数
  1667. @example
  1668. ```js
  1669. let newNode = this.myPool.get();
  1670. ```
  1671. */
  1672. get(...params: any[]): Node;
  1673. }
  1674. /** !#en `cc.audioEngine` is the singleton object, it provide simple audio APIs.
  1675. !#zh
  1676. cc.audioengine是单例对象。<br/>
  1677. 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。<br/>
  1678. 不使用的时候,请使用 `cc.audioEngine.uncache(filePath);` 进行资源释放 <br/>
  1679. 注意:<br/>
  1680. 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。<br/>
  1681. 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */
  1682. export class audioEngine {
  1683. /**
  1684. !#en Play audio.
  1685. !#zh 播放音频
  1686. @param clip The audio clip to play.
  1687. @param loop Whether the music loop or not.
  1688. @param volume Volume size.
  1689. @example
  1690. ```js
  1691. cc.resources.load(path, cc.AudioClip, null, function (err, clip) {
  1692. var audioID = cc.audioEngine.play(clip, false, 0.5);
  1693. });
  1694. ```
  1695. */
  1696. static play(clip: AudioClip, loop: boolean, volume: number): number;
  1697. /**
  1698. !#en Set audio loop.
  1699. !#zh 设置音频是否循环。
  1700. @param audioID audio id.
  1701. @param loop Whether cycle.
  1702. @example
  1703. ```js
  1704. cc.audioEngine.setLoop(id, true);
  1705. ```
  1706. */
  1707. static setLoop(audioID: number, loop: boolean): void;
  1708. /**
  1709. !#en Get audio cycle state.
  1710. !#zh 获取音频的循环状态。
  1711. @param audioID audio id.
  1712. @example
  1713. ```js
  1714. cc.audioEngine.isLoop(id);
  1715. ```
  1716. */
  1717. static isLoop(audioID: number): boolean;
  1718. /**
  1719. !#en Set the volume of audio.
  1720. !#zh 设置音量(0.0 ~ 1.0)。
  1721. @param audioID audio id.
  1722. @param volume Volume must be in 0.0~1.0 .
  1723. @example
  1724. ```js
  1725. cc.audioEngine.setVolume(id, 0.5);
  1726. ```
  1727. */
  1728. static setVolume(audioID: number, volume: number): void;
  1729. /**
  1730. !#en The volume of the music max value is 1.0,the min value is 0.0 .
  1731. !#zh 获取音量(0.0 ~ 1.0)。
  1732. @param audioID audio id.
  1733. @example
  1734. ```js
  1735. var volume = cc.audioEngine.getVolume(id);
  1736. ```
  1737. */
  1738. static getVolume(audioID: number): number;
  1739. /**
  1740. !#en Set current time
  1741. !#zh 设置当前的音频时间。
  1742. @param audioID audio id.
  1743. @param sec current time.
  1744. @example
  1745. ```js
  1746. cc.audioEngine.setCurrentTime(id, 2);
  1747. ```
  1748. */
  1749. static setCurrentTime(audioID: number, sec: number): boolean;
  1750. /**
  1751. !#en Get current time
  1752. !#zh 获取当前的音频播放时间。
  1753. @param audioID audio id.
  1754. @example
  1755. ```js
  1756. var time = cc.audioEngine.getCurrentTime(id);
  1757. ```
  1758. */
  1759. static getCurrentTime(audioID: number): number;
  1760. /**
  1761. !#en Get audio duration
  1762. !#zh 获取音频总时长。
  1763. @param audioID audio id.
  1764. @example
  1765. ```js
  1766. var time = cc.audioEngine.getDuration(id);
  1767. ```
  1768. */
  1769. static getDuration(audioID: number): number;
  1770. /**
  1771. !#en Get audio state
  1772. !#zh 获取音频状态。
  1773. @param audioID audio id.
  1774. @example
  1775. ```js
  1776. var state = cc.audioEngine.getState(id);
  1777. ```
  1778. */
  1779. static getState(audioID: number): audioEngine.AudioState;
  1780. /**
  1781. !#en Whether the audio is playing
  1782. !#zh 音乐是否正在播放
  1783. @example
  1784. ```js
  1785. cc.audioEngine.isPlaying(audioID);
  1786. ```
  1787. */
  1788. static isPlaying(): boolean;
  1789. /**
  1790. !#en Set Audio finish callback
  1791. !#zh 设置一个音频结束后的回调
  1792. @param audioID audio id.
  1793. @param callback loaded callback.
  1794. @example
  1795. ```js
  1796. cc.audioEngine.setFinishCallback(id, function () {});
  1797. ```
  1798. */
  1799. static setFinishCallback(audioID: number, callback: Function): void;
  1800. /**
  1801. !#en Pause playing audio.
  1802. !#zh 暂停正在播放音频。
  1803. @param audioID The return value of function play.
  1804. @example
  1805. ```js
  1806. cc.audioEngine.pause(audioID);
  1807. ```
  1808. */
  1809. static pause(audioID: number): void;
  1810. /**
  1811. !#en Pause all playing audio
  1812. !#zh 暂停现在正在播放的所有音频。
  1813. @example
  1814. ```js
  1815. cc.audioEngine.pauseAll();
  1816. ```
  1817. */
  1818. static pauseAll(): void;
  1819. /**
  1820. !#en Resume playing audio.
  1821. !#zh 恢复播放指定的音频。
  1822. @param audioID The return value of function play.
  1823. @example
  1824. ```js
  1825. cc.audioEngine.resume(audioID);
  1826. ```
  1827. */
  1828. static resume(audioID: number): void;
  1829. /**
  1830. !#en Resume all playing audio.
  1831. !#zh 恢复播放所有之前暂停的所有音频。
  1832. @example
  1833. ```js
  1834. cc.audioEngine.resumeAll();
  1835. ```
  1836. */
  1837. static resumeAll(): void;
  1838. /**
  1839. !#en Stop playing audio.
  1840. !#zh 停止播放指定音频。
  1841. @param audioID The return value of function play.
  1842. @example
  1843. ```js
  1844. cc.audioEngine.stop(audioID);
  1845. ```
  1846. */
  1847. static stop(audioID: number): void;
  1848. /**
  1849. !#en Stop all playing audio.
  1850. !#zh 停止正在播放的所有音频。
  1851. @example
  1852. ```js
  1853. cc.audioEngine.stopAll();
  1854. ```
  1855. */
  1856. static stopAll(): void;
  1857. /**
  1858. !#en Set up an audio can generate a few examples.
  1859. !#zh 设置一个音频可以设置几个实例
  1860. @param num a number of instances to be created from within an audio
  1861. @example
  1862. ```js
  1863. cc.audioEngine.setMaxAudioInstance(20);
  1864. ```
  1865. */
  1866. static setMaxAudioInstance(num: number): void;
  1867. /**
  1868. !#en Getting audio can produce several examples.
  1869. !#zh 获取一个音频可以设置几个实例
  1870. @example
  1871. ```js
  1872. cc.audioEngine.getMaxAudioInstance();
  1873. ```
  1874. */
  1875. static getMaxAudioInstance(): number;
  1876. /**
  1877. !#en Unload the preloaded audio from internal buffer.
  1878. !#zh 卸载预加载的音频。
  1879. @param clip clip
  1880. @example
  1881. ```js
  1882. cc.audioEngine.uncache(filePath);
  1883. ```
  1884. */
  1885. static uncache(clip: AudioClip): void;
  1886. /**
  1887. !#en Unload all audio from internal buffer.
  1888. !#zh 卸载所有音频。
  1889. @example
  1890. ```js
  1891. cc.audioEngine.uncacheAll();
  1892. ```
  1893. */
  1894. static uncacheAll(): void;
  1895. /**
  1896. !#en Play background music
  1897. !#zh 播放背景音乐
  1898. @param clip The audio clip to play.
  1899. @param loop Whether the music loop or not.
  1900. @example
  1901. ```js
  1902. cc.resources.load(path, cc.AudioClip, null, function (err, clip) {
  1903. var audioID = cc.audioEngine.playMusic(clip, false);
  1904. });
  1905. ```
  1906. */
  1907. static playMusic(clip: AudioClip, loop: boolean): number;
  1908. /**
  1909. !#en Stop background music.
  1910. !#zh 停止播放背景音乐。
  1911. @example
  1912. ```js
  1913. cc.audioEngine.stopMusic();
  1914. ```
  1915. */
  1916. static stopMusic(): void;
  1917. /**
  1918. !#en Pause the background music.
  1919. !#zh 暂停播放背景音乐。
  1920. @example
  1921. ```js
  1922. cc.audioEngine.pauseMusic();
  1923. ```
  1924. */
  1925. static pauseMusic(): void;
  1926. /**
  1927. !#en Resume playing background music.
  1928. !#zh 恢复播放背景音乐。
  1929. @example
  1930. ```js
  1931. cc.audioEngine.resumeMusic();
  1932. ```
  1933. */
  1934. static resumeMusic(): void;
  1935. /**
  1936. !#en Get the volume(0.0 ~ 1.0).
  1937. !#zh 获取音量(0.0 ~ 1.0)。
  1938. @example
  1939. ```js
  1940. var volume = cc.audioEngine.getMusicVolume();
  1941. ```
  1942. */
  1943. static getMusicVolume(): number;
  1944. /**
  1945. !#en Set the background music volume.
  1946. !#zh 设置背景音乐音量(0.0 ~ 1.0)。
  1947. @param volume Volume must be in 0.0~1.0.
  1948. @example
  1949. ```js
  1950. cc.audioEngine.setMusicVolume(0.5);
  1951. ```
  1952. */
  1953. static setMusicVolume(volume: number): void;
  1954. /**
  1955. !#en Background music playing state
  1956. !#zh 背景音乐是否正在播放
  1957. @example
  1958. ```js
  1959. cc.audioEngine.isMusicPlaying();
  1960. ```
  1961. */
  1962. static isMusicPlaying(): boolean;
  1963. /**
  1964. !#en Play effect audio.
  1965. !#zh 播放音效
  1966. @param clip The audio clip to play.
  1967. @param loop Whether the music loop or not.
  1968. @example
  1969. ```js
  1970. cc.resources.load(path, cc.AudioClip, null, function (err, clip) {
  1971. var audioID = cc.audioEngine.playEffect(clip, false);
  1972. });
  1973. ```
  1974. */
  1975. static playEffect(clip: AudioClip, loop: boolean): number;
  1976. /**
  1977. !#en Set the volume of effect audio.
  1978. !#zh 设置音效音量(0.0 ~ 1.0)。
  1979. @param volume Volume must be in 0.0~1.0.
  1980. @example
  1981. ```js
  1982. cc.audioEngine.setEffectsVolume(0.5);
  1983. ```
  1984. */
  1985. static setEffectsVolume(volume: number): void;
  1986. /**
  1987. !#en The volume of the effect audio max value is 1.0,the min value is 0.0 .
  1988. !#zh 获取音效音量(0.0 ~ 1.0)。
  1989. @example
  1990. ```js
  1991. var volume = cc.audioEngine.getEffectsVolume();
  1992. ```
  1993. */
  1994. static getEffectsVolume(): number;
  1995. /**
  1996. !#en Pause effect audio.
  1997. !#zh 暂停播放音效。
  1998. @param audioID audio id.
  1999. @example
  2000. ```js
  2001. cc.audioEngine.pauseEffect(audioID);
  2002. ```
  2003. */
  2004. static pauseEffect(audioID: number): void;
  2005. /**
  2006. !#en Stop playing all the sound effects.
  2007. !#zh 暂停播放所有音效。
  2008. @example
  2009. ```js
  2010. cc.audioEngine.pauseAllEffects();
  2011. ```
  2012. */
  2013. static pauseAllEffects(): void;
  2014. /**
  2015. !#en Resume effect audio.
  2016. !#zh 恢复播放音效音频。
  2017. @param audioID The return value of function play.
  2018. @example
  2019. ```js
  2020. cc.audioEngine.resumeEffect(audioID);
  2021. ```
  2022. */
  2023. static resumeEffect(audioID: number): void;
  2024. /**
  2025. !#en Resume all effect audio.
  2026. !#zh 恢复播放所有之前暂停的音效。
  2027. @example
  2028. ```js
  2029. cc.audioEngine.resumeAllEffects();
  2030. ```
  2031. */
  2032. static resumeAllEffects(): void;
  2033. /**
  2034. !#en Stop playing the effect audio.
  2035. !#zh 停止播放音效。
  2036. @param audioID audio id.
  2037. @example
  2038. ```js
  2039. cc.audioEngine.stopEffect(id);
  2040. ```
  2041. */
  2042. static stopEffect(audioID: number): void;
  2043. /**
  2044. !#en Stop playing all the effects.
  2045. !#zh 停止播放所有音效。
  2046. @example
  2047. ```js
  2048. cc.audioEngine.stopAllEffects();
  2049. ```
  2050. */
  2051. static stopAllEffects(): void;
  2052. }
  2053. /** !#en Base class cc.Action for action classes.
  2054. !#zh Action 类是所有动作类型的基类。 */
  2055. export class Action {
  2056. /**
  2057. !#en
  2058. to copy object with deep copy.
  2059. returns a clone of action.
  2060. !#zh 返回一个克隆的动作。
  2061. */
  2062. clone(): Action;
  2063. /**
  2064. !#en
  2065. return true if the action has finished.
  2066. !#zh 如果动作已完成就返回 true。
  2067. */
  2068. isDone(): boolean;
  2069. /**
  2070. !#en get the target.
  2071. !#zh 获取当前目标节点。
  2072. */
  2073. getTarget(): Node;
  2074. /**
  2075. !#en The action will modify the target properties.
  2076. !#zh 设置目标节点。
  2077. @param target target
  2078. */
  2079. setTarget(target: Node): void;
  2080. /**
  2081. !#en get the original target.
  2082. !#zh 获取原始目标节点。
  2083. */
  2084. getOriginalTarget(): Node;
  2085. /**
  2086. !#en get tag number.
  2087. !#zh 获取用于识别动作的标签。
  2088. */
  2089. getTag(): number;
  2090. /**
  2091. !#en set tag number.
  2092. !#zh 设置标签,用于识别动作。
  2093. @param tag tag
  2094. */
  2095. setTag(tag: number): void;
  2096. /** !#en Default Action tag.
  2097. !#zh 默认动作标签。 */
  2098. static TAG_INVALID: number;
  2099. }
  2100. /** !#en
  2101. Base class actions that do have a finite time duration. <br/>
  2102. Possible actions: <br/>
  2103. - An action with a duration of 0 seconds. <br/>
  2104. - An action with a duration of 35.5 seconds.
  2105. Infinite time actions are valid
  2106. !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */
  2107. export class FiniteTimeAction extends Action {
  2108. /**
  2109. !#en get duration of the action. (seconds).
  2110. !#zh 获取动作以秒为单位的持续时间。
  2111. */
  2112. getDuration(): number;
  2113. /**
  2114. !#en set duration of the action. (seconds).
  2115. !#zh 设置动作以秒为单位的持续时间。
  2116. @param duration duration
  2117. */
  2118. setDuration(duration: number): void;
  2119. /**
  2120. !#en
  2121. Returns a reversed action. <br />
  2122. For example: <br />
  2123. - The action will be x coordinates of 0 move to 100. <br />
  2124. - The reversed action will be x of 100 move to 0.
  2125. - Will be rewritten
  2126. !#zh 返回一个新的动作,执行与原动作完全相反的动作。
  2127. */
  2128. reverse(): void;
  2129. /**
  2130. !#en
  2131. to copy object with deep copy.
  2132. returns a clone of action.
  2133. !#zh 返回一个克隆的动作。
  2134. */
  2135. clone(): FiniteTimeAction;
  2136. }
  2137. /** !#en
  2138. <p> An interval action is an action that takes place within a certain period of time. <br/>
  2139. It has an start time, and a finish time. The finish time is the parameter<br/>
  2140. duration plus the start time.</p>
  2141. <p>These CCActionInterval actions have some interesting properties, like:<br/>
  2142. - They can run normally (default) <br/>
  2143. - They can run reversed with the reverse method <br/>
  2144. - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions. </p>
  2145. <p>For example, you can simulate a Ping Pong effect running the action normally and<br/>
  2146. then running it again in Reverse mode. </p>
  2147. !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */
  2148. export class ActionInterval extends FiniteTimeAction {
  2149. /**
  2150. !#en Implementation of ease motion.
  2151. !#zh 缓动运动。
  2152. @param easeObj easeObj
  2153. @example
  2154. ```js
  2155. action.easing(cc.easeIn(3.0));
  2156. ```
  2157. */
  2158. easing(easeObj: any): ActionInterval;
  2159. /**
  2160. !#en
  2161. Repeats an action a number of times.
  2162. To repeat an action forever use the CCRepeatForever action.
  2163. !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。
  2164. @param times times
  2165. */
  2166. repeat(times: number): ActionInterval;
  2167. /**
  2168. !#en
  2169. Repeats an action for ever. <br/>
  2170. To repeat the an action for a limited number of times use the Repeat action. <br/>
  2171. !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。
  2172. */
  2173. repeatForever(): ActionInterval;
  2174. }
  2175. /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions.
  2176. !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */
  2177. export class ActionInstant extends FiniteTimeAction {
  2178. }
  2179. /** !#en
  2180. cc.ActionManager is a class that can manage actions.<br/>
  2181. Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface,
  2182. which uses this class's singleton object.
  2183. But there are some cases where you might need to use this class. <br/>
  2184. Examples:<br/>
  2185. - When you want to run an action where the target is different from a CCNode.<br/>
  2186. - When you want to pause / resume the actions<br/>
  2187. !#zh
  2188. cc.ActionManager 是可以管理动作的单例类。<br/>
  2189. 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。<br/>
  2190. 但也有一些情况下,您可能需要使用这个类。 <br/>
  2191. 例如:
  2192. - 当你想要运行一个动作,但目标不是 CCNode 类型时。 <br/>
  2193. - 当你想要暂停/恢复动作时。 <br/> */
  2194. export class ActionManager {
  2195. /**
  2196. !#en
  2197. Adds an action with a target.<br/>
  2198. If the target is already present, then the action will be added to the existing target.
  2199. 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.
  2200. When the target is paused, the queued actions won't be 'ticked'.
  2201. !#zh
  2202. 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。<br/>
  2203. 如果目标已存在,动作将会被直接添加到现有的节点中。<br/>
  2204. 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。<br/>
  2205. 当目标状态的 paused 为 true,动作将不会被执行
  2206. @param action action
  2207. @param target target
  2208. @param paused paused
  2209. */
  2210. addAction(action: Action, target: Node, paused: boolean): void;
  2211. /**
  2212. !#en Removes all actions from all the targets.
  2213. !#zh 移除所有对象的所有动作。
  2214. */
  2215. removeAllActions(): void;
  2216. /**
  2217. !#en
  2218. Removes all actions from a certain target. <br/>
  2219. All the actions that belongs to the target will be removed.
  2220. !#zh
  2221. 移除指定对象上的所有动作。<br/>
  2222. 属于该目标的所有的动作将被删除。
  2223. @param target target
  2224. @param forceDelete forceDelete
  2225. */
  2226. removeAllActionsFromTarget(target: Node, forceDelete: boolean): void;
  2227. /**
  2228. !#en Removes an action given an action reference.
  2229. !#zh 移除指定的动作。
  2230. @param action action
  2231. */
  2232. removeAction(action: Action): void;
  2233. /**
  2234. !#en Removes an action given its tag and the target.
  2235. !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。
  2236. @param tag tag
  2237. @param target target
  2238. */
  2239. removeActionByTag(tag: number, target?: Node): void;
  2240. /**
  2241. !#en Removes all actions given the tag and the target.
  2242. !#zh 删除指定对象下特定标签的所有动作。
  2243. @param tag tag
  2244. @param target target
  2245. */
  2246. removeAllActionsByTag(tag: number, target?: Node): void;
  2247. /**
  2248. !#en Gets an action given its tag an a target.
  2249. !#zh 通过目标对象和标签获取一个动作。
  2250. @param tag tag
  2251. @param target target
  2252. */
  2253. getActionByTag(tag: number, target: Node): Action;
  2254. /**
  2255. !#en
  2256. Returns the numbers of actions that are running in a certain target. <br/>
  2257. Composable actions are counted as 1 action. <br/>
  2258. Example: <br/>
  2259. - If you are running 1 Sequence of 7 actions, it will return 1. <br/>
  2260. - If you are running 7 Sequences of 2 actions, it will return 7.
  2261. !#zh
  2262. 返回指定对象下所有正在运行的动作数量。 <br/>
  2263. 组合动作被算作一个动作。<br/>
  2264. 例如:<br/>
  2265. - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。<br/>
  2266. - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。<br/>
  2267. @param target target
  2268. */
  2269. getNumberOfRunningActionsInTarget(target: Node): number;
  2270. /**
  2271. !#en Pauses the target: all running actions and newly added actions will be paused.
  2272. !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。
  2273. @param target target
  2274. */
  2275. pauseTarget(target: Node): void;
  2276. /**
  2277. !#en Resumes the target. All queued actions will be resumed.
  2278. !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。
  2279. @param target target
  2280. */
  2281. resumeTarget(target: Node): void;
  2282. /**
  2283. !#en Pauses all running actions, returning a list of targets whose actions were paused.
  2284. !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。
  2285. */
  2286. pauseAllRunningActions(): any[];
  2287. /**
  2288. !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call).
  2289. !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。
  2290. @param targetsToResume targetsToResume
  2291. */
  2292. resumeTargets(targetsToResume: any[]): void;
  2293. /**
  2294. !#en Pause a set of targets.
  2295. !#zh 暂停一组指定对象。
  2296. @param targetsToPause targetsToPause
  2297. */
  2298. pauseTargets(targetsToPause: any[]): void;
  2299. /**
  2300. !#en
  2301. purges the shared action manager. It releases the retained instance. <br/>
  2302. because it uses this, so it can not be static.
  2303. !#zh
  2304. 清除共用的动作管理器。它释放了持有的实例。 <br/>
  2305. 因为它使用 this,因此它不能是静态的。
  2306. */
  2307. purgeSharedManager(): void;
  2308. /**
  2309. !#en The ActionManager update。
  2310. !#zh ActionManager 主循环。
  2311. @param dt delta time in seconds
  2312. */
  2313. update(dt: number): void;
  2314. }
  2315. /** !#en
  2316. Tween provide a simple and flexible way to create action. Tween's api is more flexible than `cc.Action`:
  2317. - Support creating an action sequence in chained api.
  2318. - Support animate any objects' any properties, not limited to node's properties. By contrast, `cc.Action` needs to create a new action class to support new node property.
  2319. - Support working with `cc.Action`.
  2320. - Support easing and progress function.
  2321. !#zh
  2322. Tween 提供了一个简单灵活的方法来创建 action。相对于 Cocos 传统的 `cc.Action`,`cc.Tween` 在创建动画上要灵活非常多:
  2323. - 支持以链式结构的方式创建一个动画序列。
  2324. - 支持对任意对象的任意属性进行缓动,不再局限于节点上的属性,而 `cc.Action` 添加一个属性的支持时还需要添加一个新的 action 类型。
  2325. - 支持与 `cc.Action` 混用。
  2326. - 支持设置 {{#crossLink "Easing"}}{{/crossLink}} 或者 progress 函数。 */
  2327. export class Tween<T = any> {
  2328. /**
  2329. @param target target
  2330. */
  2331. constructor(target?: any);
  2332. /**
  2333. !#en Stop all tweens
  2334. !#zh 停止所有缓动
  2335. */
  2336. static stopAll(): void;
  2337. /**
  2338. !#en Stop all tweens by tag
  2339. !#zh 停止所有指定标签的缓动
  2340. @param tag tag
  2341. */
  2342. static stopAllByTag(tag: number): void;
  2343. /**
  2344. !#en Stop all tweens by target
  2345. !#zh 停止所有指定对象的缓动
  2346. @param target target
  2347. */
  2348. static stopAllByTarget(target: any): void;
  2349. /**
  2350. !#en
  2351. Insert an action or tween to this sequence
  2352. !#zh
  2353. 插入一个 action 或者 tween 到队列中
  2354. @param other other
  2355. */
  2356. then(other: Action|Tween<T>): Tween<T>;
  2357. /**
  2358. !#en
  2359. Set tween target
  2360. !#zh
  2361. 设置 tween 的 target
  2362. @param target target
  2363. */
  2364. target(target: any): Tween<T>;
  2365. /**
  2366. !#en
  2367. Start this tween
  2368. !#zh
  2369. 运行当前 tween
  2370. */
  2371. start(): Tween<T>;
  2372. /**
  2373. !#en
  2374. Stop this tween
  2375. !#zh
  2376. 停止当前 tween
  2377. */
  2378. stop(): Tween<T>;
  2379. /**
  2380. !#en Sets tween tag
  2381. !#zh 设置缓动的标签
  2382. @param tag tag
  2383. */
  2384. tag(tag: number): Tween<T>;
  2385. /**
  2386. !#en
  2387. Clone a tween
  2388. !#zh
  2389. 克隆当前 tween
  2390. @param target target
  2391. */
  2392. clone(target?: any): Tween<T>;
  2393. /**
  2394. !#en
  2395. Integrate all previous actions to an action.
  2396. !#zh
  2397. 将之前所有的 action 整合为一个 action。
  2398. */
  2399. union(): Tween;
  2400. /**
  2401. !#en Sets target's position property according to the bezier curve.
  2402. !#zh 按照贝塞尔路径设置目标的 position 属性。
  2403. @param duration duration
  2404. @param c1 c1
  2405. @param c2 c2
  2406. @param to to
  2407. */
  2408. bezierTo(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween<T>;
  2409. /**
  2410. !#en Sets target's position property according to the bezier curve.
  2411. !#zh 按照贝塞尔路径设置目标的 position 属性。
  2412. @param duration duration
  2413. @param c1 c1
  2414. @param c2 c2
  2415. @param to to
  2416. */
  2417. bezierBy(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween<T>;
  2418. /**
  2419. !#en Flips target's scaleX
  2420. !#zh 翻转目标的 scaleX 属性
  2421. */
  2422. flipX(): Tween<T>;
  2423. /**
  2424. !#en Flips target's scaleY
  2425. !#zh 翻转目标的 scaleY 属性
  2426. */
  2427. flipY(): Tween<T>;
  2428. /**
  2429. !#en Blinks target by set target's opacity property
  2430. !#zh 通过设置目标的 opacity 属性达到闪烁效果
  2431. @param duration duration
  2432. @param times times
  2433. @param opts opts
  2434. */
  2435. blink(duration: number, times: number, opts?: {progress?: Function; easing?: Function|string; }): Tween<T>;
  2436. /**
  2437. !#en
  2438. Add an action which calculate with absolute value
  2439. !#zh
  2440. 添加一个对属性进行绝对值计算的 action
  2441. @param duration duration
  2442. @param props {scale: 2, position: cc.v3(100, 100, 100)}
  2443. @param opts opts
  2444. */
  2445. to<OPTS extends Partial<{ progress: Function, easing: Function | String, onUpdate: Function }>>(duration: number, props: ConstructorType<T>, opts?: OPTS): Tween<T>;
  2446. /**
  2447. !#en
  2448. Add an action which calculate with relative value
  2449. !#zh
  2450. 添加一个对属性进行相对值计算的 action
  2451. @param duration duration
  2452. @param props {scale: 2, position: cc.v3(100, 100, 100)}
  2453. @param opts opts
  2454. */
  2455. by<OPTS extends Partial<{ progress: Function, easing: Function | String, onUpdate: Function }>>(duration: number, props: ConstructorType<T>, opts?: OPTS): Tween<T>;
  2456. /**
  2457. !#en
  2458. Directly set target properties
  2459. !#zh
  2460. 直接设置 target 的属性
  2461. @param props props
  2462. */
  2463. set (props: ConstructorType<T>) : Tween<T>;
  2464. /**
  2465. !#en
  2466. Add an delay action
  2467. !#zh
  2468. 添加一个延时 action
  2469. @param duration duration
  2470. */
  2471. delay(duration: number): Tween<T>;
  2472. /**
  2473. !#en
  2474. Add an callback action
  2475. !#zh
  2476. 添加一个回调 action
  2477. @param callback callback
  2478. @param selectTarget selectTarget
  2479. */
  2480. call(callback: Function, selectTarget?: object): Tween<T>;
  2481. /**
  2482. !#en
  2483. Add an hide action
  2484. !#zh
  2485. 添加一个隐藏 action
  2486. */
  2487. hide(): Tween<T>;
  2488. /**
  2489. !#en
  2490. Add an show action
  2491. !#zh
  2492. 添加一个显示 action
  2493. */
  2494. show(): Tween<T>;
  2495. /**
  2496. !#en
  2497. Add an removeSelf action
  2498. !#zh
  2499. 添加一个移除自己 action
  2500. */
  2501. removeSelf(): Tween<T>;
  2502. /**
  2503. !#en
  2504. Add an sequence action
  2505. !#zh
  2506. 添加一个队列 action
  2507. @param action action
  2508. @param actions actions
  2509. */
  2510. sequence(action: Action|Tween<T>, ...actions: (Action|Tween<T>)[]): Tween<T>;
  2511. /**
  2512. !#en
  2513. Add an parallel action
  2514. !#zh
  2515. 添加一个并行 action
  2516. @param action action
  2517. @param actions actions
  2518. */
  2519. parallel(action: Action|Tween<T>, ...actions: (Action|Tween<T>)[]): Tween<T>;
  2520. /**
  2521. !#en
  2522. Add an repeat action. This action will integrate before actions to a sequence action as their parameters.
  2523. !#zh
  2524. 添加一个重复 action,这个 action 会将前一个动作作为他的参数。
  2525. @param repeatTimes repeatTimes
  2526. @param action action
  2527. */
  2528. repeat(repeatTimes: number, action?: Action|Tween<T>): Tween<T>;
  2529. /**
  2530. !#en
  2531. Add an repeat forever action. This action will integrate before actions to a sequence action as their parameters.
  2532. !#zh
  2533. 添加一个永久重复 action,这个 action 会将前一个动作作为他的参数。
  2534. @param action action
  2535. */
  2536. repeatForever(action?: Action|Tween<T>): Tween<T>;
  2537. /**
  2538. !#en
  2539. Add an reverse time action. This action will integrate before actions to a sequence action as their parameters.
  2540. !#zh
  2541. 添加一个倒置时间 action,这个 action 会将前一个动作作为他的参数。
  2542. @param action action
  2543. */
  2544. reverseTime(action?: Action|Tween<T>): Tween<T>;
  2545. }
  2546. /** !#en An object to boot the game.
  2547. !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */
  2548. export class debug {
  2549. /**
  2550. !#en Gets error message with the error id and possible parameters.
  2551. !#zh 通过 error id 和必要的参数来获取错误信息。
  2552. @param errorId errorId
  2553. @param param param
  2554. */
  2555. static getError(errorId: number, param?: any): string;
  2556. /**
  2557. !#en Returns whether or not to display the FPS informations.
  2558. !#zh 是否显示 FPS 信息。
  2559. */
  2560. static isDisplayStats(): boolean;
  2561. /**
  2562. !#en Sets whether display the FPS on the bottom-left corner.
  2563. !#zh 设置是否在左下角显示 FPS。
  2564. @param displayStats displayStats
  2565. */
  2566. static setDisplayStats(displayStats: boolean): void;
  2567. }
  2568. /** !#en
  2569. <p>
  2570. ATTENTION: USE cc.director INSTEAD OF cc.Director.<br/>
  2571. cc.director is a singleton object which manage your game's logic flow.<br/>
  2572. Since the cc.director is a singleton, you don't need to call any constructor or create functions,<br/>
  2573. the standard way to use it is by calling:<br/>
  2574. - cc.director.methodName(); <br/>
  2575. It creates and handle the main Window and manages how and when to execute the Scenes.<br/>
  2576. <br/>
  2577. The cc.director is also responsible for:<br/>
  2578. - initializing the OpenGL context<br/>
  2579. - setting the OpenGL pixel format (default on is RGB565)<br/>
  2580. - setting the OpenGL buffer depth (default on is 0-bit)<br/>
  2581. - setting the color for clear screen (default one is BLACK)<br/>
  2582. - setting the projection (default one is 3D)<br/>
  2583. - setting the orientation (default one is Portrait)<br/>
  2584. <br/>
  2585. <br/>
  2586. The cc.director also sets the default OpenGL context:<br/>
  2587. - GL_TEXTURE_2D is enabled<br/>
  2588. - GL_VERTEX_ARRAY is enabled<br/>
  2589. - GL_COLOR_ARRAY is enabled<br/>
  2590. - GL_TEXTURE_COORD_ARRAY is enabled<br/>
  2591. </p>
  2592. <p>
  2593. cc.director also synchronizes timers with the refresh rate of the display.<br/>
  2594. Features and Limitations:<br/>
  2595. - Scheduled timers & drawing are synchronizes with the refresh rate of the display<br/>
  2596. - Only supports animation intervals of 1/60 1/30 & 1/15<br/>
  2597. </p>
  2598. !#zh
  2599. <p>
  2600. 注意:用 cc.director 代替 cc.Director。<br/>
  2601. cc.director 一个管理你的游戏的逻辑流程的单例对象。<br/>
  2602. 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,<br/>
  2603. 使用它的标准方法是通过调用:<br/>
  2604. - cc.director.methodName();
  2605. <br/>
  2606. 它创建和处理主窗口并且管理什么时候执行场景。<br/>
  2607. <br/>
  2608. cc.director 还负责:<br/>
  2609. - 初始化 OpenGL 环境。<br/>
  2610. - 设置OpenGL像素格式。(默认是 RGB565)<br/>
  2611. - 设置OpenGL缓冲区深度 (默认是 0-bit)<br/>
  2612. - 设置空白场景的颜色 (默认是 黑色)<br/>
  2613. - 设置投影 (默认是 3D)<br/>
  2614. - 设置方向 (默认是 Portrait)<br/>
  2615. <br/>
  2616. cc.director 设置了 OpenGL 默认环境 <br/>
  2617. - GL_TEXTURE_2D 启用。<br/>
  2618. - GL_VERTEX_ARRAY 启用。<br/>
  2619. - GL_COLOR_ARRAY 启用。<br/>
  2620. - GL_TEXTURE_COORD_ARRAY 启用。<br/>
  2621. </p>
  2622. <p>
  2623. cc.director 也同步定时器与显示器的刷新速率。
  2624. <br/>
  2625. 特点和局限性: <br/>
  2626. - 将计时器 & 渲染与显示器的刷新频率同步。<br/>
  2627. - 只支持动画的间隔 1/60 1/30 & 1/15。<br/>
  2628. </p> */
  2629. export class Director extends EventTarget {
  2630. /**
  2631. !#en
  2632. Converts a view coordinate to an WebGL coordinate<br/>
  2633. Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)<br/>
  2634. Implementation can be found in CCDirectorWebGL.
  2635. !#zh 将触摸点的屏幕坐标转换为 WebGL View 下的坐标。
  2636. @param uiPoint uiPoint
  2637. */
  2638. convertToGL(uiPoint: Vec2): Vec2;
  2639. /**
  2640. !#en
  2641. Converts an OpenGL coordinate to a view coordinate<br/>
  2642. Useful to convert node points to window points for calls such as glScissor<br/>
  2643. Implementation can be found in CCDirectorWebGL.
  2644. !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。
  2645. @param glPoint glPoint
  2646. */
  2647. convertToUI(glPoint: Vec2): Vec2;
  2648. /**
  2649. End the life of director in the next frame
  2650. */
  2651. end(): void;
  2652. /**
  2653. !#en
  2654. Returns the size of the WebGL view in points.<br/>
  2655. It takes into account any possible rotation (device orientation) of the window.
  2656. !#zh 获取视图的大小,以点为单位。
  2657. */
  2658. getWinSize(): Size;
  2659. /**
  2660. !#en
  2661. Returns the size of the OpenGL view in pixels.<br/>
  2662. It takes into account any possible rotation (device orientation) of the window.<br/>
  2663. On Mac winSize and winSizeInPixels return the same value.
  2664. (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())
  2665. !#zh
  2666. 获取视图大小,以像素为单位(这里的像素指的是资源分辨率。
  2667. 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize())
  2668. */
  2669. getWinSizeInPixels(): Size;
  2670. /**
  2671. !#en Pause the director's ticker, only involve the game logic execution.
  2672. It won't pause the rendering process nor the event manager.
  2673. If you want to pause the entier game including rendering, audio and event,
  2674. please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}
  2675. !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。
  2676. 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。
  2677. */
  2678. pause(): void;
  2679. /**
  2680. !#en
  2681. Run a scene. Replaces the running scene with a new one or enter the first scene.<br/>
  2682. The new scene will be launched immediately.
  2683. !#zh 立刻切换指定场景。
  2684. @param scene The need run scene.
  2685. @param onBeforeLoadScene The function invoked at the scene before loading.
  2686. @param onLaunched The function invoked at the scene after launch.
  2687. */
  2688. runSceneImmediate(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void;
  2689. /**
  2690. !#en
  2691. Run a scene. Replaces the running scene with a new one or enter the first scene.
  2692. The new scene will be launched at the end of the current frame.
  2693. !#zh 运行指定场景。
  2694. @param scene The need run scene.
  2695. @param onBeforeLoadScene The function invoked at the scene before loading.
  2696. @param onLaunched The function invoked at the scene after launch.
  2697. */
  2698. runScene(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void;
  2699. /**
  2700. !#en Loads the scene by its name.
  2701. !#zh 通过场景名称进行加载场景。
  2702. @param sceneName The name of the scene to load.
  2703. @param onLaunched callback, will be called after scene launched.
  2704. */
  2705. loadScene(sceneName: string, onLaunched?: Function): boolean;
  2706. /**
  2707. !#en
  2708. Preloads the scene to reduces loading time. You can call this method at any time you want.
  2709. After calling this method, you still need to launch the scene by `cc.director.loadScene`.
  2710. It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not
  2711. yet finished, the scene will be launched after loaded automatically.
  2712. !#zh 预加载场景,你可以在任何时候调用这个方法。
  2713. 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。
  2714. 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。
  2715. @param sceneName The name of the scene to preload.
  2716. @param onProgress callback, will be called when the load progression change.
  2717. @param onLoaded callback, will be called after scene loaded.
  2718. */
  2719. preloadScene(sceneName: string, onProgress?: (completedCount: number, totalCount: number, item: any) => void, onLoaded?: (error: Error) => void): void;
  2720. /**
  2721. !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen.
  2722. !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。
  2723. */
  2724. resume(): void;
  2725. /**
  2726. !#en
  2727. Enables or disables WebGL depth test.<br/>
  2728. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js
  2729. !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。
  2730. @param on on
  2731. */
  2732. setDepthTest(on: boolean): void;
  2733. /**
  2734. !#en
  2735. Set color for clear screen.<br/>
  2736. (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js)
  2737. !#zh
  2738. 设置场景的默认擦除颜色。<br/>
  2739. 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。
  2740. @param clearColor clearColor
  2741. */
  2742. setClearColor(clearColor: Color): void;
  2743. /**
  2744. !#en Returns current logic Scene.
  2745. !#zh 获取当前逻辑场景。
  2746. @example
  2747. ```js
  2748. // This will help you to get the Canvas node in scene
  2749. cc.director.getScene().getChildByName('Canvas');
  2750. ```
  2751. */
  2752. getScene(): Scene;
  2753. /**
  2754. !#en Returns the FPS value. Please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} to control animation interval.
  2755. !#zh 获取单位帧执行时间。请使用 {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} 来控制游戏帧率。
  2756. */
  2757. getAnimationInterval(): number;
  2758. /**
  2759. Sets animation interval, this doesn't control the main loop.
  2760. To control the game's frame rate overall, please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}}
  2761. @param value The animation interval desired.
  2762. */
  2763. setAnimationInterval(value: number): void;
  2764. /**
  2765. !#en Returns the delta time since last frame.
  2766. !#zh 获取上一帧的增量时间。
  2767. */
  2768. getDeltaTime(): number;
  2769. /**
  2770. !#en Returns the total passed time since game start, unit: ms
  2771. !#zh 获取从游戏开始到现在总共经过的时间,单位为 ms
  2772. */
  2773. getTotalTime(): number;
  2774. /**
  2775. !#en Returns how many frames were called since the director started.
  2776. !#zh 获取 director 启动以来游戏运行的总帧数。
  2777. */
  2778. getTotalFrames(): number;
  2779. /**
  2780. !#en Returns whether or not the Director is paused.
  2781. !#zh 是否处于暂停状态。
  2782. */
  2783. isPaused(): boolean;
  2784. /**
  2785. !#en Returns the cc.Scheduler associated with this director.
  2786. !#zh 获取和 director 相关联的 cc.Scheduler。
  2787. */
  2788. getScheduler(): Scheduler;
  2789. /**
  2790. !#en Sets the cc.Scheduler associated with this director.
  2791. !#zh 设置和 director 相关联的 cc.Scheduler。
  2792. @param scheduler scheduler
  2793. */
  2794. setScheduler(scheduler: Scheduler): void;
  2795. /**
  2796. !#en Returns the cc.ActionManager associated with this director.
  2797. !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。
  2798. */
  2799. getActionManager(): ActionManager;
  2800. /**
  2801. !#en Sets the cc.ActionManager associated with this director.
  2802. !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。
  2803. @param actionManager actionManager
  2804. */
  2805. setActionManager(actionManager: ActionManager): void;
  2806. /**
  2807. !#en Returns the cc.CollisionManager associated with this director.
  2808. !#zh 获取和 director 相关联的 cc.CollisionManager (碰撞管理器)。
  2809. */
  2810. getCollisionManager(): CollisionManager;
  2811. /**
  2812. !#en Returns the cc.PhysicsManager associated with this director.
  2813. !#zh 返回与 director 相关联的 cc.PhysicsManager (物理管理器)。
  2814. */
  2815. getPhysicsManager(): PhysicsManager;
  2816. /**
  2817. !#en Returns the cc.Physics3DManager associated with this director.
  2818. !#zh 返回与 director 相关联的 cc.Physics3DManager (物理管理器)。
  2819. */
  2820. getPhysics3DManager(): Physics3DManager;
  2821. /** !#en The event projection changed of cc.Director. This event will not get triggered since v2.0
  2822. !#zh cc.Director 投影变化的事件。从 v2.0 开始这个事件不会再被触发 */
  2823. static EVENT_PROJECTION_CHANGED: string;
  2824. /** !#en The event which will be triggered before loading a new scene.
  2825. !#zh 加载新场景之前所触发的事件。 */
  2826. static EVENT_BEFORE_SCENE_LOADING: string;
  2827. /** !#en The event which will be triggered before launching a new scene.
  2828. !#zh 运行新场景之前所触发的事件。 */
  2829. static EVENT_BEFORE_SCENE_LAUNCH: string;
  2830. /** !#en The event which will be triggered after launching a new scene.
  2831. !#zh 运行新场景之后所触发的事件。 */
  2832. static EVENT_AFTER_SCENE_LAUNCH: string;
  2833. /** !#en The event which will be triggered at the beginning of every frame.
  2834. !#zh 每个帧的开始时所触发的事件。 */
  2835. static EVENT_BEFORE_UPDATE: string;
  2836. /** !#en The event which will be triggered after engine and components update logic.
  2837. !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。 */
  2838. static EVENT_AFTER_UPDATE: string;
  2839. /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead
  2840. !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */
  2841. static EVENT_BEFORE_VISIT: string;
  2842. /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead
  2843. !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */
  2844. static EVENT_AFTER_VISIT: string;
  2845. /** !#en The event which will be triggered before the rendering process.
  2846. !#zh 渲染过程之前所触发的事件。 */
  2847. static EVENT_BEFORE_DRAW: string;
  2848. /** !#en The event which will be triggered after the rendering process.
  2849. !#zh 渲染过程之后所触发的事件。 */
  2850. static EVENT_AFTER_DRAW: string;
  2851. /** Constant for 2D projection (orthogonal projection) */
  2852. static PROJECTION_2D: number;
  2853. /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */
  2854. static PROJECTION_3D: number;
  2855. /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */
  2856. static PROJECTION_CUSTOM: number;
  2857. /** Constant for default projection of cc.Director, default projection is 2D projection */
  2858. static PROJECTION_DEFAULT: number;
  2859. }
  2860. /** !#en
  2861. Class of all entities in Cocos Creator scenes.<br/>
  2862. For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}}
  2863. !#zh
  2864. Cocos Creator 场景中的所有节点类。<br/>
  2865. 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */
  2866. export class Node extends _BaseNode {
  2867. /** !#en
  2868. Group index of node.<br/>
  2869. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  2870. !#zh
  2871. 节点的分组索引。<br/>
  2872. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  2873. groupIndex: number;
  2874. /** !#en
  2875. Group of node.<br/>
  2876. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  2877. !#zh
  2878. 节点的分组。<br/>
  2879. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  2880. group: string;
  2881. /** !#en The position (x, y) of the node in its parent's coordinates.
  2882. !#zh 节点在父节点坐标系中的位置(x, y)。 */
  2883. position: Vec3;
  2884. /** !#en x axis position of node.
  2885. !#zh 节点 X 轴坐标。 */
  2886. x: number;
  2887. /** !#en y axis position of node.
  2888. !#zh 节点 Y 轴坐标。 */
  2889. y: number;
  2890. /** !#en z axis position of node.
  2891. !#zh 节点 Z 轴坐标。 */
  2892. z: number;
  2893. /** !#en Rotation of node.
  2894. !#zh 该节点旋转角度。 */
  2895. rotation: number;
  2896. /** !#en
  2897. Angle of node, the positive value is anti-clockwise direction.
  2898. !#zh
  2899. 该节点的旋转角度,正值为逆时针方向。 */
  2900. angle: number;
  2901. /** !#en The rotation as Euler angles in degrees, used in 3D node.
  2902. !#zh 该节点的欧拉角度,用于 3D 节点。 */
  2903. eulerAngles: Vec3;
  2904. /** !#en Rotation on x axis.
  2905. !#zh 该节点 X 轴旋转角度。 */
  2906. rotationX: number;
  2907. /** !#en Rotation on y axis.
  2908. !#zh 该节点 Y 轴旋转角度。 */
  2909. rotationY: number;
  2910. /** !#en The local scale relative to the parent.
  2911. !#zh 节点相对父节点的缩放。 */
  2912. scale: number;
  2913. /** !#en Scale on x axis.
  2914. !#zh 节点 X 轴缩放。 */
  2915. scaleX: number;
  2916. /** !#en Scale on y axis.
  2917. !#zh 节点 Y 轴缩放。 */
  2918. scaleY: number;
  2919. /** !#en Scale on z axis.
  2920. !#zh 节点 Z 轴缩放。 */
  2921. scaleZ: number;
  2922. /** !#en Skew x
  2923. !#zh 该节点 X 轴倾斜角度。 */
  2924. skewX: number;
  2925. /** !#en Skew y
  2926. !#zh 该节点 Y 轴倾斜角度。 */
  2927. skewY: number;
  2928. /** !#en Opacity of node, default value is 255.
  2929. !#zh 节点透明度,默认值为 255。 */
  2930. opacity: number;
  2931. /** !#en Color of node, default value is white: (255, 255, 255).
  2932. !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */
  2933. color: Color;
  2934. /** !#en Anchor point's position on x axis.
  2935. !#zh 节点 X 轴锚点位置。 */
  2936. anchorX: number;
  2937. /** !#en Anchor point's position on y axis.
  2938. !#zh 节点 Y 轴锚点位置。 */
  2939. anchorY: number;
  2940. /** !#en Width of node.
  2941. !#zh 节点宽度。 */
  2942. width: number;
  2943. /** !#en Height of node.
  2944. !#zh 节点高度。 */
  2945. height: number;
  2946. /** !#en zIndex is the 'key' used to sort the node relative to its siblings.<br/>
  2947. The value of zIndex should be in the range between cc.macro.MIN_ZINDEX and cc.macro.MAX_ZINDEX.<br/>
  2948. The Node's parent will sort all its children based on the zIndex value and the arrival order.<br/>
  2949. Nodes with greater zIndex will be sorted after nodes with smaller zIndex.<br/>
  2950. If two nodes have the same zIndex, then the node that was added first to the children's array will be in front of the other node in the array.<br/>
  2951. Node's order in children list will affect its rendering order. Parent is always rendering before all children.
  2952. !#zh zIndex 是用来对节点进行排序的关键属性,它决定一个节点在兄弟节点之间的位置。<br/>
  2953. zIndex 的取值应该介于 cc.macro.MIN_ZINDEX 和 cc.macro.MAX_ZINDEX 之间
  2954. 父节点主要根据节点的 zIndex 和添加次序来排序,拥有更高 zIndex 的节点将被排在后面,如果两个节点的 zIndex 一致,先添加的节点会稳定排在另一个节点之前。<br/>
  2955. 节点在 children 中的顺序决定了其渲染顺序。父节点永远在所有子节点之前被渲染 */
  2956. zIndex: number;
  2957. /** !#en
  2958. Switch 2D/3D node. The 2D nodes will run faster.
  2959. !#zh
  2960. 切换 2D/3D 节点,2D 节点会有更高的运行效率 */
  2961. is3DNode: boolean;
  2962. /** !#en Returns a normalized vector representing the up direction (Y axis) of the node in world space.
  2963. !#zh 获取节点正上方(y 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
  2964. up: Vec3;
  2965. /** !#en Returns a normalized vector representing the right direction (X axis) of the node in world space.
  2966. !#zh 获取节点正右方(x 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
  2967. right: Vec3;
  2968. /** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space.
  2969. !#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
  2970. forward: Vec3;
  2971. /**
  2972. @param name name
  2973. */
  2974. constructor(name?: string);
  2975. /**
  2976. !#en
  2977. Register a callback of a specific event type on Node.<br/>
  2978. Use this method to register touch or mouse event permit propagation based on scene graph,<br/>
  2979. These kinds of event are triggered with dispatchEvent, the dispatch process has three steps:<br/>
  2980. 1. Capturing phase: dispatch in capture targets (`_getCapturingTargets`), e.g. parents in node tree, from root to the real target<br/>
  2981. 2. At target phase: dispatch to the listeners of the real target<br/>
  2982. 3. Bubbling phase: dispatch in bubble targets (`_getBubblingTargets`), e.g. parents in node tree, from the real target to root<br/>
  2983. In any moment of the dispatching process, it can be stopped via `event.stopPropagation()` or `event.stopPropagationImmidiate()`.<br/>
  2984. It's the recommended way to register touch/mouse event for Node,<br/>
  2985. please do not use cc.eventManager directly for Node.<br/>
  2986. You can also register custom event and use `emit` to trigger custom event on Node.<br/>
  2987. For such events, there won't be capturing and bubbling phase, your event will be dispatched directly to its listeners registered on the same node.<br/>
  2988. You can also pass event callback parameters with `emit` by passing parameters after `type`.
  2989. !#zh
  2990. 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。<br/>
  2991. 鼠标或触摸事件会被系统调用 dispatchEvent 方法触发,触发的过程包含三个阶段:<br/>
  2992. 1. 捕获阶段:派发事件给捕获目标(通过 `_getCapturingTargets` 获取),比如,节点树中注册了捕获阶段的父节点,从根节点开始派发直到目标节点。<br/>
  2993. 2. 目标阶段:派发给目标节点的监听器。<br/>
  2994. 3. 冒泡阶段:派发事件给冒泡目标(通过 `_getBubblingTargets` 获取),比如,节点树中注册了冒泡阶段的父节点,从目标节点开始派发直到根节点。<br/>
  2995. 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。<br/>
  2996. 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。<br/>
  2997. 你也可以注册自定义事件到节点上,并通过 emit 方法触发此类事件,对于这类事件,不会发生捕获冒泡阶段,只会直接派发给注册在该节点上的监听器<br/>
  2998. 你可以通过在 emit 方法调用时在 type 之后传递额外的参数作为事件回调的参数列表
  2999. @param type A string representing the event type to listen for.<br>See {{#crossLink "Node/EventTyupe/POSITION_CHANGED"}}Node Events{{/crossLink}} for all builtin events.
  3000. @param callback The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique).
  3001. @param target The target (this object) to invoke the callback, can be null
  3002. @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase.
  3003. @example
  3004. ```js
  3005. this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass.
  3006. node.on(cc.Node.EventType.TOUCH_START, callback, this);
  3007. node.on(cc.Node.EventType.TOUCH_MOVE, callback, this);
  3008. node.on(cc.Node.EventType.TOUCH_END, callback, this);
  3009. node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this);
  3010. node.on(cc.Node.EventType.ANCHOR_CHANGED, callback);
  3011. node.on(cc.Node.EventType.COLOR_CHANGED, callback);
  3012. ```
  3013. */
  3014. on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
  3015. /**
  3016. !#en
  3017. Register an callback of a specific event type on the Node,
  3018. the callback will remove itself after the first time it is triggered.
  3019. !#zh
  3020. 注册节点的特定事件类型回调,回调会在第一时间被触发后删除自身。
  3021. @param type A string representing the event type to listen for.
  3022. @param callback The callback that will be invoked when the event is dispatched.
  3023. The callback is ignored if it is a duplicate (the callbacks are unique).
  3024. @param target The target (this object) to invoke the callback, can be null
  3025. @example
  3026. ```js
  3027. node.once(cc.Node.EventType.ANCHOR_CHANGED, callback);
  3028. ```
  3029. */
  3030. once<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
  3031. /**
  3032. !#en
  3033. Removes the callback previously registered with the same type, callback, target and or useCapture.
  3034. This method is merely an alias to removeEventListener.
  3035. !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。
  3036. @param type A string representing the event type being removed.
  3037. @param callback The callback to remove.
  3038. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  3039. @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase.
  3040. @example
  3041. ```js
  3042. this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this);
  3043. node.off(cc.Node.EventType.TOUCH_START, callback, this.node);
  3044. node.off(cc.Node.EventType.ANCHOR_CHANGED, callback, this);
  3045. ```
  3046. */
  3047. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  3048. /**
  3049. !#en Removes all callbacks previously registered with the same target.
  3050. !#zh 移除目标上的所有注册事件。
  3051. @param target The target to be searched for all related callbacks
  3052. @example
  3053. ```js
  3054. node.targetOff(target);
  3055. ```
  3056. */
  3057. targetOff(target: any): void;
  3058. /**
  3059. !#en Checks whether the EventTarget object has any callback registered for a specific type of event.
  3060. !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。
  3061. @param type The type of event.
  3062. */
  3063. hasEventListener(type: string): boolean;
  3064. /**
  3065. !#en
  3066. Trigger an event directly with the event name and necessary arguments.
  3067. !#zh
  3068. 通过事件名发送自定义事件
  3069. @param type event type
  3070. @param arg1 First argument in callback
  3071. @param arg2 Second argument in callback
  3072. @param arg3 Third argument in callback
  3073. @param arg4 Fourth argument in callback
  3074. @param arg5 Fifth argument in callback
  3075. @example
  3076. ```js
  3077. eventTarget.emit('fire', event);
  3078. eventTarget.emit('fire', message, emitter);
  3079. ```
  3080. */
  3081. emit(type: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void;
  3082. /**
  3083. !#en
  3084. Dispatches an event into the event flow.
  3085. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  3086. !#zh 分发事件到事件流中。
  3087. @param event The Event object that is dispatched into the event flow
  3088. */
  3089. dispatchEvent(event: Event): void;
  3090. /**
  3091. !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events.
  3092. 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.
  3093. Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/
  3094. !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。
  3095. 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。
  3096. 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html
  3097. @param recursive Whether to pause node system events on the sub node tree.
  3098. @example
  3099. ```js
  3100. node.pauseSystemEvents(true);
  3101. ```
  3102. */
  3103. pauseSystemEvents(recursive: boolean): void;
  3104. /**
  3105. !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events.
  3106. 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.
  3107. Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/
  3108. !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。
  3109. 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。
  3110. 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html
  3111. @param recursive Whether to resume node system events on the sub node tree.
  3112. @example
  3113. ```js
  3114. node.resumeSystemEvents(true);
  3115. ```
  3116. */
  3117. resumeSystemEvents(recursive: boolean): void;
  3118. /**
  3119. !#en
  3120. Executes an action, and returns the action that is executed.<br/>
  3121. The node becomes the action's target. Refer to cc.Action's getTarget() <br/>
  3122. Calling runAction while the node is not active won't have any effect. <br/>
  3123. Note:You shouldn't modify the action after runAction, that won't take any effect.<br/>
  3124. if you want to modify, when you define action plus.
  3125. !#zh
  3126. 执行并返回该执行的动作。该节点将会变成动作的目标。<br/>
  3127. 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。<br/>
  3128. 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。
  3129. @param action action
  3130. @example
  3131. ```js
  3132. var action = cc.scaleTo(0.2, 1, 0.6);
  3133. node.runAction(action);
  3134. node.runAction(action).repeatForever(); // fail
  3135. node.runAction(action.repeatForever()); // right
  3136. ```
  3137. */
  3138. runAction(action: Action): Action;
  3139. /**
  3140. !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`.
  3141. !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。
  3142. @example
  3143. ```js
  3144. node.pauseAllActions();
  3145. ```
  3146. */
  3147. pauseAllActions(): void;
  3148. /**
  3149. !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`.
  3150. !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。
  3151. @example
  3152. ```js
  3153. node.resumeAllActions();
  3154. ```
  3155. */
  3156. resumeAllActions(): void;
  3157. /**
  3158. !#en Stops and removes all actions from the running action list .
  3159. !#zh 停止并且移除所有正在运行的动作列表。
  3160. @example
  3161. ```js
  3162. node.stopAllActions();
  3163. ```
  3164. */
  3165. stopAllActions(): void;
  3166. /**
  3167. !#en Stops and removes an action from the running action list.
  3168. !#zh 停止并移除指定的动作。
  3169. @param action An action object to be removed.
  3170. @example
  3171. ```js
  3172. var action = cc.scaleTo(0.2, 1, 0.6);
  3173. node.stopAction(action);
  3174. ```
  3175. */
  3176. stopAction(action: Action): void;
  3177. /**
  3178. !#en Removes an action from the running action list by its tag.
  3179. !#zh 停止并且移除指定标签的动作。
  3180. @param tag A tag that indicates the action to be removed.
  3181. @example
  3182. ```js
  3183. node.stopActionByTag(1);
  3184. ```
  3185. */
  3186. stopActionByTag(tag: number): void;
  3187. /**
  3188. !#en Returns an action from the running action list by its tag.
  3189. !#zh 通过标签获取指定动作。
  3190. @param tag tag
  3191. @example
  3192. ```js
  3193. var action = node.getActionByTag(1);
  3194. ```
  3195. */
  3196. getActionByTag(tag: number): Action;
  3197. /**
  3198. !#en
  3199. Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).<br/>
  3200. Composable actions are counted as 1 action. Example:<br/>
  3201. If you are running 1 Sequence of 7 actions, it will return 1. <br/>
  3202. If you are running 7 Sequences of 2 actions, it will return 7.</p>
  3203. !#zh
  3204. 获取运行着的动作加上正在调度运行的动作的总数。<br/>
  3205. 例如:<br/>
  3206. - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。<br/>
  3207. - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。<br/>
  3208. @example
  3209. ```js
  3210. var count = node.getNumberOfRunningActions();
  3211. cc.log("Running Action Count: " + count);
  3212. ```
  3213. */
  3214. getNumberOfRunningActions(): number;
  3215. /**
  3216. !#en
  3217. Returns a copy of the position (x, y, z) of the node in its parent's coordinates.
  3218. You can pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values.
  3219. !#zh
  3220. 获取节点在父节点坐标系中的位置(x, y, z)。
  3221. 你可以传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。
  3222. @param out The return value to receive position
  3223. @example
  3224. ```js
  3225. cc.log("Node Position: " + node.getPosition());
  3226. ```
  3227. */
  3228. getPosition(out?: Vec2|Vec3): Vec2;
  3229. /**
  3230. !#en
  3231. Sets the position (x, y, z) of the node in its parent's coordinates.<br/>
  3232. Usually we use cc.v2(x, y) to compose cc.Vec2 object, in this case, position.z will become 0.<br/>
  3233. and passing two numbers (x, y) is more efficient than passing cc.Vec2 object, in this case, position.z will remain unchanged.
  3234. For 3D node we can use cc.v3(x, y, z) to compose cc.Vec3 object,<br/>
  3235. and passing three numbers (x, y, z) is more efficient than passing cc.Vec3 object.
  3236. !#zh
  3237. 设置节点在父节点坐标系中的位置。<br/>
  3238. 可以通过下面的方式设置坐标点:<br/>
  3239. 1. 传入 2 个数值 x, y (此时不会改变 position.z 的值)。<br/>
  3240. 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象 (此时 position.z 的值将被设置为0)。
  3241. 3. 对于 3D 节点可以传入 3 个数值 x, y, z。<br/>
  3242. 4. 对于 3D 节点可以传入 cc.v3(x, y, z) 类型为 cc.Vec3 的对象。
  3243. @param x X coordinate for position or the position object
  3244. @param y Y coordinate for position
  3245. @param z Z coordinate for position
  3246. */
  3247. setPosition(x: Vec2|Vec3|number, y?: number, z?: number): void;
  3248. /**
  3249. !#en
  3250. Returns the scale factor of the node.
  3251. Need pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values.
  3252. !#zh 获取节点的缩放,需要传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。
  3253. @param out out
  3254. @example
  3255. ```js
  3256. cc.log("Node Scale: " + node.getScale(cc.v3()));
  3257. ```
  3258. */
  3259. getScale(out: Vec2|Vec3): Vec2;
  3260. /**
  3261. !#en
  3262. Sets the scale of axis in local coordinates of the node.
  3263. You can operate 2 axis in 2D node, and 3 axis in 3D node.
  3264. When only (x, y) is passed, the value of scale.z will not be changed.
  3265. When a Vec2 is passed in, the value of scale.z will be set to 0.
  3266. !#zh
  3267. 设置节点在本地坐标系中坐标轴上的缩放比例。
  3268. 2D 节点可以操作两个坐标轴,而 3D 节点可以操作三个坐标轴。
  3269. 当只传入 (x, y) 时,scale.z 的值不会被改变。
  3270. 当只传入 Vec2 对象时,scale.z 的值将被设置为0。
  3271. @param x scaleX or scale object
  3272. @param y y
  3273. @param z z
  3274. @example
  3275. ```js
  3276. node.setScale(cc.v2(2, 2)); // Notice: scaleZ will be 0
  3277. node.setScale(cc.v3(2, 2, 2)); // for 3D node
  3278. node.setScale(2);
  3279. ```
  3280. */
  3281. setScale(x: number|Vec2|Vec3, y?: number, z?: number): void;
  3282. /**
  3283. !#en
  3284. Get rotation of node (in quaternion).
  3285. Need pass a cc.Quat as the argument to receive the return values.
  3286. !#zh
  3287. 获取该节点的 quaternion 旋转角度,需要传一个 cc.Quat 作为参数来接收返回值。
  3288. @param out out
  3289. */
  3290. getRotation(out: Quat): Quat;
  3291. /**
  3292. !#en Set rotation of node (in quaternion).
  3293. !#zh 设置该节点的 quaternion 旋转角度。
  3294. @param quat Quaternion object represents the rotation or the x value of quaternion
  3295. @param y y value of quternion
  3296. @param z z value of quternion
  3297. @param w w value of quternion
  3298. */
  3299. setRotation(quat: Quat|number, y?: number, z?: number, w?: number): void;
  3300. /**
  3301. !#en
  3302. Returns a copy the untransformed size of the node. <br/>
  3303. The contentSize remains the same no matter the node is scaled or rotated.<br/>
  3304. All nodes has a size. Layer and Scene has the same size of the screen by default. <br/>
  3305. !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。
  3306. @example
  3307. ```js
  3308. cc.log("Content Size: " + node.getContentSize());
  3309. ```
  3310. */
  3311. getContentSize(): Size;
  3312. /**
  3313. !#en
  3314. Sets the untransformed size of the node.<br/>
  3315. The contentSize remains the same no matter the node is scaled or rotated.<br/>
  3316. All nodes has a size. Layer and Scene has the same size of the screen.
  3317. !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。
  3318. @param size The untransformed size of the node or The untransformed size's width of the node.
  3319. @param height The untransformed size's height of the node.
  3320. @example
  3321. ```js
  3322. node.setContentSize(cc.size(100, 100));
  3323. node.setContentSize(100, 100);
  3324. ```
  3325. */
  3326. setContentSize(size: Size|number, height?: number): void;
  3327. /**
  3328. !#en
  3329. Returns a copy of the anchor point.<br/>
  3330. Anchor point is the point around which all transformations and positioning manipulations take place.<br/>
  3331. It's like a pin in the node where it is "attached" to its parent. <br/>
  3332. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. <br/>
  3333. But you can use values higher than (1,1) and lower than (0,0) too. <br/>
  3334. The default anchor point is (0.5,0.5), so it starts at the center of the node.
  3335. !#zh
  3336. 获取节点锚点,用百分比表示。<br/>
  3337. 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
  3338. 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
  3339. 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
  3340. 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
  3341. 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
  3342. @example
  3343. ```js
  3344. cc.log("Node AnchorPoint: " + node.getAnchorPoint());
  3345. ```
  3346. */
  3347. getAnchorPoint(): Vec2;
  3348. /**
  3349. !#en
  3350. Sets the anchor point in percent. <br/>
  3351. anchor point is the point around which all transformations and positioning manipulations take place. <br/>
  3352. It's like a pin in the node where it is "attached" to its parent. <br/>
  3353. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.<br/>
  3354. But you can use values higher than (1,1) and lower than (0,0) too.<br/>
  3355. The default anchor point is (0.5,0.5), so it starts at the center of the node.
  3356. !#zh
  3357. 设置锚点的百分比。<br/>
  3358. 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
  3359. 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
  3360. 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
  3361. 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
  3362. 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
  3363. @param point The anchor point of node or The x axis anchor of node.
  3364. @param y The y axis anchor of node.
  3365. @example
  3366. ```js
  3367. node.setAnchorPoint(cc.v2(1, 1));
  3368. node.setAnchorPoint(1, 1);
  3369. ```
  3370. */
  3371. setAnchorPoint(point: Vec2|number, y?: number): void;
  3372. /**
  3373. !#en Set rotation by lookAt target point, normally used by Camera Node
  3374. !#zh 通过观察目标来设置 rotation,一般用于 Camera Node 上
  3375. @param pos pos
  3376. @param up default is (0,1,0)
  3377. */
  3378. lookAt(pos: Vec3, up?: Vec3): void;
  3379. /**
  3380. !#en
  3381. Get the local transform matrix (4x4), based on parent node coordinates
  3382. !#zh 返回局部空间坐标系的矩阵,基于父节点坐标系。
  3383. @param out The matrix object to be filled with data
  3384. @example
  3385. ```js
  3386. let mat4 = cc.mat4();
  3387. node.getLocalMatrix(mat4);
  3388. ```
  3389. */
  3390. getLocalMatrix(out: Mat4): Mat4;
  3391. /**
  3392. !#en
  3393. Get the world transform matrix (4x4)
  3394. !#zh 返回世界空间坐标系的矩阵。
  3395. @param out The matrix object to be filled with data
  3396. @example
  3397. ```js
  3398. let mat4 = cc.mat4();
  3399. node.getWorldMatrix(mat4);
  3400. ```
  3401. */
  3402. getWorldMatrix(out: Mat4): Mat4;
  3403. /**
  3404. !#en
  3405. Converts a Point to node (local) space coordinates.
  3406. !#zh
  3407. 将一个点转换到节点 (局部) 空间坐标系。
  3408. @param worldPoint worldPoint
  3409. @param out out
  3410. @example
  3411. ```js
  3412. var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100));
  3413. var newVec3 = node.convertToNodeSpaceAR(cc.v3(100, 100, 100));
  3414. ```
  3415. */
  3416. convertToNodeSpaceAR<T extends cc.Vec2 | cc.Vec3>(worldPoint: T, out?: T): T;
  3417. /**
  3418. !#en
  3419. Converts a Point in node coordinates to world space coordinates.
  3420. !#zh
  3421. 将节点坐标系下的一个点转换到世界空间坐标系。
  3422. @param nodePoint nodePoint
  3423. @param out out
  3424. @example
  3425. ```js
  3426. var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100));
  3427. var newVec3 = node.convertToWorldSpaceAR(cc.v3(100, 100, 100));
  3428. ```
  3429. */
  3430. convertToWorldSpaceAR<T extends cc.Vec2 | cc.Vec3>(nodePoint: T, out?: T): T;
  3431. /**
  3432. !#en Converts a Point to node (local) space coordinates then add the anchor point position.
  3433. So the return position will be related to the left bottom corner of the node's bounding box.
  3434. This equals to the API behavior of cocos2d-x, you probably want to use convertToNodeSpaceAR instead
  3435. !#zh 将一个点转换到节点 (局部) 坐标系,并加上锚点的坐标。<br/>
  3436. 也就是说返回的坐标是相对于节点包围盒左下角的坐标。<br/>
  3437. 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToNodeSpaceAR。
  3438. @param worldPoint worldPoint
  3439. @example
  3440. ```js
  3441. var newVec2 = node.convertToNodeSpace(cc.v2(100, 100));
  3442. ```
  3443. */
  3444. convertToNodeSpace(worldPoint: Vec2): Vec2;
  3445. /**
  3446. !#en Converts a Point related to the left bottom corner of the node's bounding box to world space coordinates.
  3447. This equals to the API behavior of cocos2d-x, you probably want to use convertToWorldSpaceAR instead
  3448. !#zh 将一个相对于节点左下角的坐标位置转换到世界空间坐标系。
  3449. 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToWorldSpaceAR
  3450. @param nodePoint nodePoint
  3451. @example
  3452. ```js
  3453. var newVec2 = node.convertToWorldSpace(cc.v2(100, 100));
  3454. ```
  3455. */
  3456. convertToWorldSpace(nodePoint: Vec2): Vec2;
  3457. /**
  3458. !#en
  3459. Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
  3460. The matrix is in Pixels.
  3461. !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。
  3462. @param out The affine transform object to be filled with data
  3463. @example
  3464. ```js
  3465. let affineTransform = cc.AffineTransform.create();
  3466. node.getNodeToParentTransform(affineTransform);
  3467. ```
  3468. */
  3469. getNodeToParentTransform(out?: AffineTransform): AffineTransform;
  3470. /**
  3471. !#en
  3472. Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
  3473. The matrix is in Pixels.<br/>
  3474. This method is AR (Anchor Relative).
  3475. !#zh
  3476. 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。<br/>
  3477. 这个矩阵以像素为单位。<br/>
  3478. 该方法基于节点坐标。
  3479. @param out The affine transform object to be filled with data
  3480. @example
  3481. ```js
  3482. let affineTransform = cc.AffineTransform.create();
  3483. node.getNodeToParentTransformAR(affineTransform);
  3484. ```
  3485. */
  3486. getNodeToParentTransformAR(out?: AffineTransform): AffineTransform;
  3487. /**
  3488. !#en Returns the world affine transform matrix. The matrix is in Pixels.
  3489. !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。
  3490. @param out The affine transform object to be filled with data
  3491. @example
  3492. ```js
  3493. let affineTransform = cc.AffineTransform.create();
  3494. node.getNodeToWorldTransform(affineTransform);
  3495. ```
  3496. */
  3497. getNodeToWorldTransform(out?: AffineTransform): AffineTransform;
  3498. /**
  3499. !#en
  3500. Returns the world affine transform matrix. The matrix is in Pixels.<br/>
  3501. This method is AR (Anchor Relative).
  3502. !#zh
  3503. 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。<br/>
  3504. 该方法基于节点坐标。
  3505. @param out The affine transform object to be filled with data
  3506. @example
  3507. ```js
  3508. let affineTransform = cc.AffineTransform.create();
  3509. node.getNodeToWorldTransformAR(affineTransform);
  3510. ```
  3511. */
  3512. getNodeToWorldTransformAR(out?: AffineTransform): AffineTransform;
  3513. /**
  3514. !#en
  3515. Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.<br/>
  3516. The matrix is in Pixels. The returned transform is readonly and cannot be changed.
  3517. !#zh
  3518. 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。<br/>
  3519. 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。
  3520. @param out The affine transform object to be filled with data
  3521. @example
  3522. ```js
  3523. let affineTransform = cc.AffineTransform.create();
  3524. node.getParentToNodeTransform(affineTransform);
  3525. ```
  3526. */
  3527. getParentToNodeTransform(out?: AffineTransform): AffineTransform;
  3528. /**
  3529. !#en Returns the inverse world affine transform matrix. The matrix is in Pixels.
  3530. !#en 返回世界坐标系到节点坐标系的逆矩阵。
  3531. @param out The affine transform object to be filled with data
  3532. @example
  3533. ```js
  3534. let affineTransform = cc.AffineTransform.create();
  3535. node.getWorldToNodeTransform(affineTransform);
  3536. ```
  3537. */
  3538. getWorldToNodeTransform(out?: AffineTransform): AffineTransform;
  3539. /**
  3540. !#en convenience methods which take a cc.Touch instead of cc.Vec2.
  3541. !#zh 将触摸点转换成本地坐标系中位置。
  3542. @param touch The touch object
  3543. @example
  3544. ```js
  3545. var newVec2 = node.convertTouchToNodeSpace(touch);
  3546. ```
  3547. */
  3548. convertTouchToNodeSpace(touch: Touch): Vec2;
  3549. /**
  3550. !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative).
  3551. !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。
  3552. @param touch The touch object
  3553. @example
  3554. ```js
  3555. var newVec2 = node.convertTouchToNodeSpaceAR(touch);
  3556. ```
  3557. */
  3558. convertTouchToNodeSpaceAR(touch: Touch): Vec2;
  3559. /**
  3560. !#en
  3561. Returns a "local" axis aligned bounding box of the node. <br/>
  3562. The returned box is relative only to its parent.
  3563. !#zh 返回父节坐标系下的轴向对齐的包围盒。
  3564. @example
  3565. ```js
  3566. var boundingBox = node.getBoundingBox();
  3567. ```
  3568. */
  3569. getBoundingBox(): Rect;
  3570. /**
  3571. !#en
  3572. Returns a "world" axis aligned bounding box of the node.<br/>
  3573. The bounding box contains self and active children's world bounding box.
  3574. !#zh
  3575. 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。<br/>
  3576. 该边框包含自身和已激活的子节点的世界边框。
  3577. @example
  3578. ```js
  3579. var newRect = node.getBoundingBoxToWorld();
  3580. ```
  3581. */
  3582. getBoundingBoxToWorld(): Rect;
  3583. /** !#en
  3584. Set Group index of node without children.<br/>
  3585. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  3586. !#zh
  3587. 设置节点本身的分组索引。不影响子节点<br/>
  3588. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  3589. groupIndex: number;
  3590. /**
  3591. !#en
  3592. Adds a child to the node with z order and name.
  3593. !#zh
  3594. 添加子节点,并且可以修改该节点的 局部 Z 顺序和名字。
  3595. @param child A child node
  3596. @param zIndex Z order for drawing priority. Please refer to zIndex property
  3597. @param name A name to identify the node easily. Please refer to name property
  3598. @example
  3599. ```js
  3600. node.addChild(newNode, 1, "node");
  3601. ```
  3602. */
  3603. addChild(child: Node, zIndex?: number, name?: string): void;
  3604. /**
  3605. !#en Stops all running actions and schedulers.
  3606. !#zh 停止所有正在播放的动作和计时器。
  3607. @example
  3608. ```js
  3609. node.cleanup();
  3610. ```
  3611. */
  3612. cleanup(): void;
  3613. /**
  3614. !#en Sorts the children array depends on children's zIndex and arrivalOrder,
  3615. normally you won't need to invoke this function.
  3616. !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。
  3617. */
  3618. sortAllChildren(): void;
  3619. /**
  3620. !#en
  3621. Returns the displayed opacity of Node,
  3622. 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.
  3623. !#zh
  3624. 获取节点显示透明度,
  3625. 显示透明度和透明度之间的不同之处在于当启用级连透明度时,
  3626. 显示透明度是基于自身透明度和父节点透明度计算的。
  3627. */
  3628. getDisplayedOpacity(): number;
  3629. /**
  3630. !#en
  3631. Returns the displayed color of Node,
  3632. 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.
  3633. !#zh
  3634. 获取节点的显示颜色,
  3635. 显示颜色和颜色之间的不同之处在于当启用级连颜色时,
  3636. 显示颜色是基于自身颜色和父节点颜色计算的。
  3637. */
  3638. getDisplayedColor(): Color;
  3639. /** !#en Cascade opacity is removed from v2.0
  3640. Indicate whether node's opacity value affect its child nodes, default value is true.
  3641. !#zh 透明度级联功能从 v2.0 开始已移除
  3642. 节点的不透明度值是否影响其子节点,默认值为 true。 */
  3643. cascadeOpacity: boolean;
  3644. /**
  3645. !#en Cascade opacity is removed from v2.0
  3646. Returns whether node's opacity value affect its child nodes.
  3647. !#zh 透明度级联功能从 v2.0 开始已移除
  3648. 返回节点的不透明度值是否影响其子节点。
  3649. */
  3650. isCascadeOpacityEnabled(): boolean;
  3651. /**
  3652. !#en Cascade opacity is removed from v2.0
  3653. Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity.
  3654. !#zh 透明度级联功能从 v2.0 开始已移除
  3655. 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。
  3656. @param cascadeOpacityEnabled cascadeOpacityEnabled
  3657. */
  3658. setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void;
  3659. /**
  3660. !#en Opacity modify RGB have been removed since v2.0
  3661. Set whether color should be changed with the opacity value,
  3662. useless in ccsg.Node, but this function is override in some class to have such behavior.
  3663. !#zh 透明度影响颜色配置已经被废弃
  3664. 设置更改透明度时是否修改RGB值,
  3665. @param opacityValue opacityValue
  3666. */
  3667. setOpacityModifyRGB(opacityValue: boolean): void;
  3668. /**
  3669. !#en Opacity modify RGB have been removed since v2.0
  3670. Get whether color should be changed with the opacity value.
  3671. !#zh 透明度影响颜色配置已经被废弃
  3672. 获取更改透明度时是否修改RGB值。
  3673. */
  3674. isOpacityModifyRGB(): boolean;
  3675. }
  3676. /** !#en An object to boot the game.
  3677. !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */
  3678. export class Game extends EventTarget {
  3679. /** !#en Event triggered when game hide to background.
  3680. Please note that this event is not 100% guaranteed to be fired on Web platform,
  3681. on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event.
  3682. !#zh 游戏进入后台时触发的事件。
  3683. 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。
  3684. 在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */
  3685. EVENT_HIDE: string;
  3686. /** !#en Event triggered when game back to foreground
  3687. Please note that this event is not 100% guaranteed to be fired on Web platform,
  3688. on native platforms, it corresponds to enter foreground event.
  3689. !#zh 游戏进入前台运行时触发的事件。
  3690. 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。
  3691. 在原生平台,它对应的是应用被切换到前台事件。 */
  3692. EVENT_SHOW: string;
  3693. /** !#en Event triggered when game restart
  3694. !#zh 调用restart后,触发事件。 */
  3695. EVENT_RESTART: string;
  3696. /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */
  3697. EVENT_GAME_INITED: string;
  3698. /** Event triggered after engine inited, at this point you will be able to use all engine classes.
  3699. It was defined as EVENT_RENDERER_INITED in cocos creator v1.x and renamed in v2.0 */
  3700. EVENT_ENGINE_INITED: string;
  3701. /** Web Canvas 2d API as renderer backend */
  3702. RENDER_TYPE_CANVAS: number;
  3703. /** WebGL API as renderer backend */
  3704. RENDER_TYPE_WEBGL: number;
  3705. /** OpenGL API as renderer backend */
  3706. RENDER_TYPE_OPENGL: number;
  3707. /** !#en The outer frame of the game canvas, parent of game container.
  3708. !#zh 游戏画布的外框,container 的父容器。 */
  3709. frame: any;
  3710. /** !#en The container of game canvas.
  3711. !#zh 游戏画布的容器。 */
  3712. container: HTMLDivElement;
  3713. /** !#en The canvas of the game.
  3714. !#zh 游戏的画布。 */
  3715. canvas: HTMLCanvasElement;
  3716. /** !#en The renderer backend of the game.
  3717. !#zh 游戏的渲染器类型。 */
  3718. renderType: number;
  3719. /** !#en
  3720. The current game configuration, including:<br/>
  3721. 1. debugMode<br/>
  3722. "debugMode" possible values :<br/>
  3723. 0 - No message will be printed. <br/>
  3724. 1 - cc.error, cc.assert, cc.warn, cc.log will print in console. <br/>
  3725. 2 - cc.error, cc.assert, cc.warn will print in console. <br/>
  3726. 3 - cc.error, cc.assert will print in console. <br/>
  3727. 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.<br/>
  3728. 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. <br/>
  3729. 6 - cc.error, cc.assert will print on canvas, available only on web. <br/>
  3730. 2. showFPS<br/>
  3731. Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.<br/>
  3732. 3. exposeClassName<br/>
  3733. Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.<br/>
  3734. 4. frameRate<br/>
  3735. "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.<br/>
  3736. 5. id<br/>
  3737. "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.<br/>
  3738. 6. renderMode<br/>
  3739. "renderMode" sets the renderer type, only useful on web :<br/>
  3740. 0 - Automatically chosen by engine<br/>
  3741. 1 - Forced to use canvas renderer<br/>
  3742. 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers<br/>
  3743. <br/>
  3744. Please DO NOT modify this object directly, it won't have any effect.<br/>
  3745. !#zh
  3746. 当前的游戏配置,包括: <br/>
  3747. 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略) <br/>
  3748. "debugMode" 各种设置选项的意义。 <br/>
  3749. 0 - 没有消息被打印出来。 <br/>
  3750. 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。 <br/>
  3751. 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。 <br/>
  3752. 3 - cc.error,cc.assert 将打印在 console 中。 <br/>
  3753. 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3754. 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3755. 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3756. 2. showFPS(显示 FPS) <br/>
  3757. 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。 <br/>
  3758. 3. exposeClassName <br/>
  3759. 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。 <br/>
  3760. 4. frameRate (帧率) <br/>
  3761. “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。 <br/>
  3762. 5. id <br/>
  3763. "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。 <br/>
  3764. 6. renderMode(渲染模式) <br/>
  3765. “renderMode” 设置渲染器类型,仅适用于 web 端: <br/>
  3766. 0 - 通过引擎自动选择。 <br/>
  3767. 1 - 强制使用 canvas 渲染。
  3768. 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。 <br/>
  3769. <br/>
  3770. 注意:请不要直接修改这个对象,它不会有任何效果。 */
  3771. config: any;
  3772. /**
  3773. !#en Callback when the scripts of engine have been load.
  3774. !#zh 当引擎完成启动后的回调函数。
  3775. */
  3776. onStart(): void;
  3777. /**
  3778. !#en Set frame rate of game.
  3779. !#zh 设置游戏帧率。
  3780. @param frameRate frameRate
  3781. */
  3782. setFrameRate(frameRate: number): void;
  3783. /**
  3784. !#en Get frame rate set for the game, it doesn't represent the real frame rate.
  3785. !#zh 获取设置的游戏帧率(不等同于实际帧率)。
  3786. */
  3787. getFrameRate(): number;
  3788. /**
  3789. !#en Run the game frame by frame.
  3790. !#zh 执行一帧游戏循环。
  3791. */
  3792. step(): void;
  3793. /**
  3794. !#en Pause the game main loop. This will pause:
  3795. game logic execution, rendering process, event manager, background music and all audio effects.
  3796. This is different with cc.director.pause which only pause the game logic execution.
  3797. !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。
  3798. */
  3799. pause(): void;
  3800. /**
  3801. !#en Resume the game from pause. This will resume:
  3802. game logic execution, rendering process, event manager, background music and all audio effects.
  3803. !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。
  3804. */
  3805. resume(): void;
  3806. /**
  3807. !#en Check whether the game is paused.
  3808. !#zh 判断游戏是否暂停。
  3809. */
  3810. isPaused(): boolean;
  3811. /**
  3812. !#en Restart game.
  3813. !#zh 重新开始游戏
  3814. */
  3815. restart(): void;
  3816. /**
  3817. !#en End game, it will close the game window
  3818. !#zh 退出游戏
  3819. */
  3820. end(): void;
  3821. /**
  3822. !#en
  3823. Register an callback of a specific event type on the game object.
  3824. This type of event should be triggered via `emit`.
  3825. !#zh
  3826. 注册 game 的特定事件类型回调。这种类型的事件应该被 `emit` 触发。
  3827. @param type A string representing the event type to listen for.
  3828. @param callback The callback that will be invoked when the event is dispatched.
  3829. The callback is ignored if it is a duplicate (the callbacks are unique).
  3830. @param target The target (this object) to invoke the callback, can be null
  3831. */
  3832. on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
  3833. /**
  3834. !#en
  3835. Register an callback of a specific event type on the game object,
  3836. the callback will remove itself after the first time it is triggered.
  3837. !#zh
  3838. 注册 game 的特定事件类型回调,回调会在第一时间被触发后删除自身。
  3839. @param type A string representing the event type to listen for.
  3840. @param callback The callback that will be invoked when the event is dispatched.
  3841. The callback is ignored if it is a duplicate (the callbacks are unique).
  3842. @param target The target (this object) to invoke the callback, can be null
  3843. */
  3844. once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
  3845. /**
  3846. !#en Prepare game.
  3847. !#zh 准备引擎,请不要直接调用这个函数。
  3848. @param cb cb
  3849. */
  3850. prepare(cb: Function): void;
  3851. /**
  3852. !#en Run game with configuration object and onStart function.
  3853. !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。
  3854. @param config Pass configuration object or onStart function
  3855. @param onStart function to be executed after game initialized
  3856. */
  3857. run(config: any, onStart: Function): void;
  3858. /**
  3859. !#en
  3860. Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.<br/>
  3861. The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect.
  3862. !#zh
  3863. 声明常驻根节点,该节点不会被在场景切换中被销毁。<br/>
  3864. 目标节点必须位于为层级的根节点,否则无效。
  3865. @param node The node to be made persistent
  3866. */
  3867. addPersistRootNode(node: Node): void;
  3868. /**
  3869. !#en Remove a persistent root node.
  3870. !#zh 取消常驻根节点。
  3871. @param node The node to be removed from persistent node list
  3872. */
  3873. removePersistRootNode(node: Node): void;
  3874. /**
  3875. !#en Check whether the node is a persistent root node.
  3876. !#zh 检查节点是否是常驻根节点。
  3877. @param node The node to be checked
  3878. */
  3879. isPersistRootNode(node: Node): boolean;
  3880. }
  3881. /** !#en
  3882. Class of private entities in Cocos Creator scenes.<br/>
  3883. The PrivateNode is hidden in editor, and completely transparent to users.<br/>
  3884. It's normally used as Node's private content created by components in parent node.<br/>
  3885. So in theory private nodes are not children, they are part of the parent node.<br/>
  3886. Private node have two important characteristics:<br/>
  3887. 1. It has the minimum z index and cannot be modified, because they can't be displayed over real children.<br/>
  3888. 2. The positioning of private nodes is also special, they will consider the left bottom corner of the parent node's bounding box as the origin of local coordinates.<br/>
  3889. In this way, they can be easily kept inside the bounding box.<br/>
  3890. Currently, it's used by RichText component and TileMap component.
  3891. !#zh
  3892. Cocos Creator 场景中的私有节点类。<br/>
  3893. 私有节点在编辑器中不可见,对用户透明。<br/>
  3894. 通常私有节点是被一些特殊的组件创建出来作为父节点的一部分而存在的,理论上来说,它们不是子节点,而是父节点的组成部分。<br/>
  3895. 私有节点有两个非常重要的特性:<br/>
  3896. 1. 它有着最小的渲染排序的 Z 轴深度,并且无法被更改,因为它们不能被显示在其他正常子节点之上。<br/>
  3897. 2. 它的定位也是特殊的,对于私有节点来说,父节点包围盒的左下角是它的局部坐标系原点,这个原点相当于父节点的位置减去它锚点的偏移。这样私有节点可以比较容易被控制在包围盒之中。<br/>
  3898. 目前在引擎中,RichText 和 TileMap 都有可能生成私有节点。 */
  3899. export class PrivateNode extends Node {
  3900. /**
  3901. @param name name
  3902. */
  3903. constructor(name?: string);
  3904. }
  3905. /** !#en
  3906. cc.Scene is a subclass of cc.Node that is used only as an abstract concept.<br/>
  3907. cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually.
  3908. !#zh
  3909. cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。<br/>
  3910. cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */
  3911. export class Scene extends Node {
  3912. /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading.
  3913. !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */
  3914. autoReleaseAssets: boolean;
  3915. }
  3916. /** !#en
  3917. Scheduler is responsible of triggering the scheduled callbacks.<br/>
  3918. You should not use NSTimer. Instead use this class.<br/>
  3919. <br/>
  3920. There are 2 different types of callbacks (selectors):<br/>
  3921. - update callback: the 'update' callback will be called every frame. You can customize the priority.<br/>
  3922. - custom callback: A custom callback will be called every frame, or with a custom interval of time<br/>
  3923. <br/>
  3924. The 'custom selectors' should be avoided when possible. It is faster,
  3925. and consumes less memory to use the 'update callback'. *
  3926. !#zh
  3927. Scheduler 是负责触发回调函数的类。<br/>
  3928. 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。<br/>
  3929. 有两种不同类型的定时器:<br/>
  3930. - update 定时器:每一帧都会触发。您可以自定义优先级。<br/>
  3931. - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。<br/>
  3932. 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */
  3933. export class Scheduler {
  3934. /**
  3935. !#en This method should be called for any target which needs to schedule tasks, and this method should be called before any scheduler API usage.
  3936. This method will add a `_id` property if it doesn't exist.
  3937. !#zh 任何需要用 Scheduler 管理任务的对象主体都应该调用这个方法,并且应该在调用任何 Scheduler API 之前调用这个方法。
  3938. 这个方法会给对象添加一个 `_id` 属性,如果这个属性不存在的话。
  3939. @param target target
  3940. */
  3941. enableForTarget(target: any): void;
  3942. /**
  3943. !#en
  3944. Modifies the time of all scheduled callbacks.<br/>
  3945. You can use this property to create a 'slow motion' or 'fast forward' effect.<br/>
  3946. Default is 1.0. To create a 'slow motion' effect, use values below 1.0.<br/>
  3947. To create a 'fast forward' effect, use values higher than 1.0.<br/>
  3948. Note:It will affect EVERY scheduled selector / action.
  3949. !#zh
  3950. 设置时间间隔的缩放比例。<br/>
  3951. 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。<br/>
  3952. 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。<br/>
  3953. 要使用 “fast forward(快进)” 效果,使用值大于 1.0。<br/>
  3954. 注意:它影响该 Scheduler 下管理的所有定时器。
  3955. @param timeScale timeScale
  3956. */
  3957. setTimeScale(timeScale: number): void;
  3958. /**
  3959. !#en Returns time scale of scheduler.
  3960. !#zh 获取时间间隔的缩放比例。
  3961. */
  3962. getTimeScale(): number;
  3963. /**
  3964. !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.)
  3965. !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果)
  3966. @param dt delta time
  3967. */
  3968. update(dt: number): void;
  3969. /**
  3970. !#en
  3971. <p>
  3972. The scheduled method will be called every 'interval' seconds.<br/>
  3973. If paused is YES, then it won't be called until it is resumed.<br/>
  3974. If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.<br/>
  3975. If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.<br/>
  3976. repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously<br/>
  3977. delay is the amount of time the action will wait before it'll start. Unit: s.<br/>
  3978. </p>
  3979. !#zh
  3980. 指定回调函数,调用对象等信息来添加一个新的定时器。<br/>
  3981. 如果 paused 值为 true,那么直到 resume 被调用才开始计时。<br/>
  3982. 当时间间隔达到指定值时,设置的回调函数将会被调用。<br/>
  3983. 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样,
  3984. 建议使用 scheduleUpdateForTarget 代替。<br/>
  3985. 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。<br/>
  3986. repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER
  3987. 可以让定时器一直循环触发。<br/>
  3988. delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时,单位: 秒。
  3989. @param callback callback
  3990. @param target target
  3991. @param interval interval
  3992. @param repeat repeat
  3993. @param delay delay
  3994. @param paused paused
  3995. @example
  3996. ```js
  3997. //register a schedule to scheduler
  3998. cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning);
  3999. ```
  4000. */
  4001. schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void;
  4002. schedule(callback: Function, target: any, interval: number, paused?: boolean): void;
  4003. /**
  4004. !#en
  4005. Schedules the update callback for a given target,
  4006. During every frame after schedule started, the "update" function of target will be invoked.
  4007. !#zh
  4008. 使用指定的优先级为指定的对象设置 update 定时器。
  4009. update 定时器每一帧都会被触发,触发时自动调用指定对象的 "update" 函数。
  4010. 优先级的值越低,定时器被触发的越早。
  4011. @param target target
  4012. @param priority priority
  4013. @param paused paused
  4014. */
  4015. scheduleUpdate(target: any, priority: number, paused: boolean): void;
  4016. /**
  4017. !#en
  4018. Unschedules a callback for a callback and a given target.
  4019. If you want to unschedule the "update", use `unscheduleUpdate()`
  4020. !#zh
  4021. 取消指定对象定时器。
  4022. 如果需要取消 update 定时器,请使用 unscheduleUpdate()。
  4023. @param callback The callback to be unscheduled
  4024. @param target The target bound to the callback.
  4025. */
  4026. unschedule(callback: Function, target: any): void;
  4027. /**
  4028. !#en Unschedules the update callback for a given target.
  4029. !#zh 取消指定对象的 update 定时器。
  4030. @param target The target to be unscheduled.
  4031. */
  4032. unscheduleUpdate(target: any): void;
  4033. /**
  4034. !#en
  4035. Unschedules all scheduled callbacks for a given target.
  4036. This also includes the "update" callback.
  4037. !#zh 取消指定对象的所有定时器,包括 update 定时器。
  4038. @param target The target to be unscheduled.
  4039. */
  4040. unscheduleAllForTarget(target: any): void;
  4041. /**
  4042. !#en
  4043. Unschedules all scheduled callbacks from all targets including the system callbacks.<br/>
  4044. You should NEVER call this method, unless you know what you are doing.
  4045. !#zh
  4046. 取消所有对象的所有定时器,包括系统定时器。<br/>
  4047. 不要调用此函数,除非你确定你在做什么。
  4048. */
  4049. unscheduleAll(): void;
  4050. /**
  4051. !#en
  4052. Unschedules all callbacks from all targets with a minimum priority.<br/>
  4053. You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher.
  4054. !#zh
  4055. 取消所有优先级的值大于指定优先级的定时器。<br/>
  4056. 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  4057. @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which
  4058. priority is higher than minPriority will be unscheduled.
  4059. */
  4060. unscheduleAllWithMinPriority(minPriority: number): void;
  4061. /**
  4062. !#en Checks whether a callback for a given target is scheduled.
  4063. !#zh 检查指定的回调函数和回调对象组合是否存在定时器。
  4064. @param callback The callback to check.
  4065. @param target The target of the callback.
  4066. */
  4067. isScheduled(callback: Function, target: any): boolean;
  4068. /**
  4069. !#en
  4070. Pause all selectors from all targets.<br/>
  4071. You should NEVER call this method, unless you know what you are doing.
  4072. !#zh
  4073. 暂停所有对象的所有定时器。<br/>
  4074. 不要调用这个方法,除非你知道你正在做什么。
  4075. */
  4076. pauseAllTargets(): void;
  4077. /**
  4078. !#en
  4079. Pause all selectors from all targets with a minimum priority. <br/>
  4080. You should only call this with kCCPriorityNonSystemMin or higher.
  4081. !#zh
  4082. 暂停所有优先级的值大于指定优先级的定时器。<br/>
  4083. 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  4084. @param minPriority minPriority
  4085. */
  4086. pauseAllTargetsWithMinPriority(minPriority: number): void;
  4087. /**
  4088. !#en
  4089. Resume selectors on a set of targets.<br/>
  4090. This can be useful for undoing a call to pauseAllCallbacks.
  4091. !#zh
  4092. 恢复指定数组中所有对象的定时器。<br/>
  4093. 这个函数是 pauseAllCallbacks 的逆操作。
  4094. @param targetsToResume targetsToResume
  4095. */
  4096. resumeTargets(targetsToResume: any[]): void;
  4097. /**
  4098. !#en
  4099. Pauses the target.<br/>
  4100. All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.<br/>
  4101. If the target is not present, nothing happens.
  4102. !#zh
  4103. 暂停指定对象的定时器。<br/>
  4104. 指定对象的所有定时器都会被暂停。<br/>
  4105. 如果指定的对象没有定时器,什么也不会发生。
  4106. @param target target
  4107. */
  4108. pauseTarget(target: any): void;
  4109. /**
  4110. !#en
  4111. Resumes the target.<br/>
  4112. The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.<br/>
  4113. If the target is not present, nothing happens.
  4114. !#zh
  4115. 恢复指定对象的所有定时器。<br/>
  4116. 指定对象的所有定时器将继续工作。<br/>
  4117. 如果指定的对象没有定时器,什么也不会发生。
  4118. @param target target
  4119. */
  4120. resumeTarget(target: any): void;
  4121. /**
  4122. !#en Returns whether or not the target is paused.
  4123. !#zh 返回指定对象的定时器是否暂停了。
  4124. @param target target
  4125. */
  4126. isTargetPaused(target: any): boolean;
  4127. /** !#en Priority level reserved for system services.
  4128. !#zh 系统服务的优先级。 */
  4129. static PRIORITY_SYSTEM: number;
  4130. /** !#en Minimum priority level for user scheduling.
  4131. !#zh 用户调度最低优先级。 */
  4132. static PRIORITY_NON_SYSTEM: number;
  4133. }
  4134. /** !#en Class for animation data handling.
  4135. !#zh 动画剪辑,用于存储动画数据。 */
  4136. export class AnimationClip extends Asset {
  4137. /** !#en Duration of this animation.
  4138. !#zh 动画的持续时间。 */
  4139. duration: number;
  4140. /** !#en FrameRate of this animation.
  4141. !#zh 动画的帧速率。 */
  4142. sample: number;
  4143. /** !#en Speed of this animation.
  4144. !#zh 动画的播放速度。 */
  4145. speed: number;
  4146. /** !#en WrapMode of this animation.
  4147. !#zh 动画的循环模式。 */
  4148. wrapMode: WrapMode;
  4149. /** !#en Curve data.
  4150. !#zh 曲线数据。 */
  4151. curveData: any;
  4152. /** !#en Event data.
  4153. !#zh 事件数据。 */
  4154. events: {frame: number, func: string, params: string[]}[];
  4155. /**
  4156. !#en Crate clip with a set of sprite frames
  4157. !#zh 使用一组序列帧图片来创建动画剪辑
  4158. @param spriteFrames spriteFrames
  4159. @param sample sample
  4160. @example
  4161. ```js
  4162. var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10);
  4163. ```
  4164. */
  4165. static createWithSpriteFrames(spriteFrames: SpriteFrame[], sample: number): AnimationClip;
  4166. }
  4167. /** !#en
  4168. The AnimationState gives full control over animation playback process.
  4169. In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control.
  4170. !#zh
  4171. AnimationState 完全控制动画播放过程。<br/>
  4172. 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */
  4173. export class AnimationState extends Playable {
  4174. /**
  4175. @param clip clip
  4176. @param name name
  4177. */
  4178. constructor(clip: AnimationClip, name?: string);
  4179. /** !#en The curves list.
  4180. !#zh 曲线列表。 */
  4181. curves: any[];
  4182. /** !#en The start delay which represents the number of seconds from an animation's start time to the start of
  4183. the active interval.
  4184. !#zh 延迟多少秒播放。 */
  4185. delay: number;
  4186. /** !#en The animation's iteration count property.
  4187. A real number greater than or equal to zero (including positive infinity) representing the number of times
  4188. to repeat the animation node.
  4189. Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model
  4190. calculations.
  4191. !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */
  4192. repeatCount: number;
  4193. /** !#en The iteration duration of this animation in seconds. (length)
  4194. !#zh 单次动画的持续时间,秒。 */
  4195. duration: number;
  4196. /** !#en The animation's playback speed. 1 is normal playback speed.
  4197. !#zh 播放速率。 */
  4198. speed: number;
  4199. /** !#en
  4200. Wrapping mode of the playing animation.
  4201. Notice : dynamic change wrapMode will reset time and repeatCount property
  4202. !#zh
  4203. 动画循环方式。
  4204. 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */
  4205. wrapMode: WrapMode;
  4206. /** !#en The current time of this animation in seconds.
  4207. !#zh 动画当前的时间,秒。 */
  4208. time: number;
  4209. /** !#en The clip that is being played by this animation state.
  4210. !#zh 此动画状态正在播放的剪辑。 */
  4211. clip: AnimationClip;
  4212. /** !#en The name of the playing animation.
  4213. !#zh 动画的名字 */
  4214. name: string;
  4215. }
  4216. /** !#en
  4217. This class provide easing methods for {{#crossLink "tween"}}{{/crossLink}} class.<br>
  4218. Demonstratio: https://easings.net/
  4219. !#zh
  4220. 缓动函数类,为 {{#crossLink "Tween"}}{{/crossLink}} 提供缓动效果函数。<br>
  4221. 函数效果演示: https://easings.net/ */
  4222. export class Easing {
  4223. /**
  4224. !#en Easing in with quadratic formula. From slow to fast.
  4225. !#zh 平方曲线缓入函数。运动由慢到快。
  4226. @param t The current time as a percentage of the total time.
  4227. */
  4228. quadIn(t: number): number;
  4229. /**
  4230. !#en Easing out with quadratic formula. From fast to slow.
  4231. !#zh 平方曲线缓出函数。运动由快到慢。
  4232. @param t The current time as a percentage of the total time.
  4233. */
  4234. quadOut(t: number): number;
  4235. /**
  4236. !#en Easing in and out with quadratic formula. From slow to fast, then back to slow.
  4237. !#zh 平方曲线缓入缓出函数。运动由慢到快再到慢。
  4238. @param t The current time as a percentage of the total time.
  4239. */
  4240. quadInOut(t: number): number;
  4241. /**
  4242. !#en Easing in with cubic formula. From slow to fast.
  4243. !#zh 立方曲线缓入函数。运动由慢到快。
  4244. @param t The current time as a percentage of the total time.
  4245. */
  4246. cubicIn(t: number): number;
  4247. /**
  4248. !#en Easing out with cubic formula. From slow to fast.
  4249. !#zh 立方曲线缓出函数。运动由快到慢。
  4250. @param t The current time as a percentage of the total time.
  4251. */
  4252. cubicOut(t: number): number;
  4253. /**
  4254. !#en Easing in and out with cubic formula. From slow to fast, then back to slow.
  4255. !#zh 立方曲线缓入缓出函数。运动由慢到快再到慢。
  4256. @param t The current time as a percentage of the total time.
  4257. */
  4258. cubicInOut(t: number): number;
  4259. /**
  4260. !#en Easing in with quartic formula. From slow to fast.
  4261. !#zh 四次方曲线缓入函数。运动由慢到快。
  4262. @param t The current time as a percentage of the total time.
  4263. */
  4264. quartIn(t: number): number;
  4265. /**
  4266. !#en Easing out with quartic formula. From fast to slow.
  4267. !#zh 四次方曲线缓出函数。运动由快到慢。
  4268. @param t The current time as a percentage of the total time.
  4269. */
  4270. quartOut(t: number): number;
  4271. /**
  4272. !#en Easing in and out with quartic formula. From slow to fast, then back to slow.
  4273. !#zh 四次方曲线缓入缓出函数。运动由慢到快再到慢。
  4274. @param t The current time as a percentage of the total time.
  4275. */
  4276. quartInOut(t: number): number;
  4277. /**
  4278. !#en Easing in with quintic formula. From slow to fast.
  4279. !#zh 五次方曲线缓入函数。运动由慢到快。
  4280. @param t The current time as a percentage of the total time.
  4281. */
  4282. quintIn(t: number): number;
  4283. /**
  4284. !#en Easing out with quintic formula. From fast to slow.
  4285. !#zh 五次方曲线缓出函数。运动由快到慢。
  4286. @param t The current time as a percentage of the total time.
  4287. */
  4288. quintOut(t: number): number;
  4289. /**
  4290. !#en Easing in and out with quintic formula. From slow to fast, then back to slow.
  4291. !#zh 五次方曲线缓入缓出函数。运动由慢到快再到慢。
  4292. @param t The current time as a percentage of the total time.
  4293. */
  4294. quintInOut(t: number): number;
  4295. /**
  4296. !#en Easing in and out with sine formula. From slow to fast.
  4297. !#zh 正弦曲线缓入函数。运动由慢到快。
  4298. @param t The current time as a percentage of the total time.
  4299. */
  4300. sineIn(t: number): number;
  4301. /**
  4302. !#en Easing in and out with sine formula. From fast to slow.
  4303. !#zh 正弦曲线缓出函数。运动由快到慢。
  4304. @param t The current time as a percentage of the total time.
  4305. */
  4306. sineOut(t: number): number;
  4307. /**
  4308. !#en Easing in and out with sine formula. From slow to fast, then back to slow.
  4309. !#zh 正弦曲线缓入缓出函数。运动由慢到快再到慢。
  4310. @param t The current time as a percentage of the total time.
  4311. */
  4312. sineInOut(t: number): number;
  4313. /**
  4314. !#en Easing in and out with exponential formula. From slow to fast.
  4315. !#zh 指数曲线缓入函数。运动由慢到快。
  4316. @param t The current time as a percentage of the total time.
  4317. */
  4318. expoIn(t: number): number;
  4319. /**
  4320. !#en Easing in and out with exponential formula. From fast to slow.
  4321. !#zh 指数曲线缓出函数。运动由快到慢。
  4322. @param t The current time as a percentage of the total time.
  4323. */
  4324. expoOut(t: number): number;
  4325. /**
  4326. !#en Easing in and out with exponential formula. From slow to fast.
  4327. !#zh 指数曲线缓入和缓出函数。运动由慢到很快再到慢。
  4328. @param t The current time as a percentage of the total time, then back to slow.
  4329. */
  4330. expoInOut(t: number): number;
  4331. /**
  4332. !#en Easing in and out with circular formula. From slow to fast.
  4333. !#zh 循环公式缓入函数。运动由慢到快。
  4334. @param t The current time as a percentage of the total time.
  4335. */
  4336. circIn(t: number): number;
  4337. /**
  4338. !#en Easing in and out with circular formula. From fast to slow.
  4339. !#zh 循环公式缓出函数。运动由快到慢。
  4340. @param t The current time as a percentage of the total time.
  4341. */
  4342. circOut(t: number): number;
  4343. /**
  4344. !#en Easing in and out with circular formula. From slow to fast.
  4345. !#zh 指数曲线缓入缓出函数。运动由慢到很快再到慢。
  4346. @param t The current time as a percentage of the total time, then back to slow.
  4347. */
  4348. circInOut(t: number): number;
  4349. /**
  4350. !#en Easing in action with a spring oscillating effect.
  4351. !#zh 弹簧回震效果的缓入函数。
  4352. @param t The current time as a percentage of the total time.
  4353. */
  4354. elasticIn(t: number): number;
  4355. /**
  4356. !#en Easing out action with a spring oscillating effect.
  4357. !#zh 弹簧回震效果的缓出函数。
  4358. @param t The current time as a percentage of the total time.
  4359. */
  4360. elasticOut(t: number): number;
  4361. /**
  4362. !#en Easing in and out action with a spring oscillating effect.
  4363. !#zh 弹簧回震效果的缓入缓出函数。
  4364. @param t The current time as a percentage of the total time.
  4365. */
  4366. elasticInOut(t: number): number;
  4367. /**
  4368. !#en Easing in action with "back up" behavior.
  4369. !#zh 回退效果的缓入函数。
  4370. @param t The current time as a percentage of the total time.
  4371. */
  4372. backIn(t: number): number;
  4373. /**
  4374. !#en Easing out action with "back up" behavior.
  4375. !#zh 回退效果的缓出函数。
  4376. @param t The current time as a percentage of the total time.
  4377. */
  4378. backOut(t: number): number;
  4379. /**
  4380. !#en Easing in and out action with "back up" behavior.
  4381. !#zh 回退效果的缓入缓出函数。
  4382. @param t The current time as a percentage of the total time.
  4383. */
  4384. backInOut(t: number): number;
  4385. /**
  4386. !#en Easing in action with bouncing effect.
  4387. !#zh 弹跳效果的缓入函数。
  4388. @param t The current time as a percentage of the total time.
  4389. */
  4390. bounceIn(t: number): number;
  4391. /**
  4392. !#en Easing out action with bouncing effect.
  4393. !#zh 弹跳效果的缓出函数。
  4394. @param t The current time as a percentage of the total time.
  4395. */
  4396. bounceOut(t: number): number;
  4397. /**
  4398. !#en Easing in and out action with bouncing effect.
  4399. !#zh 弹跳效果的缓入缓出函数。
  4400. @param t The current time as a percentage of the total time.
  4401. */
  4402. bounceInOut(t: number): number;
  4403. /**
  4404. !#en Target will run action with smooth effect.
  4405. !#zh 平滑效果函数。
  4406. @param t The current time as a percentage of the total time.
  4407. */
  4408. smooth(t: number): number;
  4409. /**
  4410. !#en Target will run action with fade effect.
  4411. !#zh 渐褪效果函数。
  4412. @param t The current time as a percentage of the total time.
  4413. */
  4414. fade(t: number): number;
  4415. }
  4416. /** undefined */
  4417. export class Playable {
  4418. /** !#en Is playing or paused in play mode?
  4419. !#zh 当前是否正在播放。 */
  4420. isPlaying: boolean;
  4421. /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false).
  4422. !#zh 当前是否正在暂停 */
  4423. isPaused: boolean;
  4424. /**
  4425. !#en Play this animation.
  4426. !#zh 播放动画。
  4427. */
  4428. play(): void;
  4429. /**
  4430. !#en Stop this animation.
  4431. !#zh 停止动画播放。
  4432. */
  4433. stop(): void;
  4434. /**
  4435. !#en Pause this animation.
  4436. !#zh 暂停动画。
  4437. */
  4438. pause(): void;
  4439. /**
  4440. !#en Resume this animation.
  4441. !#zh 重新播放动画。
  4442. */
  4443. resume(): void;
  4444. /**
  4445. !#en Perform a single frame step.
  4446. !#zh 执行一帧动画。
  4447. */
  4448. step(): void;
  4449. }
  4450. /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation.
  4451. !#zh 动画使用的循环模式。 */
  4452. export enum WrapMode {
  4453. Default = 0,
  4454. Normal = 0,
  4455. Reverse = 0,
  4456. Loop = 0,
  4457. LoopReverse = 0,
  4458. PingPong = 0,
  4459. PingPongReverse = 0,
  4460. }
  4461. /** cc.TMXLayerInfo contains the information about the layers like:
  4462. - Layer name
  4463. - Layer size
  4464. - Layer opacity at creation time (it can be modified at runtime)
  4465. - Whether the layer is visible (if it's not visible, then the CocosNode won't be created)
  4466. This information is obtained from the TMX file. */
  4467. export class TMXLayerInfo {
  4468. /** Properties of the layer info. */
  4469. properties: any;
  4470. }
  4471. /** cc.TMXImageLayerInfo contains the information about the image layers.
  4472. This information is obtained from the TMX file. */
  4473. export class TMXImageLayerInfo {
  4474. }
  4475. /** <p>cc.TMXObjectGroupInfo contains the information about the object group like:
  4476. - group name
  4477. - group size
  4478. - group opacity at creation time (it can be modified at runtime)
  4479. - Whether the group is visible
  4480. This information is obtained from the TMX file.</p> */
  4481. export class TMXObjectGroupInfo {
  4482. /** Properties of the ObjectGroup info. */
  4483. properties: any[];
  4484. }
  4485. /** <p>cc.TMXTilesetInfo contains the information about the tilesets like: <br />
  4486. - Tileset name<br />
  4487. - Tileset spacing<br />
  4488. - Tileset margin<br />
  4489. - size of the tiles<br />
  4490. - Image used for the tiles<br />
  4491. - Image size<br />
  4492. This information is obtained from the TMX file. </p> */
  4493. export class TMXTilesetInfo {
  4494. /** Tileset name */
  4495. name: string;
  4496. /** First grid */
  4497. firstGid: number;
  4498. /** Spacing */
  4499. spacing: number;
  4500. /** Margin */
  4501. margin: number;
  4502. /** Texture containing the tiles (should be sprite sheet / texture atlas) */
  4503. sourceImage: any;
  4504. /** Size in pixels of the image */
  4505. imageSize: Size;
  4506. }
  4507. /** <p>cc.TMXMapInfo contains the information about the map like: <br/>
  4508. - Map orientation (hexagonal, isometric or orthogonal)<br/>
  4509. - Tile size<br/>
  4510. - Map size</p>
  4511. <p>And it also contains: <br/>
  4512. - Layers (an array of TMXLayerInfo objects)<br/>
  4513. - Tilesets (an array of TMXTilesetInfo objects) <br/>
  4514. - ObjectGroups (an array of TMXObjectGroupInfo objects) </p>
  4515. <p>This information is obtained from the TMX file. </p> */
  4516. export class TMXMapInfo {
  4517. /** Properties of the map info. */
  4518. properties: any[];
  4519. /** Map orientation. */
  4520. orientation: number;
  4521. /** Parent element. */
  4522. parentElement: any;
  4523. /** Parent GID. */
  4524. parentGID: number;
  4525. /** Layer attributes. */
  4526. layerAttrs: any;
  4527. /** Is reading storing characters stream. */
  4528. storingCharacters: boolean;
  4529. /** Current string stored from characters stream. */
  4530. currentString: string;
  4531. /** Width of the map */
  4532. mapWidth: number;
  4533. /** Height of the map */
  4534. mapHeight: number;
  4535. /** Width of a tile */
  4536. tileWidth: number;
  4537. /** Height of a tile */
  4538. tileHeight: number;
  4539. static ATTRIB_NONE: number;
  4540. static ATTRIB_BASE64: number;
  4541. static ATTRIB_GZIP: number;
  4542. static ATTRIB_ZLIB: number;
  4543. }
  4544. /** !#en Render the TMX layer.
  4545. !#zh 渲染 TMX layer。 */
  4546. export class TiledLayer extends Component {
  4547. /**
  4548. !#en enable or disable culling
  4549. !#zh 开启或关闭裁剪。
  4550. @param value value
  4551. */
  4552. enableCulling(value: boolean): void;
  4553. /**
  4554. !#en Adds user's node into layer.
  4555. !#zh 添加用户节点。
  4556. @param node node
  4557. */
  4558. addUserNode(node: Node): boolean;
  4559. /**
  4560. !#en Removes user's node.
  4561. !#zh 移除用户节点。
  4562. @param node node
  4563. */
  4564. removeUserNode(node: Node): boolean;
  4565. /**
  4566. !#en Destroy user's node.
  4567. !#zh 销毁用户节点。
  4568. @param node node
  4569. */
  4570. destroyUserNode(node: Node): void;
  4571. /**
  4572. !#en Gets the layer name.
  4573. !#zh 获取层的名称。
  4574. @example
  4575. ```js
  4576. let layerName = tiledLayer.getLayerName();
  4577. cc.log(layerName);
  4578. ```
  4579. */
  4580. getLayerName(): string;
  4581. /**
  4582. !#en Set the layer name.
  4583. !#zh 设置层的名称
  4584. @param layerName layerName
  4585. @example
  4586. ```js
  4587. tiledLayer.setLayerName("New Layer");
  4588. ```
  4589. */
  4590. setLayerName(layerName: string): void;
  4591. /**
  4592. !#en Return the value for the specific property name.
  4593. !#zh 获取指定属性名的值。
  4594. @param propertyName propertyName
  4595. @example
  4596. ```js
  4597. let property = tiledLayer.getProperty("info");
  4598. cc.log(property);
  4599. ```
  4600. */
  4601. getProperty(propertyName: string): any;
  4602. /**
  4603. !#en Returns the position in pixels of a given tile coordinate.
  4604. !#zh 获取指定 tile 的像素坐标。
  4605. @param pos position or x
  4606. @param y y
  4607. @example
  4608. ```js
  4609. let pos = tiledLayer.getPositionAt(cc.v2(0, 0));
  4610. cc.log("Pos: " + pos);
  4611. let pos = tiledLayer.getPositionAt(0, 0);
  4612. cc.log("Pos: " + pos);
  4613. ```
  4614. */
  4615. getPositionAt(pos: Vec2|number, y?: number): Vec2;
  4616. /**
  4617. !#en
  4618. Sets the tiles gid (gid = tile global id) at a given tiles rect.
  4619. !#zh
  4620. 设置给定区域的 tile 的 gid (gid = tile 全局 id),
  4621. @param gids an array contains gid
  4622. @param beginCol begin col number
  4623. @param beginRow begin row number
  4624. @param totalCols count of column
  4625. @example
  4626. ```js
  4627. tiledLayer.setTilesGIDAt([1, 1, 1, 1], 10, 10, 2)
  4628. ```
  4629. */
  4630. setTilesGIDAt(gids: any[], beginCol: number, beginRow: number, totalCols: number): void;
  4631. /**
  4632. !#en
  4633. Sets the tile gid (gid = tile global id) at a given tile coordinate.<br />
  4634. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.<br />
  4635. If a tile is already placed at that position, then it will be removed.
  4636. !#zh
  4637. 设置给定坐标的 tile 的 gid (gid = tile 全局 id),
  4638. tile 的 GID 可以使用方法 “tileGIDAt” 来获得。<br />
  4639. 如果一个 tile 已经放在那个位置,那么它将被删除。
  4640. @param gid gid
  4641. @param posOrX position or x
  4642. @param flagsOrY flags or y
  4643. @param flags flags
  4644. @example
  4645. ```js
  4646. tiledLayer.setTileGIDAt(1001, 10, 10, 1)
  4647. ```
  4648. */
  4649. setTileGIDAt(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void;
  4650. /**
  4651. !#en
  4652. Returns the tiles data.An array fill with GIDs. <br />
  4653. !#zh
  4654. 返回 tiles 数据. 由GID构成的一个数组. <br />
  4655. */
  4656. getTiles(): number[];
  4657. /**
  4658. !#en
  4659. Returns the tile gid at a given tile coordinate. <br />
  4660. if it returns 0, it means that the tile is empty. <br />
  4661. !#zh
  4662. 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID. <br />
  4663. 如果它返回 0,则表示该 tile 为空。<br />
  4664. @param pos or x
  4665. @param y y
  4666. @example
  4667. ```js
  4668. let tileGid = tiledLayer.getTileGIDAt(0, 0);
  4669. ```
  4670. */
  4671. getTileGIDAt(pos: Vec2|number, y?: number): number;
  4672. /**
  4673. !#en Layer orientation, which is the same as the map orientation.
  4674. !#zh 获取 Layer 方向(同地图方向)。
  4675. @example
  4676. ```js
  4677. let orientation = tiledLayer.getLayerOrientation();
  4678. cc.log("Layer Orientation: " + orientation);
  4679. ```
  4680. */
  4681. getLayerOrientation(): number;
  4682. /**
  4683. !#en properties from the layer. They can be added using Tiled.
  4684. !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。
  4685. @example
  4686. ```js
  4687. let properties = tiledLayer.getProperties();
  4688. cc.log("Properties: " + properties);
  4689. ```
  4690. */
  4691. getProperties(): any;
  4692. /**
  4693. !#en
  4694. Get the TiledTile with the tile coordinate.<br/>
  4695. If there is no tile in the specified coordinate and forceCreate parameter is true, <br/>
  4696. then will create a new TiledTile at the coordinate.
  4697. The renderer will render the tile with the rotation, scale, position and color property of the TiledTile.
  4698. !#zh
  4699. 通过指定的 tile 坐标获取对应的 TiledTile。 <br/>
  4700. 如果指定的坐标没有 tile,并且设置了 forceCreate 那么将会在指定的坐标创建一个新的 TiledTile 。<br/>
  4701. 在渲染这个 tile 的时候,将会使用 TiledTile 的节点的旋转、缩放、位移、颜色属性。<br/>
  4702. @param x x
  4703. @param y y
  4704. @param forceCreate forceCreate
  4705. @example
  4706. ```js
  4707. let tile = tiledLayer.getTiledTileAt(100, 100, true);
  4708. cc.log(tile);
  4709. ```
  4710. */
  4711. getTiledTileAt(x: number, y: number, forceCreate: boolean): TiledTile;
  4712. /**
  4713. !#en
  4714. Change tile to TiledTile at the specified coordinate.
  4715. !#zh
  4716. 将指定的 tile 坐标替换为指定的 TiledTile。
  4717. @param x x
  4718. @param y y
  4719. @param tiledTile tiledTile
  4720. */
  4721. setTiledTileAt(x: number, y: number, tiledTile: TiledTile): TiledTile;
  4722. /**
  4723. !#en Return texture.
  4724. !#zh 获取纹理。
  4725. @param index The index of textures
  4726. */
  4727. getTexture(index: any): Texture2D;
  4728. /**
  4729. !#en Return texture.
  4730. !#zh 获取纹理。
  4731. */
  4732. getTextures(): Texture2D;
  4733. /**
  4734. !#en Set the texture.
  4735. !#zh 设置纹理。
  4736. @param texture texture
  4737. */
  4738. setTexture(texture: Texture2D): void;
  4739. /**
  4740. !#en Set the texture.
  4741. !#zh 设置纹理。
  4742. @param textures textures
  4743. */
  4744. setTexture(textures: Texture2D): void;
  4745. /**
  4746. !#en Gets layer size.
  4747. !#zh 获得层大小。
  4748. @example
  4749. ```js
  4750. let size = tiledLayer.getLayerSize();
  4751. cc.log("layer size: " + size);
  4752. ```
  4753. */
  4754. getLayerSize(): Size;
  4755. /**
  4756. !#en Size of the map's tile (could be different from the tile's size).
  4757. !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。
  4758. @example
  4759. ```js
  4760. let mapTileSize = tiledLayer.getMapTileSize();
  4761. cc.log("MapTile size: " + mapTileSize);
  4762. ```
  4763. */
  4764. getMapTileSize(): Size;
  4765. /**
  4766. !#en Gets Tile set first information for the layer.
  4767. !#zh 获取 layer 索引位置为0的 Tileset 信息。
  4768. @param index The index of tilesets
  4769. */
  4770. getTileSet(index: any): TMXTilesetInfo;
  4771. /**
  4772. !#en Gets tile set all information for the layer.
  4773. !#zh 获取 layer 所有的 Tileset 信息。
  4774. */
  4775. getTileSet(): TMXTilesetInfo;
  4776. /**
  4777. !#en Sets tile set information for the layer.
  4778. !#zh 设置 layer 的 tileset 信息。
  4779. @param tileset tileset
  4780. */
  4781. setTileSet(tileset: TMXTilesetInfo): void;
  4782. /**
  4783. !#en Sets Tile set information for the layer.
  4784. !#zh 设置 layer 的 Tileset 信息。
  4785. @param tilesets tilesets
  4786. */
  4787. setTileSets(tilesets: TMXTilesetInfo): void;
  4788. }
  4789. /** !#en Renders a TMX Tile Map in the scene.
  4790. !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */
  4791. export class TiledMap extends Component {
  4792. /** !#en The TiledMap Asset.
  4793. !#zh TiledMap 资源。 */
  4794. tmxAsset: TiledMapAsset;
  4795. /**
  4796. !#en Gets the map size.
  4797. !#zh 获取地图大小。
  4798. @example
  4799. ```js
  4800. let mapSize = tiledMap.getMapSize();
  4801. cc.log("Map Size: " + mapSize);
  4802. ```
  4803. */
  4804. getMapSize(): Size;
  4805. /**
  4806. !#en Gets the tile size.
  4807. !#zh 获取地图背景中 tile 元素的大小。
  4808. @example
  4809. ```js
  4810. let tileSize = tiledMap.getTileSize();
  4811. cc.log("Tile Size: " + tileSize);
  4812. ```
  4813. */
  4814. getTileSize(): Size;
  4815. /**
  4816. !#en map orientation.
  4817. !#zh 获取地图方向。
  4818. @example
  4819. ```js
  4820. let mapOrientation = tiledMap.getMapOrientation();
  4821. cc.log("Map Orientation: " + mapOrientation);
  4822. ```
  4823. */
  4824. getMapOrientation(): number;
  4825. /**
  4826. !#en object groups.
  4827. !#zh 获取所有的对象层。
  4828. @example
  4829. ```js
  4830. let objGroups = titledMap.getObjectGroups();
  4831. for (let i = 0; i < objGroups.length; ++i) {
  4832. cc.log("obj: " + objGroups[i]);
  4833. }
  4834. ```
  4835. */
  4836. getObjectGroups(): TiledObjectGroup[];
  4837. /**
  4838. !#en Return the TMXObjectGroup for the specific group.
  4839. !#zh 获取指定的 TMXObjectGroup。
  4840. @param groupName groupName
  4841. @example
  4842. ```js
  4843. let group = titledMap.getObjectGroup("Players");
  4844. cc.log("ObjectGroup: " + group);
  4845. ```
  4846. */
  4847. getObjectGroup(groupName: string): TiledObjectGroup;
  4848. /**
  4849. !#en enable or disable culling
  4850. !#zh 开启或关闭裁剪。
  4851. @param value value
  4852. */
  4853. enableCulling(value: boolean): void;
  4854. /**
  4855. !#en Gets the map properties.
  4856. !#zh 获取地图的属性。
  4857. @example
  4858. ```js
  4859. let properties = titledMap.getProperties();
  4860. for (let i = 0; i < properties.length; ++i) {
  4861. cc.log("Properties: " + properties[i]);
  4862. }
  4863. ```
  4864. */
  4865. getProperties(): any[];
  4866. /**
  4867. !#en Return All layers array.
  4868. !#zh 返回包含所有 layer 的数组。
  4869. @example
  4870. ```js
  4871. let layers = titledMap.getLayers();
  4872. for (let i = 0; i < layers.length; ++i) {
  4873. cc.log("Layers: " + layers[i]);
  4874. }
  4875. ```
  4876. */
  4877. getLayers(): TiledLayer[];
  4878. /**
  4879. !#en return the cc.TiledLayer for the specific layer.
  4880. !#zh 获取指定名称的 layer。
  4881. @param layerName layerName
  4882. @example
  4883. ```js
  4884. let layer = titledMap.getLayer("Player");
  4885. cc.log(layer);
  4886. ```
  4887. */
  4888. getLayer(layerName: string): TiledLayer;
  4889. /**
  4890. !#en Return the value for the specific property name.
  4891. !#zh 通过属性名称,获取指定的属性。
  4892. @param propertyName propertyName
  4893. @example
  4894. ```js
  4895. let property = titledMap.getProperty("info");
  4896. cc.log("Property: " + property);
  4897. ```
  4898. */
  4899. getProperty(propertyName: string): string;
  4900. /**
  4901. !#en Return properties dictionary for tile GID.
  4902. !#zh 通过 GID ,获取指定的属性。
  4903. @param GID GID
  4904. @example
  4905. ```js
  4906. let properties = titledMap.getPropertiesForGID(GID);
  4907. cc.log("Properties: " + properties);
  4908. ```
  4909. */
  4910. getPropertiesForGID(GID: number): any;
  4911. }
  4912. /** !#en Renders the TMX object group.
  4913. !#zh 渲染 tmx object group。 */
  4914. export class TiledObjectGroup extends Component {
  4915. /**
  4916. !#en Offset position of child objects.
  4917. !#zh 获取子对象的偏移位置。
  4918. @example
  4919. ```js
  4920. let offset = tMXObjectGroup.getPositionOffset();
  4921. ```
  4922. */
  4923. getPositionOffset(): Vec2;
  4924. /**
  4925. !#en List of properties stored in a dictionary.
  4926. !#zh 以映射的形式获取属性列表。
  4927. @example
  4928. ```js
  4929. let offset = tMXObjectGroup.getProperties();
  4930. ```
  4931. */
  4932. getProperties(): any;
  4933. /**
  4934. !#en Gets the Group name.
  4935. !#zh 获取组名称。
  4936. @example
  4937. ```js
  4938. let groupName = tMXObjectGroup.getGroupName;
  4939. ```
  4940. */
  4941. getGroupName(): string;
  4942. /**
  4943. !#en
  4944. Return the object for the specific object name. <br />
  4945. It will return the 1st object found on the array for the given name.
  4946. !#zh 获取指定的对象。
  4947. @param objectName objectName
  4948. @example
  4949. ```js
  4950. let object = tMXObjectGroup.getObject("Group");
  4951. ```
  4952. */
  4953. getObject(objectName: string): any;
  4954. /**
  4955. !#en Gets the objects.
  4956. !#zh 获取对象数组。
  4957. @example
  4958. ```js
  4959. let objects = tMXObjectGroup.getObjects();
  4960. ```
  4961. */
  4962. getObjects(): any[];
  4963. }
  4964. /** Class for tiled map asset handling. */
  4965. export class TiledMapAsset extends Asset {
  4966. textures: Texture2D[];
  4967. textureNames: string[];
  4968. textureSizes: Size[];
  4969. imageLayerTextures: Texture2D[];
  4970. imageLayerTextureNames: string[];
  4971. }
  4972. /** !#en TiledTile can control the specified map tile.
  4973. It will apply the node rotation, scale, translate to the map tile.
  4974. You can change the TiledTile's gid to change the map tile's style.
  4975. !#zh TiledTile 可以单独对某一个地图块进行操作。
  4976. 他会将节点的旋转,缩放,平移操作应用在这个地图块上,并可以通过更换当前地图块的 gid 来更换地图块的显示样式。 */
  4977. export class TiledTile extends Component {
  4978. /** !#en Specify the TiledTile horizontal coordinate,use map tile as the unit.
  4979. !#zh 指定 TiledTile 的横向坐标,以地图块为单位 */
  4980. x: number;
  4981. /** !#en Specify the TiledTile vertical coordinate,use map tile as the unit.
  4982. !#zh 指定 TiledTile 的纵向坐标,以地图块为单位 */
  4983. y: number;
  4984. /** !#en Specify the TiledTile gid.
  4985. !#zh 指定 TiledTile 的 gid 值 */
  4986. gid: number;
  4987. }
  4988. /** Class for particle asset handling. */
  4989. export class ParticleAsset extends Asset {
  4990. }
  4991. /** Particle System base class. <br/>
  4992. Attributes of a Particle System:<br/>
  4993. - emmision rate of the particles<br/>
  4994. - Gravity Mode (Mode A): <br/>
  4995. - gravity <br/>
  4996. - direction <br/>
  4997. - speed +- variance <br/>
  4998. - tangential acceleration +- variance<br/>
  4999. - radial acceleration +- variance<br/>
  5000. - Radius Mode (Mode B): <br/>
  5001. - startRadius +- variance <br/>
  5002. - endRadius +- variance <br/>
  5003. - rotate +- variance <br/>
  5004. - Properties common to all modes: <br/>
  5005. - life +- life variance <br/>
  5006. - start spin +- variance <br/>
  5007. - end spin +- variance <br/>
  5008. - start size +- variance <br/>
  5009. - end size +- variance <br/>
  5010. - start color +- variance <br/>
  5011. - end color +- variance <br/>
  5012. - life +- variance <br/>
  5013. - blending function <br/>
  5014. - texture <br/>
  5015. <br/>
  5016. cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).<br/>
  5017. 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, <br/>
  5018. cocos2d uses a another approach, but the results are almost identical.<br/>
  5019. cocos2d supports all the variables used by Particle Designer plus a bit more: <br/>
  5020. - spinning particles (supported when using ParticleSystem) <br/>
  5021. - tangential acceleration (Gravity mode) <br/>
  5022. - radial acceleration (Gravity mode) <br/>
  5023. - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only) <br/>
  5024. It is possible to customize any of the above mentioned properties in runtime. Example: <br/> */
  5025. export class ParticleSystem extends RenderComponent implements BlendFunc {
  5026. /** !#en Play particle in edit mode.
  5027. !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */
  5028. preview: boolean;
  5029. /** !#en
  5030. If set custom to true, then use custom properties insteadof read particle file.
  5031. !#zh 是否自定义粒子属性。 */
  5032. custom: boolean;
  5033. /** !#en The plist file.
  5034. !#zh plist 格式的粒子配置文件。 */
  5035. file: ParticleAsset;
  5036. /** !#en SpriteFrame used for particles display
  5037. !#zh 用于粒子呈现的 SpriteFrame */
  5038. spriteFrame: SpriteFrame;
  5039. /** !#en Texture of Particle System, readonly, please use spriteFrame to setup new texture。
  5040. !#zh 粒子贴图,只读属性,请使用 spriteFrame 属性来替换贴图。 */
  5041. texture: string;
  5042. /** !#en Current quantity of particles that are being simulated.
  5043. !#zh 当前播放的粒子数量。 */
  5044. particleCount: number;
  5045. /** !#en Indicate whether the system simulation have stopped.
  5046. !#zh 指示粒子播放是否完毕。 */
  5047. stopped: boolean;
  5048. /** !#en If set to true, the particle system will automatically start playing on onLoad.
  5049. !#zh 如果设置为 true 运行时会自动发射粒子。 */
  5050. playOnLoad: boolean;
  5051. /** !#en Indicate whether the owner node will be auto-removed when it has no particles left.
  5052. !#zh 粒子播放完毕后自动销毁所在的节点。 */
  5053. autoRemoveOnFinish: boolean;
  5054. /** !#en Indicate whether the particle system is activated.
  5055. !#zh 是否激活粒子。 */
  5056. active: boolean;
  5057. /** !#en Maximum particles of the system.
  5058. !#zh 粒子最大数量。 */
  5059. totalParticles: number;
  5060. /** !#en How many seconds the emitter wil run. -1 means 'forever'.
  5061. !#zh 发射器生存时间,单位秒,-1表示持续发射。 */
  5062. duration: number;
  5063. /** !#en Emission rate of the particles.
  5064. !#zh 每秒发射的粒子数目。 */
  5065. emissionRate: number;
  5066. /** !#en Life of each particle setter.
  5067. !#zh 粒子的运行时间。 */
  5068. life: number;
  5069. /** !#en Variation of life.
  5070. !#zh 粒子的运行时间变化范围。 */
  5071. lifeVar: number;
  5072. /** !#en Start color of each particle.
  5073. !#zh 粒子初始颜色。 */
  5074. startColor: Color;
  5075. /** !#en Variation of the start color.
  5076. !#zh 粒子初始颜色变化范围。 */
  5077. startColorVar: Color;
  5078. /** !#en Ending color of each particle.
  5079. !#zh 粒子结束颜色。 */
  5080. endColor: Color;
  5081. /** !#en Variation of the end color.
  5082. !#zh 粒子结束颜色变化范围。 */
  5083. endColorVar: Color;
  5084. /** !#en Angle of each particle setter.
  5085. !#zh 粒子角度。 */
  5086. angle: number;
  5087. /** !#en Variation of angle of each particle setter.
  5088. !#zh 粒子角度变化范围。 */
  5089. angleVar: number;
  5090. /** !#en Start size in pixels of each particle.
  5091. !#zh 粒子的初始大小。 */
  5092. startSize: number;
  5093. /** !#en Variation of start size in pixels.
  5094. !#zh 粒子初始大小的变化范围。 */
  5095. startSizeVar: number;
  5096. /** !#en End size in pixels of each particle.
  5097. !#zh 粒子结束时的大小。 */
  5098. endSize: number;
  5099. /** !#en Variation of end size in pixels.
  5100. !#zh 粒子结束大小的变化范围。 */
  5101. endSizeVar: number;
  5102. /** !#en Start angle of each particle.
  5103. !#zh 粒子开始自旋角度。 */
  5104. startSpin: number;
  5105. /** !#en Variation of start angle.
  5106. !#zh 粒子开始自旋角度变化范围。 */
  5107. startSpinVar: number;
  5108. /** !#en End angle of each particle.
  5109. !#zh 粒子结束自旋角度。 */
  5110. endSpin: number;
  5111. /** !#en Variation of end angle.
  5112. !#zh 粒子结束自旋角度变化范围。 */
  5113. endSpinVar: number;
  5114. /** !#en Source position of the emitter.
  5115. !#zh 发射器位置。 */
  5116. sourcePos: Vec2;
  5117. /** !#en Variation of source position.
  5118. !#zh 发射器位置的变化范围。(横向和纵向) */
  5119. posVar: Vec2;
  5120. /** !#en Particles movement type.
  5121. !#zh 粒子位置类型。 */
  5122. positionType: ParticleSystem.PositionType;
  5123. /** !#en Particles emitter modes.
  5124. !#zh 发射器类型。 */
  5125. emitterMode: ParticleSystem.EmitterMode;
  5126. /** !#en Gravity of the emitter.
  5127. !#zh 重力。 */
  5128. gravity: Vec2;
  5129. /** !#en Speed of the emitter.
  5130. !#zh 速度。 */
  5131. speed: number;
  5132. /** !#en Variation of the speed.
  5133. !#zh 速度变化范围。 */
  5134. speedVar: number;
  5135. /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode.
  5136. !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */
  5137. tangentialAccel: number;
  5138. /** !#en Variation of the tangential acceleration.
  5139. !#zh 每个粒子的切向加速度变化范围。 */
  5140. tangentialAccelVar: number;
  5141. /** !#en Acceleration of each particle. Only available in 'Gravity' mode.
  5142. !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */
  5143. radialAccel: number;
  5144. /** !#en Variation of the radial acceleration.
  5145. !#zh 粒子径向加速度变化范围。 */
  5146. radialAccelVar: number;
  5147. /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode.
  5148. !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */
  5149. rotationIsDir: boolean;
  5150. /** !#en Starting radius of the particles. Only available in 'Radius' mode.
  5151. !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */
  5152. startRadius: number;
  5153. /** !#en Variation of the starting radius.
  5154. !#zh 初始半径变化范围。 */
  5155. startRadiusVar: number;
  5156. /** !#en Ending radius of the particles. Only available in 'Radius' mode.
  5157. !#zh 结束半径,只有在半径模式下可用。 */
  5158. endRadius: number;
  5159. /** !#en Variation of the ending radius.
  5160. !#zh 结束半径变化范围。 */
  5161. endRadiusVar: number;
  5162. /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
  5163. !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */
  5164. rotatePerS: number;
  5165. /** !#en Variation of the degress to rotate a particle around the source pos per second.
  5166. !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */
  5167. rotatePerSVar: number;
  5168. /** !#en The Particle emitter lives forever.
  5169. !#zh 表示发射器永久存在 */
  5170. static DURATION_INFINITY: number;
  5171. /** !#en The starting size of the particle is equal to the ending size.
  5172. !#zh 表示粒子的起始大小等于结束大小。 */
  5173. static START_SIZE_EQUAL_TO_END_SIZE: number;
  5174. /** !#en The starting radius of the particle is equal to the ending radius.
  5175. !#zh 表示粒子的起始半径等于结束半径。 */
  5176. static START_RADIUS_EQUAL_TO_END_RADIUS: number;
  5177. /**
  5178. !#en Stop emitting particles. Running particles will continue to run until they die.
  5179. !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。
  5180. @example
  5181. ```js
  5182. // stop particle system.
  5183. myParticleSystem.stopSystem();
  5184. ```
  5185. */
  5186. stopSystem(): void;
  5187. /**
  5188. !#en Kill all living particles.
  5189. !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。
  5190. @example
  5191. ```js
  5192. // play particle system.
  5193. myParticleSystem.resetSystem();
  5194. ```
  5195. */
  5196. resetSystem(): void;
  5197. /**
  5198. !#en Whether or not the system is full.
  5199. !#zh 发射器中粒子是否大于等于设置的总粒子数量。
  5200. */
  5201. isFull(): boolean;
  5202. /**
  5203. !#en Sets a new texture with a rect. The rect is in texture position and size.
  5204. Please use spriteFrame property instead, this function is deprecated since v1.9
  5205. !#zh 设置一张新贴图和关联的矩形。
  5206. 请直接设置 spriteFrame 属性,这个函数从 v1.9 版本开始已经被废弃
  5207. @param texture texture
  5208. @param rect rect
  5209. */
  5210. setTextureWithRect(texture: Texture2D, rect: Rect): void;
  5211. /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost.
  5212. !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */
  5213. srcBlendFactor: macro.BlendFactor;
  5214. /** !#en specify the destination Blend Factor.
  5215. !#zh 指定目标的混合模式 */
  5216. dstBlendFactor: macro.BlendFactor;
  5217. }
  5218. /** !#en cc.WebView is a component for display web pages in the game. Because different platforms have different authorization, API and control methods for WebView component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported.
  5219. !#zh WebView 组件,用于在游戏中显示网页。由于不同平台对于 WebView 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */
  5220. export class WebView extends Component {
  5221. /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix.
  5222. !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */
  5223. url: string;
  5224. /** !#en The webview's event callback , it will be triggered when certain webview event occurs.
  5225. !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */
  5226. webviewLoadedEvents: Component.EventHandler[];
  5227. /**
  5228. !#en
  5229. Set javascript interface scheme (see also setOnJSCallback). <br/>
  5230. Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
  5231. Please refer to the official documentation for more details.
  5232. !#zh
  5233. 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。<br/>
  5234. 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。<br/>
  5235. 详情请参阅官方文档
  5236. @param scheme scheme
  5237. */
  5238. setJavascriptInterfaceScheme(scheme: string): void;
  5239. /**
  5240. !#en
  5241. This callback called when load URL that start with javascript
  5242. interface scheme (see also setJavascriptInterfaceScheme). <br/>
  5243. Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
  5244. Please refer to the official documentation for more details.
  5245. !#zh
  5246. 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。<br/>
  5247. 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。
  5248. 详情请参阅官方文档
  5249. @param callback callback
  5250. */
  5251. setOnJSCallback(callback: Function): void;
  5252. /**
  5253. !#en
  5254. Evaluates JavaScript in the context of the currently displayed page. <br/>
  5255. Please refer to the official document for more details <br/>
  5256. Note: Cross domain issues need to be resolved by yourself <br/>
  5257. !#zh
  5258. 执行 WebView 内部页面脚本(详情请参阅官方文档) <br/>
  5259. 注意:需要自行解决跨域问题
  5260. @param str str
  5261. */
  5262. evaluateJS(str: string): void;
  5263. /**
  5264. !#en if you don't need the WebView and it isn't in any running Scene, you should
  5265. call the destroy method on this component or the associated node explicitly.
  5266. Otherwise, the created DOM element won't be removed from web page.
  5267. !#zh
  5268. 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  5269. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  5270. @example
  5271. ```js
  5272. webview.node.parent = null; // or webview.node.removeFromParent(false);
  5273. // when you don't need webview anymore
  5274. webview.node.destroy();
  5275. ```
  5276. */
  5277. destroy(): boolean;
  5278. }
  5279. /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game. Because different platforms have different authorization, API and control methods for VideoPlayer component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported.
  5280. !#zh Video 组件,用于在游戏中播放视频。由于不同平台对于 VideoPlayer 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */
  5281. export class VideoPlayer extends Component {
  5282. /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path.
  5283. !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */
  5284. resourceType: VideoPlayer.ResourceType;
  5285. /** !#en The remote URL of video.
  5286. !#zh 远程视频的 URL */
  5287. remoteURL: string;
  5288. /** !#en The local video clip.
  5289. !#zh 本地视频剪辑 */
  5290. clip: VideoClip;
  5291. /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time.
  5292. !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */
  5293. currentTime: number;
  5294. /** !#en The volume of the video.
  5295. !#zh 视频的音量(0.0 ~ 1.0) */
  5296. volume: number;
  5297. /** !#en Mutes the VideoPlayer. Mute sets the volume=0, Un-Mute restore the original volume.
  5298. !#zh 是否静音视频。静音时设置音量为 0,取消静音是恢复原来的音量。 */
  5299. mute: boolean;
  5300. /** !#en Whether keep the aspect ration of the original video.
  5301. !#zh 是否保持视频原来的宽高比 */
  5302. keepAspectRatio: boolean;
  5303. /** !#en Whether play video in fullscreen mode.
  5304. !#zh 是否全屏播放视频 */
  5305. isFullscreen: boolean;
  5306. /** !#en Always below the game view (only useful on Web. Note: The specific effects are not guaranteed to be consistent, depending on whether each browser supports or restricts).
  5307. !#zh 永远在游戏视图最底层(这个属性只有在 Web 平台上有效果。注意:具体效果无法保证一致,跟各个浏览器是否支持与限制有关) */
  5308. stayOnBottom: boolean;
  5309. /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed.
  5310. !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */
  5311. videoPlayerEvent: Component.EventHandler[];
  5312. /**
  5313. !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch.
  5314. !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。
  5315. */
  5316. play(): void;
  5317. /**
  5318. !#en If a video is paused, call this method to resume playing.
  5319. !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。
  5320. */
  5321. resume(): void;
  5322. /**
  5323. !#en If a video is playing, call this method to pause playing.
  5324. !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。
  5325. */
  5326. pause(): void;
  5327. /**
  5328. !#en If a video is playing, call this method to stop playing immediately.
  5329. !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。
  5330. */
  5331. stop(): void;
  5332. /**
  5333. !#en Gets the duration of the video
  5334. !#zh 获取视频文件的播放总时长
  5335. */
  5336. getDuration(): number;
  5337. /**
  5338. !#en Determine whether video is playing or not.
  5339. !#zh 判断当前视频是否处于播放状态
  5340. */
  5341. isPlaying(): boolean;
  5342. /**
  5343. !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should
  5344. call the destroy method on this component or the associated node explicitly.
  5345. Otherwise, the created DOM element won't be removed from web page.
  5346. !#zh
  5347. 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  5348. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  5349. @example
  5350. ```js
  5351. videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false);
  5352. // when you don't need videoplayer anymore
  5353. videoplayer.node.destroy();
  5354. ```
  5355. */
  5356. destroy(): boolean;
  5357. }
  5358. /** !#en The Light Component
  5359. !#zh 光源组件 */
  5360. export class Light extends Component {
  5361. }
  5362. /** !#en
  5363. Camera is usefull when making reel game or other games which need scroll screen.
  5364. Using camera will be more efficient than moving node to scroll screen.
  5365. Camera
  5366. !#zh
  5367. 摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */
  5368. export class Camera extends Component {
  5369. /** !#en
  5370. The camera zoom ratio, only support 2D camera.
  5371. !#zh
  5372. 摄像机缩放比率, 只支持 2D camera。 */
  5373. zoomRatio: number;
  5374. /** !#en
  5375. Field of view. The width of the Camera’s view angle, measured in degrees along the local Y axis.
  5376. !#zh
  5377. 决定摄像机视角的宽度,当摄像机处于透视投影模式下这个属性才会生效。 */
  5378. fov: number;
  5379. /** !#en
  5380. The viewport size of the Camera when set to orthographic projection.
  5381. !#zh
  5382. 摄像机在正交投影模式下的视窗大小。 */
  5383. orthoSize: number;
  5384. /** !#en
  5385. The near clipping plane.
  5386. !#zh
  5387. 摄像机的近剪裁面。 */
  5388. nearClip: number;
  5389. /** !#en
  5390. The far clipping plane.
  5391. !#zh
  5392. 摄像机的远剪裁面。 */
  5393. farClip: number;
  5394. /** !#en
  5395. Is the camera orthographic (true) or perspective (false)?
  5396. !#zh
  5397. 设置摄像机的投影模式是正交还是透视模式。 */
  5398. ortho: boolean;
  5399. /** !#en
  5400. Four values (0 ~ 1) that indicate where on the screen this camera view will be drawn.
  5401. !#zh
  5402. 决定摄像机绘制在屏幕上哪个位置,值为(0 ~ 1)。 */
  5403. rect: Rect;
  5404. /** !#en
  5405. This is used to render parts of the scene selectively.
  5406. !#zh
  5407. 决定摄像机会渲染场景的哪一部分。 */
  5408. cullingMask: number;
  5409. /** !#en
  5410. Determining what to clear when camera rendering.
  5411. !#zh
  5412. 决定摄像机渲染时会清除哪些状态。 */
  5413. clearFlags: Camera.ClearFlags;
  5414. /** !#en
  5415. The color with which the screen will be cleared.
  5416. !#zh
  5417. 摄像机用于清除屏幕的背景色。 */
  5418. backgroundColor: Color;
  5419. /** !#en
  5420. Camera's depth in the camera rendering order. Cameras with higher depth are rendered after cameras with lower depth.
  5421. !#zh
  5422. 摄像机深度。用于决定摄像机的渲染顺序,值越大渲染在越上层。 */
  5423. depth: number;
  5424. /** !#en
  5425. Destination render texture.
  5426. Usually cameras render directly to screen, but for some effects it is useful to make a camera render into a texture.
  5427. !#zh
  5428. 摄像机渲染的目标 RenderTexture。
  5429. 一般摄像机会直接渲染到屏幕上,但是有一些效果可以使用摄像机渲染到 RenderTexture 上再对 RenderTexture 进行处理来实现。 */
  5430. targetTexture: RenderTexture;
  5431. /** !#en
  5432. Sets the camera's render stages.
  5433. !#zh
  5434. 设置摄像机渲染的阶段 */
  5435. renderStages: number;
  5436. /** !#en Whether auto align camera viewport to screen
  5437. !#zh 是否自动将摄像机的视口对准屏幕 */
  5438. alignWithScreen: boolean;
  5439. /** !#en
  5440. The primary camera in the scene. Returns the rear most rendered camera, which is the camera with the lowest depth.
  5441. !#zh
  5442. 当前场景中激活的主摄像机。将会返回渲染在屏幕最底层,也就是 depth 最小的摄像机。 */
  5443. static main: Camera;
  5444. /** !#en
  5445. All enabled cameras.
  5446. !#zh
  5447. 当前激活的所有摄像机。 */
  5448. static cameras: Camera[];
  5449. /**
  5450. !#en
  5451. Get the first camera which the node belong to.
  5452. !#zh
  5453. 获取节点所在的第一个摄像机。
  5454. @param node node
  5455. */
  5456. static findCamera(node: Node): Camera;
  5457. /**
  5458. !#en
  5459. Get the screen to world matrix, only support 2D camera which alignWithScreen is true.
  5460. !#zh
  5461. 获取屏幕坐标系到世界坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。
  5462. @param out the matrix to receive the result
  5463. */
  5464. getScreenToWorldMatrix2D(out: Mat4): Mat4;
  5465. /**
  5466. !#en
  5467. Get the world to camera matrix, only support 2D camera which alignWithScreen is true.
  5468. !#zh
  5469. 获取世界坐标系到摄像机坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。
  5470. @param out the matrix to receive the result
  5471. */
  5472. getWorldToScreenMatrix2D(out: Mat4): Mat4;
  5473. /**
  5474. !#en
  5475. Convert point from screen to world.
  5476. !#zh
  5477. 将坐标从屏幕坐标系转换到世界坐标系。
  5478. @param screenPosition screenPosition
  5479. @param out out
  5480. */
  5481. getScreenToWorldPoint(screenPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3;
  5482. /**
  5483. !#en
  5484. Convert point from world to screen.
  5485. !#zh
  5486. 将坐标从世界坐标系转化到屏幕坐标系。
  5487. @param worldPosition worldPosition
  5488. @param out out
  5489. */
  5490. getWorldToScreenPoint(worldPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3;
  5491. /**
  5492. !#en
  5493. Get a ray from screen position
  5494. !#zh
  5495. 从屏幕坐标获取一条射线
  5496. @param screenPos screenPos
  5497. */
  5498. getRay(screenPos: Vec2): geomUtils.Ray;
  5499. /**
  5500. !#en
  5501. Check whether the node is in the camera.
  5502. !#zh
  5503. 检测节点是否被此摄像机影响
  5504. @param node the node which need to check
  5505. */
  5506. containsNode(node: Node): boolean;
  5507. /**
  5508. !#en
  5509. Render the camera manually.
  5510. !#zh
  5511. 手动渲染摄像机。
  5512. @param rootNode rootNode
  5513. */
  5514. render(rootNode?: Node): void;
  5515. /**
  5516. !#en
  5517. Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates.
  5518. !#zh
  5519. 返回一个将节点坐标系转换到摄像机坐标系下的矩阵
  5520. @param node the node which should transform
  5521. */
  5522. getNodeToCameraTransform(node: Node): AffineTransform;
  5523. /**
  5524. !#en
  5525. Conver a camera coordinates point to world coordinates.
  5526. !#zh
  5527. 将一个摄像机坐标系下的点转换到世界坐标系下。
  5528. @param point the point which should transform
  5529. @param out the point to receive the result
  5530. */
  5531. getCameraToWorldPoint(point: Vec2, out?: Vec2): Vec2;
  5532. /**
  5533. !#en
  5534. Conver a world coordinates point to camera coordinates.
  5535. !#zh
  5536. 将一个世界坐标系下的点转换到摄像机坐标系下。
  5537. @param point point
  5538. @param out the point to receive the result
  5539. */
  5540. getWorldToCameraPoint(point: Vec2, out?: Vec2): Vec2;
  5541. /**
  5542. !#en
  5543. Get the camera to world matrix
  5544. !#zh
  5545. 获取摄像机坐标系到世界坐标系的矩阵
  5546. @param out the matrix to receive the result
  5547. */
  5548. getCameraToWorldMatrix(out: Mat4): Mat4;
  5549. /**
  5550. !#en
  5551. Get the world to camera matrix
  5552. !#zh
  5553. 获取世界坐标系到摄像机坐标系的矩阵
  5554. @param out the matrix to receive the result
  5555. */
  5556. getWorldToCameraMatrix(out: Mat4): Mat4;
  5557. }
  5558. /** !#en Box Collider.
  5559. !#zh 包围盒碰撞组件 */
  5560. export class BoxCollider extends Collider implements Collider.Box {
  5561. /** !#en
  5562. Collider info in world coordinate.
  5563. !#zh
  5564. 碰撞体的世界坐标系下的信息。 */
  5565. world: ColliderInfo;
  5566. /** !#en Position offset
  5567. !#zh 位置偏移量 */
  5568. offset: Vec2;
  5569. /** !#en Box size
  5570. !#zh 包围盒大小 */
  5571. size: Size;
  5572. }
  5573. /** !#en Circle Collider.
  5574. !#zh 圆形碰撞组件 */
  5575. export class CircleCollider extends Collider implements Collider.Circle {
  5576. /** !#en
  5577. Collider info in world coordinate.
  5578. !#zh
  5579. 碰撞体的世界坐标系下的信息。 */
  5580. world: ColliderInfo;
  5581. /** !#en Position offset
  5582. !#zh 位置偏移量 */
  5583. offset: Vec2;
  5584. /** !#en Circle radius
  5585. !#zh 圆形半径 */
  5586. radius: number;
  5587. }
  5588. /** !#en Collider component base class.
  5589. !#zh 碰撞组件基类 */
  5590. export class Collider extends Component {
  5591. /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag.
  5592. !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */
  5593. tag: number;
  5594. }
  5595. /** !#en
  5596. Collider Info.
  5597. !#zh
  5598. 碰撞体信息。 */
  5599. export class ColliderInfo {
  5600. /** !#en
  5601. Collider aabb information of last frame
  5602. !#zh
  5603. 碰撞体上一帧的 aabb 信息 */
  5604. preAabb: Rect;
  5605. /** !#en
  5606. Collider aabb information of current frame
  5607. !#zh
  5608. 碰撞体当前帧的 aabb 信息 */
  5609. aabb: Rect;
  5610. /** !#en
  5611. Collider matrix
  5612. !#zh
  5613. 碰撞体的矩阵信息 */
  5614. matrix: Mat4;
  5615. /** !#en
  5616. Collider radius (for CircleCollider)
  5617. !#zh
  5618. 碰撞体的半径(只对 CircleCollider 有效) */
  5619. radius: number;
  5620. /** !#en
  5621. Collider position (for CircleCollider)
  5622. !#zh
  5623. 碰撞体的位置(只对 CircleCollider 有效) */
  5624. position: Vec2;
  5625. /** !#en
  5626. Collider points (for BoxCollider and PolygonCollider)
  5627. !#zh
  5628. 碰撞体的顶点信息(只对 BoxCollider 和 PolygonCollider 有效) */
  5629. points: Vec2[];
  5630. }
  5631. /** !#en
  5632. A simple collision manager class.
  5633. It will calculate whether the collider collides other colliders, if collides then call the callbacks.
  5634. !#zh
  5635. 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */
  5636. export class CollisionManager implements EventTarget {
  5637. /** !#en
  5638. !#zh
  5639. 是否开启碰撞管理,默认为不开启 */
  5640. enabled: boolean;
  5641. /** !#en
  5642. !#zh
  5643. 是否绘制碰撞组件的包围盒,默认为不绘制 */
  5644. enabledDrawBoundingBox: boolean;
  5645. /** !#en
  5646. !#zh
  5647. 是否绘制碰撞组件的形状,默认为不绘制 */
  5648. enabledDebugDraw: boolean;
  5649. /**
  5650. !#en Checks whether the EventTarget object has any callback registered for a specific type of event.
  5651. !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。
  5652. @param type The type of event.
  5653. */
  5654. hasEventListener(type: string): boolean;
  5655. /**
  5656. !#en
  5657. Register an callback of a specific event type on the EventTarget.
  5658. This type of event should be triggered via `emit`.
  5659. !#zh
  5660. 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。
  5661. @param type A string representing the event type to listen for.
  5662. @param callback The callback that will be invoked when the event is dispatched.
  5663. The callback is ignored if it is a duplicate (the callbacks are unique).
  5664. @param target The target (this object) to invoke the callback, can be null
  5665. @example
  5666. ```js
  5667. eventTarget.on('fire', function () {
  5668. cc.log("fire in the hole");
  5669. }, node);
  5670. ```
  5671. */
  5672. on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
  5673. /**
  5674. !#en
  5675. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  5676. if only type is passed as parameter, all listeners registered with that type will be removed.
  5677. !#zh
  5678. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  5679. @param type A string representing the event type being removed.
  5680. @param callback The callback to remove.
  5681. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  5682. @example
  5683. ```js
  5684. // register fire eventListener
  5685. var callback = eventTarget.on('fire', function () {
  5686. cc.log("fire in the hole");
  5687. }, target);
  5688. // remove fire event listener
  5689. eventTarget.off('fire', callback, target);
  5690. // remove all fire event listeners
  5691. eventTarget.off('fire');
  5692. ```
  5693. */
  5694. off(type: string, callback?: Function, target?: any): void;
  5695. /**
  5696. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  5697. This is not for removing all listeners in the current event target,
  5698. and this is not for removing all listeners the target parameter have registered.
  5699. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  5700. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  5701. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  5702. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  5703. @param target The target to be searched for all related listeners
  5704. */
  5705. targetOff(target: any): void;
  5706. /**
  5707. !#en
  5708. Register an callback of a specific event type on the EventTarget,
  5709. the callback will remove itself after the first time it is triggered.
  5710. !#zh
  5711. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  5712. @param type A string representing the event type to listen for.
  5713. @param callback The callback that will be invoked when the event is dispatched.
  5714. The callback is ignored if it is a duplicate (the callbacks are unique).
  5715. @param target The target (this object) to invoke the callback, can be null
  5716. @example
  5717. ```js
  5718. eventTarget.once('fire', function () {
  5719. cc.log("this is the callback and will be invoked only once");
  5720. }, node);
  5721. ```
  5722. */
  5723. once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
  5724. /**
  5725. !#en
  5726. Send an event with the event object.
  5727. !#zh
  5728. 通过事件对象派发事件
  5729. @param event event
  5730. */
  5731. dispatchEvent(event: Event): void;
  5732. /**
  5733. !#en
  5734. Destroy all callbackInfos.
  5735. !#zh
  5736. 销毁记录的事件
  5737. */
  5738. clear(): void;
  5739. }
  5740. /** !#en Intersection helper class
  5741. !#zh 辅助类,用于测试形状与形状是否相交 */
  5742. export class Intersection {
  5743. /**
  5744. !#en Test line and line
  5745. !#zh 测试线段与线段是否相交
  5746. @param a1 The start point of the first line
  5747. @param a2 The end point of the first line
  5748. @param b1 The start point of the second line
  5749. @param b2 The end point of the second line
  5750. */
  5751. static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean;
  5752. /**
  5753. !#en Test line and rect
  5754. !#zh 测试线段与矩形是否相交
  5755. @param a1 The start point of the line
  5756. @param a2 The end point of the line
  5757. @param b The rect
  5758. */
  5759. static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean;
  5760. /**
  5761. !#en Test line and polygon
  5762. !#zh 测试线段与多边形是否相交
  5763. @param a1 The start point of the line
  5764. @param a2 The end point of the line
  5765. @param b The polygon, a set of points
  5766. */
  5767. static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean;
  5768. /**
  5769. !#en Test rect and rect
  5770. !#zh 测试矩形与矩形是否相交
  5771. @param a The first rect
  5772. @param b The second rect
  5773. */
  5774. static rectRect(a: Rect, b: Rect): boolean;
  5775. /**
  5776. !#en Test rect and polygon
  5777. !#zh 测试矩形与多边形是否相交
  5778. @param a The rect
  5779. @param b The polygon, a set of points
  5780. */
  5781. static rectPolygon(a: Rect, b: Vec2[]): boolean;
  5782. /**
  5783. !#en Test polygon and polygon
  5784. !#zh 测试多边形与多边形是否相交
  5785. @param a The first polygon, a set of points
  5786. @param b The second polygon, a set of points
  5787. */
  5788. static polygonPolygon(a: Vec2[], b: Vec2[]): boolean;
  5789. /**
  5790. !#en Test circle and circle
  5791. !#zh 测试圆形与圆形是否相交
  5792. @param a Object contains position and radius
  5793. @param b Object contains position and radius
  5794. */
  5795. static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean;
  5796. /**
  5797. !#en Test polygon and circle
  5798. !#zh 测试矩形与圆形是否相交
  5799. @param polygon The Polygon, a set of points
  5800. @param circle Object contains position and radius
  5801. */
  5802. static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean;
  5803. /**
  5804. !#en Test whether the point is in the polygon
  5805. !#zh 测试一个点是否在一个多边形中
  5806. @param point The point
  5807. @param polygon The polygon, a set of points
  5808. */
  5809. static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean;
  5810. /**
  5811. !#en Calculate the distance of point to line.
  5812. !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。
  5813. @param point The point
  5814. @param start The start point of line
  5815. @param end The end point of line
  5816. @param isSegment whether this line is a segment
  5817. */
  5818. static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): number;
  5819. }
  5820. /** !#en Polygon Collider.
  5821. !#zh 多边形碰撞组件 */
  5822. export class PolygonCollider extends Collider implements Collider.Polygon {
  5823. /** !#en
  5824. Collider info in world coordinate.
  5825. !#zh
  5826. 碰撞体的世界坐标系下的信息。 */
  5827. world: ColliderInfo;
  5828. /** !#en Position offset
  5829. !#zh 位置偏移量 */
  5830. offset: Vec2;
  5831. /** !#en Polygon points
  5832. !#zh 多边形顶点数组 */
  5833. points: Vec2[];
  5834. }
  5835. /** !#en The animation component is used to play back animations.
  5836. Animation provide several events to register:
  5837. - play : Emit when begin playing animation
  5838. - stop : Emit when stop playing animation
  5839. - pause : Emit when pause animation
  5840. - resume : Emit when resume animation
  5841. - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame
  5842. - finished : Emit when finish playing animation
  5843. !#zh Animation 组件用于播放动画。
  5844. Animation 提供了一系列可注册的事件:
  5845. - play : 开始播放时
  5846. - stop : 停止播放时
  5847. - pause : 暂停播放时
  5848. - resume : 恢复播放时
  5849. - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时
  5850. - finished : 动画播放完成时 */
  5851. export class Animation extends Component implements EventTarget {
  5852. /** !#en Animation will play the default clip when start game.
  5853. !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */
  5854. defaultClip: AnimationClip;
  5855. /** !#en Current played clip.
  5856. !#zh 当前播放的动画剪辑。 */
  5857. currentClip: AnimationClip;
  5858. /** !#en Whether the animation should auto play the default clip when start game.
  5859. !#zh 是否在运行游戏后自动播放默认动画剪辑。 */
  5860. playOnLoad: boolean;
  5861. /**
  5862. !#en Get all the clips used in this animation.
  5863. !#zh 获取动画组件上的所有动画剪辑。
  5864. */
  5865. getClips(): AnimationClip[];
  5866. /**
  5867. !#en Plays an animation and stop other animations.
  5868. !#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。
  5869. @param name The name of animation to play. If no name is supplied then the default animation will be played.
  5870. @param startTime play an animation from startTime
  5871. @example
  5872. ```js
  5873. var animCtrl = this.node.getComponent(cc.Animation);
  5874. animCtrl.play("linear");
  5875. ```
  5876. */
  5877. play(name?: string, startTime?: number): AnimationState;
  5878. /**
  5879. !#en
  5880. Plays an additive animation, it will not stop other animations.
  5881. If there are other animations playing, then will play several animations at the same time.
  5882. !#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。
  5883. @param name The name of animation to play. If no name is supplied then the default animation will be played.
  5884. @param startTime play an animation from startTime
  5885. @example
  5886. ```js
  5887. // linear_1 and linear_2 at the same time playing.
  5888. var animCtrl = this.node.getComponent(cc.Animation);
  5889. animCtrl.playAdditive("linear_1");
  5890. animCtrl.playAdditive("linear_2");
  5891. ```
  5892. */
  5893. playAdditive(name?: string, startTime?: number): AnimationState;
  5894. /**
  5895. !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation. <br/>
  5896. Stopping an animation also Rewinds it to the Start.
  5897. !#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。
  5898. @param name The animation to stop, if not supplied then stops all playing animations.
  5899. */
  5900. stop(name?: string): void;
  5901. /**
  5902. !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation.
  5903. !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。
  5904. @param name The animation to pauses, if not supplied then pauses all playing animations.
  5905. */
  5906. pause(name?: string): void;
  5907. /**
  5908. !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation.
  5909. !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。
  5910. @param name The animation to resumes, if not supplied then resumes all paused animations.
  5911. */
  5912. resume(name?: string): void;
  5913. /**
  5914. !#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.
  5915. !#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。
  5916. @param time The time to go to
  5917. @param name Specified animation name, if not supplied then make all animations go to the time.
  5918. */
  5919. setCurrentTime(time?: number, name?: string): void;
  5920. /**
  5921. !#en Returns the animation state named name. If no animation with the specified name, the function will return null.
  5922. !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。
  5923. @param name name
  5924. */
  5925. getAnimationState(name: string): AnimationState;
  5926. /**
  5927. !#en Check whether the animation State with the name already exists.
  5928. !#zh 通过名称判断是否包含某动画状态。也可用来判断是否已经添加了同名 clip.
  5929. @param name name
  5930. */
  5931. hasAnimationState(name: string): boolean;
  5932. /**
  5933. !#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.
  5934. !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。
  5935. @param clip the clip to add
  5936. @param newName newName
  5937. */
  5938. addClip(clip: AnimationClip, newName?: string): AnimationState;
  5939. /**
  5940. !#en
  5941. Remove clip from the animation list. This will remove the clip and any animation states based on it.
  5942. If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip.
  5943. 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
  5944. !#zh
  5945. 从动画列表中移除指定的动画剪辑,<br/>
  5946. 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。
  5947. 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。
  5948. @param clip clip
  5949. @param force If force is true, then will always remove the clip and any animation states based on it.
  5950. */
  5951. removeClip(clip: AnimationClip, force?: boolean): void;
  5952. /**
  5953. !#en
  5954. Samples animations at the current state.<br/>
  5955. This is useful when you explicitly want to set up some animation state, and sample it once.
  5956. !#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。
  5957. @param name name
  5958. */
  5959. sample(name: string): void;
  5960. /**
  5961. !#en
  5962. Register animation event callback.
  5963. The event arguments will provide the AnimationState which emit the event.
  5964. When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped.
  5965. !#zh
  5966. 注册动画事件回调。
  5967. 回调的事件里将会附上发送事件的 AnimationState。
  5968. 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。
  5969. @param type A string representing the event type to listen for.
  5970. @param callback The callback that will be invoked when the event is dispatched.
  5971. The callback is ignored if it is a duplicate (the callbacks are unique).
  5972. @param state state
  5973. @param target The target (this object) to invoke the callback, can be null
  5974. @param useCapture When set to true, the capture argument prevents callback
  5975. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5976. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5977. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5978. @example
  5979. ```js
  5980. onPlay: function (type, state) {
  5981. // callback
  5982. }
  5983. // register event to all animation
  5984. animation.on('play', this.onPlay, this);
  5985. ```
  5986. */
  5987. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5988. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5989. on(type: string, callback: (type: string, state: cc.AnimationState) => void, target?: any, useCapture?: boolean): (type: string, state: cc.AnimationState) => void;
  5990. /**
  5991. !#en
  5992. Unregister animation event callback.
  5993. !#zh
  5994. 取消注册动画事件回调。
  5995. @param type A string representing the event type being removed.
  5996. @param callback The callback to remove.
  5997. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  5998. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  5999. If not specified, useCapture defaults to false. If a callback was registered twice,
  6000. one with capture and one without, each must be removed separately. Removal of a capturing callback
  6001. does not affect a non-capturing version of the same listener, and vice versa.
  6002. @example
  6003. ```js
  6004. // unregister event to all animation
  6005. animation.off('play', this.onPlay, this);
  6006. ```
  6007. */
  6008. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  6009. /**
  6010. !#en Checks whether the EventTarget object has any callback registered for a specific type of event.
  6011. !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。
  6012. @param type The type of event.
  6013. */
  6014. hasEventListener(type: string): boolean;
  6015. /**
  6016. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  6017. This is not for removing all listeners in the current event target,
  6018. and this is not for removing all listeners the target parameter have registered.
  6019. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  6020. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  6021. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  6022. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  6023. @param target The target to be searched for all related listeners
  6024. */
  6025. targetOff(target: any): void;
  6026. /**
  6027. !#en
  6028. Register an callback of a specific event type on the EventTarget,
  6029. the callback will remove itself after the first time it is triggered.
  6030. !#zh
  6031. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  6032. @param type A string representing the event type to listen for.
  6033. @param callback The callback that will be invoked when the event is dispatched.
  6034. The callback is ignored if it is a duplicate (the callbacks are unique).
  6035. @param target The target (this object) to invoke the callback, can be null
  6036. @example
  6037. ```js
  6038. eventTarget.once('fire', function () {
  6039. cc.log("this is the callback and will be invoked only once");
  6040. }, node);
  6041. ```
  6042. */
  6043. once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
  6044. /**
  6045. !#en
  6046. Send an event with the event object.
  6047. !#zh
  6048. 通过事件对象派发事件
  6049. @param event event
  6050. */
  6051. dispatchEvent(event: Event): void;
  6052. /**
  6053. !#en
  6054. Destroy all callbackInfos.
  6055. !#zh
  6056. 销毁记录的事件
  6057. */
  6058. clear(): void;
  6059. }
  6060. /** !#en Audio Source.
  6061. !#zh 音频源组件,能对音频剪辑。 */
  6062. export class AudioSource extends Component {
  6063. /** !#en
  6064. Is the audio source playing (Read Only). <br/>
  6065. Note: isPlaying is not supported for Native platforms.
  6066. !#zh
  6067. 该音频剪辑是否正播放(只读)。<br/>
  6068. 注意:Native 平台暂时不支持 isPlaying。 */
  6069. isPlaying: boolean;
  6070. /** !#en The clip of the audio source to play.
  6071. !#zh 要播放的音频剪辑。 */
  6072. clip: AudioClip;
  6073. /** !#en The volume of the audio source.
  6074. !#zh 音频源的音量(0.0 ~ 1.0)。 */
  6075. volume: number;
  6076. /** !#en Is the audio source mute?
  6077. !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */
  6078. mute: boolean;
  6079. /** !#en Is the audio source looping?
  6080. !#zh 音频源是否循环播放? */
  6081. loop: boolean;
  6082. /** !#en If set to true, the audio source will automatically start playing on onEnable.
  6083. !#zh 如果设置为 true,音频源将在 onEnable 时自动播放。 */
  6084. playOnLoad: boolean;
  6085. /** !#en If set to true and AudioClip is a deferred load resource, the component will preload AudioClip in the onLoad phase.
  6086. !#zh 如果设置为 true 且 AudioClip 为延迟加载资源,组件将在 onLoad 阶段预加载 AudioClip。 */
  6087. preload: boolean;
  6088. /**
  6089. !#en Plays the clip.
  6090. !#zh 播放音频剪辑。
  6091. */
  6092. play(): void;
  6093. /**
  6094. !#en Stops the clip.
  6095. !#zh 停止当前音频剪辑。
  6096. */
  6097. stop(): void;
  6098. /**
  6099. !#en Pause the clip.
  6100. !#zh 暂停当前音频剪辑。
  6101. */
  6102. pause(): void;
  6103. /**
  6104. !#en Resume the clip.
  6105. !#zh 恢复播放。
  6106. */
  6107. resume(): void;
  6108. /**
  6109. !#en Rewind playing music.
  6110. !#zh 从头开始播放。
  6111. */
  6112. rewind(): void;
  6113. /**
  6114. !#en Get current time
  6115. !#zh 获取当前的播放时间
  6116. */
  6117. getCurrentTime(): number;
  6118. /**
  6119. !#en Set current time
  6120. !#zh 设置当前的播放时间
  6121. @param time time
  6122. */
  6123. setCurrentTime(time: number): number;
  6124. /**
  6125. !#en Get audio duration
  6126. !#zh 获取当前音频的长度
  6127. */
  6128. getDuration(): number;
  6129. }
  6130. /** !#en
  6131. 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>
  6132. This component does not have any API interface and can be added directly to the scene to take effect.
  6133. !#zh
  6134. 该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。<br>
  6135. 该组件没有任何 API 接口,直接添加到场景即可生效。 */
  6136. export class BlockInputEvents extends Component {
  6137. }
  6138. /** !#en
  6139. Button component. Can be pressed or clicked. Button has 4 Transition types:
  6140. - Button.Transition.NONE // Button will do nothing
  6141. - Button.Transition.COLOR // Button will change target's color
  6142. - Button.Transition.SPRITE // Button will change target Sprite's sprite
  6143. - Button.Transition.SCALE // Button will change target node's scale
  6144. The button can bind events (but you must be on the button's node to bind events).<br/>
  6145. The following events can be triggered on all platforms.
  6146. - cc.Node.EventType.TOUCH_START // Press
  6147. - cc.Node.EventType.TOUCH_MOVE // After pressing and moving
  6148. - cc.Node.EventType.TOUCH_END // After pressing and releasing
  6149. - cc.Node.EventType.TOUCH_CANCEL // Press to cancel
  6150. The following events are only triggered on the PC platform:
  6151. - cc.Node.EventType.MOUSE_DOWN
  6152. - cc.Node.EventType.MOUSE_MOVE
  6153. - cc.Node.EventType.MOUSE_ENTER
  6154. - cc.Node.EventType.MOUSE_LEAVE
  6155. - cc.Node.EventType.MOUSE_UP
  6156. - cc.Node.EventType.MOUSE_WHEEL
  6157. User can get the current clicked node with 'event.target' from event object which is passed as parameter in the callback function of click event.
  6158. !#zh
  6159. 按钮组件。可以被按下,或者点击。
  6160. 按钮可以通过修改 Transition 来设置按钮状态过渡的方式:
  6161. - Button.Transition.NONE // 不做任何过渡
  6162. - Button.Transition.COLOR // 进行颜色之间过渡
  6163. - Button.Transition.SPRITE // 进行精灵之间过渡
  6164. - Button.Transition.SCALE // 进行缩放过渡
  6165. 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):<br/>
  6166. 以下事件可以在全平台上都触发:
  6167. - cc.Node.EventType.TOUCH_START // 按下时事件
  6168. - cc.Node.EventType.TOUCH_MOVE // 按住移动后事件
  6169. - cc.Node.EventType.TOUCH_END // 按下后松开后事件
  6170. - cc.Node.EventType.TOUCH_CANCEL // 按下取消事件
  6171. 以下事件只在 PC 平台上触发:
  6172. - cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件
  6173. - cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件
  6174. - cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件
  6175. - cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件
  6176. - cc.Node.EventType.MOUSE_UP // 鼠标松开事件
  6177. - cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件
  6178. 用户可以通过获取 __点击事件__ 回调函数的参数 event 的 target 属性获取当前点击对象。 */
  6179. export class Button extends Component implements GraySpriteState {
  6180. /** !#en
  6181. Whether the Button is disabled.
  6182. If true, the Button will trigger event and do transition.
  6183. !#zh
  6184. 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */
  6185. interactable: boolean;
  6186. /** !#en When this flag is true, Button target sprite will turn gray when interactable is false.
  6187. !#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */
  6188. enableAutoGrayEffect: boolean;
  6189. /** !#en Transition type
  6190. !#zh 按钮状态改变时过渡方式。 */
  6191. transition: Button.Transition;
  6192. /** !#en Normal state color.
  6193. !#zh 普通状态下按钮所显示的颜色。 */
  6194. normalColor: Color;
  6195. /** !#en Pressed state color
  6196. !#zh 按下状态时按钮所显示的颜色。 */
  6197. pressedColor: Color;
  6198. /** !#en Hover state color
  6199. !#zh 悬停状态下按钮所显示的颜色。 */
  6200. hoverColor: Color;
  6201. /** !#en Disabled state color
  6202. !#zh 禁用状态下按钮所显示的颜色。 */
  6203. disabledColor: Color;
  6204. /** !#en Color and Scale transition duration
  6205. !#zh 颜色过渡和缩放过渡时所需时间 */
  6206. duration: number;
  6207. /** !#en When user press the button, the button will zoom to a scale.
  6208. The final scale of the button equals (button original scale * zoomScale)
  6209. !#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */
  6210. zoomScale: number;
  6211. /** !#en Normal state sprite
  6212. !#zh 普通状态下按钮所显示的 Sprite 。 */
  6213. normalSprite: SpriteFrame;
  6214. /** !#en Pressed state sprite
  6215. !#zh 按下状态时按钮所显示的 Sprite 。 */
  6216. pressedSprite: SpriteFrame;
  6217. /** !#en Hover state sprite
  6218. !#zh 悬停状态下按钮所显示的 Sprite 。 */
  6219. hoverSprite: SpriteFrame;
  6220. /** !#en Disabled state sprite
  6221. !#zh 禁用状态下按钮所显示的 Sprite 。 */
  6222. disabledSprite: SpriteFrame;
  6223. /** !#en
  6224. Transition target.
  6225. When Button state changed:
  6226. If Transition type is Button.Transition.NONE, Button will do nothing
  6227. If Transition type is Button.Transition.COLOR, Button will change target's color
  6228. If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
  6229. !#zh
  6230. 需要过渡的目标。
  6231. 当前按钮状态改变规则:
  6232. -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。
  6233. -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。
  6234. -如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */
  6235. target: Node;
  6236. /** !#en If Button is clicked, it will trigger event's handler
  6237. !#zh 按钮的点击事件列表。 */
  6238. clickEvents: Component.EventHandler[];
  6239. /** !#en The normal material.
  6240. !#zh 正常状态的材质。 */
  6241. normalMaterial: Material;
  6242. /** !#en The gray material.
  6243. !#zh 置灰状态的材质。 */
  6244. grayMaterial: Material;
  6245. }
  6246. /** !#zh 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。<br>
  6247. 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */
  6248. export class Canvas extends Component {
  6249. /** !#en Current active canvas, the scene should only have one active canvas at the same time.
  6250. !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */
  6251. static instance: Canvas;
  6252. /** !#en The desigin resolution for current scene.
  6253. !#zh 当前场景设计分辨率。 */
  6254. designResolution: Size;
  6255. /** !#en TODO
  6256. !#zh: 是否优先将设计分辨率高度撑满视图高度。 */
  6257. fitHeight: boolean;
  6258. /** !#en TODO
  6259. !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */
  6260. fitWidth: boolean;
  6261. }
  6262. /** !#en
  6263. Base class for everything attached to Node(Entity).<br/>
  6264. <br/>
  6265. NOTE: Not allowed to use construction parameters for Component's subclasses,
  6266. because Component is created by the engine.
  6267. !#zh
  6268. 所有附加到节点的基类。<br/>
  6269. <br/>
  6270. 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */
  6271. export class Component extends Object {
  6272. /** !#en The node this component is attached to. A component is always attached to a node.
  6273. !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */
  6274. node: Node;
  6275. /** !#en The uuid for editor.
  6276. !#zh 组件的 uuid,用于编辑器。 */
  6277. uuid: string;
  6278. /** !#en indicates whether this component is enabled or not.
  6279. !#zh 表示该组件自身是否启用。 */
  6280. enabled: boolean;
  6281. /** !#en indicates whether this component is enabled and its node is also active in the hierarchy.
  6282. !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */
  6283. enabledInHierarchy: boolean;
  6284. /** !#en Returns a value which used to indicate the onLoad get called or not.
  6285. !#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */
  6286. _isOnLoadCalled: number;
  6287. /**
  6288. !#en Update is called every frame, if the Component is enabled.<br/>
  6289. This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
  6290. !#zh 如果该组件启用,则每帧调用 update。<br/>
  6291. 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
  6292. @param dt the delta time in seconds it took to complete the last frame
  6293. */
  6294. protected update(dt: number): void;
  6295. /**
  6296. !#en LateUpdate is called every frame, if the Component is enabled.<br/>
  6297. This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
  6298. !#zh 如果该组件启用,则每帧调用 LateUpdate。<br/>
  6299. 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
  6300. @param dt the delta time in seconds it took to complete the last frame
  6301. */
  6302. protected lateUpdate(dt: number): void;
  6303. /**
  6304. !#en
  6305. When attaching to an active node or its node first activated.
  6306. onLoad is always called before any start functions, this allows you to order initialization of scripts.<br/>
  6307. This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
  6308. !#zh
  6309. 当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。<br/>
  6310. 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
  6311. */
  6312. protected onLoad(): void;
  6313. /**
  6314. !#en
  6315. Called before all scripts' update if the Component is enabled the first time.
  6316. Usually used to initialize some logic which need to be called after all components' `onload` methods called.<br/>
  6317. This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
  6318. !#zh
  6319. 如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。<br/>
  6320. 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
  6321. */
  6322. protected start(): void;
  6323. /**
  6324. !#en Called when this component becomes enabled and its node is active.<br/>
  6325. This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
  6326. !#zh 当该组件被启用,并且它的节点也激活时。<br/>
  6327. 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
  6328. */
  6329. protected onEnable(): void;
  6330. /**
  6331. !#en Called when this component becomes disabled or its node becomes inactive.<br/>
  6332. This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
  6333. !#zh 当该组件被禁用或节点变为无效时调用。<br/>
  6334. 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
  6335. */
  6336. protected onDisable(): void;
  6337. /**
  6338. !#en Called when this component will be destroyed.<br/>
  6339. This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
  6340. !#zh 当该组件被销毁时调用<br/>
  6341. 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
  6342. */
  6343. protected onDestroy(): void;
  6344. protected onFocusInEditor(): void;
  6345. protected onLostFocusInEditor(): void;
  6346. /**
  6347. !#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.
  6348. !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。
  6349. */
  6350. protected resetInEditor(): void;
  6351. /**
  6352. !#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
  6353. !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。
  6354. @param typeOrClassName the constructor or the class name of the component to add
  6355. @example
  6356. ```js
  6357. var sprite = node.addComponent(cc.Sprite);
  6358. var test = node.addComponent("Test");
  6359. ```
  6360. */
  6361. addComponent<T extends Component>(type: {new(): T}): T;
  6362. addComponent(className: string): any;
  6363. /**
  6364. !#en
  6365. Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
  6366. You can also get component in the node by passing in the name of the script.
  6367. !#zh
  6368. 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。<br/>
  6369. 传入参数也可以是脚本的名称。
  6370. @param typeOrClassName typeOrClassName
  6371. @example
  6372. ```js
  6373. // get sprite component.
  6374. var sprite = node.getComponent(cc.Sprite);
  6375. // get custom test calss.
  6376. var test = node.getComponent("Test");
  6377. ```
  6378. */
  6379. getComponent<T extends Component>(type: {prototype: T}): T;
  6380. getComponent(className: string): any;
  6381. /**
  6382. !#en Returns all components of supplied Type in the node.
  6383. !#zh 返回节点上指定类型的所有组件。
  6384. @param typeOrClassName typeOrClassName
  6385. @example
  6386. ```js
  6387. var sprites = node.getComponents(cc.Sprite);
  6388. var tests = node.getComponents("Test");
  6389. ```
  6390. */
  6391. getComponents<T extends Component>(type: {prototype: T}): T[];
  6392. getComponents(className: string): any[];
  6393. /**
  6394. !#en Returns the component of supplied type in any of its children using depth first search.
  6395. !#zh 递归查找所有子节点中第一个匹配指定类型的组件。
  6396. @param typeOrClassName typeOrClassName
  6397. @example
  6398. ```js
  6399. var sprite = node.getComponentInChildren(cc.Sprite);
  6400. var Test = node.getComponentInChildren("Test");
  6401. ```
  6402. */
  6403. getComponentInChildren<T extends Component>(type: {prototype: T}): T;
  6404. getComponentInChildren(className: string): any;
  6405. /**
  6406. !#en Returns the components of supplied type in self or any of its children using depth first search.
  6407. !#zh 递归查找自身或所有子节点中指定类型的组件
  6408. @param typeOrClassName typeOrClassName
  6409. @example
  6410. ```js
  6411. var sprites = node.getComponentsInChildren(cc.Sprite);
  6412. var tests = node.getComponentsInChildren("Test");
  6413. ```
  6414. */
  6415. getComponentsInChildren<T extends Component>(type: {prototype: T}): T[];
  6416. getComponentsInChildren(className: string): any[];
  6417. /**
  6418. !#en
  6419. If the component's bounding box is different from the node's, you can implement this method to supply
  6420. a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly.
  6421. !#zh
  6422. 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB),
  6423. 以便编辑器的场景视图可以正确地执行点选测试。
  6424. @param out_rect the Rect to receive the bounding box
  6425. */
  6426. _getLocalBounds(out_rect: Rect): void;
  6427. /**
  6428. !#en
  6429. onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs
  6430. an undo operation on this component.<br/>
  6431. <br/>
  6432. If the component contains the "internal state", short for "temporary member variables which not included<br/>
  6433. in its CCClass properties", then you may need to implement this function.<br/>
  6434. <br/>
  6435. The editor will call the getset accessors of your component to record/restore the component's state<br/>
  6436. for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement<br/>
  6437. this function to manually synchronize your component's "internal states" with its public properties.<br/>
  6438. Once you implement this function, all the getset accessors of your component will not be called when<br/>
  6439. the user performs an undo/redo operation. Which means that only the properties with default value<br/>
  6440. will be recorded or restored by editor.<br/>
  6441. <br/>
  6442. Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need<br/>
  6443. to support the reset menu, you should manually synchronize your component's "internal states" with its<br/>
  6444. properties in this function. Once you implement this function, all the getset accessors of your component<br/>
  6445. will not be called during reset operation. Which means that only the properties with default value<br/>
  6446. will be reset by editor.
  6447. This function is only called in editor mode.
  6448. !#zh
  6449. onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。<br/>
  6450. <br/>
  6451. 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。<br/>
  6452. <br/>
  6453. 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。然而,在极端的情况下,它可能无法良好运作。<br/>
  6454. 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。这意味着仅仅指定了默认值的属性将被编辑器记录和还原。<br/>
  6455. <br/>
  6456. 同样的,编辑可能无法在极端情况下正确地重置您的组件。如果你需要支持组件重置菜单,则需要在该方法中手工同步组件属性到“内部状态”。一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。这意味着仅仅指定了默认值的属性将被编辑器重置。
  6457. <br/>
  6458. 此方法仅在编辑器下会被调用。
  6459. */
  6460. onRestore(): void;
  6461. /**
  6462. !#en
  6463. Schedules a custom selector.<br/>
  6464. If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.
  6465. !#zh
  6466. 调度一个自定义的回调函数。<br/>
  6467. 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。
  6468. @param callback The callback function
  6469. @param interval Tick interval in seconds. 0 means tick every frame.
  6470. @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely.
  6471. @param delay The amount of time that the first tick will wait before execution. Unit: s
  6472. @example
  6473. ```js
  6474. var timeCallback = function (dt) {
  6475. cc.log("time: " + dt);
  6476. }
  6477. this.schedule(timeCallback, 1);
  6478. ```
  6479. */
  6480. schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void;
  6481. /**
  6482. !#en Schedules a callback function that runs only once, with a delay of 0 or larger.
  6483. !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。
  6484. @param callback A function wrapped as a selector
  6485. @param delay The amount of time that the first tick will wait before execution. Unit: s
  6486. @example
  6487. ```js
  6488. var timeCallback = function (dt) {
  6489. cc.log("time: " + dt);
  6490. }
  6491. this.scheduleOnce(timeCallback, 2);
  6492. ```
  6493. */
  6494. scheduleOnce(callback: Function, delay?: number): void;
  6495. /**
  6496. !#en Unschedules a custom callback function.
  6497. !#zh 取消调度一个自定义的回调函数。
  6498. @param callback_fn A function wrapped as a selector
  6499. @example
  6500. ```js
  6501. this.unschedule(_callback);
  6502. ```
  6503. */
  6504. unschedule(callback_fn: Function): void;
  6505. /**
  6506. !#en
  6507. unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.<br/>
  6508. Actions are not affected by this method.
  6509. !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 `update` 回调函数。动作不受此方法影响。
  6510. @example
  6511. ```js
  6512. this.unscheduleAllCallbacks();
  6513. ```
  6514. */
  6515. unscheduleAllCallbacks(): void;
  6516. }
  6517. /** !#en The Label Component.
  6518. !#zh 文字标签组件 */
  6519. export class Label extends RenderComponent {
  6520. /** !#en Content string of label.
  6521. !#zh 标签显示的文本内容。 */
  6522. string: string;
  6523. /** !#en Horizontal Alignment of label.
  6524. !#zh 文本内容的水平对齐方式。 */
  6525. horizontalAlign: Label.HorizontalAlign;
  6526. /** !#en Vertical Alignment of label.
  6527. !#zh 文本内容的垂直对齐方式。 */
  6528. verticalAlign: Label.VerticalAlign;
  6529. /** !#en The actual rendering font size in shrink mode
  6530. !#zh SHRINK 模式下面文本实际渲染的字体大小 */
  6531. actualFontSize: number;
  6532. /** !#en Font size of label.
  6533. !#zh 文本字体大小。 */
  6534. fontSize: number;
  6535. /** !#en Font family of label, only take effect when useSystemFont property is true.
  6536. !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */
  6537. fontFamily: string;
  6538. /** !#en Line Height of label.
  6539. !#zh 文本行高。 */
  6540. lineHeight: number;
  6541. /** !#en Overflow of label.
  6542. !#zh 文字显示超出范围时的处理方式。 */
  6543. overflow: Label.Overflow;
  6544. /** !#en Whether auto wrap label when string width is large than label width.
  6545. !#zh 是否自动换行。 */
  6546. enableWrapText: boolean;
  6547. /** !#en The font of label.
  6548. !#zh 文本字体。 */
  6549. font: Font;
  6550. /** !#en Whether use system font name or not.
  6551. !#zh 是否使用系统字体。 */
  6552. useSystemFont: boolean;
  6553. /** !#en The spacing of the x axis between characters, only take Effect when using bitmap fonts.
  6554. !#zh 文字之间 x 轴的间距,仅在使用位图字体时生效。 */
  6555. spacingX: number;
  6556. /** !#en The cache mode of label. This mode only supports system fonts.
  6557. !#zh 文本缓存模式, 该模式只支持系统字体。 */
  6558. cacheMode: Label.CacheMode;
  6559. /** !#en Whether enable bold.
  6560. !#zh 是否启用黑体。 */
  6561. enableBold: boolean;
  6562. /** !#en Whether enable italic.
  6563. !#zh 是否启用斜体。 */
  6564. enableItalic: boolean;
  6565. /** !#en Whether enable underline.
  6566. !#zh 是否启用下划线。 */
  6567. enableUnderline: boolean;
  6568. /** !#en The height of underline.
  6569. !#zh 下划线高度。 */
  6570. underlineHeight: number;
  6571. /**
  6572. !#zh 需要保证当前场景中没有使用CHAR缓存的Label才可以清除,否则已渲染的文字没有重新绘制会不显示
  6573. !#en It can be cleared that need to ensure there is not use the CHAR cache in the current scene. Otherwise, the rendered text will not be displayed without repainting.
  6574. */
  6575. static clearCharCache(): void;
  6576. }
  6577. /** !#en Outline effect used to change the display, only for system fonts or TTF fonts
  6578. !#zh 描边效果组件,用于字体描边,只能用于系统字体 */
  6579. export class LabelOutline extends Component {
  6580. /** !#en outline color
  6581. !#zh 改变描边的颜色 */
  6582. color: Color;
  6583. /** !#en Change the outline width
  6584. !#zh 改变描边的宽度 */
  6585. width: number;
  6586. }
  6587. /** !#en Shadow effect for Label component, only for system fonts or TTF fonts
  6588. !#zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体 */
  6589. export class LabelShadow extends Component {
  6590. /** !#en The shadow color
  6591. !#zh 阴影的颜色 */
  6592. color: Color;
  6593. /** !#en Offset between font and shadow
  6594. !#zh 字体与阴影的偏移 */
  6595. offset: Vec2;
  6596. /** !#en A non-negative float specifying the level of shadow blur
  6597. !#zh 阴影的模糊程度 */
  6598. blur: number;
  6599. }
  6600. /** !#en
  6601. The Layout is a container component, use it to arrange child elements easily.<br>
  6602. Note:<br>
  6603. 1.Scaling and rotation of child nodes are not considered.<br>
  6604. 2.After setting the Layout, the results need to be updated until the next frame,
  6605. unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。
  6606. !#zh
  6607. Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。<br>
  6608. 注意:<br>
  6609. 1.不会考虑子节点的缩放和旋转。<br>
  6610. 2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */
  6611. export class Layout extends Component {
  6612. /** !#en The layout type.
  6613. !#zh 布局类型 */
  6614. type: Layout.Type;
  6615. /** !#en
  6616. The are three resize modes for Layout.
  6617. None, resize Container and resize children.
  6618. !#zh 缩放模式 */
  6619. resizeMode: Layout.ResizeMode;
  6620. /** !#en The cell size for grid layout.
  6621. !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */
  6622. cellSize: Size;
  6623. /** !#en
  6624. The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first,
  6625. and then break line on demand. Choose vertical if you want to layout vertically at first .
  6626. !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */
  6627. startAxis: Layout.AxisDirection;
  6628. /** !#en The left padding of layout, it only effect the layout in one direction.
  6629. !#zh 容器内左边距,只会在一个布局方向上生效。 */
  6630. paddingLeft: number;
  6631. /** !#en The right padding of layout, it only effect the layout in one direction.
  6632. !#zh 容器内右边距,只会在一个布局方向上生效。 */
  6633. paddingRight: number;
  6634. /** !#en The top padding of layout, it only effect the layout in one direction.
  6635. !#zh 容器内上边距,只会在一个布局方向上生效。 */
  6636. paddingTop: number;
  6637. /** !#en The bottom padding of layout, it only effect the layout in one direction.
  6638. !#zh 容器内下边距,只会在一个布局方向上生效。 */
  6639. paddingBottom: number;
  6640. /** !#en The distance in x-axis between each element in layout.
  6641. !#zh 子节点之间的水平间距。 */
  6642. spacingX: number;
  6643. /** !#en The distance in y-axis between each element in layout.
  6644. !#zh 子节点之间的垂直间距。 */
  6645. spacingY: number;
  6646. /** !#en
  6647. Only take effect in Vertical layout mode.
  6648. This option changes the start element's positioning.
  6649. !#zh 垂直排列子节点的方向。 */
  6650. verticalDirection: Layout.VerticalDirection;
  6651. /** !#en
  6652. Only take effect in Horizontal layout mode.
  6653. This option changes the start element's positioning.
  6654. !#zh 水平排列子节点的方向。 */
  6655. horizontalDirection: Layout.HorizontalDirection;
  6656. /** !#en Adjust the layout if the children scaled.
  6657. !#zh 子节点缩放比例是否影响布局。 */
  6658. affectedByScale: boolean;
  6659. /**
  6660. !#en Perform the layout update
  6661. !#zh 立即执行更新布局
  6662. @example
  6663. ```js
  6664. layout.type = cc.Layout.HORIZONTAL;
  6665. layout.node.addChild(childNode);
  6666. cc.log(childNode.x); // not yet changed
  6667. layout.updateLayout();
  6668. cc.log(childNode.x); // changed
  6669. ```
  6670. */
  6671. updateLayout(): void;
  6672. }
  6673. /** !#en
  6674. cc.MotionStreak manages a Ribbon based on it's motion in absolute space. <br/>
  6675. You construct it with a fadeTime, minimum segment size, texture path, texture <br/>
  6676. length and color. The fadeTime controls how long it takes each vertex in <br/>
  6677. the streak to fade out, the minimum segment size it how many pixels the <br/>
  6678. streak will move before adding a new ribbon segment, and the texture <br/>
  6679. length is the how many pixels the texture is stretched across. The texture <br/>
  6680. is vertically aligned along the streak segment.
  6681. !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */
  6682. export class MotionStreak extends Component implements BlendFunc {
  6683. /** !#en
  6684. !#zh 在编辑器模式下预览拖尾效果。 */
  6685. preview: boolean;
  6686. /** !#en The fade time to fade.
  6687. !#zh 拖尾的渐隐时间,以秒为单位。 */
  6688. fadeTime: number;
  6689. /** !#en The minimum segment size.
  6690. !#zh 拖尾之间最小距离。 */
  6691. minSeg: number;
  6692. /** !#en The stroke's width.
  6693. !#zh 拖尾的宽度。 */
  6694. stroke: number;
  6695. /** !#en The texture of the MotionStreak.
  6696. !#zh 拖尾的贴图。 */
  6697. texture: Texture2D;
  6698. /** !#en The color of the MotionStreak.
  6699. !#zh 拖尾的颜色 */
  6700. color: Color;
  6701. /** !#en The fast Mode.
  6702. !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */
  6703. fastMode: boolean;
  6704. /**
  6705. !#en Remove all living segments of the ribbon.
  6706. !#zh 删除当前所有的拖尾片段。
  6707. @example
  6708. ```js
  6709. // Remove all living segments of the ribbon.
  6710. myMotionStreak.reset();
  6711. ```
  6712. */
  6713. reset(): void;
  6714. /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost.
  6715. !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */
  6716. srcBlendFactor: macro.BlendFactor;
  6717. /** !#en specify the destination Blend Factor.
  6718. !#zh 指定目标的混合模式 */
  6719. dstBlendFactor: macro.BlendFactor;
  6720. }
  6721. /** !#en The Mask Component
  6722. !#zh 遮罩组件 */
  6723. export class Mask extends RenderComponent {
  6724. /** !#en The mask type.
  6725. !#zh 遮罩类型 */
  6726. type: Mask.Type;
  6727. /** !#en The mask image
  6728. !#zh 遮罩所需要的贴图 */
  6729. spriteFrame: SpriteFrame;
  6730. /** !#en
  6731. The alpha threshold.(Not supported Canvas Mode) <br/>
  6732. The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold. <br/>
  6733. Should be a float between 0 and 1. <br/>
  6734. This default to 0.1.
  6735. When it's set to 1, the stencil will discard all pixels, nothing will be shown.
  6736. !#zh
  6737. Alpha 阈值(不支持 Canvas 模式)<br/>
  6738. 只有当模板的像素的 alpha 大于等于 alphaThreshold 时,才会绘制内容。<br/>
  6739. 该数值 0 ~ 1 之间的浮点数,默认值为 0.1
  6740. 当被设置为 1 时,会丢弃所有蒙版像素,所以不会显示任何内容 */
  6741. alphaThreshold: number;
  6742. /** !#en Reverse mask (Not supported Canvas Mode)
  6743. !#zh 反向遮罩(不支持 Canvas 模式) */
  6744. inverted: boolean;
  6745. /** TODO: remove segments, not supported by graphics
  6746. !#en The segements for ellipse mask.
  6747. !#zh 椭圆遮罩的曲线细分数 */
  6748. segements: number;
  6749. }
  6750. /** !#en The PageView control
  6751. !#zh 页面视图组件 */
  6752. export class PageView extends ScrollView {
  6753. /** !#en Specify the size type of each page in PageView.
  6754. !#zh 页面视图中每个页面大小类型 */
  6755. sizeMode: PageView.SizeMode;
  6756. /** !#en The page view direction
  6757. !#zh 页面视图滚动类型 */
  6758. direction: PageView.Direction;
  6759. /** !#en
  6760. The scroll threshold value, when drag exceeds this value,
  6761. release the next page will automatically scroll, less than the restore
  6762. !#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */
  6763. scrollThreshold: number;
  6764. /** !#en
  6765. Auto page turning velocity threshold. When users swipe the PageView quickly,
  6766. it will calculate a velocity based on the scroll distance and time,
  6767. if the calculated velocity is larger than the threshold, then it will trigger page turning.
  6768. !#zh
  6769. 快速滑动翻页临界值。
  6770. 当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值,
  6771. 该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */
  6772. autoPageTurningThreshold: number;
  6773. /** !#en Change the PageTurning event timing of PageView.
  6774. !#zh 设置 PageView PageTurning 事件的发送时机。 */
  6775. pageTurningEventTiming: number;
  6776. /** !#en The Page View Indicator
  6777. !#zh 页面视图指示器组件 */
  6778. indicator: PageViewIndicator;
  6779. /** !#en The time required to turn over a page. unit: second
  6780. !#zh 每个页面翻页时所需时间。单位:秒 */
  6781. pageTurningSpeed: number;
  6782. /** !#en PageView events callback
  6783. !#zh 滚动视图的事件回调函数 */
  6784. pageEvents: Component.EventHandler[];
  6785. /**
  6786. !#en Returns current page index
  6787. !#zh 返回当前页面索引
  6788. */
  6789. getCurrentPageIndex(): number;
  6790. /**
  6791. !#en Set current page index
  6792. !#zh 设置当前页面索引
  6793. @param index index
  6794. */
  6795. setCurrentPageIndex(index: number): void;
  6796. /**
  6797. !#en Returns all pages of pageview
  6798. !#zh 返回视图中的所有页面
  6799. */
  6800. getPages(): Node[];
  6801. /**
  6802. !#en At the end of the current page view to insert a new view
  6803. !#zh 在当前页面视图的尾部插入一个新视图
  6804. @param page page
  6805. */
  6806. addPage(page: Node): void;
  6807. /**
  6808. !#en Inserts a page in the specified location
  6809. !#zh 将页面插入指定位置中
  6810. @param page page
  6811. @param index index
  6812. */
  6813. insertPage(page: Node, index: number): void;
  6814. /**
  6815. !#en Removes a page from PageView.
  6816. !#zh 移除指定页面
  6817. @param page page
  6818. */
  6819. removePage(page: Node): void;
  6820. /**
  6821. !#en Removes a page at index of PageView.
  6822. !#zh 移除指定下标的页面
  6823. @param index index
  6824. */
  6825. removePageAtIndex(index: number): void;
  6826. /**
  6827. !#en Removes all pages from PageView
  6828. !#zh 移除所有页面
  6829. */
  6830. removeAllPages(): void;
  6831. /**
  6832. !#en Scroll PageView to index.
  6833. !#zh 滚动到指定页面
  6834. @param idx index of page.
  6835. @param timeInSecond scrolling time
  6836. */
  6837. scrollToPage(idx: number, timeInSecond: number): void;
  6838. }
  6839. /** !#en The Page View Indicator Component
  6840. !#zh 页面视图每页标记组件 */
  6841. export class PageViewIndicator extends Component {
  6842. /** !#en The spriteFrame for each element.
  6843. !#zh 每个页面标记显示的图片 */
  6844. spriteFrame: SpriteFrame;
  6845. /** !#en The location direction of PageViewIndicator.
  6846. !#zh 页面标记摆放方向 */
  6847. direction: PageViewIndicator.Direction;
  6848. /** !#en The cellSize for each element.
  6849. !#zh 每个页面标记的大小 */
  6850. cellSize: Size;
  6851. /** !#en The distance between each element.
  6852. !#zh 每个页面标记之间的边距 */
  6853. spacing: number;
  6854. /**
  6855. !#en Set Page View
  6856. !#zh 设置页面视图
  6857. @param target target
  6858. */
  6859. setPageView(target: PageView): void;
  6860. }
  6861. /** !#en
  6862. Visual indicator of progress in some operation.
  6863. Displays a bar to the user representing how far the operation has progressed.
  6864. !#zh
  6865. 进度条组件,可用于显示加载资源时的进度。 */
  6866. export class ProgressBar extends Component {
  6867. /** !#en The targeted Sprite which will be changed progressively.
  6868. !#zh 用来显示进度条比例的 Sprite 对象。 */
  6869. barSprite: Sprite;
  6870. /** !#en The progress mode, there are two modes supported now: horizontal and vertical.
  6871. !#zh 进度条的模式 */
  6872. mode: ProgressBar.Mode;
  6873. /** !#en The total width or height of the bar sprite.
  6874. !#zh 进度条实际的总长度 */
  6875. totalLength: number;
  6876. /** !#en The current progress of the bar sprite. The valid value is between 0-1.
  6877. !#zh 当前进度值,该数值的区间是 0-1 之间。 */
  6878. progress: number;
  6879. /** !#en Whether reverse the progress direction of the bar sprite.
  6880. !#zh 进度条是否进行反方向变化。 */
  6881. reverse: boolean;
  6882. }
  6883. /** !#en
  6884. Base class for components which supports rendering features.
  6885. !#zh
  6886. 所有支持渲染的组件的基类 */
  6887. export class RenderComponent extends Component {
  6888. /** !#en The materials used by this render component.
  6889. !#zh 渲染组件使用的材质。 */
  6890. sharedMaterials: Material[];
  6891. /**
  6892. !#en Get the material by index.
  6893. !#zh 根据指定索引获取材质
  6894. @param index index
  6895. */
  6896. getMaterial(index: number): MaterialVariant;
  6897. /**
  6898. !#en Gets all the materials.
  6899. !#zh 获取所有材质。
  6900. */
  6901. getMaterials(): MaterialVariant[];
  6902. /**
  6903. !#en Set the material by index.
  6904. !#zh 根据指定索引设置材质
  6905. @param index index
  6906. @param material material
  6907. */
  6908. setMaterial(index: number, material: Material): Material;
  6909. }
  6910. /** !#en The RichText Component.
  6911. !#zh 富文本组件 */
  6912. export class RichText extends Component {
  6913. /** !#en Content string of RichText.
  6914. !#zh 富文本显示的文本内容。 */
  6915. string: string;
  6916. /** !#en Horizontal Alignment of each line in RichText.
  6917. !#zh 文本内容的水平对齐方式。 */
  6918. horizontalAlign: macro.TextAlignment;
  6919. /** !#en Font size of RichText.
  6920. !#zh 富文本字体大小。 */
  6921. fontSize: number;
  6922. /** !#en Custom System font of RichText
  6923. !#zh 富文本定制系统字体 */
  6924. fontFamily: string;
  6925. /** !#en Custom TTF font of RichText
  6926. !#zh 富文本定制字体 */
  6927. font: TTFFont;
  6928. /** !#en Whether use system font name or not.
  6929. !#zh 是否使用系统字体。 */
  6930. useSystemFont: boolean;
  6931. /** !#en The cache mode of label. This mode only supports system fonts.
  6932. !#zh 文本缓存模式, 该模式只支持系统字体。 */
  6933. cacheMode: Label.CacheMode;
  6934. /** !#en The maximize width of the RichText
  6935. !#zh 富文本的最大宽度 */
  6936. maxWidth: number;
  6937. /** !#en Line Height of RichText.
  6938. !#zh 富文本行高。 */
  6939. lineHeight: number;
  6940. /** !#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.
  6941. !#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */
  6942. imageAtlas: SpriteAtlas;
  6943. /** !#en
  6944. Once checked, the RichText will block all input events (mouse and touch) within
  6945. the bounding box of the node, preventing the input from penetrating into the underlying node.
  6946. !#zh
  6947. 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */
  6948. handleTouchEvent: boolean;
  6949. }
  6950. /** !#en
  6951. This component is used to adjust the layout of current node to respect the safe area of a notched mobile device such as the iPhone X.
  6952. It is typically used for the top node of the UI interaction area. For specific usage, refer to the official [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases).
  6953. The concept of safe area is to give you a fixed inner rectangle in which you can safely display content that will be drawn on screen.
  6954. You are strongly discouraged from providing controls outside of this area. But your screen background could embellish edges.
  6955. This component internally uses the API `cc.sys.getSafeAreaRect();` to obtain the safe area of the current iOS or Android device,
  6956. and implements the adaptation by using the Widget component and set anchor.
  6957. !#zh
  6958. 该组件会将所在节点的布局适配到 iPhone X 等异形屏手机的安全区域内,通常用于 UI 交互区域的顶层节点,具体用法可参考官方范例 [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases)。
  6959. 该组件内部通过 API `cc.sys.getSafeAreaRect();` 获取到当前 iOS 或 Android 设备的安全区域,并通过 Widget 组件实现适配。 */
  6960. export class SafeArea extends Component {
  6961. /**
  6962. !#en Adapt to safe area
  6963. !#zh 立即适配安全区域
  6964. @example
  6965. ```js
  6966. let safeArea = this.node.addComponent(cc.SafeArea);
  6967. safeArea.updateArea();
  6968. ```
  6969. */
  6970. updateArea(): void;
  6971. }
  6972. /** !#en
  6973. The Scrollbar control allows the user to scroll an image or other view that is too large to see completely
  6974. !#zh 滚动条组件 */
  6975. export class Scrollbar extends Component {
  6976. /** !#en The "handle" part of the scrollbar.
  6977. !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */
  6978. handle: Sprite;
  6979. /** !#en The direction of scrollbar.
  6980. !#zh ScrollBar 的滚动方向。 */
  6981. direction: Scrollbar.Direction;
  6982. /** !#en Whether enable auto hide or not.
  6983. !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */
  6984. enableAutoHide: boolean;
  6985. /** !#en
  6986. The time to hide scrollbar when scroll finished.
  6987. Note: This value is only useful when enableAutoHide is true.
  6988. !#zh
  6989. 没有滚动动作后经过多久会自动隐藏。
  6990. 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */
  6991. autoHideTime: number;
  6992. }
  6993. /** !#en
  6994. Layout container for a view hierarchy that can be scrolled by the user,
  6995. allowing it to be larger than the physical display.
  6996. !#zh
  6997. 滚动视图组件 */
  6998. export class ScrollView extends Component {
  6999. /** !#en This is a reference to the UI element to be scrolled.
  7000. !#zh 可滚动展示内容的节点。 */
  7001. content: Node;
  7002. /** !#en Enable horizontal scroll.
  7003. !#zh 是否开启水平滚动。 */
  7004. horizontal: boolean;
  7005. /** !#en Enable vertical scroll.
  7006. !#zh 是否开启垂直滚动。 */
  7007. vertical: boolean;
  7008. /** !#en When inertia is set, the content will continue to move when touch ended.
  7009. !#zh 是否开启滚动惯性。 */
  7010. inertia: boolean;
  7011. /** !#en
  7012. It determines how quickly the content stop moving. A value of 1 will stop the movement immediately.
  7013. A value of 0 will never stop the movement until it reaches to the boundary of scrollview.
  7014. !#zh
  7015. 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */
  7016. brake: number;
  7017. /** !#en When elastic is set, the content will be bounce back when move out of boundary.
  7018. !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */
  7019. elastic: boolean;
  7020. /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately.
  7021. !#zh 回弹持续的时间,0 表示将立即反弹。 */
  7022. bounceDuration: number;
  7023. /** !#en The horizontal scrollbar reference.
  7024. !#zh 水平滚动的 ScrollBar。 */
  7025. horizontalScrollBar: Scrollbar;
  7026. /** !#en The vertical scrollbar reference.
  7027. !#zh 垂直滚动的 ScrollBar。 */
  7028. verticalScrollBar: Scrollbar;
  7029. /** !#en Scrollview events callback
  7030. !#zh 滚动视图的事件回调函数 */
  7031. scrollEvents: Component.EventHandler[];
  7032. /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes
  7033. It's set to true by default.
  7034. !#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。
  7035. 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */
  7036. cancelInnerEvents: boolean;
  7037. /**
  7038. !#en Scroll the content to the bottom boundary of ScrollView.
  7039. !#zh 视图内容将在规定时间内滚动到视图底部。
  7040. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7041. the content will jump to the bottom boundary immediately.
  7042. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7043. @example
  7044. ```js
  7045. // Scroll to the bottom of the view.
  7046. scrollView.scrollToBottom(0.1);
  7047. ```
  7048. */
  7049. scrollToBottom(timeInSecond?: number, attenuated?: boolean): void;
  7050. /**
  7051. !#en Scroll the content to the top boundary of ScrollView.
  7052. !#zh 视图内容将在规定时间内滚动到视图顶部。
  7053. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7054. the content will jump to the top boundary immediately.
  7055. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7056. @example
  7057. ```js
  7058. // Scroll to the top of the view.
  7059. scrollView.scrollToTop(0.1);
  7060. ```
  7061. */
  7062. scrollToTop(timeInSecond?: number, attenuated?: boolean): void;
  7063. /**
  7064. !#en Scroll the content to the left boundary of ScrollView.
  7065. !#zh 视图内容将在规定时间内滚动到视图左边。
  7066. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7067. the content will jump to the left boundary immediately.
  7068. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7069. @example
  7070. ```js
  7071. // Scroll to the left of the view.
  7072. scrollView.scrollToLeft(0.1);
  7073. ```
  7074. */
  7075. scrollToLeft(timeInSecond?: number, attenuated?: boolean): void;
  7076. /**
  7077. !#en Scroll the content to the right boundary of ScrollView.
  7078. !#zh 视图内容将在规定时间内滚动到视图右边。
  7079. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7080. the content will jump to the right boundary immediately.
  7081. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7082. @example
  7083. ```js
  7084. // Scroll to the right of the view.
  7085. scrollView.scrollToRight(0.1);
  7086. ```
  7087. */
  7088. scrollToRight(timeInSecond?: number, attenuated?: boolean): void;
  7089. /**
  7090. !#en Scroll the content to the top left boundary of ScrollView.
  7091. !#zh 视图内容将在规定时间内滚动到视图左上角。
  7092. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7093. the content will jump to the top left boundary immediately.
  7094. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7095. @example
  7096. ```js
  7097. // Scroll to the upper left corner of the view.
  7098. scrollView.scrollToTopLeft(0.1);
  7099. ```
  7100. */
  7101. scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void;
  7102. /**
  7103. !#en Scroll the content to the top right boundary of ScrollView.
  7104. !#zh 视图内容将在规定时间内滚动到视图右上角。
  7105. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7106. the content will jump to the top right boundary immediately.
  7107. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7108. @example
  7109. ```js
  7110. // Scroll to the top right corner of the view.
  7111. scrollView.scrollToTopRight(0.1);
  7112. ```
  7113. */
  7114. scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void;
  7115. /**
  7116. !#en Scroll the content to the bottom left boundary of ScrollView.
  7117. !#zh 视图内容将在规定时间内滚动到视图左下角。
  7118. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7119. the content will jump to the bottom left boundary immediately.
  7120. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7121. @example
  7122. ```js
  7123. // Scroll to the lower left corner of the view.
  7124. scrollView.scrollToBottomLeft(0.1);
  7125. ```
  7126. */
  7127. scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void;
  7128. /**
  7129. !#en Scroll the content to the bottom right boundary of ScrollView.
  7130. !#zh 视图内容将在规定时间内滚动到视图右下角。
  7131. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7132. the content will jump to the bottom right boundary immediately.
  7133. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7134. @example
  7135. ```js
  7136. // Scroll to the lower right corner of the view.
  7137. scrollView.scrollToBottomRight(0.1);
  7138. ```
  7139. */
  7140. scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void;
  7141. /**
  7142. !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the
  7143. specific offset immediately.
  7144. !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。
  7145. @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset
  7146. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7147. the content will jump to the specific offset of ScrollView immediately.
  7148. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7149. @example
  7150. ```js
  7151. // Scroll to middle position in 0.1 second in x-axis
  7152. let maxScrollOffset = this.getMaxScrollOffset();
  7153. scrollView.scrollToOffset(cc.v2(maxScrollOffset.x / 2, 0), 0.1);
  7154. ```
  7155. */
  7156. scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void;
  7157. /**
  7158. !#en Get the positive offset value corresponds to the content's top left boundary.
  7159. !#zh 获取滚动视图相对于左上角原点的当前滚动偏移
  7160. */
  7161. getScrollOffset(): Vec2;
  7162. /**
  7163. !#en Get the maximize available scroll offset
  7164. !#zh 获取滚动视图最大可以滚动的偏移量
  7165. */
  7166. getMaxScrollOffset(): Vec2;
  7167. /**
  7168. !#en Scroll the content to the horizontal percent position of ScrollView.
  7169. !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。
  7170. @param percent A value between 0 and 1.
  7171. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7172. the content will jump to the horizontal percent position of ScrollView immediately.
  7173. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7174. @example
  7175. ```js
  7176. // Scroll to middle position.
  7177. scrollView.scrollToBottomRight(0.5, 0.1);
  7178. ```
  7179. */
  7180. scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void;
  7181. /**
  7182. !#en Scroll the content to the percent position of ScrollView in any direction.
  7183. !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。
  7184. @param anchor A point which will be clamp between cc.v2(0,0) and cc.v2(1,1).
  7185. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7186. the content will jump to the percent position of ScrollView immediately.
  7187. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7188. @example
  7189. ```js
  7190. // Vertical scroll to the bottom of the view.
  7191. scrollView.scrollTo(cc.v2(0, 1), 0.1);
  7192. // Horizontal scroll to view right.
  7193. scrollView.scrollTo(cc.v2(1, 0), 0.1);
  7194. ```
  7195. */
  7196. scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void;
  7197. /**
  7198. !#en Scroll the content to the vertical percent position of ScrollView.
  7199. !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。
  7200. @param percent A value between 0 and 1.
  7201. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7202. the content will jump to the vertical percent position of ScrollView immediately.
  7203. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7204. // Scroll to middle position.
  7205. scrollView.scrollToPercentVertical(0.5, 0.1);
  7206. */
  7207. scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void;
  7208. /**
  7209. !#en Stop auto scroll immediately
  7210. !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动
  7211. */
  7212. stopAutoScroll(): void;
  7213. /**
  7214. !#en Modify the content position.
  7215. !#zh 设置当前视图内容的坐标点。
  7216. @param position The position in content's parent space.
  7217. */
  7218. setContentPosition(position: Vec2): void;
  7219. /**
  7220. !#en Query the content's position in its parent space.
  7221. !#zh 获取当前视图内容的坐标点。
  7222. */
  7223. getContentPosition(): Vec2;
  7224. /**
  7225. !#en Query whether the user is currently dragging the ScrollView to scroll it
  7226. !#zh 用户是否在拖拽当前滚动视图
  7227. */
  7228. isScrolling(): boolean;
  7229. /**
  7230. !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown.
  7231. !#zh 当前滚动视图是否在惯性滚动
  7232. */
  7233. isAutoScrolling(): boolean;
  7234. /**
  7235. !#en Whether this scroll view has the nested view group.
  7236. !#zh 此 Scoll View 是否含有嵌套的 View Group
  7237. */
  7238. hasNestedViewGroup(): boolean;
  7239. }
  7240. /** !#en The Slider Control
  7241. !#zh 滑动器组件 */
  7242. export class Slider extends Component {
  7243. /** !#en The "handle" part of the slider
  7244. !#zh 滑动器滑块按钮部件 */
  7245. handle: Button;
  7246. /** !#en The slider direction
  7247. !#zh 滑动器方向 */
  7248. direction: Slider.Direction;
  7249. /** !#en The current progress of the slider. The valid value is between 0-1
  7250. !#zh 当前进度值,该数值的区间是 0-1 之间 */
  7251. progress: number;
  7252. /** !#en The slider slide events' callback array
  7253. !#zh 滑动器组件滑动事件回调函数数组 */
  7254. slideEvents: Component.EventHandler[];
  7255. }
  7256. /** !#en Renders a sprite in the scene.
  7257. !#zh 该组件用于在场景中渲染精灵。 */
  7258. export class Sprite extends RenderComponent implements BlendFunc {
  7259. /** !#en The sprite frame of the sprite.
  7260. !#zh 精灵的精灵帧 */
  7261. spriteFrame: SpriteFrame;
  7262. /** !#en The sprite render type.
  7263. !#zh 精灵渲染类型 */
  7264. type: Sprite.Type;
  7265. /** !#en
  7266. The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7267. !#zh
  7268. 精灵填充类型,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
  7269. fillType: Sprite.FillType;
  7270. /** !#en
  7271. The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7272. !#zh
  7273. 填充中心点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
  7274. fillCenter: Vec2;
  7275. /** !#en
  7276. The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7277. !#zh
  7278. 填充起始点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
  7279. fillStart: number;
  7280. /** !#en
  7281. The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7282. !#zh
  7283. 填充范围,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
  7284. fillRange: number;
  7285. /** !#en specify the frame is trimmed or not.
  7286. !#zh 是否使用裁剪模式 */
  7287. trim: boolean;
  7288. /** !#en specify the size tracing mode.
  7289. !#zh 精灵尺寸调整模式 */
  7290. sizeMode: Sprite.SizeMode;
  7291. /**
  7292. Change the state of sprite.
  7293. @param state NORMAL or GRAY State.
  7294. */
  7295. setState(state: Sprite.State): void;
  7296. /**
  7297. Gets the current state.
  7298. */
  7299. getState(): Sprite.State;
  7300. /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost.
  7301. !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */
  7302. srcBlendFactor: macro.BlendFactor;
  7303. /** !#en specify the destination Blend Factor.
  7304. !#zh 指定目标的混合模式 */
  7305. dstBlendFactor: macro.BlendFactor;
  7306. }
  7307. /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it
  7308. could be treated as a RadioButton.
  7309. !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */
  7310. export class Toggle extends Button implements GraySpriteState {
  7311. /** !#en When this value is true, the check mark component will be enabled, otherwise
  7312. the check mark component will be disabled.
  7313. !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */
  7314. isChecked: boolean;
  7315. /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox.
  7316. Otherwise, the toggle is a RadioButton.
  7317. !#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox,
  7318. 否则,Toggle 是一个 RadioButton。 */
  7319. toggleGroup: ToggleGroup;
  7320. /** !#en The image used for the checkmark.
  7321. !#zh Toggle 处于选中状态时显示的图片 */
  7322. checkMark: Sprite;
  7323. /** !#en If Toggle is clicked, it will trigger event's handler
  7324. !#zh Toggle 按钮的点击事件列表。 */
  7325. checkEvents: Component.EventHandler[];
  7326. /**
  7327. !#en Make the toggle button checked.
  7328. !#zh 使 toggle 按钮处于选中状态
  7329. */
  7330. check(): void;
  7331. /**
  7332. !#en Make the toggle button unchecked.
  7333. !#zh 使 toggle 按钮处于未选中状态
  7334. */
  7335. uncheck(): void;
  7336. /** !#en The normal material.
  7337. !#zh 正常状态的材质。 */
  7338. normalMaterial: Material;
  7339. /** !#en The gray material.
  7340. !#zh 置灰状态的材质。 */
  7341. grayMaterial: Material;
  7342. }
  7343. /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles. <br/>
  7344. Toggles that belong to the same group could only have one of them to be switched on at a time.<br/>
  7345. Note: All the first layer child node containing the toggle component will auto be added to the container
  7346. !#zh ToggleContainer 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。<br/>
  7347. 当一组 Toggle 属于同一个 ToggleContainer 的时候,任何时候只能有一个 Toggle 处于选中状态。<br/>
  7348. 注意:所有包含 Toggle 组件的一级子节点都会自动被添加到该容器中 */
  7349. export class ToggleContainer extends Component {
  7350. /** !#en If this setting is true, a toggle could be switched off and on when pressed.
  7351. If it is false, it will make sure there is always only one toggle could be switched on
  7352. and the already switched on toggle can't be switched off.
  7353. !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */
  7354. allowSwitchOff: boolean;
  7355. /** !#en If Toggle is clicked, it will trigger event's handler
  7356. !#zh Toggle 按钮的点击事件列表。 */
  7357. checkEvents: Component.EventHandler[];
  7358. /** !#en Read only property, return the toggle items array reference managed by ToggleContainer.
  7359. !#zh 只读属性,返回 ToggleContainer 管理的 toggle 数组引用 */
  7360. toggleItems: Toggle[];
  7361. }
  7362. /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles.
  7363. Toggles that belong to the same group could only have one of them to be switched on at a time.
  7364. !#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候,
  7365. 任何时候只能有一个 Toggle 处于选中状态。 */
  7366. export class ToggleGroup extends Component {
  7367. /** !#en If this setting is true, a toggle could be switched off and on when pressed.
  7368. If it is false, it will make sure there is always only one toggle could be switched on
  7369. and the already switched on toggle can't be switched off.
  7370. !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */
  7371. allowSwitchOff: boolean;
  7372. /** !#en Read only property, return the toggle items array reference managed by toggleGroup.
  7373. !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */
  7374. toggleItems: any[];
  7375. }
  7376. /** !#en
  7377. Handling touch events in a ViewGroup takes special care,
  7378. because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself.
  7379. To make sure that each view correctly receives the touch events intended for it,
  7380. ViewGroup should register capture phase event and handle the event propagation properly.
  7381. Please refer to Scrollview for more information.
  7382. !#zh
  7383. ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。
  7384. 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。
  7385. 请参考 ScrollView 的实现来获取更多信息。 */
  7386. export class ViewGroup extends Component {
  7387. }
  7388. /** !#en
  7389. Stores and manipulate the anchoring based on its parent.
  7390. Widget are used for GUI but can also be used for other things.
  7391. 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.
  7392. !#zh
  7393. Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。
  7394. Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */
  7395. export class Widget extends Component {
  7396. /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node.
  7397. The default value is null, and when null, indicates the current parent.
  7398. !#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */
  7399. target: Node;
  7400. /** !#en Whether to align the top.
  7401. !#zh 是否对齐上边。 */
  7402. isAlignTop: boolean;
  7403. /** !#en
  7404. Vertically aligns the midpoint, This will open the other vertical alignment options cancel.
  7405. !#zh
  7406. 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */
  7407. isAlignVerticalCenter: boolean;
  7408. /** !#en Whether to align the bottom.
  7409. !#zh 是否对齐下边。 */
  7410. isAlignBottom: boolean;
  7411. /** !#en Whether to align the left.
  7412. !#zh 是否对齐左边 */
  7413. isAlignLeft: boolean;
  7414. /** !#en
  7415. Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled.
  7416. !#zh
  7417. 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */
  7418. isAlignHorizontalCenter: boolean;
  7419. /** !#en Whether to align the right.
  7420. !#zh 是否对齐右边。 */
  7421. isAlignRight: boolean;
  7422. /** !#en
  7423. Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally,
  7424. the width setting is invalid (read only).
  7425. !#zh
  7426. 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */
  7427. isStretchWidth: boolean;
  7428. /** !#en
  7429. Whether the stretched vertically, when enable the left and right alignment will be stretched vertically,
  7430. then height setting is invalid (read only)
  7431. !#zh
  7432. 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */
  7433. isStretchHeight: boolean;
  7434. /** !#en
  7435. The margins between the top of this node and the top of parent node,
  7436. the value can be negative, Only available in 'isAlignTop' open.
  7437. !#zh
  7438. 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */
  7439. top: number;
  7440. /** !#en
  7441. The margins between the bottom of this node and the bottom of parent node,
  7442. the value can be negative, Only available in 'isAlignBottom' open.
  7443. !#zh
  7444. 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */
  7445. bottom: number;
  7446. /** !#en
  7447. The margins between the left of this node and the left of parent node,
  7448. the value can be negative, Only available in 'isAlignLeft' open.
  7449. !#zh
  7450. 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */
  7451. left: number;
  7452. /** !#en
  7453. The margins between the right of this node and the right of parent node,
  7454. the value can be negative, Only available in 'isAlignRight' open.
  7455. !#zh
  7456. 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */
  7457. right: number;
  7458. /** !#en
  7459. Horizontal aligns the midpoint offset value,
  7460. the value can be negative, Only available in 'isAlignHorizontalCenter' open.
  7461. !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */
  7462. horizontalCenter: number;
  7463. /** !#en
  7464. Vertical aligns the midpoint offset value,
  7465. the value can be negative, Only available in 'isAlignVerticalCenter' open.
  7466. !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */
  7467. verticalCenter: number;
  7468. /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
  7469. !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
  7470. isAbsoluteHorizontalCenter: boolean;
  7471. /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
  7472. !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
  7473. isAbsoluteVerticalCenter: boolean;
  7474. /** !#en
  7475. If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
  7476. !#zh
  7477. 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
  7478. isAbsoluteTop: boolean;
  7479. /** !#en
  7480. If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
  7481. !#zh
  7482. 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
  7483. isAbsoluteBottom: boolean;
  7484. /** !#en
  7485. If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
  7486. !#zh
  7487. 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
  7488. isAbsoluteLeft: boolean;
  7489. /** !#en
  7490. If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
  7491. !#zh
  7492. 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
  7493. isAbsoluteRight: boolean;
  7494. /** !#en Specifies the alignment mode of the Widget, which determines when the widget should refresh.
  7495. !#zh 指定 Widget 的对齐模式,用于决定 Widget 应该何时刷新。 */
  7496. alignMode: Widget.AlignMode;
  7497. /**
  7498. !#en
  7499. Immediately perform the widget alignment. You need to manually call this method only if
  7500. you need to get the latest results after the alignment before the end of current frame.
  7501. !#zh
  7502. 立刻执行 widget 对齐操作。这个接口一般不需要手工调用。
  7503. 只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。
  7504. @example
  7505. ```js
  7506. widget.top = 10; // change top margin
  7507. cc.log(widget.node.y); // not yet changed
  7508. widget.updateAlignment();
  7509. cc.log(widget.node.y); // changed
  7510. ```
  7511. */
  7512. updateAlignment(): void;
  7513. /** !#en
  7514. When turned on, it will only be aligned once at the end of the onEnable frame,
  7515. then immediately disables the current component.
  7516. This will allow the script or animation to continue controlling the current node.
  7517. Note: It will still be aligned at the frame when onEnable is called.
  7518. !#zh
  7519. 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。
  7520. 这样便于脚本或动画继续控制当前节点。
  7521. 注意:onEnable 时所在的那一帧仍然会进行对齐。 */
  7522. isAlignOnce: boolean;
  7523. }
  7524. /** !#en SubContextView is a view component which controls open data context viewport in minigame platform.<br/>
  7525. The component's node size decide the viewport of the sub context content in main context,
  7526. the entire sub context texture will be scaled to the node's bounding box area.<br/>
  7527. This component provides multiple important features:<br/>
  7528. 1. Sub context could use its own resolution size and policy.<br/>
  7529. 2. Sub context could be minized to smallest size it needed.<br/>
  7530. 3. Resolution of sub context content could be increased.<br/>
  7531. 4. User touch input is transformed to the correct viewport.<br/>
  7532. 5. Texture update is handled by this component. User don't need to worry.<br/>
  7533. One important thing to be noted, whenever the node's bounding box change,
  7534. !#zh SubContextView 可以用来控制小游戏平台开放数据域在主域中的视窗的位置。<br/>
  7535. 这个组件的节点尺寸决定了开放数据域内容在主域中的尺寸,整个开放数据域会被缩放到节点的包围盒范围内。<br/>
  7536. 在这个组件的控制下,用户可以更自由得控制开放数据域:<br/>
  7537. 1. 子域中可以使用独立的设计分辨率和适配模式<br/>
  7538. 2. 子域区域尺寸可以缩小到只容纳内容即可<br/>
  7539. 3. 子域的分辨率也可以被放大,以便获得更清晰的显示效果<br/>
  7540. 4. 用户输入坐标会被自动转换到正确的子域视窗中<br/>
  7541. 5. 子域内容贴图的更新由组件负责,用户不需要处理<br/> */
  7542. export class SubContextView extends Component {
  7543. /**
  7544. !#en Reset open data context size and viewport
  7545. !#zh 重置开放数据域的尺寸和视窗
  7546. */
  7547. reset(): void;
  7548. /**
  7549. !#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes.
  7550. !#zh 更新开放数据域相对于主域的 viewport,这个函数应该在节点包围盒改变时手动调用。
  7551. */
  7552. updateSubContextViewport(): void;
  7553. }
  7554. /** !#en WXSubContextView is deprecated since v2.4.1, please use SubContextView instead.
  7555. !#zh 自 v2.4.1 起,WXSubContextView 已经废弃,请使用 SubContextView */
  7556. export class WXSubContextView extends Component {
  7557. }
  7558. /** !#en SwanSubContextView is deprecated since v2.4.1, please use SubContextView instead.
  7559. !#zh 自 v2.4.1 起,SwanSubContextView 已经废弃,请使用 SubContextView */
  7560. export class SwanSubContextView extends Component {
  7561. }
  7562. /** !#en The touch event class
  7563. !#zh 封装了触摸相关的信息。 */
  7564. export class Touch {
  7565. /**
  7566. !#en Returns the current touch location in OpenGL coordinates.、
  7567. !#zh 获取当前触点位置。
  7568. */
  7569. getLocation(): Vec2;
  7570. /**
  7571. !#en Returns X axis location value.
  7572. !#zh 获取当前触点 X 轴位置。
  7573. */
  7574. getLocationX(): number;
  7575. /**
  7576. !#en Returns Y axis location value.
  7577. !#zh 获取当前触点 Y 轴位置。
  7578. */
  7579. getLocationY(): number;
  7580. /**
  7581. !#en Returns the previous touch location in OpenGL coordinates.
  7582. !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
  7583. */
  7584. getPreviousLocation(): Vec2;
  7585. /**
  7586. !#en Returns the start touch location in OpenGL coordinates.
  7587. !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。
  7588. */
  7589. getStartLocation(): Vec2;
  7590. /**
  7591. !#en Returns the delta distance from the previous touche to the current one in screen coordinates.
  7592. !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  7593. */
  7594. getDelta(): Vec2;
  7595. /**
  7596. !#en Returns the current touch location in screen coordinates.
  7597. !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
  7598. */
  7599. getLocationInView(): Vec2;
  7600. /**
  7601. !#en Returns the previous touch location in screen coordinates.
  7602. !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
  7603. */
  7604. getPreviousLocationInView(): Vec2;
  7605. /**
  7606. !#en Returns the start touch location in screen coordinates.
  7607. !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
  7608. */
  7609. getStartLocationInView(): Vec2;
  7610. /**
  7611. !#en Returns the id of cc.Touch.
  7612. !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
  7613. */
  7614. getID(): number;
  7615. /**
  7616. !#en Sets information to touch.
  7617. !#zh 设置触摸相关的信息。用于监控触摸事件。
  7618. @param id id
  7619. @param x x
  7620. @param y y
  7621. */
  7622. setTouchInfo(id: number, x: number, y: number): void;
  7623. }
  7624. /** !#en
  7625. EventTarget is an object to which an event is dispatched when something has occurred.
  7626. Entity are the most common event targets, but other objects can be event targets too.
  7627. Event targets are an important part of the Fireball event model.
  7628. The event target serves as the focal point for how events flow through the scene graph.
  7629. When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object
  7630. into the event flow from the root of the hierarchy. The event object then makes its way through
  7631. the scene graph until it reaches the event target, at which point it begins its return trip through
  7632. the scene graph. This round-trip journey to the event target is conceptually divided into three phases:
  7633. - The capture phase comprises the journey from the root to the last node before the event target's node
  7634. - The target phase comprises only the event target node
  7635. - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree
  7636. See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7637. Event targets can implement the following methods:
  7638. - _getCapturingTargets
  7639. - _getBubblingTargets
  7640. !#zh
  7641. 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标,
  7642. 但是其他对象也可以是事件目标。<br/> */
  7643. export class EventTarget extends CallbacksInvoker {
  7644. /**
  7645. !#en Checks whether the EventTarget object has any callback registered for a specific type of event.
  7646. !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。
  7647. @param type The type of event.
  7648. */
  7649. hasEventListener(type: string): boolean;
  7650. /**
  7651. !#en
  7652. Register an callback of a specific event type on the EventTarget.
  7653. This type of event should be triggered via `emit`.
  7654. !#zh
  7655. 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。
  7656. @param type A string representing the event type to listen for.
  7657. @param callback The callback that will be invoked when the event is dispatched.
  7658. The callback is ignored if it is a duplicate (the callbacks are unique).
  7659. @param target The target (this object) to invoke the callback, can be null
  7660. @example
  7661. ```js
  7662. eventTarget.on('fire', function () {
  7663. cc.log("fire in the hole");
  7664. }, node);
  7665. ```
  7666. */
  7667. on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
  7668. /**
  7669. !#en
  7670. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  7671. if only type is passed as parameter, all listeners registered with that type will be removed.
  7672. !#zh
  7673. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  7674. @param type A string representing the event type being removed.
  7675. @param callback The callback to remove.
  7676. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  7677. @example
  7678. ```js
  7679. // register fire eventListener
  7680. var callback = eventTarget.on('fire', function () {
  7681. cc.log("fire in the hole");
  7682. }, target);
  7683. // remove fire event listener
  7684. eventTarget.off('fire', callback, target);
  7685. // remove all fire event listeners
  7686. eventTarget.off('fire');
  7687. ```
  7688. */
  7689. off(type: string, callback?: Function, target?: any): void;
  7690. /**
  7691. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  7692. This is not for removing all listeners in the current event target,
  7693. and this is not for removing all listeners the target parameter have registered.
  7694. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  7695. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  7696. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  7697. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  7698. @param target The target to be searched for all related listeners
  7699. */
  7700. targetOff(target: any): void;
  7701. /**
  7702. !#en
  7703. Register an callback of a specific event type on the EventTarget,
  7704. the callback will remove itself after the first time it is triggered.
  7705. !#zh
  7706. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  7707. @param type A string representing the event type to listen for.
  7708. @param callback The callback that will be invoked when the event is dispatched.
  7709. The callback is ignored if it is a duplicate (the callbacks are unique).
  7710. @param target The target (this object) to invoke the callback, can be null
  7711. @example
  7712. ```js
  7713. eventTarget.once('fire', function () {
  7714. cc.log("this is the callback and will be invoked only once");
  7715. }, node);
  7716. ```
  7717. */
  7718. once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
  7719. /**
  7720. !#en
  7721. Send an event with the event object.
  7722. !#zh
  7723. 通过事件对象派发事件
  7724. @param event event
  7725. */
  7726. dispatchEvent(event: Event): void;
  7727. /**
  7728. !#en
  7729. Destroy all callbackInfos.
  7730. !#zh
  7731. 销毁记录的事件
  7732. */
  7733. clear(): void;
  7734. }
  7735. /** !#en Base class of all kinds of events.
  7736. !#zh 包含事件相关信息的对象。 */
  7737. export class Event {
  7738. /**
  7739. @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
  7740. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  7741. */
  7742. constructor(type: string, bubbles: boolean);
  7743. /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit".
  7744. !#zh 事件类型。 */
  7745. type: string;
  7746. /** !#en Indicate whether the event bubbles up through the tree or not.
  7747. !#zh 表示该事件是否进行冒泡。 */
  7748. bubbles: boolean;
  7749. /** !#en A reference to the target to which the event was originally dispatched.
  7750. !#zh 最初事件触发的目标 */
  7751. target: any;
  7752. /** !#en A reference to the currently registered target for the event.
  7753. !#zh 当前目标 */
  7754. currentTarget: any;
  7755. /** !#en
  7756. Indicates which phase of the event flow is currently being evaluated.
  7757. Returns an integer value represented by 4 constants:
  7758. - Event.NONE = 0
  7759. - Event.CAPTURING_PHASE = 1
  7760. - Event.AT_TARGET = 2
  7761. - Event.BUBBLING_PHASE = 3
  7762. The phases are explained in the [section 3.1, Event dispatch and DOM event flow]
  7763. (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification.
  7764. !#zh 事件阶段 */
  7765. eventPhase: number;
  7766. /**
  7767. !#en Reset the event for being stored in the object pool.
  7768. !#zh 重置对象池中存储的事件。
  7769. */
  7770. unuse(): string;
  7771. /**
  7772. !#en Reuse the event for being used again by the object pool.
  7773. !#zh 用于对象池再次使用的事件。
  7774. */
  7775. reuse(): string;
  7776. /**
  7777. !#en Stops propagation for current event.
  7778. !#zh 停止传递当前事件。
  7779. */
  7780. stopPropagation(): void;
  7781. /**
  7782. !#en Stops propagation for current event immediately,
  7783. the event won't even be dispatched to the listeners attached in the current target.
  7784. !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。
  7785. */
  7786. stopPropagationImmediate(): void;
  7787. /**
  7788. !#en Checks whether the event has been stopped.
  7789. !#zh 检查该事件是否已经停止传递.
  7790. */
  7791. isStopped(): boolean;
  7792. /**
  7793. !#en
  7794. <p>
  7795. Gets current target of the event <br/>
  7796. note: It only be available when the event listener is associated with node. <br/>
  7797. It returns 0 when the listener is associated with fixed priority.
  7798. </p>
  7799. !#zh 获取当前目标节点
  7800. */
  7801. getCurrentTarget(): Node;
  7802. /**
  7803. !#en Gets the event type.
  7804. !#zh 获取事件类型
  7805. */
  7806. getType(): string;
  7807. /** !#en Code for event without type.
  7808. !#zh 没有类型的事件 */
  7809. static NO_TYPE: string;
  7810. /** !#en The type code of Touch event.
  7811. !#zh 触摸事件类型 */
  7812. static TOUCH: string;
  7813. /** !#en The type code of Mouse event.
  7814. !#zh 鼠标事件类型 */
  7815. static MOUSE: string;
  7816. /** !#en The type code of Keyboard event.
  7817. !#zh 键盘事件类型 */
  7818. static KEYBOARD: string;
  7819. /** !#en The type code of Acceleration event.
  7820. !#zh 加速器事件类型 */
  7821. static ACCELERATION: string;
  7822. /** !#en Events not currently dispatched are in this phase
  7823. !#zh 尚未派发事件阶段 */
  7824. static NONE: number;
  7825. /** !#en
  7826. The capturing phase comprises the journey from the root to the last node before the event target's node
  7827. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7828. !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */
  7829. static CAPTURING_PHASE: number;
  7830. /** !#en
  7831. The target phase comprises only the event target node
  7832. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7833. !#zh 目标阶段仅包括事件目标节点。 */
  7834. static AT_TARGET: number;
  7835. /** !#en
  7836. The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy
  7837. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7838. !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */
  7839. static BUBBLING_PHASE: number;
  7840. }
  7841. /** !#en
  7842. The System event, it currently supports keyboard events and accelerometer events.<br>
  7843. You can get the SystemEvent instance with cc.systemEvent.<br>
  7844. !#zh
  7845. 系统事件,它目前支持按键事件和重力感应事件。<br>
  7846. 你可以通过 cc.systemEvent 获取到 SystemEvent 的实例。<br> */
  7847. export class SystemEvent extends EventTarget {
  7848. /**
  7849. !#en whether enable accelerometer event
  7850. !#zh 是否启用加速度计事件
  7851. @param isEnable isEnable
  7852. */
  7853. setAccelerometerEnabled(isEnable: boolean): void;
  7854. /**
  7855. !#en set accelerometer interval value
  7856. !#zh 设置加速度计间隔值
  7857. @param interval interval
  7858. */
  7859. setAccelerometerInterval(interval: number): void;
  7860. }
  7861. /** !#en
  7862. This module controls asset's behaviors and information, include loading, releasing etc. it is a singleton
  7863. All member can be accessed with `cc.assetManager`.
  7864. !#zh
  7865. 此模块管理资源的行为和信息,包括加载,释放等,这是一个单例,所有成员能够通过 `cc.assetManager` 调用 */
  7866. export class AssetManager {
  7867. /** !#en
  7868. Normal loading pipeline
  7869. !#zh
  7870. 正常加载管线 */
  7871. pipeline: cc.AssetManager.Pipeline;
  7872. /** !#en
  7873. Fetching pipeline
  7874. !#zh
  7875. 下载管线 */
  7876. fetchPipeline: cc.AssetManager.Pipeline;
  7877. /** !#en
  7878. Url transformer
  7879. !#zh
  7880. Url 转换器 */
  7881. transformPipeline: cc.AssetManager.Pipeline;
  7882. /** !#en
  7883. The collection of bundle which is already loaded, you can remove cache with {{#crossLink "AssetManager/removeBundle:method"}}{{/crossLink}}
  7884. !#zh
  7885. 已加载 bundle 的集合, 你能通过 {{#crossLink "AssetManager/removeBundle:method"}}{{/crossLink}} 来移除缓存 */
  7886. bundles: AssetManager.Cache<AssetManager.Bundle>;
  7887. /** !#en
  7888. The collection of asset which is already loaded, you can remove cache with {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}}
  7889. !#zh
  7890. 已加载资源的集合, 你能通过 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} 来移除缓存 */
  7891. assets: AssetManager.Cache<cc.Asset>;
  7892. /** !#en
  7893. Manage relationship between asset and its dependencies
  7894. !#zh
  7895. 管理资源依赖关系 */
  7896. dependUtil: cc.AssetManager.DependUtil;
  7897. /** !#en
  7898. Whether or not cache the loaded asset
  7899. !#zh
  7900. 是否缓存已加载的资源 */
  7901. cacheAsset: boolean;
  7902. /** !#en
  7903. Whether or not load asset forcely, if it is true, asset will be loaded regardless of error
  7904. !#zh
  7905. 是否强制加载资源, 如果为 true ,加载资源将会忽略报错 */
  7906. force: boolean;
  7907. /** !#en
  7908. Some useful function
  7909. !#zh
  7910. 一些有用的方法 */
  7911. utils: cc.AssetManager.Helper;
  7912. /** !#en
  7913. Manage all downloading task
  7914. !#zh
  7915. 管理所有下载任务 */
  7916. downloader: cc.AssetManager.Downloader;
  7917. /** !#en
  7918. Manage all parsing task
  7919. !#zh
  7920. 管理所有解析任务 */
  7921. parser: cc.AssetManager.Parser;
  7922. /** !#en
  7923. Manage internal asset
  7924. !#zh
  7925. 管理内置资源 */
  7926. builtins: cc.AssetManager.Builtins;
  7927. /** !#en
  7928. Manage all packed asset
  7929. !#zh
  7930. 管理所有合并后的资源 */
  7931. packManager: cc.AssetManager.PackManager;
  7932. /** !#en
  7933. Cache manager is a module which controls all caches downloaded from server in non-web platform.
  7934. !#zh
  7935. 缓存管理器是一个模块,在非 WEB 平台上,用于管理所有从服务器上下载下来的缓存 */
  7936. cacheManager: cc.AssetManager.CacheManager|null;
  7937. /** !#en
  7938. The preset of options
  7939. !#zh
  7940. 可选参数的预设集 */
  7941. presets: Record<string, Record<string, any>>;
  7942. /** !#en
  7943. The builtin 'main' bundle
  7944. !#zh
  7945. 内置 main 包 */
  7946. main: cc.AssetManager.Bundle;
  7947. /** !#en
  7948. The builtin 'resources' bundle
  7949. !#zh
  7950. 内置 resources 包 */
  7951. resources: cc.AssetManager.Bundle;
  7952. /** !#en
  7953. The builtin 'internal' bundle
  7954. !#zh
  7955. 内置 internal 包 */
  7956. internal: cc.AssetManager.Bundle;
  7957. /**
  7958. !#en
  7959. Initialize assetManager with options
  7960. !#zh
  7961. 初始化资源管理器
  7962. @param options options
  7963. */
  7964. init(options: Record<string, any>): void;
  7965. /**
  7966. !#en
  7967. Get the bundle which has been loaded
  7968. !#zh
  7969. 获取已加载的分包
  7970. @param name The name of bundle
  7971. @example
  7972. ```js
  7973. // ${project}/assets/test1
  7974. cc.assetManager.getBundle('test1');
  7975. cc.assetManager.getBundle('resources');
  7976. ```
  7977. */
  7978. getBundle (name: string): cc.AssetManager.Bundle;
  7979. /**
  7980. !#en
  7981. Remove this bundle. NOTE: The asset whthin this bundle will not be released automatically, you can call {{#crossLink "Bundle/releaseAll:method"}}{{/crossLink}} manually before remove it if you need
  7982. !#zh
  7983. 移除此包, 注意:这个包内的资源不会自动释放, 如果需要的话你可以在摧毁之前手动调用 {{#crossLink "Bundle/releaseAll:method"}}{{/crossLink}} 进行释放
  7984. @param bundle The bundle to be removed
  7985. */
  7986. removeBundle(bundle: cc.AssetManager.Bundle): void;
  7987. /**
  7988. !#en
  7989. General interface used to load assets with a progression callback and a complete callback. You can achieve almost all effect you want with combination of `requests` and `options`.
  7990. It is highly recommended that you use more simple API, such as `load`, `loadDir` etc. Every custom parameter in `options` will be distribute to each of `requests`.
  7991. if request already has same one, the parameter in request will be given priority. Besides, if request has dependencies, `options` will distribute to dependencies too.
  7992. Every custom parameter in `requests` will be tranfered to handler of `downloader` and `parser` as `options`.
  7993. You can register you own handler downloader or parser to collect these custom parameters for some effect.
  7994. Reserved Keyword: `uuid`, `url`, `path`, `dir`, `scene`, `type`, `priority`, `preset`, `audioLoadMode`, `ext`, `bundle`, `onFileProgress`, `maxConcurrency`, `maxRequestsPerFrame`
  7995. `maxRetryCount`, `version`, `responseType`, `withCredentials`, `mimeType`, `timeout`, `header`, `reload`, `cacheAsset`, `cacheEnabled`,
  7996. Please DO NOT use these words as custom options!
  7997. !#zh
  7998. 通用加载资源接口,可传入进度回调以及完成回调,通过组合 `request` 和 `options` 参数,几乎可以实现和扩展所有想要的加载效果。非常建议你使用更简单的API,例如 `load`、`loadDir` 等。
  7999. `options` 中的自定义参数将会分发到 `requests` 的每一项中,如果request中已存在同名的参数则以 `requests` 中为准,同时如果有其他
  8000. 依赖资源,则 `options` 中的参数会继续向依赖项中分发。request中的自定义参数都会以 `options` 形式传入加载流程中的 `downloader`, `parser` 的方法中, 你可以
  8001. 扩展 `downloader`, `parser` 收集参数完成想实现的效果。
  8002. 保留关键字: `uuid`, `url`, `path`, `dir`, `scene`, `type`, `priority`, `preset`, `audioLoadMode`, `ext`, `bundle`, `onFileProgress`, `maxConcurrency`, `maxRequestsPerFrame`
  8003. `maxRetryCount`, `version`, `responseType`, `withCredentials`, `mimeType`, `timeout`, `header`, `reload`, `cacheAsset`, `cacheEnabled`,
  8004. 请不要使用这些字段为自定义参数!
  8005. @param requests The request you want to load
  8006. @param options Optional parameters
  8007. @param onProgress Callback invoked when progression change
  8008. @param onComplete Callback invoked when finish loading
  8009. @example
  8010. ```js
  8011. cc.assetManager.loadAny({url: 'http://example.com/a.png'}, (err, img) => cc.log(img));
  8012. cc.assetManager.loadAny(['60sVXiTH1D/6Aft4MRt9VC'], (err, assets) => cc.log(assets));
  8013. cc.assetManager.loadAny([{ uuid: '0cbZa5Y71CTZAccaIFluuZ'}, {url: 'http://example.com/a.png'}], (err, assets) => cc.log(assets));
  8014. cc.assetManager.downloader.register('.asset', (url, options, onComplete) => {
  8015. url += '?userName=' + options.userName + "&password=" + options.password;
  8016. cc.assetManager.downloader.downloadFile(url, null, onComplete);
  8017. });
  8018. cc.assetManager.parser.register('.asset', (file, options, onComplete) => {
  8019. var json = JSON.parse(file);
  8020. var skin = json[options.skin];
  8021. var model = json[options.model];
  8022. onComplete(null, {skin, model});
  8023. });
  8024. cc.assetManager.loadAny({ url: 'http://example.com/my.asset', skin: 'xxx', model: 'xxx', userName: 'xxx', password: 'xxx' });
  8025. ```
  8026. */
  8027. loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>, onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, data: any) => void): void;
  8028. loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, data: any) => void): void;
  8029. loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>, onComplete: (err: Error, data: any) => void): void;
  8030. loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], onComplete: (err: Error, data: any) => void): void;
  8031. loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>): void;
  8032. loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[]): void;
  8033. /**
  8034. !#en
  8035. General interface used to preload assets with a progression callback and a complete callback.It is highly recommended that you use more simple API, such as `preloadRes`, `preloadResDir` etc.
  8036. Everything about preload is just likes `cc.assetManager.loadAny`, the difference is `cc.assetManager.preloadAny` will only download asset but not parse asset. You need to invoke `cc.assetManager.loadAny(preloadTask)`
  8037. to finish loading asset
  8038. !#zh
  8039. 通用预加载资源接口,可传入进度回调以及完成回调,非常建议你使用更简单的 API ,例如 `preloadRes`, `preloadResDir` 等。`preloadAny` 和 `loadAny` 几乎一样,区别在于 `preloadAny` 只会下载资源,不会去解析资源,你需要调用 `cc.assetManager.loadAny(preloadTask)`
  8040. 来完成资源加载。
  8041. @param requests The request you want to preload
  8042. @param options Optional parameters
  8043. @param onProgress Callback invoked when progression change
  8044. @param onComplete Callback invoked when finish preloading
  8045. @example
  8046. ```js
  8047. cc.assetManager.preloadAny('0cbZa5Y71CTZAccaIFluuZ', (err) => cc.assetManager.loadAny('0cbZa5Y71CTZAccaIFluuZ'));
  8048. ```
  8049. */
  8050. preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>, onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void;
  8051. preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void;
  8052. preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void;
  8053. preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void;
  8054. preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>): void;
  8055. preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[]): void;
  8056. /**
  8057. !#en
  8058. Load native file of asset, if you check the option 'Async Load Assets', you may need to load native file with this before you use the asset
  8059. !#zh
  8060. 加载资源的原生文件,如果你勾选了'延迟加载资源'选项,你可能需要在使用资源之前调用此方法来加载原生文件
  8061. @param asset The asset
  8062. @param options Some optional parameters
  8063. @param onComplete Callback invoked when finish loading
  8064. @example
  8065. ```js
  8066. cc.assetManager.postLoadNative(texture, (err) => console.log(err));
  8067. ```
  8068. */
  8069. postLoadNative(asset: cc.Asset, options: Record<string, any>, onComplete: (err: Error) => void): void;
  8070. postLoadNative(asset: cc.Asset, onComplete: (err: Error) => void): void;
  8071. postLoadNative(asset: cc.Asset, options: Record<string, any>): void;
  8072. postLoadNative(asset: cc.Asset): void;
  8073. /**
  8074. !#en
  8075. Load remote asset with url, such as audio, image, text and so on.
  8076. !#zh
  8077. 使用 url 加载远程资源,例如音频,图片,文本等等。
  8078. @param url The url of asset
  8079. @param options Some optional parameters
  8080. @param onComplete Callback invoked when finish loading
  8081. @example
  8082. ```js
  8083. cc.assetManager.loadRemote('http://www.cloud.com/test1.jpg', (err, texture) => console.log(err));
  8084. cc.assetManager.loadRemote('http://www.cloud.com/test2.mp3', (err, audioClip) => console.log(err));
  8085. cc.assetManager.loadRemote('http://www.cloud.com/test3', { ext: '.png' }, (err, texture) => console.log(err));
  8086. ```
  8087. */
  8088. loadRemote<T extends cc.Asset>(url: string, options: Record<string, any>, onComplete: (err: Error, asset: T) => void): void;
  8089. loadRemote<T extends cc.Asset>(url: string, onComplete: (err: Error, asset: T) => void): void;
  8090. loadRemote<T extends cc.Asset>(url: string, options: Record<string, any>): void;
  8091. loadRemote<T extends cc.Asset>(url: string): void;
  8092. /**
  8093. !#en
  8094. Load script
  8095. !#zh
  8096. 加载脚本
  8097. @param url Url of the script
  8098. @param options Some optional paramters
  8099. @param onComplete Callback when script loaded or failed
  8100. @example
  8101. ```js
  8102. loadScript('http://localhost:8080/index.js', null, (err) => console.log(err));
  8103. ```
  8104. */
  8105. loadScript(url: string|string[], options: Record<string, any>, onComplete: (err: Error) => void): void;
  8106. loadScript(url: string|string[], onComplete: (err: Error) => void): void;
  8107. loadScript(url: string|string[], options: Record<string, any>): void;
  8108. loadScript(url: string|string[]): void;
  8109. /**
  8110. !#en
  8111. load bundle
  8112. !#zh
  8113. 加载资源包
  8114. @param nameOrUrl The name or root path of bundle
  8115. @param options Some optional paramter, same like downloader.downloadFile
  8116. @param onComplete Callback when bundle loaded or failed
  8117. @example
  8118. ```js
  8119. loadBundle('http://localhost:8080/test', null, (err, bundle) => console.log(err));
  8120. ```
  8121. */
  8122. loadBundle(nameOrUrl: string, options: Record<string, any>, onComplete: (err: Error, bundle: cc.AssetManager.Bundle) => void): void;
  8123. loadBundle(nameOrUrl: string, onComplete: (err: Error, bundle: cc.AssetManager.Bundle) => void): void;
  8124. loadBundle(nameOrUrl: string, options: Record<string, any>): void;
  8125. loadBundle(nameOrUrl: string): void;
  8126. /**
  8127. !#en
  8128. Release asset and it's dependencies.
  8129. This method will not only remove the cache of the asset in assetManager, but also clean up its content.
  8130. For example, if you release a texture, the texture asset and its gl texture data will be freed up.
  8131. 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.
  8132. !#zh
  8133. 释放资源以及其依赖资源, 这个方法不仅会从 assetManager 中删除资源的缓存引用,还会清理它的资源内容。
  8134. 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。
  8135. 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。
  8136. @param asset The asset to be released
  8137. @example
  8138. ```js
  8139. // release a texture which is no longer need
  8140. cc.assetManager.releaseAsset(texture);
  8141. ```
  8142. */
  8143. releaseAsset(asset: cc.Asset): void;
  8144. /**
  8145. !#en
  8146. Release all assets. Refer to {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} for detailed informations.
  8147. !#zh
  8148. 释放所有资源。详细信息请参考 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}}
  8149. */
  8150. releaseAll(): void;
  8151. }
  8152. /** `cc.loader` is deprecated, please backup your project and upgrade to {{#crossLink "AssetManager"}}{{/crossLink}} */
  8153. export class loader {
  8154. /** `cc.loader.onProgress` is deprecated, please transfer onProgress to API as a parameter */
  8155. static onProgress: any;
  8156. /**
  8157. `cc.loader.load` is deprecated, please use {{#crossLink "AssetManager/loadAny:method"}}{{/crossLink}} instead
  8158. @param resources Url list in an array
  8159. @param progressCallback Callback invoked when progression change
  8160. @param completeCallback Callback invoked when all resources loaded
  8161. */
  8162. static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void;
  8163. static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void;
  8164. /**
  8165. `cc.loader.getXMLHttpRequest` is deprecated, please use `XMLHttpRequest` directly
  8166. */
  8167. static getXMLHttpRequest(): XMLHttpRequest;
  8168. /**
  8169. `cc.loader.getItem` is deprecated, please use `cc.assetManager.asset.get` instead
  8170. @param id The id of the item
  8171. */
  8172. static getItem(id: any): any;
  8173. /**
  8174. `cc.loader.loadRes` is deprecated, please use {{#crossLink "Bundle/load:method"}}{{/crossLink}} instead
  8175. @param url Url of the target resource.
  8176. The url is relative to the "resources" folder, extensions must be omitted.
  8177. @param type Only asset of type will be loaded if this argument is supplied.
  8178. @param progressCallback Callback invoked when progression change.
  8179. @param completeCallback Callback invoked when the resource loaded.
  8180. */
  8181. static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void;
  8182. static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void;
  8183. static loadRes(url: string, type: typeof cc.Asset): void;
  8184. static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void;
  8185. static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void;
  8186. static loadRes(url: string): void;
  8187. /**
  8188. `cc.loader.loadResArray` is deprecated, please use {{#crossLink "Bundle/load:method"}}{{/crossLink}} instead
  8189. @param urls Array of URLs of the target resource.
  8190. The url is relative to the "resources" folder, extensions must be omitted.
  8191. @param type Only asset of type will be loaded if this argument is supplied.
  8192. @param progressCallback Callback invoked when progression change.
  8193. @param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
  8194. */
  8195. static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void;
  8196. static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void;
  8197. static loadResArray(url: string[], type: typeof cc.Asset): void;
  8198. static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void;
  8199. static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void;
  8200. static loadResArray(url: string[]): void;
  8201. static loadResArray(url: string[], type: typeof cc.Asset[]): void;
  8202. /**
  8203. `cc.loader.loadResDir` is deprecated, please use {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} instead
  8204. @param url Url of the target folder.
  8205. The url is relative to the "resources" folder, extensions must be omitted.
  8206. @param type Only asset of type will be loaded if this argument is supplied.
  8207. @param progressCallback Callback invoked when progression change.
  8208. @param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
  8209. */
  8210. 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;
  8211. static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void;
  8212. static loadResDir(url: string, type: typeof cc.Asset): void;
  8213. static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void;
  8214. static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void;
  8215. static loadResDir(url: string): void;
  8216. /**
  8217. `cc.loader.getRes` is deprecated, please use {{#crossLink "Bundle/get:method"}}{{/crossLink}} instead
  8218. @param url url
  8219. @param type Only asset of type will be returned if this argument is supplied.
  8220. */
  8221. static getRes(url: string, type?: Function): any;
  8222. /**
  8223. `cc.loader.getDependsRecursively` is deprecated, please use use {{#crossLink "DependUtil/getDepsRecursively:method"}}{{/crossLink}} instead
  8224. @param owner The owner asset or the resource url or the asset's uuid
  8225. */
  8226. static getDependsRecursively(owner: Asset|string): any[];
  8227. /** `cc.loader.assetLoader` was removed, assetLoader and md5Pipe were merged into {{#crossLink "AssetManager/transformPipeline:property"}}{{/crossLink}} */
  8228. static assetLoader: any;
  8229. /** `cc.loader.md5Pipe` is deprecated, assetLoader and md5Pipe were merged into {{#crossLink "AssetManager/transformPipeline:property"}}{{/crossLink}} */
  8230. static md5Pipe: any;
  8231. /** `cc.loader.downloader` is deprecated, please use {{#crossLink "AssetManager/downloader:property"}}{{/crossLink}} instead */
  8232. static downloader: any;
  8233. /** `cc.loader.loader` is deprecated, please use {{#crossLink "AssetManager/parser:property"}}{{/crossLink}} instead */
  8234. static loader: any;
  8235. /**
  8236. `cc.loader.addDownloadHandlers` is deprecated, please use `cc.assetManager.downloader.register` instead
  8237. @param extMap Custom supported types with corresponded handler
  8238. */
  8239. static addDownloadHandlers(extMap: any): void;
  8240. /**
  8241. `cc.loader.addLoadHandlers` is deprecated, please use `cc.assetManager.parser.register` instead
  8242. @param extMap Custom supported types with corresponded handler
  8243. */
  8244. static addLoadHandlers(extMap: any): void;
  8245. /**
  8246. `cc.loader.release` is deprecated, please use {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} instead
  8247. @param asset asset
  8248. */
  8249. static release(asset: Asset|string|any[]): void;
  8250. /**
  8251. `cc.loader.releaseAsset` is deprecated, please use {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} instead
  8252. @param asset asset
  8253. */
  8254. static releaseAsset(asset: Asset): void;
  8255. /**
  8256. `cc.loader.releaseRes` is deprecated, please use {{#crossLink "AssetManager/releaseRes:method"}}{{/crossLink}} instead
  8257. @param url url
  8258. @param type Only asset of type will be released if this argument is supplied.
  8259. */
  8260. static releaseRes(url: string, type?: Function): void;
  8261. /**
  8262. `cc.loader.releaseResDir` was removed, please use {{#crossLink "AssetManager/releaseRes:method"}}{{/crossLink}} instead
  8263. */
  8264. static releaseResDir(): void;
  8265. /**
  8266. `cc.loader.releaseAll` is deprecated, please use {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} instead
  8267. */
  8268. static releaseAll(): void;
  8269. /**
  8270. `cc.loader.removeItem` is deprecated, please use `cc.assetManager.assets.remove` instead
  8271. @param id The id of the item
  8272. */
  8273. static removeItem(id: any): boolean;
  8274. /**
  8275. `cc.loader.setAutoRelease` is deprecated, if you want to prevent some asset from auto releasing, please use {{#crossLink "Asset/addRef:method"}}{{/crossLink}} instead
  8276. @param assetOrUrlOrUuid asset object or the raw asset's url or uuid
  8277. @param autoRelease indicates whether should release automatically
  8278. */
  8279. static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void;
  8280. /**
  8281. `cc.loader.setAutoReleaseRecursively` is deprecated, if you want to prevent some asset from auto releasing, please use {{#crossLink "Asset/addRef:method"}}{{/crossLink}} instead
  8282. @param assetOrUrlOrUuid asset object or the raw asset's url or uuid
  8283. @param autoRelease indicates whether should release automatically
  8284. */
  8285. static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void;
  8286. /**
  8287. `cc.loader.isAutoRelease` is deprecated
  8288. @param assetOrUrl asset object or the raw asset's url
  8289. */
  8290. static isAutoRelease(assetOrUrl: Asset|string): boolean;
  8291. }
  8292. /** `cc.url` is deprecated */
  8293. export class url {
  8294. /**
  8295. `cc.url.raw` is deprecated, please use `cc.resources.load` directly, or use `Asset.nativeUrl` instead.
  8296. @param url url
  8297. */
  8298. static raw(url: string): string;
  8299. }
  8300. /** `cc.LoadingItems` was removed, please use {{#crossLink "Task"}}{{/crossLink}} instead */
  8301. export class LoadingItems {
  8302. }
  8303. /** !#en
  8304. Base class for handling assets used in Creator.<br/>
  8305. You may want to override:<br/>
  8306. - createNode<br/>
  8307. - getset functions of _nativeAsset<br/>
  8308. - cc.Object._serialize<br/>
  8309. - cc.Object._deserialize<br/>
  8310. !#zh
  8311. Creator 中的资源基类。<br/>
  8312. 您可能需要重写:<br/>
  8313. - createNode <br/>
  8314. - _nativeAsset 的 getset 方法<br/>
  8315. - cc.Object._serialize<br/>
  8316. - cc.Object._deserialize<br/> */
  8317. export class Asset extends Object {
  8318. /** `cc.Asset.url` is deprecated, please use {{#crossLink "Asset/nativeUrl:property"}}{{/crossLink}} instead */
  8319. url: string;
  8320. /** !#en
  8321. Whether the asset is loaded or not.
  8322. !#zh
  8323. 该资源是否已经成功加载。 */
  8324. loaded: boolean;
  8325. /** !#en
  8326. Returns the url of this asset's native object, if none it will returns an empty string.
  8327. !#zh
  8328. 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。 */
  8329. nativeUrl: string;
  8330. /** !#en
  8331. The number of reference
  8332. !#zh
  8333. 引用的数量 */
  8334. refCount: number;
  8335. /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`.
  8336. !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它原始资源。 */
  8337. static preventDeferredLoadDependents: boolean;
  8338. /** !#en Indicates whether its native object should be preloaded from native url.
  8339. !#zh 禁止预加载原生对象。 */
  8340. static preventPreloadNativeObject: boolean;
  8341. /**
  8342. !#en
  8343. Returns the asset's url.
  8344. The `Asset` object overrides the `toString()` method of the `Object` object.
  8345. For `Asset` objects, the `toString()` method returns a string representation of the object.
  8346. JavaScript calls the `toString()` method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation.
  8347. !#zh
  8348. 返回资源的 URL。
  8349. Asset 对象将会重写 Object 对象的 `toString()` 方法。
  8350. 对于 Asset 对象,`toString()` 方法返回该对象的字符串表示形式。
  8351. 当资源要表示为文本值时或在字符串连接时引用时,JavaScript 会自动调用 `toString()` 方法。
  8352. */
  8353. toString(): string;
  8354. /**
  8355. !#en
  8356. Create a new node using this asset in the scene.<br/>
  8357. If this type of asset dont have its corresponding node type, this method should be null.
  8358. !#zh
  8359. 使用该资源在场景中创建一个新节点。<br/>
  8360. 如果这类资源没有相应的节点类型,该方法应该是空的。
  8361. @param callback callback
  8362. */
  8363. createNode(callback: (error: string, node: any) => void): void;
  8364. /**
  8365. !#en
  8366. Add references of asset
  8367. !#zh
  8368. 增加资源的引用
  8369. */
  8370. addRef(): cc.Asset;
  8371. /**
  8372. !#en
  8373. Reduce references of asset and it will be auto released when refCount equals 0.
  8374. !#zh
  8375. 减少资源的引用并尝试进行自动释放。
  8376. */
  8377. decRef(): cc.Asset;
  8378. }
  8379. /** Predefined constants */
  8380. export class macro {
  8381. /** `cc.macro.DOWNLOAD_MAX_CONCURRENT` is deprecated now, please use {{#crossLink "Downloader/maxConcurrency:property"}}{{/crossLink}} instead */
  8382. static DOWNLOAD_MAX_CONCURRENT: number;
  8383. /** PI / 180 */
  8384. static RAD: number;
  8385. /** One degree */
  8386. static DEG: number;
  8387. static REPEAT_FOREVER: number;
  8388. static FLT_EPSILON: number;
  8389. /** Minimum z index value for node */
  8390. static MIN_ZINDEX: number;
  8391. /** Maximum z index value for node */
  8392. static MAX_ZINDEX: number;
  8393. static ONE: number;
  8394. static ZERO: number;
  8395. static SRC_ALPHA: number;
  8396. static SRC_ALPHA_SATURATE: number;
  8397. static SRC_COLOR: number;
  8398. static DST_ALPHA: number;
  8399. static DST_COLOR: number;
  8400. static ONE_MINUS_SRC_ALPHA: number;
  8401. static ONE_MINUS_SRC_COLOR: number;
  8402. static ONE_MINUS_DST_ALPHA: number;
  8403. static ONE_MINUS_DST_COLOR: number;
  8404. static ONE_MINUS_CONSTANT_ALPHA: number;
  8405. static ONE_MINUS_CONSTANT_COLOR: number;
  8406. /** Oriented vertically */
  8407. static ORIENTATION_PORTRAIT: number;
  8408. /** Oriented horizontally */
  8409. static ORIENTATION_LANDSCAPE: number;
  8410. /** Oriented automatically */
  8411. static ORIENTATION_AUTO: number;
  8412. /** <p>
  8413. If enabled, the texture coordinates will be calculated by using this formula: <br/>
  8414. - texCoord.left = (rect.x*2+1) / (texture.wide*2); <br/>
  8415. - texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2); <br/>
  8416. <br/>
  8417. The same for bottom and top. <br/>
  8418. <br/>
  8419. This formula prevents artifacts by using 99% of the texture. <br/>
  8420. The "correct" way to prevent artifacts is by expand the texture's border with the same color by 1 pixel<br/>
  8421. <br/>
  8422. Affected component: <br/>
  8423. - cc.TMXLayer <br/>
  8424. <br/>
  8425. Enabled by default. To disabled set it to 0. <br/>
  8426. To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h
  8427. </p> */
  8428. static FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX: number;
  8429. /** Position of the FPS (Default: 0,0 (bottom-left corner))<br/>
  8430. To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h */
  8431. static DIRECTOR_STATS_POSITION: Vec2;
  8432. /** <p>
  8433. If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked. <br/>
  8434. If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions. <br/>
  8435. If disabled, only the last run action will take effect.
  8436. </p> */
  8437. static ENABLE_STACKABLE_ACTIONS: number;
  8438. /** !#en
  8439. The timeout to determine whether a touch is no longer active and should be removed.
  8440. The reason to add this timeout is due to an issue in X5 browser core,
  8441. when X5 is presented in wechat on Android, if a touch is glissed from the bottom up, and leave the page area,
  8442. no touch cancel event is triggered, and the touch will be considered active forever.
  8443. After multiple times of this action, our maximum touches number will be reached and all new touches will be ignored.
  8444. So this new mechanism can remove the touch that should be inactive if it's not updated during the last 5000 milliseconds.
  8445. Though it might remove a real touch if it's just not moving for the last 5 seconds which is not easy with the sensibility of mobile touch screen.
  8446. You can modify this value to have a better behavior if you find it's not enough.
  8447. !#zh
  8448. 用于甄别一个触点对象是否已经失效并且可以被移除的延时时长
  8449. 添加这个时长的原因是 X5 内核在微信浏览器中出现的一个 bug。
  8450. 在这个环境下,如果用户将一个触点从底向上移出页面区域,将不会触发任何 touch cancel 或 touch end 事件,而这个触点会被永远当作停留在页面上的有效触点。
  8451. 重复这样操作几次之后,屏幕上的触点数量将达到我们的事件系统所支持的最高触点数量,之后所有的触摸事件都将被忽略。
  8452. 所以这个新的机制可以在触点在一定时间内没有任何更新的情况下视为失效触点并从事件系统中移除。
  8453. 当然,这也可能移除一个真实的触点,如果用户的触点真的在一定时间段内完全没有移动(这在当前手机屏幕的灵敏度下会很难)。
  8454. 你可以修改这个值来获得你需要的效果,默认值是 5000 毫秒。 */
  8455. static TOUCH_TIMEOUT: number;
  8456. /** !#en
  8457. The maximum vertex count for a single batched draw call.
  8458. !#zh
  8459. 最大可以被单次批处理渲染的顶点数量。 */
  8460. static BATCH_VERTEX_COUNT: number;
  8461. /** !#en
  8462. Whether or not enabled tiled map auto culling. If you set the TiledMap skew or rotation, then need to manually disable this, otherwise, the rendering will be wrong.
  8463. !#zh
  8464. 是否开启瓦片地图的自动裁减功能。瓦片地图如果设置了 skew, rotation 或者采用了摄像机的话,需要手动关闭,否则渲染会出错。 */
  8465. static ENABLE_TILEDMAP_CULLING: boolean;
  8466. /** !#en
  8467. Boolean that indicates if the canvas contains an alpha channel, default sets to false for better performance.
  8468. Though if you want to make your canvas background transparent and show other dom elements at the background,
  8469. you can set it to true before `cc.game.run`.
  8470. Web only.
  8471. !#zh
  8472. 用于设置 Canvas 背景是否支持 alpha 通道,默认为 false,这样可以有更高的性能表现。
  8473. 如果你希望 Canvas 背景是透明的,并显示背后的其他 DOM 元素,你可以在 `cc.game.run` 之前将这个值设为 true。
  8474. 仅支持 Web */
  8475. static ENABLE_TRANSPARENT_CANVAS: boolean;
  8476. /** !#en
  8477. Boolean that indicates if the WebGL context is created with `antialias` option turned on, default value is false.
  8478. Set it to true could make your game graphics slightly smoother, like texture hard edges when rotated.
  8479. Whether to use this really depend on your game design and targeted platform,
  8480. device with retina display usually have good detail on graphics with or without this option,
  8481. you probably don't want antialias if your game style is pixel art based.
  8482. Also, it could have great performance impact with some browser / device using software MSAA.
  8483. You can set it to true before `cc.game.run`.
  8484. Web only.
  8485. !#zh
  8486. 用于设置在创建 WebGL Context 时是否开启抗锯齿选项,默认值是 false。
  8487. 将这个选项设置为 true 会让你的游戏画面稍稍平滑一些,比如旋转硬边贴图时的锯齿。是否开启这个选项很大程度上取决于你的游戏和面向的平台。
  8488. 在大多数拥有 retina 级别屏幕的设备上用户往往无法区分这个选项带来的变化;如果你的游戏选择像素艺术风格,你也多半不会想开启这个选项。
  8489. 同时,在少部分使用软件级别抗锯齿算法的设备或浏览器上,这个选项会对性能产生比较大的影响。
  8490. 你可以在 `cc.game.run` 之前设置这个值,否则它不会生效。
  8491. 仅支持 Web */
  8492. static ENABLE_WEBGL_ANTIALIAS: boolean;
  8493. /** !#en
  8494. Whether or not enable auto culling.
  8495. This feature have been removed in v2.0 new renderer due to overall performance consumption.
  8496. We have no plan currently to re-enable auto culling.
  8497. If your game have more dynamic objects, we suggest to disable auto culling.
  8498. If your game have more static objects, we suggest to enable auto culling.
  8499. !#zh
  8500. 是否开启自动裁减功能,开启裁减功能将会把在屏幕外的物体从渲染队列中去除掉。
  8501. 这个功能在 v2.0 的新渲染器中被移除了,因为它在大多数游戏中所带来的损耗要高于性能的提升,目前我们没有计划重新支持自动裁剪。
  8502. 如果游戏中的动态物体比较多的话,建议将此选项关闭。
  8503. 如果游戏中的静态物体比较多的话,建议将此选项打开。 */
  8504. static ENABLE_CULLING: boolean;
  8505. /** !#en
  8506. Whether to clear the original image cache after uploaded a texture to GPU. If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/2.4/manual/en/advanced-topics/dynamic-atlas.html) will not be supported.
  8507. Normally you don't need to enable this option on the web platform, because Image object doesn't consume too much memory.
  8508. But on WeChat Game platform, the current version cache decoded data in Image object, which has high memory usage.
  8509. So we enabled this option by default on WeChat, so that we can release Image cache immediately after uploaded to GPU.
  8510. !#zh
  8511. 是否在将贴图上传至 GPU 之后删除原始图片缓存,删除之后图片将无法进行 [动态合图](https://docs.cocos.com/creator/2.4/manual/zh/advanced-topics/dynamic-atlas.html)。
  8512. 在 Web 平台,你通常不需要开启这个选项,因为在 Web 平台 Image 对象所占用的内存很小。
  8513. 但是在微信小游戏平台的当前版本,Image 对象会缓存解码后的图片数据,它所占用的内存空间很大。
  8514. 所以我们在微信平台默认开启了这个选项,这样我们就可以在上传 GL 贴图之后立即释放 Image 对象的内存,避免过高的内存占用。 */
  8515. static CLEANUP_IMAGE_CACHE: boolean;
  8516. /** !#en
  8517. Whether or not show mesh wire frame.
  8518. !#zh
  8519. 是否显示网格的线框。 */
  8520. static SHOW_MESH_WIREFRAME: boolean;
  8521. /** !#en
  8522. Whether or not show mesh normal.
  8523. !#zh
  8524. 是否显示网格的法线。 */
  8525. static SHOW_MESH_NORMAL: boolean;
  8526. /** !#en
  8527. Whether to enable multi-touch.
  8528. !#zh
  8529. 是否开启多点触摸 */
  8530. static ENABLE_MULTI_TOUCH: boolean;
  8531. /** References:
  8532. https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap
  8533. https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap
  8534. !#en
  8535. Whether to use image bitmap first. If enabled, memory usage will increase.
  8536. !#zh
  8537. 是否优先使用 image bitmap,启用之后,内存占用会变高 */
  8538. static ALLOW_IMAGE_BITMAP: boolean;
  8539. /** !#en
  8540. Whether to use native TTF renderer which is faster but layout slightly different.
  8541. !#zh
  8542. 是否使用原生的文本渲染机制, 布局和编辑器有差异. */
  8543. static ENABLE_NATIVE_TTF_RENDERER: boolean;
  8544. /** !#en
  8545. The image format supported by the engine defaults, and the supported formats may differ in different build platforms and device types.
  8546. Currently all platform and device support ['.astc', '.webp', '.jpg', '.jpeg', '.bmp', '.png'], The iOS mobile platform also supports the PVR format。
  8547. !#zh
  8548. 引擎默认支持的图片格式,支持的格式可能在不同的构建平台和设备类型上有所差别。
  8549. 目前所有平台和设备支持的格式有 ['.astc', '.webp', '.jpg', '.jpeg', '.bmp', '.png']. 另外 Ios 手机平台还额外支持了 PVR 格式。 */
  8550. static SUPPORT_TEXTURE_FORMATS: string[];
  8551. }
  8552. /** undefined */
  8553. export class Graphics extends RenderComponent {
  8554. /** !#en
  8555. Current line width.
  8556. !#zh
  8557. 当前线条宽度 */
  8558. lineWidth: number;
  8559. /** !#en
  8560. lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together.
  8561. !#zh
  8562. lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */
  8563. lineJoin: Graphics.LineJoin;
  8564. /** !#en
  8565. lineCap determines how the end points of every line are drawn.
  8566. !#zh
  8567. lineCap 指定如何绘制每一条线段末端。 */
  8568. lineCap: Graphics.LineCap;
  8569. /** !#en
  8570. stroke color
  8571. !#zh
  8572. 线段颜色 */
  8573. strokeColor: Color;
  8574. /** !#en
  8575. fill color
  8576. !#zh
  8577. 填充颜色 */
  8578. fillColor: Color;
  8579. /** !#en
  8580. Sets the miter limit ratio
  8581. !#zh
  8582. 设置斜接面限制比例 */
  8583. miterLimit: number;
  8584. /**
  8585. !#en Move path start point to (x,y).
  8586. !#zh 移动路径起点到坐标(x, y)
  8587. @param x The x axis of the coordinate for the end point.
  8588. @param y The y axis of the coordinate for the end point.
  8589. */
  8590. moveTo(x?: number, y?: number): void;
  8591. /**
  8592. !#en Adds a straight line to the path
  8593. !#zh 绘制直线路径
  8594. @param x The x axis of the coordinate for the end point.
  8595. @param y The y axis of the coordinate for the end point.
  8596. */
  8597. lineTo(x?: number, y?: number): void;
  8598. /**
  8599. !#en Adds a cubic Bézier curve to the path
  8600. !#zh 绘制三次贝赛尔曲线路径
  8601. @param c1x The x axis of the coordinate for the first control point.
  8602. @param c1y The y axis of the coordinate for first control point.
  8603. @param c2x The x axis of the coordinate for the second control point.
  8604. @param c2y The y axis of the coordinate for the second control point.
  8605. @param x The x axis of the coordinate for the end point.
  8606. @param y The y axis of the coordinate for the end point.
  8607. */
  8608. bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void;
  8609. /**
  8610. !#en Adds a quadratic Bézier curve to the path
  8611. !#zh 绘制二次贝赛尔曲线路径
  8612. @param cx The x axis of the coordinate for the control point.
  8613. @param cy The y axis of the coordinate for the control point.
  8614. @param x The x axis of the coordinate for the end point.
  8615. @param y The y axis of the coordinate for the end point.
  8616. */
  8617. quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void;
  8618. /**
  8619. !#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).
  8620. !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。
  8621. @param cx The x axis of the coordinate for the center point.
  8622. @param cy The y axis of the coordinate for the center point.
  8623. @param r The arc's radius.
  8624. @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.
  8625. @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.
  8626. @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.
  8627. */
  8628. arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): void;
  8629. /**
  8630. !#en Adds an ellipse to the path.
  8631. !#zh 绘制椭圆路径。
  8632. @param cx The x axis of the coordinate for the center point.
  8633. @param cy The y axis of the coordinate for the center point.
  8634. @param rx The ellipse's x-axis radius.
  8635. @param ry The ellipse's y-axis radius.
  8636. */
  8637. ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void;
  8638. /**
  8639. !#en Adds an circle to the path.
  8640. !#zh 绘制圆形路径。
  8641. @param cx The x axis of the coordinate for the center point.
  8642. @param cy The y axis of the coordinate for the center point.
  8643. @param r The circle's radius.
  8644. */
  8645. circle(cx?: number, cy?: number, r?: number): void;
  8646. /**
  8647. !#en Adds an rectangle to the path.
  8648. !#zh 绘制矩形路径。
  8649. @param x The x axis of the coordinate for the rectangle starting point.
  8650. @param y The y axis of the coordinate for the rectangle starting point.
  8651. @param w The rectangle's width.
  8652. @param h The rectangle's height.
  8653. */
  8654. rect(x?: number, y?: number, w?: number, h?: number): void;
  8655. /**
  8656. !#en Adds an round corner rectangle to the path.
  8657. !#zh 绘制圆角矩形路径。
  8658. @param x The x axis of the coordinate for the rectangle starting point.
  8659. @param y The y axis of the coordinate for the rectangle starting point.
  8660. @param w The rectangles width.
  8661. @param h The rectangle's height.
  8662. @param r The radius of the rectangle.
  8663. */
  8664. roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void;
  8665. /**
  8666. !#en Draws a filled rectangle.
  8667. !#zh 绘制填充矩形。
  8668. @param x The x axis of the coordinate for the rectangle starting point.
  8669. @param y The y axis of the coordinate for the rectangle starting point.
  8670. @param w The rectangle's width.
  8671. @param h The rectangle's height.
  8672. */
  8673. fillRect(x?: number, y?: number, w?: number, h?: number): void;
  8674. /**
  8675. !#en Erasing any previously drawn content.
  8676. !#zh 擦除之前绘制的所有内容的方法。
  8677. @param clean Whether to clean the graphics inner cache.
  8678. */
  8679. clear(clean?: boolean): void;
  8680. /**
  8681. !#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.
  8682. !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。
  8683. */
  8684. close(): void;
  8685. /**
  8686. !#en Strokes the current or given path with the current stroke style.
  8687. !#zh 根据当前的画线样式,绘制当前或已经存在的路径。
  8688. */
  8689. stroke(): void;
  8690. /**
  8691. !#en Fills the current or given path with the current fill style.
  8692. !#zh 根据当前的画线样式,填充当前或已经存在的路径。
  8693. */
  8694. fill(): void;
  8695. }
  8696. /** !#en
  8697. Mesh Renderer Component
  8698. !#zh
  8699. 网格渲染组件 */
  8700. export class MeshRenderer extends RenderComponent {
  8701. /** !#en
  8702. The mesh which the renderer uses.
  8703. !#zh
  8704. 设置使用的网格 */
  8705. mesh: Mesh;
  8706. /** !#en
  8707. Whether the mesh should receive shadows.
  8708. !#zh
  8709. 网格是否接受光源投射的阴影 */
  8710. receiveShadows: boolean;
  8711. /** !#en
  8712. Shadow Casting Mode
  8713. !#zh
  8714. 网格投射阴影的模式 */
  8715. shadowCastingMode: MeshRenderer.ShadowCastingMode;
  8716. /** !#en
  8717. Enable auto merge mesh, only support when mesh's VertexFormat, PrimitiveType, materials are all the same
  8718. !#zh
  8719. 开启自动合并 mesh 功能,只有在网格的 顶点格式,PrimitiveType, 使用的材质 都一致的情况下才会有效 */
  8720. enableAutoBatch: boolean;
  8721. }
  8722. /** !#en Mesh Asset.
  8723. !#zh 网格资源。 */
  8724. export class Mesh extends Asset implements EventTarget {
  8725. /** !#en Get ir set the sub meshes.
  8726. !#zh 设置或者获取子网格。 */
  8727. subMeshes: InputAssembler[];
  8728. /**
  8729. !#en
  8730. Init vertex buffer according to the vertex format.
  8731. !#zh
  8732. 根据顶点格式初始化顶点内存。
  8733. @param vertexFormat vertex format
  8734. @param vertexCount how much vertex should be create in this buffer.
  8735. @param dynamic whether or not to use dynamic buffer.
  8736. @param index index
  8737. */
  8738. init(vertexFormat: gfx.VertexFormat, vertexCount: number, dynamic?: boolean, index?: boolean): void;
  8739. /**
  8740. !#en
  8741. Set the vertex values.
  8742. !#zh
  8743. 设置顶点数据
  8744. @param name the attribute name, e.g. gfx.ATTR_POSITION
  8745. @param values the vertex values
  8746. */
  8747. setVertices(name: string, values: Vec2[]|Vec3[]|Color[]|number[]|Uint8Array|Float32Array): void;
  8748. /**
  8749. !#en
  8750. Set the sub mesh indices.
  8751. !#zh
  8752. 设置子网格索引。
  8753. @param indices the sub mesh indices.
  8754. @param index sub mesh index.
  8755. @param dynamic whether or not to use dynamic buffer.
  8756. */
  8757. setIndices(indices: number[]|Uint16Array|Uint8Array, index?: number, dynamic?: boolean): void;
  8758. /**
  8759. !#en
  8760. Set the sub mesh primitive type.
  8761. !#zh
  8762. 设置子网格绘制线条的方式。
  8763. @param type type
  8764. @param index index
  8765. */
  8766. setPrimitiveType(type: number, index: number): void;
  8767. /**
  8768. !#en
  8769. Clear the buffer data.
  8770. !#zh
  8771. 清除网格创建的内存数据。
  8772. */
  8773. clear(): void;
  8774. /**
  8775. !#en Set mesh bounding box
  8776. !#zh 设置网格的包围盒
  8777. @param min min
  8778. @param max max
  8779. */
  8780. setBoundingBox(min: Vec3, max: Vec3): void;
  8781. /**
  8782. !#en Read the specified attributes of the subgrid into the target buffer.
  8783. !#zh 读取子网格的指定属性到目标缓冲区中。
  8784. @param primitiveIndex The subgrid index.
  8785. @param attributeName attribute name.
  8786. @param buffer The target buffer.
  8787. @param stride The byte interval between adjacent attributes in the target buffer.
  8788. @param offset The offset of the first attribute in the target buffer.
  8789. */
  8790. copyAttribute(primitiveIndex: number, attributeName: string, buffer: ArrayBuffer, stride: number, offset: number): boolean;
  8791. /**
  8792. !#en Read the index data of the subgrid into the target array.
  8793. !#zh 读取子网格的索引数据到目标数组中。
  8794. @param primitiveIndex The subgrid index.
  8795. @param outputArray The target array.
  8796. */
  8797. copyIndices(primitiveIndex: number, outputArray: DataView): boolean;
  8798. /**
  8799. !#en Checks whether the EventTarget object has any callback registered for a specific type of event.
  8800. !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。
  8801. @param type The type of event.
  8802. */
  8803. hasEventListener(type: string): boolean;
  8804. /**
  8805. !#en
  8806. Register an callback of a specific event type on the EventTarget.
  8807. This type of event should be triggered via `emit`.
  8808. !#zh
  8809. 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。
  8810. @param type A string representing the event type to listen for.
  8811. @param callback The callback that will be invoked when the event is dispatched.
  8812. The callback is ignored if it is a duplicate (the callbacks are unique).
  8813. @param target The target (this object) to invoke the callback, can be null
  8814. @example
  8815. ```js
  8816. eventTarget.on('fire', function () {
  8817. cc.log("fire in the hole");
  8818. }, node);
  8819. ```
  8820. */
  8821. on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
  8822. /**
  8823. !#en
  8824. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  8825. if only type is passed as parameter, all listeners registered with that type will be removed.
  8826. !#zh
  8827. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  8828. @param type A string representing the event type being removed.
  8829. @param callback The callback to remove.
  8830. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  8831. @example
  8832. ```js
  8833. // register fire eventListener
  8834. var callback = eventTarget.on('fire', function () {
  8835. cc.log("fire in the hole");
  8836. }, target);
  8837. // remove fire event listener
  8838. eventTarget.off('fire', callback, target);
  8839. // remove all fire event listeners
  8840. eventTarget.off('fire');
  8841. ```
  8842. */
  8843. off(type: string, callback?: Function, target?: any): void;
  8844. /**
  8845. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  8846. This is not for removing all listeners in the current event target,
  8847. and this is not for removing all listeners the target parameter have registered.
  8848. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  8849. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  8850. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  8851. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  8852. @param target The target to be searched for all related listeners
  8853. */
  8854. targetOff(target: any): void;
  8855. /**
  8856. !#en
  8857. Register an callback of a specific event type on the EventTarget,
  8858. the callback will remove itself after the first time it is triggered.
  8859. !#zh
  8860. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  8861. @param type A string representing the event type to listen for.
  8862. @param callback The callback that will be invoked when the event is dispatched.
  8863. The callback is ignored if it is a duplicate (the callbacks are unique).
  8864. @param target The target (this object) to invoke the callback, can be null
  8865. @example
  8866. ```js
  8867. eventTarget.once('fire', function () {
  8868. cc.log("this is the callback and will be invoked only once");
  8869. }, node);
  8870. ```
  8871. */
  8872. once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
  8873. /**
  8874. !#en
  8875. Send an event with the event object.
  8876. !#zh
  8877. 通过事件对象派发事件
  8878. @param event event
  8879. */
  8880. dispatchEvent(event: Event): void;
  8881. }
  8882. /** The class BufferRange denotes a range of the buffer. */
  8883. export class BufferRange {
  8884. /** The offset of the range. */
  8885. offset: number;
  8886. /** The length of the range. */
  8887. length: number;
  8888. }
  8889. /** undefined */
  8890. export class VertexFormat {
  8891. /** The data range of this bundle.
  8892. This range of data is essentially mapped to a GPU vertex buffer. */
  8893. data: BufferRange;
  8894. /** The attribute formats. */
  8895. formats: VertexFormat;
  8896. /** The vertex bundle that the primitive use. */
  8897. vertexBundleIndices: number[];
  8898. /** The data range of the primitive.
  8899. This range of data is essentially mapped to a GPU indices buffer. */
  8900. data: BufferRange;
  8901. /** The type of this primitive's indices. */
  8902. indexUnit: number;
  8903. /** The primitive's topology. */
  8904. topology: number;
  8905. }
  8906. /** !#en the device accelerometer reports values for each axis in units of g-force.
  8907. !#zh 设备重力传感器传递的各个轴的数据。 */
  8908. export class constructor {
  8909. /**
  8910. whether enable accelerometer event
  8911. @param isEnable isEnable
  8912. */
  8913. setAccelerometerEnabled(isEnable: boolean): void;
  8914. /**
  8915. set accelerometer interval value
  8916. @param interval interval
  8917. */
  8918. setAccelerometerInterval(interval: number): void;
  8919. }
  8920. /** undefined */
  8921. export enum VerticalTextAlignment {
  8922. TOP = 0,
  8923. CENTER = 0,
  8924. BOTTOM = 0,
  8925. }
  8926. /** The base class of most of all the objects in Fireball. */
  8927. export class Object {
  8928. /** !#en The name of the object.
  8929. !#zh 该对象的名称。 */
  8930. name: string;
  8931. /** !#en
  8932. Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)<br>
  8933. When an object's `destroy` is called, it is actually destroyed after the end of this frame.
  8934. So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true.
  8935. If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`,
  8936. but this is often caused by a particular logical requirements, which is not normally required.
  8937. !#zh
  8938. 表示该对象是否可用(被 destroy 后将不可用)。<br>
  8939. 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 */
  8940. isValid: boolean;
  8941. /**
  8942. !#en
  8943. Destroy this Object, and release all its own references to other objects.<br/>
  8944. Actual object destruction will delayed until before rendering.
  8945. From the next frame, this object is not usable anymore.
  8946. You can use `cc.isValid(obj)` to check whether the object is destroyed before accessing it.
  8947. !#zh
  8948. 销毁该对象,并释放所有它对其它对象的引用。<br/>
  8949. 实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。
  8950. 您可以在访问对象之前使用 `cc.isValid(obj)` 来检查对象是否已被销毁。
  8951. @example
  8952. ```js
  8953. obj.destroy();
  8954. ```
  8955. */
  8956. destroy(): boolean;
  8957. }
  8958. /** Bit mask that controls object states. */
  8959. export enum Flags {
  8960. DontSave = 0,
  8961. EditorOnly = 0,
  8962. HideInHierarchy = 0,
  8963. }
  8964. /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen.
  8965. It's invalid on safari, QQbrowser and android browser */
  8966. export class screen {
  8967. /**
  8968. initialize
  8969. */
  8970. init(): void;
  8971. /**
  8972. return true if it's full now.
  8973. */
  8974. fullScreen(): boolean;
  8975. /**
  8976. change the screen to full mode.
  8977. @param element element
  8978. @param onFullScreenChange onFullScreenChange
  8979. @param onFullScreenError onFullScreenError
  8980. */
  8981. requestFullScreen(element: Element, onFullScreenChange: Function, onFullScreenError: Function): void;
  8982. /**
  8983. exit the full mode.
  8984. */
  8985. exitFullScreen(): boolean;
  8986. /**
  8987. Automatically request full screen with a touch/click event
  8988. @param element element
  8989. @param onFullScreenChange onFullScreenChange
  8990. */
  8991. autoFullScreen(element: Element, onFullScreenChange: Function): void;
  8992. }
  8993. /** System variables */
  8994. export class sys {
  8995. /** English language code */
  8996. static LANGUAGE_ENGLISH: string;
  8997. /** Chinese language code */
  8998. static LANGUAGE_CHINESE: string;
  8999. /** French language code */
  9000. static LANGUAGE_FRENCH: string;
  9001. /** Italian language code */
  9002. static LANGUAGE_ITALIAN: string;
  9003. /** German language code */
  9004. static LANGUAGE_GERMAN: string;
  9005. /** Spanish language code */
  9006. static LANGUAGE_SPANISH: string;
  9007. /** Spanish language code */
  9008. static LANGUAGE_DUTCH: string;
  9009. /** Russian language code */
  9010. static LANGUAGE_RUSSIAN: string;
  9011. /** Korean language code */
  9012. static LANGUAGE_KOREAN: string;
  9013. /** Japanese language code */
  9014. static LANGUAGE_JAPANESE: string;
  9015. /** Hungarian language code */
  9016. static LANGUAGE_HUNGARIAN: string;
  9017. /** Portuguese language code */
  9018. static LANGUAGE_PORTUGUESE: string;
  9019. /** Arabic language code */
  9020. static LANGUAGE_ARABIC: string;
  9021. /** Norwegian language code */
  9022. static LANGUAGE_NORWEGIAN: string;
  9023. /** Polish language code */
  9024. static LANGUAGE_POLISH: string;
  9025. /** Turkish language code */
  9026. static LANGUAGE_TURKISH: string;
  9027. /** Ukrainian language code */
  9028. static LANGUAGE_UKRAINIAN: string;
  9029. /** Romanian language code */
  9030. static LANGUAGE_ROMANIAN: string;
  9031. /** Bulgarian language code */
  9032. static LANGUAGE_BULGARIAN: string;
  9033. /** Unknown language code */
  9034. static LANGUAGE_UNKNOWN: string;
  9035. static OS_OPENHARMONY: string;
  9036. static OS_IOS: string;
  9037. static OS_ANDROID: string;
  9038. static OS_WINDOWS: string;
  9039. static OS_MARMALADE: string;
  9040. static OS_LINUX: string;
  9041. static OS_BADA: string;
  9042. static OS_BLACKBERRY: string;
  9043. static OS_OSX: string;
  9044. static OS_WP8: string;
  9045. static OS_WINRT: string;
  9046. static OS_UNKNOWN: string;
  9047. static UNKNOWN: number;
  9048. static WIN32: number;
  9049. static LINUX: number;
  9050. static MACOS: number;
  9051. static ANDROID: number;
  9052. static IPHONE: number;
  9053. static IPAD: number;
  9054. static BLACKBERRY: number;
  9055. static NACL: number;
  9056. static EMSCRIPTEN: number;
  9057. static TIZEN: number;
  9058. static WINRT: number;
  9059. static WP8: number;
  9060. static OPENHARMONY: number;
  9061. static MOBILE_BROWSER: number;
  9062. static DESKTOP_BROWSER: number;
  9063. /** Indicates whether executes in editor's window process (Electron's renderer context) */
  9064. static EDITOR_PAGE: number;
  9065. /** Indicates whether executes in editor's main process (Electron's browser context) */
  9066. static EDITOR_CORE: number;
  9067. static WECHAT_GAME: number;
  9068. static QQ_PLAY: number;
  9069. static FB_PLAYABLE_ADS: number;
  9070. static BAIDU_GAME: number;
  9071. static VIVO_GAME: number;
  9072. static OPPO_GAME: number;
  9073. static HUAWEI_GAME: number;
  9074. static XIAOMI_GAME: number;
  9075. static JKW_GAME: number;
  9076. static ALIPAY_GAME: number;
  9077. static WECHAT_GAME_SUB: number;
  9078. static BAIDU_GAME_SUB: number;
  9079. static QTT_GAME: number;
  9080. static BYTEDANCE_GAME: number;
  9081. static BYTEDANCE_GAME_SUB: number;
  9082. static LINKSURE: number;
  9083. static TAOBAO: number;
  9084. static TAOBAO_MINIGAME: number;
  9085. /** BROWSER_TYPE_WECHAT */
  9086. static BROWSER_TYPE_WECHAT: string;
  9087. static BROWSER_TYPE_ANDROID: string;
  9088. static BROWSER_TYPE_IE: string;
  9089. static BROWSER_TYPE_EDGE: string;
  9090. static BROWSER_TYPE_QQ: string;
  9091. static BROWSER_TYPE_MOBILE_QQ: string;
  9092. static BROWSER_TYPE_UC: string;
  9093. /** uc third party integration. */
  9094. static BROWSER_TYPE_UCBS: string;
  9095. static BROWSER_TYPE_360: string;
  9096. static BROWSER_TYPE_BAIDU_APP: string;
  9097. static BROWSER_TYPE_BAIDU: string;
  9098. static BROWSER_TYPE_MAXTHON: string;
  9099. static BROWSER_TYPE_OPERA: string;
  9100. static BROWSER_TYPE_OUPENG: string;
  9101. static BROWSER_TYPE_MIUI: string;
  9102. static BROWSER_TYPE_FIREFOX: string;
  9103. static BROWSER_TYPE_SAFARI: string;
  9104. static BROWSER_TYPE_CHROME: string;
  9105. static BROWSER_TYPE_LIEBAO: string;
  9106. static BROWSER_TYPE_QZONE: string;
  9107. static BROWSER_TYPE_SOUGOU: string;
  9108. static BROWSER_TYPE_HUAWEI: string;
  9109. static BROWSER_TYPE_UNKNOWN: string;
  9110. /** Is native ? This is set to be true in jsb auto. */
  9111. static isNative: boolean;
  9112. /** Is web browser ? */
  9113. static isBrowser: boolean;
  9114. /**
  9115. Is webgl extension support?
  9116. @param name name
  9117. */
  9118. static glExtension(name: any): boolean;
  9119. /**
  9120. Get max joint matrix size for skinned mesh renderer.
  9121. */
  9122. static getMaxJointMatrixSize(): void;
  9123. /**
  9124. !#en
  9125. Returns the safe area of the screen (in design resolution). If the screen is not notched, the visibleRect will be returned by default.
  9126. Currently supports Android, iOS and WeChat Mini Game platform.
  9127. !#zh
  9128. 返回手机屏幕安全区域(设计分辨率为单位),如果不是异形屏将默认返回 visibleRect。目前支持安卓、iOS 原生平台和微信小游戏平台。
  9129. */
  9130. static getSafeAreaRect(): Rect;
  9131. /** Indicate whether system is mobile system */
  9132. static isMobile: boolean;
  9133. /** Indicate the running platform */
  9134. static platform: number;
  9135. /** Get current language iso 639-1 code.
  9136. Examples of valid language codes include "zh-tw", "en", "en-us", "fr", "fr-fr", "es-es", etc.
  9137. The actual value totally depends on results provided by destination platform. */
  9138. static languageCode: string;
  9139. /** Indicate the current language of the running system */
  9140. static language: string;
  9141. /** Indicate the running os name */
  9142. static os: string;
  9143. /** Indicate the running os version */
  9144. static osVersion: string;
  9145. /** Indicate the running os main version */
  9146. static osMainVersion: number;
  9147. /** Indicate the running browser type */
  9148. static browserType: string|void;
  9149. /** Indicate the running browser version */
  9150. static browserVersion: string|void;
  9151. /** Indicate the real pixel resolution of the whole game window */
  9152. static windowPixelResolution: Size;
  9153. /** cc.sys.localStorage is a local storage component. */
  9154. static localStorage: any;
  9155. /** The capabilities of the current platform */
  9156. static capabilities: any;
  9157. /**
  9158. !#en
  9159. Get the network type of current device, return cc.sys.NetworkType.LAN if failure.
  9160. !#zh
  9161. 获取当前设备的网络类型, 如果网络类型无法获取,默认将返回 cc.sys.NetworkType.LAN
  9162. */
  9163. static getNetworkType(): sys.NetworkType;
  9164. /**
  9165. !#en
  9166. Get the battery level of current device, return 1.0 if failure.
  9167. !#zh
  9168. 获取当前设备的电池电量,如果电量无法获取,默认将返回 1
  9169. */
  9170. static getBatteryLevel(): number;
  9171. /**
  9172. Forces the garbage collection, only available in JSB
  9173. */
  9174. static garbageCollect(): void;
  9175. /**
  9176. Restart the JS VM, only available in JSB
  9177. */
  9178. static restartVM(): void;
  9179. /**
  9180. Check whether an object is valid,
  9181. In web engine, it will return true if the object exist
  9182. In native engine, it will return true if the JS object and the correspond native object are both valid
  9183. @param obj obj
  9184. */
  9185. static isObjectValid(obj: any): boolean;
  9186. /**
  9187. Dump system informations
  9188. */
  9189. static dump(): void;
  9190. /**
  9191. Open a url in browser
  9192. @param url url
  9193. */
  9194. static openURL(url: string): void;
  9195. /**
  9196. Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
  9197. */
  9198. static now(): number;
  9199. }
  9200. /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view,
  9201. it should represent the same rect as cc.view.getViewportRect() */
  9202. export class visibleRect {
  9203. /**
  9204. initialize
  9205. @param visibleRect visibleRect
  9206. */
  9207. static init(visibleRect: Rect): void;
  9208. /** Top left coordinate of the screen related to the game scene. */
  9209. static topLeft: Vec2;
  9210. /** Top right coordinate of the screen related to the game scene. */
  9211. static topRight: Vec2;
  9212. /** Top center coordinate of the screen related to the game scene. */
  9213. static top: Vec2;
  9214. /** Bottom left coordinate of the screen related to the game scene. */
  9215. static bottomLeft: Vec2;
  9216. /** Bottom right coordinate of the screen related to the game scene. */
  9217. static bottomRight: Vec2;
  9218. /** Bottom center coordinate of the screen related to the game scene. */
  9219. static bottom: Vec2;
  9220. /** Center coordinate of the screen related to the game scene. */
  9221. static center: Vec2;
  9222. /** Left center coordinate of the screen related to the game scene. */
  9223. static left: Vec2;
  9224. /** Right center coordinate of the screen related to the game scene. */
  9225. static right: Vec2;
  9226. /** Width of the screen. */
  9227. static width: number;
  9228. /** Height of the screen. */
  9229. static height: number;
  9230. }
  9231. /** cc.view is the singleton object which represents the game window.<br/>
  9232. It's main task include: <br/>
  9233. - Apply the design resolution policy<br/>
  9234. - Provide interaction with the window, like resize event on web, retina display support, etc...<br/>
  9235. - Manage the game view port which can be different with the window<br/>
  9236. - Manage the content scale and translation<br/>
  9237. <br/>
  9238. Since the cc.view is a singleton, you don't need to call any constructor or create functions,<br/>
  9239. the standard way to use it is by calling:<br/>
  9240. - cc.view.methodName(); <br/> */
  9241. export class View extends EventTarget {
  9242. /**
  9243. !#en
  9244. Sets view's target-densitydpi for android mobile browser. it can be set to: <br/>
  9245. 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi" <br/>
  9246. 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value) <br/>
  9247. 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value) <br/>
  9248. 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi" <br/>
  9249. 5. Custom value, e.g: "480" <br/>
  9250. !#zh 设置目标内容的每英寸像素点密度。
  9251. @param densityDPI densityDPI
  9252. */
  9253. setTargetDensityDPI(densityDPI: string): void;
  9254. /**
  9255. !#en
  9256. Returns the current target-densitydpi value of cc.view.
  9257. !#zh 获取目标内容的每英寸像素点密度。
  9258. */
  9259. getTargetDensityDPI(): string;
  9260. /**
  9261. !#en
  9262. Sets whether resize canvas automatically when browser's size changed.<br/>
  9263. Useful only on web.
  9264. !#zh 设置当发现浏览器的尺寸改变时,是否自动调整 canvas 尺寸大小。
  9265. 仅在 Web 模式下有效。
  9266. @param enabled Whether enable automatic resize with browser's resize event
  9267. */
  9268. resizeWithBrowserSize(enabled: boolean): void;
  9269. /**
  9270. !#en
  9271. Sets the callback function for cc.view's resize action,<br/>
  9272. this callback will be invoked before applying resolution policy, <br/>
  9273. so you can do any additional modifications within the callback.<br/>
  9274. Useful only on web.
  9275. !#zh 设置 cc.view 调整视窗尺寸行为的回调函数,
  9276. 这个回调函数会在应用适配模式之前被调用,
  9277. 因此你可以在这个回调函数内添加任意附加改变,
  9278. 仅在 Web 平台下有效。
  9279. @param callback The callback function
  9280. */
  9281. setResizeCallback(callback: Function|void): void;
  9282. /**
  9283. !#en
  9284. Sets the orientation of the game, it can be landscape, portrait or auto.
  9285. When set it to landscape or portrait, and screen w/h ratio doesn't fit,
  9286. cc.view will automatically rotate the game canvas using CSS.
  9287. Note that this function doesn't have any effect in native,
  9288. in native, you need to set the application orientation in native project settings
  9289. !#zh 设置游戏屏幕朝向,它能够是横版,竖版或自动。
  9290. 当设置为横版或竖版,并且屏幕的宽高比例不匹配时,
  9291. cc.view 会自动用 CSS 旋转游戏场景的 canvas,
  9292. 这个方法不会对 native 部分产生任何影响,对于 native 而言,你需要在应用设置中的设置排版。
  9293. @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO
  9294. */
  9295. setOrientation(orientation: number): void;
  9296. /**
  9297. !#en
  9298. Sets whether the engine modify the "viewport" meta in your web page.<br/>
  9299. It's enabled by default, we strongly suggest you not to disable it.<br/>
  9300. And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden<br/>
  9301. Only useful on web
  9302. !#zh 设置引擎是否调整 viewport meta 来配合屏幕适配。
  9303. 默认设置为启动,我们强烈建议你不要将它设置为关闭。
  9304. 即使当它启动时,你仍然能够设置你的 viewport meta,它不会被覆盖。
  9305. 仅在 Web 模式下有效
  9306. @param enabled Enable automatic modification to "viewport" meta
  9307. */
  9308. adjustViewportMeta(enabled: boolean): void;
  9309. /**
  9310. !#en
  9311. Retina support is enabled by default for Apple device but disabled for other devices,<br/>
  9312. it takes effect only when you called setDesignResolutionPolicy<br/>
  9313. Only useful on web
  9314. !#zh 对于 Apple 这种支持 Retina 显示的设备上默认进行优化而其他类型设备默认不进行优化,
  9315. 它仅会在你调用 setDesignResolutionPolicy 方法时有影响。
  9316. 仅在 Web 模式下有效。
  9317. @param enabled Enable or disable retina display
  9318. */
  9319. enableRetina(enabled: boolean): void;
  9320. /**
  9321. !#en
  9322. Check whether retina display is enabled.<br/>
  9323. Only useful on web
  9324. !#zh 检查是否对 Retina 显示设备进行优化。
  9325. 仅在 Web 模式下有效。
  9326. */
  9327. isRetinaEnabled(): boolean;
  9328. /**
  9329. !#en Whether to Enable on anti-alias
  9330. !#zh 控制抗锯齿是否开启
  9331. @param enabled Enable or not anti-alias
  9332. */
  9333. enableAntiAlias(enabled: boolean): void;
  9334. /**
  9335. !#en Returns whether the current enable on anti-alias
  9336. !#zh 返回当前是否抗锯齿
  9337. */
  9338. isAntiAliasEnabled(): boolean;
  9339. /**
  9340. !#en
  9341. If enabled, the application will try automatically to enter full screen mode on mobile devices<br/>
  9342. You can pass true as parameter to enable it and disable it by passing false.<br/>
  9343. Only useful on web
  9344. !#zh 启动时,移动端游戏会在移动端自动尝试进入全屏模式。
  9345. 你能够传入 true 为参数去启动它,用 false 参数来关闭它。
  9346. @param enabled Enable or disable auto full screen on mobile devices
  9347. */
  9348. enableAutoFullScreen(enabled: boolean): void;
  9349. /**
  9350. !#en
  9351. Check whether auto full screen is enabled.<br/>
  9352. Only useful on web
  9353. !#zh 检查自动进入全屏模式是否启动。
  9354. 仅在 Web 模式下有效。
  9355. */
  9356. isAutoFullScreenEnabled(): boolean;
  9357. /**
  9358. !#en
  9359. Returns the canvas size of the view.<br/>
  9360. On native platforms, it returns the screen size since the view is a fullscreen view.<br/>
  9361. On web, it returns the size of the canvas element.
  9362. !#zh 返回视图中 canvas 的尺寸。
  9363. 在 native 平台下,它返回全屏视图下屏幕的尺寸。
  9364. 在 Web 平台下,它返回 canvas 元素尺寸。
  9365. */
  9366. getCanvasSize(): Size;
  9367. /**
  9368. !#en
  9369. Returns the frame size of the view.<br/>
  9370. On native platforms, it returns the screen size since the view is a fullscreen view.<br/>
  9371. On web, it returns the size of the canvas's outer DOM element.
  9372. !#zh 返回视图中边框尺寸。
  9373. 在 native 平台下,它返回全屏视图下屏幕的尺寸。
  9374. 在 web 平台下,它返回 canvas 元素的外层 DOM 元素尺寸。
  9375. */
  9376. getFrameSize(): Size;
  9377. /**
  9378. !#en
  9379. On native, it sets the frame size of view.<br/>
  9380. On web, it sets the size of the canvas's outer DOM element.
  9381. !#zh 在 native 平台下,设置视图框架尺寸。
  9382. 在 web 平台下,设置 canvas 外层 DOM 元素尺寸。
  9383. @param width width
  9384. @param height height
  9385. */
  9386. setFrameSize(width: number, height: number): void;
  9387. /**
  9388. !#en
  9389. Returns the visible area size of the view port.
  9390. !#zh 返回视图窗口可见区域尺寸。
  9391. */
  9392. getVisibleSize(): Size;
  9393. /**
  9394. !#en
  9395. Returns the visible area size of the view port.
  9396. !#zh 返回视图窗口可见区域像素尺寸。
  9397. */
  9398. getVisibleSizeInPixel(): Size;
  9399. /**
  9400. !#en
  9401. Returns the visible origin of the view port.
  9402. !#zh 返回视图窗口可见区域原点。
  9403. */
  9404. getVisibleOrigin(): Vec2;
  9405. /**
  9406. !#en
  9407. Returns the visible origin of the view port.
  9408. !#zh 返回视图窗口可见区域像素原点。
  9409. */
  9410. getVisibleOriginInPixel(): Vec2;
  9411. /**
  9412. !#en
  9413. Returns the current resolution policy
  9414. !#zh 返回当前分辨率方案
  9415. */
  9416. getResolutionPolicy(): ResolutionPolicy;
  9417. /**
  9418. !#en
  9419. Sets the current resolution policy
  9420. !#zh 设置当前分辨率模式
  9421. @param resolutionPolicy resolutionPolicy
  9422. */
  9423. setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void;
  9424. /**
  9425. !#en
  9426. Sets the resolution policy with designed view size in points.<br/>
  9427. The resolution policy include: <br/>
  9428. [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/>
  9429. [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/>
  9430. [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/>
  9431. [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width<br/>
  9432. [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height<br/>
  9433. [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy<br/>
  9434. !#zh 通过设置设计分辨率和匹配模式来进行游戏画面的屏幕适配。
  9435. @param width Design resolution width.
  9436. @param height Design resolution height.
  9437. @param resolutionPolicy The resolution policy desired
  9438. */
  9439. setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void;
  9440. /**
  9441. !#en
  9442. Returns the designed size for the view.
  9443. Default resolution size is the same as 'getFrameSize'.
  9444. !#zh 返回视图的设计分辨率。
  9445. 默认下分辨率尺寸同 `getFrameSize` 方法相同
  9446. */
  9447. getDesignResolutionSize(): Size;
  9448. /**
  9449. !#en
  9450. Sets the container to desired pixel resolution and fit the game content to it.
  9451. This function is very useful for adaptation in mobile browsers.
  9452. In some HD android devices, the resolution is very high, but its browser performance may not be very good.
  9453. In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry.
  9454. But this API can be helpful to set a desired pixel resolution which is in between.
  9455. This API will do the following:
  9456. 1. Set viewport's width to the desired width in pixel
  9457. 2. Set body width to the exact pixel resolution
  9458. 3. The resolution policy will be reset with designed view size in points.
  9459. !#zh 设置容器(container)需要的像素分辨率并且适配相应分辨率的游戏内容。
  9460. @param width Design resolution width.
  9461. @param height Design resolution height.
  9462. @param resolutionPolicy The resolution policy desired
  9463. */
  9464. setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void;
  9465. /**
  9466. !#en
  9467. Sets view port rectangle with points.
  9468. !#zh 用设计分辨率下的点尺寸来设置视窗。
  9469. @param x x
  9470. @param y y
  9471. @param w width
  9472. @param h height
  9473. */
  9474. setViewportInPoints(x: number, y: number, w: number, h: number): void;
  9475. /**
  9476. !#en
  9477. Sets Scissor rectangle with points.
  9478. !#zh 用设计分辨率下的点的尺寸来设置 scissor 剪裁区域。
  9479. @param x x
  9480. @param y y
  9481. @param w w
  9482. @param h h
  9483. */
  9484. setScissorInPoints(x: number, y: number, w: number, h: number): void;
  9485. /**
  9486. !#en
  9487. Returns whether GL_SCISSOR_TEST is enable
  9488. !#zh 检查 scissor 是否生效。
  9489. */
  9490. isScissorEnabled(): boolean;
  9491. /**
  9492. !#en
  9493. Returns the current scissor rectangle
  9494. !#zh 返回当前的 scissor 剪裁区域。
  9495. */
  9496. getScissorRect(): Rect;
  9497. /**
  9498. !#en
  9499. Returns the view port rectangle.
  9500. !#zh 返回视窗剪裁区域。
  9501. */
  9502. getViewportRect(): Rect;
  9503. /**
  9504. !#en
  9505. Returns scale factor of the horizontal direction (X axis).
  9506. !#zh 返回横轴的缩放比,这个缩放比是将画布像素分辨率放到设计分辨率的比例。
  9507. */
  9508. getScaleX(): number;
  9509. /**
  9510. !#en
  9511. Returns scale factor of the vertical direction (Y axis).
  9512. !#zh 返回纵轴的缩放比,这个缩放比是将画布像素分辨率缩放到设计分辨率的比例。
  9513. */
  9514. getScaleY(): number;
  9515. /**
  9516. !#en
  9517. Returns device pixel ratio for retina display.
  9518. !#zh 返回设备或浏览器像素比例。
  9519. */
  9520. getDevicePixelRatio(): number;
  9521. /**
  9522. !#en
  9523. Returns the real location in view for a translation based on a related position
  9524. !#zh 将屏幕坐标转换为游戏视图下的坐标。
  9525. @param tx The X axis translation
  9526. @param ty The Y axis translation
  9527. @param relatedPos The related position object including "left", "top", "width", "height" informations
  9528. */
  9529. convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2;
  9530. }
  9531. /** <p>cc.game.containerStrategy class is the root strategy class of container's scale strategy,
  9532. it controls the behavior of how to scale the cc.game.container and cc.game.canvas object</p> */
  9533. export class ContainerStrategy {
  9534. /**
  9535. !#en
  9536. Manipulation before appling the strategy
  9537. !#zh 在应用策略之前的操作
  9538. @param view The target view
  9539. */
  9540. preApply(view: View): void;
  9541. /**
  9542. !#en
  9543. Function to apply this strategy
  9544. !#zh 策略应用方法
  9545. @param view view
  9546. @param designedResolution designedResolution
  9547. */
  9548. apply(view: View, designedResolution: Size): void;
  9549. /**
  9550. !#en
  9551. Manipulation after applying the strategy
  9552. !#zh 策略调用之后的操作
  9553. @param view The target view
  9554. */
  9555. postApply(view: View): void;
  9556. }
  9557. /** <p>cc.ContentStrategy class is the root strategy class of content's scale strategy,
  9558. it controls the behavior of how to scale the scene and setup the viewport for the game</p> */
  9559. export class ContentStrategy {
  9560. /**
  9561. !#en
  9562. Manipulation before applying the strategy
  9563. !#zh 策略应用前的操作
  9564. @param view The target view
  9565. */
  9566. preApply(view: View): void;
  9567. /**
  9568. !#en Function to apply this strategy
  9569. The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
  9570. The target view can then apply these value to itself, it's preferred not to modify directly its private variables
  9571. !#zh 调用策略方法
  9572. @param view view
  9573. @param designedResolution designedResolution
  9574. */
  9575. apply(view: View, designedResolution: Size): any;
  9576. /**
  9577. !#en
  9578. Manipulation after applying the strategy
  9579. !#zh 策略调用之后的操作
  9580. @param view The target view
  9581. */
  9582. postApply(view: View): void;
  9583. }
  9584. /** undefined */
  9585. export class EqualToFrame extends ContainerStrategy {
  9586. }
  9587. /** undefined */
  9588. export class ProportionalToFrame extends ContainerStrategy {
  9589. }
  9590. /** undefined */
  9591. export class EqualToWindow extends EqualToFrame {
  9592. }
  9593. /** undefined */
  9594. export class ProportionalToWindow extends ProportionalToFrame {
  9595. }
  9596. /** undefined */
  9597. export class OriginalContainer extends ContainerStrategy {
  9598. }
  9599. /** <p>cc.ResolutionPolicy class is the root strategy class of scale strategy,
  9600. its main task is to maintain the compatibility with Cocos2d-x</p> */
  9601. export class ResolutionPolicy {
  9602. /**
  9603. @param containerStg The container strategy
  9604. @param contentStg The content strategy
  9605. */
  9606. constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy);
  9607. /**
  9608. !#en Manipulation before applying the resolution policy
  9609. !#zh 策略应用前的操作
  9610. @param view The target view
  9611. */
  9612. preApply(view: View): void;
  9613. /**
  9614. !#en Function to apply this resolution policy
  9615. The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
  9616. The target view can then apply these value to itself, it's preferred not to modify directly its private variables
  9617. !#zh 调用策略方法
  9618. @param view The target view
  9619. @param designedResolution The user defined design resolution
  9620. */
  9621. apply(view: View, designedResolution: Size): any;
  9622. /**
  9623. !#en Manipulation after appyling the strategy
  9624. !#zh 策略应用之后的操作
  9625. @param view The target view
  9626. */
  9627. postApply(view: View): void;
  9628. /**
  9629. !#en
  9630. Setup the container's scale strategy
  9631. !#zh 设置容器的适配策略
  9632. @param containerStg containerStg
  9633. */
  9634. setContainerStrategy(containerStg: ContainerStrategy): void;
  9635. /**
  9636. !#en
  9637. Setup the content's scale strategy
  9638. !#zh 设置内容的适配策略
  9639. @param contentStg contentStg
  9640. */
  9641. setContentStrategy(contentStg: ContentStrategy): void;
  9642. /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.<br/>
  9643. Distortion can occur, and the application may appear stretched or compressed. */
  9644. static EXACT_FIT: number;
  9645. /** The entire application fills the specified area, without distortion but possibly with some cropping,<br/>
  9646. while maintaining the original aspect ratio of the application. */
  9647. static NO_BORDER: number;
  9648. /** The entire application is visible in the specified area without distortion while maintaining the original<br/>
  9649. aspect ratio of the application. Borders can appear on two sides of the application. */
  9650. static SHOW_ALL: number;
  9651. /** The application takes the height of the design resolution size and modifies the width of the internal<br/>
  9652. canvas so that it fits the aspect ratio of the device<br/>
  9653. no distortion will occur however you must make sure your application works on different<br/>
  9654. aspect ratios */
  9655. static FIXED_HEIGHT: number;
  9656. /** The application takes the width of the design resolution size and modifies the height of the internal<br/>
  9657. canvas so that it fits the aspect ratio of the device<br/>
  9658. no distortion will occur however you must make sure your application works on different<br/>
  9659. aspect ratios */
  9660. static FIXED_WIDTH: number;
  9661. /** Unknow policy */
  9662. static UNKNOWN: number;
  9663. }
  9664. /** !#en The callbacks invoker to handle and invoke callbacks by key.
  9665. !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */
  9666. export class CallbacksInvoker {
  9667. /**
  9668. !#zh
  9669. 检查指定事件是否已注册回调。
  9670. !#en
  9671. Check if the specified key has any registered callback. If a callback is also specified,
  9672. it will only return true if the callback is registered.
  9673. @param key key
  9674. @param callback callback
  9675. @param target target
  9676. */
  9677. hasEventListener(key: string, callback?: Function, target?: any): boolean;
  9678. /**
  9679. !#zh
  9680. 移除在特定事件类型中注册的所有回调或在某个目标中注册的所有回调。
  9681. !#en
  9682. Removes all callbacks registered in a certain event type or all callbacks registered with a certain target
  9683. @param keyOrTarget The event key to be removed or the target to be removed
  9684. */
  9685. removeAll(keyOrTarget: string|any): void;
  9686. /**
  9687. !#zh
  9688. 删除之前与同类型,回调,目标注册的回调。
  9689. @param key key
  9690. @param callback callback
  9691. @param target target
  9692. */
  9693. off(key: string, callback: Function, target?: any): void;
  9694. /**
  9695. !#en
  9696. Trigger an event directly with the event name and necessary arguments.
  9697. !#zh
  9698. 通过事件名发送自定义事件
  9699. @param key event type
  9700. @param arg1 First argument
  9701. @param arg2 Second argument
  9702. @param arg3 Third argument
  9703. @param arg4 Fourth argument
  9704. @param arg5 Fifth argument
  9705. @example
  9706. ```js
  9707. eventTarget.emit('fire', event);
  9708. eventTarget.emit('fire', message, emitter);
  9709. ```
  9710. */
  9711. emit(key: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void;
  9712. }
  9713. /** !#en Contains information collected during deserialization
  9714. !#zh 包含反序列化时的一些信息 */
  9715. export class Details {
  9716. /** the obj list whose field needs to load asset by uuid */
  9717. uuidObjList: any[];
  9718. /** the corresponding field name which referenced to the asset */
  9719. uuidPropList: (String|Number)[];
  9720. /** list of the depends assets' uuid */
  9721. uuidList: string[];
  9722. /**
  9723. @param data data
  9724. */
  9725. init(data: any): void;
  9726. reset(): void;
  9727. /**
  9728. @param obj obj
  9729. @param propName propName
  9730. @param uuid uuid
  9731. */
  9732. push(obj: any, propName: string, uuid: string): void;
  9733. /** list of the depends assets' uuid */
  9734. uuidList: string[];
  9735. /** the obj list whose field needs to load asset by uuid */
  9736. uuidObjList: any[];
  9737. /** the corresponding field name which referenced to the asset */
  9738. uuidPropList: string[];
  9739. reset(): void;
  9740. /**
  9741. @param obj obj
  9742. @param propName propName
  9743. @param uuid uuid
  9744. */
  9745. push(obj: any, propName: string, uuid: string): void;
  9746. }
  9747. /** !#en The renderer object which provide access to render system APIs,
  9748. detailed APIs will be available progressively.
  9749. !#zh 提供基础渲染接口的渲染器对象,渲染层的基础接口将逐步开放给用户 */
  9750. export class renderer {
  9751. /** !#en The render engine is available only after cc.game.EVENT_ENGINE_INITED event.<br/>
  9752. Normally it will be inited as the webgl render engine, but in wechat open context domain,
  9753. it will be inited as the canvas render engine. Canvas render engine is no longer available for other use case since v2.0.
  9754. !#zh 基础渲染引擎对象只在 cc.game.EVENT_ENGINE_INITED 事件触发后才可获取。<br/>
  9755. 大多数情况下,它都会是 WebGL 渲染引擎实例,但是在微信开放数据域当中,它会是 Canvas 渲染引擎实例。请注意,从 2.0 开始,我们在其他平台和环境下都废弃了 Canvas 渲染器。 */
  9756. static renderEngine: any;
  9757. /** !#en The total draw call count in last rendered frame.
  9758. !#zh 上一次渲染帧所提交的渲染批次总数。 */
  9759. static drawCalls: number;
  9760. }
  9761. /** undefined */
  9762. export class WorldManifold {
  9763. /** !#en
  9764. world contact point (point of intersection)
  9765. !#zh
  9766. 碰撞点集合 */
  9767. points: Vec2[];
  9768. /** !#en
  9769. world vector pointing from A to B
  9770. !#zh
  9771. 世界坐标系下由 A 指向 B 的向量 */
  9772. normal: Vec2;
  9773. }
  9774. /** !#en
  9775. A manifold point is a contact point belonging to a contact manifold.
  9776. It holds details related to the geometry and dynamics of the contact points.
  9777. Note: the impulses are used for internal caching and may not
  9778. provide reliable contact forces, especially for high speed collisions.
  9779. !#zh
  9780. ManifoldPoint 是接触信息中的接触点信息。它拥有关于几何和接触点的详细信息。
  9781. 注意:信息中的冲量用于系统内部缓存,提供的接触力可能不是很准确,特别是高速移动中的碰撞信息。 */
  9782. export class ManifoldPoint {
  9783. /** !#en
  9784. The local point usage depends on the manifold type:
  9785. -e_circles: the local center of circleB
  9786. -e_faceA: the local center of circleB or the clip point of polygonB
  9787. -e_faceB: the clip point of polygonA
  9788. !#zh
  9789. 本地坐标点的用途取决于 manifold 的类型
  9790. - e_circles: circleB 的本地中心点
  9791. - e_faceA: circleB 的本地中心点 或者是 polygonB 的截取点
  9792. - e_faceB: polygonB 的截取点 */
  9793. localPoint: Vec2;
  9794. /** !#en
  9795. Normal impulse.
  9796. !#zh
  9797. 法线冲量。 */
  9798. normalImpulse: number;
  9799. /** !#en
  9800. Tangent impulse.
  9801. !#zh
  9802. 切线冲量。 */
  9803. tangentImpulse: number;
  9804. }
  9805. /** undefined */
  9806. export class Manifold {
  9807. /** !#en
  9808. Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB
  9809. !#zh
  9810. Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */
  9811. type: number;
  9812. /** !#en
  9813. The local point usage depends on the manifold type:
  9814. -e_circles: the local center of circleA
  9815. -e_faceA: the center of faceA
  9816. -e_faceB: the center of faceB
  9817. !#zh
  9818. 用途取决于 manifold 类型
  9819. -e_circles: circleA 的本地中心点
  9820. -e_faceA: faceA 的本地中心点
  9821. -e_faceB: faceB 的本地中心点 */
  9822. localPoint: Vec2;
  9823. /** !#en
  9824. -e_circles: not used
  9825. -e_faceA: the normal on polygonA
  9826. -e_faceB: the normal on polygonB
  9827. !#zh
  9828. -e_circles: 没被使用到
  9829. -e_faceA: polygonA 的法向量
  9830. -e_faceB: polygonB 的法向量 */
  9831. localNormal: Vec2;
  9832. /** !#en
  9833. the points of contact.
  9834. !#zh
  9835. 接触点信息。 */
  9836. points: ManifoldPoint[];
  9837. }
  9838. /** !#en
  9839. Contact impulses for reporting.
  9840. !#zh
  9841. 用于返回给回调的接触冲量。 */
  9842. export class PhysicsImpulse {
  9843. /** !#en
  9844. Normal impulses.
  9845. !#zh
  9846. 法线方向的冲量 */
  9847. normalImpulses: any;
  9848. /** !#en
  9849. Tangent impulses
  9850. !#zh
  9851. 切线方向的冲量 */
  9852. tangentImpulses: any;
  9853. }
  9854. /** !#en
  9855. PhysicsContact will be generated during begin and end collision as a parameter of the collision callback.
  9856. Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact.
  9857. !#zh
  9858. 物理接触会在开始和结束碰撞之间生成,并作为参数传入到碰撞回调函数中。
  9859. 注意:传入的物理接触会被系统进行重用,所以不要在使用中缓存里面的任何信息。 */
  9860. export class PhysicsContact {
  9861. /**
  9862. !#en
  9863. Get the world manifold.
  9864. !#zh
  9865. 获取世界坐标系下的碰撞信息。
  9866. */
  9867. getWorldManifold(): WorldManifold;
  9868. /**
  9869. !#en
  9870. Get the manifold.
  9871. !#zh
  9872. 获取本地(局部)坐标系下的碰撞信息。
  9873. */
  9874. getManifold(): Manifold;
  9875. /**
  9876. !#en
  9877. Get the impulses.
  9878. Note: PhysicsImpulse can only used in onPostSolve callback.
  9879. !#zh
  9880. 获取冲量信息
  9881. 注意:这个信息只有在 onPostSolve 回调中才能获取到
  9882. */
  9883. getImpulse(): PhysicsImpulse;
  9884. /** !#en
  9885. One of the collider that collided
  9886. !#zh
  9887. 发生碰撞的碰撞体之一 */
  9888. colliderA: Collider;
  9889. /** !#en
  9890. One of the collider that collided
  9891. !#zh
  9892. 发生碰撞的碰撞体之一 */
  9893. colliderB: Collider;
  9894. /** !#en
  9895. If set disabled to true, the contact will be ignored until contact end.
  9896. If you just want to disabled contact for current time step or sub-step, please use disabledOnce.
  9897. !#zh
  9898. 如果 disabled 被设置为 true,那么直到接触结束此接触都将被忽略。
  9899. 如果只是希望在当前时间步或子步中忽略此接触,请使用 disabledOnce 。 */
  9900. disabled: boolean;
  9901. /** !#en
  9902. Disabled contact for current time step or sub-step.
  9903. !#zh
  9904. 在当前时间步或子步中忽略此接触。 */
  9905. disabledOnce: boolean;
  9906. /**
  9907. !#en
  9908. Is this contact touching?
  9909. !#zh
  9910. 返回碰撞体是否已经接触到。
  9911. */
  9912. isTouching(): boolean;
  9913. /**
  9914. !#en
  9915. Set the desired tangent speed for a conveyor belt behavior.
  9916. !#zh
  9917. 为传送带设置期望的切线速度
  9918. @param tangentSpeed tangentSpeed
  9919. */
  9920. setTangentSpeed(tangentSpeed: number): void;
  9921. /**
  9922. !#en
  9923. Get the desired tangent speed.
  9924. !#zh
  9925. 获取切线速度
  9926. */
  9927. getTangentSpeed(): number;
  9928. /**
  9929. !#en
  9930. Override the default friction mixture. You can call this in onPreSolve callback.
  9931. !#zh
  9932. 覆盖默认的摩擦力系数。你可以在 onPreSolve 回调中调用此函数。
  9933. @param friction friction
  9934. */
  9935. setFriction(friction: number): void;
  9936. /**
  9937. !#en
  9938. Get the friction.
  9939. !#zh
  9940. 获取当前摩擦力系数
  9941. */
  9942. getFriction(): number;
  9943. /**
  9944. !#en
  9945. Reset the friction mixture to the default value.
  9946. !#zh
  9947. 重置摩擦力系数到默认值
  9948. */
  9949. resetFriction(): void;
  9950. /**
  9951. !#en
  9952. Override the default restitution mixture. You can call this in onPreSolve callback.
  9953. !#zh
  9954. 覆盖默认的恢复系数。你可以在 onPreSolve 回调中调用此函数。
  9955. @param restitution restitution
  9956. */
  9957. setRestitution(restitution: number): void;
  9958. /**
  9959. !#en
  9960. Get the restitution.
  9961. !#zh
  9962. 获取当前恢复系数
  9963. */
  9964. getRestitution(): number;
  9965. /**
  9966. !#en
  9967. Reset the restitution mixture to the default value.
  9968. !#zh
  9969. 重置恢复系数到默认值
  9970. */
  9971. resetRestitution(): void;
  9972. }
  9973. /** !#en Enum for RigidBodyType.
  9974. !#zh 刚体类型 */
  9975. export enum RigidBodyType {
  9976. Static = 0,
  9977. Kinematic = 0,
  9978. Dynamic = 0,
  9979. Animated = 0,
  9980. }
  9981. /** !#en Enum for RayCastType.
  9982. !#zh 射线检测类型 */
  9983. export enum RayCastType {
  9984. Closest = 0,
  9985. Any = 0,
  9986. AllClosest = 0,
  9987. All = 0,
  9988. }
  9989. /** !#en
  9990. Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node).
  9991. You can visit some common box2d function through physics manager(hit testing, raycast, debug info).
  9992. Physics manager distributes the collision information to each collision callback when collision is produced.
  9993. Note: You need first enable the collision listener in the rigidbody.
  9994. !#zh
  9995. 物理系统将 box2d 作为内部物理系统,并且隐藏了大部分 box2d 实现细节(比如创建刚体,同步刚体信息到节点中等)。
  9996. 你可以通过物理系统访问一些 box2d 常用的功能,比如点击测试,射线测试,设置测试信息等。
  9997. 物理系统还管理碰撞信息的分发,她会在产生碰撞时,将碰撞信息分发到各个碰撞回调中。
  9998. 注意:你需要先在刚体中开启碰撞接听才会产生相应的碰撞回调。<br>
  9999. 支持的物理系统指定绘制信息事件,请参阅 {{#crossLink "PhysicsManager.DrawBits"}}{{/crossLink}} */
  10000. export class PhysicsManager implements EventTarget {
  10001. /** !#en
  10002. The ratio transform between physics unit and pixel unit, generally is 32.
  10003. !#zh
  10004. 物理单位与像素单位互相转换的比率,一般是 32。 */
  10005. static PTM_RATIO: number;
  10006. /** !#en
  10007. The velocity iterations for the velocity constraint solver.
  10008. !#zh
  10009. 速度更新迭代数 */
  10010. static VELOCITY_ITERATIONS: number;
  10011. /** !#en
  10012. The position Iterations for the position constraint solver.
  10013. !#zh
  10014. 位置迭代更新数 */
  10015. static POSITION_ITERATIONS: number;
  10016. /** !#en
  10017. Specify the fixed time step.
  10018. Need enabledAccumulator to make it work.
  10019. !#zh
  10020. 指定固定的物理更新间隔时间,需要开启 enabledAccumulator 才有效。 */
  10021. static FIXED_TIME_STEP: number;
  10022. /** !#en
  10023. Specify the max accumulator time.
  10024. Need enabledAccumulator to make it work.
  10025. !#zh
  10026. 每次可用于更新物理系统的最大时间,需要开启 enabledAccumulator 才有效。 */
  10027. static MAX_ACCUMULATOR: number;
  10028. /** !#en
  10029. If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP.
  10030. And if the update dt is bigger than the time step, then will call step function several times.
  10031. If disabled accumulator, then will call step function with a time step calculated with the frame rate.
  10032. !#zh
  10033. 如果开启此选项,那么将会以固定的间隔时间 FIXED_TIME_STEP 来更新物理引擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物理引擎进行多次更新。
  10034. 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个间隔时间来更新物理引擎。 */
  10035. enabledAccumulator: boolean;
  10036. /**
  10037. !#en
  10038. Test which collider contains the given world point
  10039. !#zh
  10040. 获取包含给定世界坐标系点的碰撞体
  10041. @param point the world point
  10042. */
  10043. testPoint(point: Vec2): PhysicsCollider;
  10044. /**
  10045. !#en
  10046. Test which colliders intersect the given world rect
  10047. !#zh
  10048. 获取与给定世界坐标系矩形相交的碰撞体
  10049. @param rect the world rect
  10050. */
  10051. testAABB(rect: Rect): PhysicsCollider[];
  10052. /**
  10053. !#en
  10054. Raycast the world for all colliders in the path of the ray.
  10055. The raycast ignores colliders that contain the starting point.
  10056. !#zh
  10057. 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。
  10058. @param p1 start point of the raycast
  10059. @param p2 end point of the raycast
  10060. @param type optional, default is RayCastType.Closest
  10061. */
  10062. rayCast(p1: Vec2, p2: Vec2, type: RayCastType): PhysicsRayCastResult[];
  10063. /** !#en
  10064. Enabled the physics manager?
  10065. !#zh
  10066. 指定是否启用物理系统? */
  10067. enabled: boolean;
  10068. /** !#en
  10069. Debug draw flags.
  10070. !#zh
  10071. 设置调试绘制标志 */
  10072. debugDrawFlags: number;
  10073. /** !#en
  10074. The physics world gravity.
  10075. !#zh
  10076. 物理世界重力值 */
  10077. gravity: Vec2;
  10078. /**
  10079. !#en Checks whether the EventTarget object has any callback registered for a specific type of event.
  10080. !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。
  10081. @param type The type of event.
  10082. */
  10083. hasEventListener(type: string): boolean;
  10084. /**
  10085. !#en
  10086. Register an callback of a specific event type on the EventTarget.
  10087. This type of event should be triggered via `emit`.
  10088. !#zh
  10089. 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。
  10090. @param type A string representing the event type to listen for.
  10091. @param callback The callback that will be invoked when the event is dispatched.
  10092. The callback is ignored if it is a duplicate (the callbacks are unique).
  10093. @param target The target (this object) to invoke the callback, can be null
  10094. @example
  10095. ```js
  10096. eventTarget.on('fire', function () {
  10097. cc.log("fire in the hole");
  10098. }, node);
  10099. ```
  10100. */
  10101. on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
  10102. /**
  10103. !#en
  10104. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  10105. if only type is passed as parameter, all listeners registered with that type will be removed.
  10106. !#zh
  10107. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  10108. @param type A string representing the event type being removed.
  10109. @param callback The callback to remove.
  10110. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  10111. @example
  10112. ```js
  10113. // register fire eventListener
  10114. var callback = eventTarget.on('fire', function () {
  10115. cc.log("fire in the hole");
  10116. }, target);
  10117. // remove fire event listener
  10118. eventTarget.off('fire', callback, target);
  10119. // remove all fire event listeners
  10120. eventTarget.off('fire');
  10121. ```
  10122. */
  10123. off(type: string, callback?: Function, target?: any): void;
  10124. /**
  10125. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  10126. This is not for removing all listeners in the current event target,
  10127. and this is not for removing all listeners the target parameter have registered.
  10128. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  10129. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  10130. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  10131. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  10132. @param target The target to be searched for all related listeners
  10133. */
  10134. targetOff(target: any): void;
  10135. /**
  10136. !#en
  10137. Register an callback of a specific event type on the EventTarget,
  10138. the callback will remove itself after the first time it is triggered.
  10139. !#zh
  10140. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  10141. @param type A string representing the event type to listen for.
  10142. @param callback The callback that will be invoked when the event is dispatched.
  10143. The callback is ignored if it is a duplicate (the callbacks are unique).
  10144. @param target The target (this object) to invoke the callback, can be null
  10145. @example
  10146. ```js
  10147. eventTarget.once('fire', function () {
  10148. cc.log("this is the callback and will be invoked only once");
  10149. }, node);
  10150. ```
  10151. */
  10152. once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
  10153. /**
  10154. !#en
  10155. Send an event with the event object.
  10156. !#zh
  10157. 通过事件对象派发事件
  10158. @param event event
  10159. */
  10160. dispatchEvent(event: Event): void;
  10161. /**
  10162. !#en
  10163. Destroy all callbackInfos.
  10164. !#zh
  10165. 销毁记录的事件
  10166. */
  10167. clear(): void;
  10168. }
  10169. /** undefined */
  10170. export class PhysicsRayCastResult {
  10171. /** !#en
  10172. The PhysicsCollider which intersects with the raycast
  10173. !#zh
  10174. 与射线相交的碰撞体 */
  10175. collider: PhysicsCollider;
  10176. /** !#en
  10177. The intersection point
  10178. !#zh
  10179. 射线与碰撞体相交的点 */
  10180. point: Vec2;
  10181. /** !#en
  10182. The normal vector at the point of intersection
  10183. !#zh
  10184. 射线与碰撞体相交的点的法向量 */
  10185. normal: Vec2;
  10186. /** !#en
  10187. The fraction of the raycast path at the point of intersection
  10188. !#zh
  10189. 射线与碰撞体相交的点占射线长度的分数 */
  10190. fraction: number;
  10191. }
  10192. /** undefined */
  10193. export class RigidBody extends Component {
  10194. /** !#en
  10195. Should enabled contact listener?
  10196. When a collision is trigger, the collision callback will only be called when enabled contact listener.
  10197. !#zh
  10198. 是否启用接触接听器。
  10199. 当 collider 产生碰撞时,只有开启了接触接听器才会调用相应的回调函数 */
  10200. enabledContactListener: boolean;
  10201. /**
  10202. !#en
  10203. Collision callback.
  10204. Called when two collider begin to touch.
  10205. !#zh
  10206. 碰撞回调。
  10207. 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体开始接触时被调用。
  10208. @param contact contact information
  10209. @param selfCollider the collider belong to this rigidbody
  10210. @param otherCollider the collider belong to another rigidbody
  10211. */
  10212. onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  10213. /**
  10214. !#en
  10215. Collision callback.
  10216. Called when two collider cease to touch.
  10217. !#zh
  10218. 碰撞回调。
  10219. 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体停止接触时被调用。
  10220. @param contact contact information
  10221. @param selfCollider the collider belong to this rigidbody
  10222. @param otherCollider the collider belong to another rigidbody
  10223. */
  10224. onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  10225. /**
  10226. !#en
  10227. Collision callback.
  10228. This is called when a contact is updated.
  10229. This allows you to inspect a contact before it goes to the solver(e.g. disable contact).
  10230. Note: this is called only for awake bodies.
  10231. Note: this is called even when the number of contact points is zero.
  10232. Note: this is not called for sensors.
  10233. !#zh
  10234. 碰撞回调。
  10235. 如果你的脚本中实现了这个函数,那么它将会在接触更新时被调用。
  10236. 你可以在接触被处理前根据他包含的信息作出相应的处理,比如将这个接触禁用掉。
  10237. 注意:回调只会为醒着的刚体调用。
  10238. 注意:接触点为零的时候也有可能被调用。
  10239. 注意:感知体(sensor)的回调不会被调用。
  10240. @param contact contact information
  10241. @param selfCollider the collider belong to this rigidbody
  10242. @param otherCollider the collider belong to another rigidbody
  10243. */
  10244. onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  10245. /**
  10246. !#en
  10247. Collision callback.
  10248. This is called after a contact is updated.
  10249. You can get the impulses from the contact in this callback.
  10250. !#zh
  10251. 碰撞回调。
  10252. 如果你的脚本中实现了这个函数,那么它将会在接触更新完后被调用。
  10253. 你可以在这个回调中从接触信息中获取到冲量信息。
  10254. @param contact contact information
  10255. @param selfCollider the collider belong to this rigidbody
  10256. @param otherCollider the collider belong to another rigidbody
  10257. */
  10258. onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  10259. /** !#en
  10260. Is this a fast moving body that should be prevented from tunneling through
  10261. other moving bodies?
  10262. Note :
  10263. - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies.
  10264. - You should use this flag sparingly since it increases processing time.
  10265. !#zh
  10266. 这个刚体是否是一个快速移动的刚体,并且需要禁止穿过其他快速移动的刚体?
  10267. 需要注意的是 :
  10268. - 所有刚体都被禁止从 运动刚体 和 静态刚体 中穿过。此选项只关注于 动态刚体。
  10269. - 应该尽量少的使用此选项,因为它会增加程序处理时间。 */
  10270. bullet: boolean;
  10271. /** !#en
  10272. Rigidbody type : Static, Kinematic, Dynamic or Animated.
  10273. !#zh
  10274. 刚体类型: Static, Kinematic, Dynamic or Animated. */
  10275. type: RigidBodyType;
  10276. /** !#en
  10277. Set this flag to false if this body should never fall asleep.
  10278. Note that this increases CPU usage.
  10279. !#zh
  10280. 如果此刚体永远都不应该进入睡眠,那么设置这个属性为 false。
  10281. 需要注意这将使 CPU 占用率提高。 */
  10282. allowSleep: boolean;
  10283. /** !#en
  10284. Scale the gravity applied to this body.
  10285. !#zh
  10286. 缩放应用在此刚体上的重力值 */
  10287. gravityScale: number;
  10288. /** !#en
  10289. Linear damping is use to reduce the linear velocity.
  10290. The damping parameter can be larger than 1, but the damping effect becomes sensitive to the
  10291. time step when the damping parameter is large.
  10292. !#zh
  10293. Linear damping 用于衰减刚体的线性速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */
  10294. linearDamping: number;
  10295. /** !#en
  10296. Angular damping is use to reduce the angular velocity. The damping parameter
  10297. can be larger than 1 but the damping effect becomes sensitive to the
  10298. time step when the damping parameter is large.
  10299. !#zh
  10300. Angular damping 用于衰减刚体的角速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */
  10301. angularDamping: number;
  10302. /** !#en
  10303. The linear velocity of the body's origin in world co-ordinates.
  10304. !#zh
  10305. 刚体在世界坐标下的线性速度 */
  10306. linearVelocity: Vec2;
  10307. /** !#en
  10308. The angular velocity of the body.
  10309. !#zh
  10310. 刚体的角速度 */
  10311. angularVelocity: number;
  10312. /** !#en
  10313. Should this body be prevented from rotating?
  10314. !#zh
  10315. 是否禁止此刚体进行旋转 */
  10316. fixedRotation: boolean;
  10317. /** !#en
  10318. Set the sleep state of the body. A sleeping body has very low CPU cost.(When the rigid body is hit, if the rigid body is in sleep state, it will be immediately awakened.)
  10319. !#zh
  10320. 设置刚体的睡眠状态。 睡眠的刚体具有非常低的 CPU 成本。(当刚体被碰撞到时,如果刚体处于睡眠状态,它会立即被唤醒) */
  10321. awake: boolean;
  10322. /** !#en
  10323. Whether to wake up this rigid body during initialization
  10324. !#zh
  10325. 是否在初始化时唤醒此刚体 */
  10326. awakeOnLoad: boolean;
  10327. /** !#en
  10328. Set the active state of the body. An inactive body is not
  10329. simulated and cannot be collided with or woken up.
  10330. If body is active, all fixtures will be added to the
  10331. broad-phase.
  10332. If body is inactive, all fixtures will be removed from
  10333. the broad-phase and all contacts will be destroyed.
  10334. Fixtures on an inactive body are implicitly inactive and will
  10335. not participate in collisions, ray-casts, or queries.
  10336. Joints connected to an inactive body are implicitly inactive.
  10337. !#zh
  10338. 设置刚体的激活状态。一个非激活状态下的刚体是不会被模拟和碰撞的,不管它是否处于睡眠状态下。
  10339. 如果刚体处于激活状态下,所有夹具会被添加到 粗测阶段(broad-phase)。
  10340. 如果刚体处于非激活状态下,所有夹具会被从 粗测阶段(broad-phase)中移除。
  10341. 在非激活状态下的夹具不会参与到碰撞,射线,或者查找中
  10342. 链接到非激活状态下刚体的关节也是非激活的。 */
  10343. active: boolean;
  10344. /**
  10345. !#en
  10346. Converts a given point in the world coordinate system to this rigid body's local coordinate system
  10347. !#zh
  10348. 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点
  10349. @param worldPoint a point in world coordinates.
  10350. @param out optional, the receiving point
  10351. */
  10352. getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2;
  10353. /**
  10354. !#en
  10355. Converts a given point in this rigid body's local coordinate system to the world coordinate system
  10356. !#zh
  10357. 将一个给定的刚体本地坐标系下的点转换为世界坐标系下的点
  10358. @param localPoint a point in local coordinates.
  10359. @param out optional, the receiving point
  10360. */
  10361. getWorldPoint(localPoint: Vec2, out: Vec2): Vec2;
  10362. /**
  10363. !#en
  10364. Converts a given vector in this rigid body's local coordinate system to the world coordinate system
  10365. !#zh
  10366. 将一个给定的刚体本地坐标系下的向量转换为世界坐标系下的向量
  10367. @param localVector a vector in world coordinates.
  10368. @param out optional, the receiving vector
  10369. */
  10370. getWorldVector(localVector: Vec2, out: Vec2): Vec2;
  10371. /**
  10372. !#en
  10373. Converts a given vector in the world coordinate system to this rigid body's local coordinate system
  10374. !#zh
  10375. 将一个给定的世界坐标系下的向量转换为刚体本地坐标系下的向量
  10376. @param worldVector a vector in world coordinates.
  10377. @param out optional, the receiving vector
  10378. */
  10379. getLocalVector(worldVector: Vec2, out: Vec2): Vec2;
  10380. /**
  10381. !#en
  10382. Get the world body origin position.
  10383. !#zh
  10384. 获取刚体世界坐标系下的原点值
  10385. @param out optional, the receiving point
  10386. */
  10387. getWorldPosition(out: Vec2): Vec2;
  10388. /**
  10389. !#en
  10390. Get the world body rotation angle.
  10391. !#zh
  10392. 获取刚体世界坐标系下的旋转值。
  10393. */
  10394. getWorldRotation(): number;
  10395. /**
  10396. !#en
  10397. Get the local position of the center of mass.
  10398. !#zh
  10399. 获取刚体本地坐标系下的质心
  10400. */
  10401. getLocalCenter(): Vec2;
  10402. /**
  10403. !#en
  10404. Get the world position of the center of mass.
  10405. !#zh
  10406. 获取刚体世界坐标系下的质心
  10407. */
  10408. getWorldCenter(): Vec2;
  10409. /**
  10410. !#en
  10411. Get the world linear velocity of a world point attached to this body.
  10412. !#zh
  10413. 获取刚体上指定点的线性速度
  10414. @param worldPoint a point in world coordinates.
  10415. @param out optional, the receiving point
  10416. */
  10417. getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2;
  10418. /**
  10419. !#en
  10420. Get total mass of the body.
  10421. !#zh
  10422. 获取刚体的质量。
  10423. */
  10424. getMass(): number;
  10425. /**
  10426. !#en
  10427. Get the rotational inertia of the body about the local origin.
  10428. !#zh
  10429. 获取刚体本地坐标系下原点的旋转惯性
  10430. */
  10431. getInertia(): number;
  10432. /**
  10433. !#en
  10434. Get all the joints connect to the rigidbody.
  10435. !#zh
  10436. 获取链接到此刚体的所有关节
  10437. */
  10438. getJointList(): Joint[];
  10439. /**
  10440. !#en
  10441. Apply a force at a world point. If the force is not
  10442. applied at the center of mass, it will generate a torque and
  10443. affect the angular velocity.
  10444. !#zh
  10445. 施加一个力到刚体上的一个点。如果力没有施加到刚体的质心上,还会产生一个扭矩并且影响到角速度。
  10446. @param force the world force vector.
  10447. @param point the world position.
  10448. @param wake also wake up the body.
  10449. */
  10450. applyForce(force: Vec2, point: Vec2, wake: boolean): void;
  10451. /**
  10452. !#en
  10453. Apply a force to the center of mass.
  10454. !#zh
  10455. 施加一个力到刚体上的质心上。
  10456. @param force the world force vector.
  10457. @param wake also wake up the body.
  10458. */
  10459. applyForceToCenter(force: Vec2, wake: boolean): void;
  10460. /**
  10461. !#en
  10462. Apply a torque. This affects the angular velocity.
  10463. !#zh
  10464. 施加一个扭矩力,将影响刚体的角速度
  10465. @param torque about the z-axis (out of the screen), usually in N-m.
  10466. @param wake also wake up the body
  10467. */
  10468. applyTorque(torque: number, wake: boolean): void;
  10469. /**
  10470. !#en
  10471. Apply a impulse at a world point, This immediately modifies the velocity.
  10472. If the impulse is not applied at the center of mass, it will generate a torque and
  10473. affect the angular velocity.
  10474. !#zh
  10475. 施加冲量到刚体上的一个点,将立即改变刚体的线性速度。
  10476. 如果冲量施加到的点不是刚体的质心,那么将产生一个扭矩并影响刚体的角速度。
  10477. @param impulse the world impulse vector, usually in N-seconds or kg-m/s.
  10478. @param point the world position
  10479. @param wake alse wake up the body
  10480. */
  10481. applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void;
  10482. /**
  10483. !#en
  10484. Apply an angular impulse.
  10485. !#zh
  10486. 施加一个角速度冲量。
  10487. @param impulse the angular impulse in units of kg*m*m/s
  10488. @param wake also wake up the body
  10489. */
  10490. applyAngularImpulse(impulse: number, wake: boolean): void;
  10491. /**
  10492. !#en
  10493. Synchronize node's world position to box2d rigidbody's position.
  10494. If enableAnimated is true and rigidbody's type is Animated type,
  10495. will set linear velocity instead of directly set rigidbody's position.
  10496. !#zh
  10497. 同步节点的世界坐标到 box2d 刚体的坐标上。
  10498. 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度来代替直接设置刚体的位置。
  10499. @param enableAnimated enableAnimated
  10500. */
  10501. syncPosition(enableAnimated: boolean): void;
  10502. /**
  10503. !#en
  10504. Synchronize node's world angle to box2d rigidbody's angle.
  10505. If enableAnimated is true and rigidbody's type is Animated type,
  10506. will set angular velocity instead of directly set rigidbody's angle.
  10507. !#zh
  10508. 同步节点的世界旋转角度值到 box2d 刚体的旋转值上。
  10509. 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度来代替直接设置刚体的角度。
  10510. @param enableAnimated enableAnimated
  10511. */
  10512. syncRotation(enableAnimated: boolean): void;
  10513. }
  10514. /** !#en Class for audio data handling.
  10515. !#zh 音频资源类。 */
  10516. export class AudioClip extends Asset implements EventTarget {
  10517. /** !#en Get the audio clip duration
  10518. !#zh 获取音频剪辑的长度 */
  10519. duration: number;
  10520. /**
  10521. !#en Checks whether the EventTarget object has any callback registered for a specific type of event.
  10522. !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。
  10523. @param type The type of event.
  10524. */
  10525. hasEventListener(type: string): boolean;
  10526. /**
  10527. !#en
  10528. Register an callback of a specific event type on the EventTarget.
  10529. This type of event should be triggered via `emit`.
  10530. !#zh
  10531. 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。
  10532. @param type A string representing the event type to listen for.
  10533. @param callback The callback that will be invoked when the event is dispatched.
  10534. The callback is ignored if it is a duplicate (the callbacks are unique).
  10535. @param target The target (this object) to invoke the callback, can be null
  10536. @example
  10537. ```js
  10538. eventTarget.on('fire', function () {
  10539. cc.log("fire in the hole");
  10540. }, node);
  10541. ```
  10542. */
  10543. on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
  10544. /**
  10545. !#en
  10546. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  10547. if only type is passed as parameter, all listeners registered with that type will be removed.
  10548. !#zh
  10549. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  10550. @param type A string representing the event type being removed.
  10551. @param callback The callback to remove.
  10552. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  10553. @example
  10554. ```js
  10555. // register fire eventListener
  10556. var callback = eventTarget.on('fire', function () {
  10557. cc.log("fire in the hole");
  10558. }, target);
  10559. // remove fire event listener
  10560. eventTarget.off('fire', callback, target);
  10561. // remove all fire event listeners
  10562. eventTarget.off('fire');
  10563. ```
  10564. */
  10565. off(type: string, callback?: Function, target?: any): void;
  10566. /**
  10567. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  10568. This is not for removing all listeners in the current event target,
  10569. and this is not for removing all listeners the target parameter have registered.
  10570. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  10571. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  10572. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  10573. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  10574. @param target The target to be searched for all related listeners
  10575. */
  10576. targetOff(target: any): void;
  10577. /**
  10578. !#en
  10579. Register an callback of a specific event type on the EventTarget,
  10580. the callback will remove itself after the first time it is triggered.
  10581. !#zh
  10582. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  10583. @param type A string representing the event type to listen for.
  10584. @param callback The callback that will be invoked when the event is dispatched.
  10585. The callback is ignored if it is a duplicate (the callbacks are unique).
  10586. @param target The target (this object) to invoke the callback, can be null
  10587. @example
  10588. ```js
  10589. eventTarget.once('fire', function () {
  10590. cc.log("this is the callback and will be invoked only once");
  10591. }, node);
  10592. ```
  10593. */
  10594. once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
  10595. /**
  10596. !#en
  10597. Send an event with the event object.
  10598. !#zh
  10599. 通过事件对象派发事件
  10600. @param event event
  10601. */
  10602. dispatchEvent(event: Event): void;
  10603. /**
  10604. !#en
  10605. Destroy all callbackInfos.
  10606. !#zh
  10607. 销毁记录的事件
  10608. */
  10609. clear(): void;
  10610. }
  10611. /** !#en Class for BitmapFont handling.
  10612. !#zh 位图字体资源类。 */
  10613. export class BitmapFont extends Font {
  10614. }
  10615. /** undefined */
  10616. export class BufferAsset extends Asset {
  10617. }
  10618. /** !#en Class for Font handling.
  10619. !#zh 字体资源类。 */
  10620. export class Font extends Asset {
  10621. }
  10622. /** !#en
  10623. Class for JSON file. When the JSON file is loaded, this object is returned.
  10624. The parsed JSON object can be accessed through the `json` attribute in it.<br>
  10625. If you want to get the original JSON text, you should modify the extname to `.txt`
  10626. so that it is loaded as a `TextAsset` instead of a `JsonAsset`.
  10627. !#zh
  10628. JSON 资源类。JSON 文件加载后,将会返回该对象。可以通过其中的 `json` 属性访问解析后的 JSON 对象。<br>
  10629. 如果你想要获得 JSON 的原始文本,那么应该修改源文件的后缀为 `.txt`,这样就会加载为一个 `TextAsset` 而不是 `JsonAsset`。 */
  10630. export class JsonAsset extends Asset {
  10631. /** The loaded JSON object. */
  10632. json: any;
  10633. }
  10634. /** !#en Class for LabelAtlas handling.
  10635. !#zh 艺术数字字体资源类。 */
  10636. export class LabelAtlas extends BitmapFont {
  10637. }
  10638. /** Render textures are textures that can be rendered to. */
  10639. export class RenderTexture extends Texture2D {
  10640. /**
  10641. !#en
  10642. Init the render texture with size.
  10643. !#zh
  10644. 初始化 render texture
  10645. @param width width
  10646. @param height height
  10647. @param depthStencilFormat depthStencilFormat
  10648. */
  10649. initWithSize(width?: number, height?: number, depthStencilFormat?: number): void;
  10650. /**
  10651. !#en
  10652. Get pixels from render texture, the pixels data stores in a RGBA Uint8Array.
  10653. It will return a new (width * height * 4) length Uint8Array by default。
  10654. You can specify a data to store the pixels to reuse the data,
  10655. you and can specify other params to specify the texture region to read.
  10656. !#zh
  10657. 从 render texture 读取像素数据,数据类型为 RGBA 格式的 Uint8Array 数组。
  10658. 默认每次调用此函数会生成一个大小为 (长 x 高 x 4) 的 Uint8Array。
  10659. 你可以通过传入 data 来接收像素数据,也可以通过传参来指定需要读取的区域的像素。
  10660. @param data data
  10661. @param x x
  10662. @param y y
  10663. @param w w
  10664. @param h h
  10665. */
  10666. readPixels(data?: Uint8Array, x?: number, y?: number, w?: number, h?: number): Uint8Array;
  10667. }
  10668. /** !#en Class for prefab handling.
  10669. !#zh 预制资源类。 */
  10670. export class Prefab extends Asset {
  10671. /** the main cc.Node in the prefab */
  10672. data: Node;
  10673. /** !#zh
  10674. 设置实例化这个 prefab 时所用的优化策略。根据使用情况设置为合适的值,能优化该 prefab 实例化所用的时间。
  10675. !#en
  10676. Indicates the optimization policy for instantiating this prefab.
  10677. Set to a suitable value based on usage, can optimize the time it takes to instantiate this prefab. */
  10678. optimizationPolicy: Prefab.OptimizationPolicy;
  10679. /** !#en Indicates the raw assets of this prefab can be load after prefab loaded.
  10680. !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */
  10681. asyncLoadAssets: boolean;
  10682. readonly: boolean;
  10683. /**
  10684. Dynamically translation prefab data into minimized code.<br/>
  10685. This method will be called automatically before the first time the prefab being instantiated,
  10686. but you can re-call to refresh the create function once you modified the original prefab data in script.
  10687. */
  10688. compileCreateFunction(): void;
  10689. }
  10690. /** !#en Class for scene handling.
  10691. !#zh 场景资源类。 */
  10692. export class SceneAsset extends Asset {
  10693. scene: Scene;
  10694. /** !#en Indicates the raw assets of this scene can be load after scene launched.
  10695. !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */
  10696. asyncLoadAssets: boolean;
  10697. }
  10698. /** !#en Class for script handling.
  10699. !#zh Script 资源类。 */
  10700. export class _Script extends Asset {
  10701. }
  10702. /** !#en Class for JavaScript handling.
  10703. !#zh JavaScript 资源类。 */
  10704. export class _JavaScript extends Asset {
  10705. }
  10706. /** !#en Class for TypeScript handling.
  10707. !#zh TypeScript 资源类。 */
  10708. export class TypeScript extends Asset {
  10709. }
  10710. /** !#en Class for sprite atlas handling.
  10711. !#zh 精灵图集资源类。 */
  10712. export class SpriteAtlas extends Asset {
  10713. /**
  10714. Returns the texture of the sprite atlas
  10715. */
  10716. getTexture(): Texture2D;
  10717. /**
  10718. Returns the sprite frame correspond to the given key in sprite atlas.
  10719. @param key key
  10720. */
  10721. getSpriteFrame(key: string): SpriteFrame;
  10722. /**
  10723. Returns the sprite frames in sprite atlas.
  10724. */
  10725. getSpriteFrames(): SpriteFrame[];
  10726. }
  10727. /** !#en Class for TTFFont handling.
  10728. !#zh TTF 字体资源类。 */
  10729. export class TTFFont extends Font {
  10730. }
  10731. /** !#en
  10732. A cc.SpriteFrame has:<br/>
  10733. - texture: A cc.Texture2D that will be used by render components<br/>
  10734. - rectangle: A rectangle of the texture
  10735. !#zh
  10736. 一个 SpriteFrame 包含:<br/>
  10737. - 纹理:会被渲染组件使用的 Texture2D 对象。<br/>
  10738. - 矩形:在纹理中的矩形区域。 */
  10739. export class SpriteFrame extends Asset implements EventTarget {
  10740. /** !#en Top border of the sprite
  10741. !#zh sprite 的顶部边框 */
  10742. insetTop: number;
  10743. /** !#en Bottom border of the sprite
  10744. !#zh sprite 的底部边框 */
  10745. insetBottom: number;
  10746. /** !#en Left border of the sprite
  10747. !#zh sprite 的左边边框 */
  10748. insetLeft: number;
  10749. /** !#en Right border of the sprite
  10750. !#zh sprite 的左边边框 */
  10751. insetRight: number;
  10752. /**
  10753. !#en
  10754. Constructor of SpriteFrame class.
  10755. !#zh
  10756. SpriteFrame 类的构造函数。
  10757. @param filename filename
  10758. @param rect rect
  10759. @param rotated Whether the frame is rotated in the texture
  10760. @param offset The offset of the frame in the texture
  10761. @param originalSize The size of the frame in the texture
  10762. */
  10763. constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size);
  10764. /**
  10765. !#en Returns whether the texture have been loaded
  10766. !#zh 返回是否已加载纹理
  10767. */
  10768. textureLoaded(): boolean;
  10769. /**
  10770. !#en Returns whether the sprite frame is rotated in the texture.
  10771. !#zh 获取 SpriteFrame 是否旋转
  10772. */
  10773. isRotated(): boolean;
  10774. /**
  10775. !#en Set whether the sprite frame is rotated in the texture.
  10776. !#zh 设置 SpriteFrame 是否旋转
  10777. @param bRotated bRotated
  10778. */
  10779. setRotated(bRotated: boolean): void;
  10780. /**
  10781. !#en Returns whether the sprite frame is flip x axis in the texture.
  10782. !#zh 获取 SpriteFrame 是否反转 x 轴
  10783. */
  10784. isFlipX(): boolean;
  10785. /**
  10786. !#en Returns whether the sprite frame is flip y axis in the texture.
  10787. !#zh 获取 SpriteFrame 是否反转 y 轴
  10788. */
  10789. isFlipY(): boolean;
  10790. /**
  10791. !#en Set whether the sprite frame is flip x axis in the texture.
  10792. !#zh 设置 SpriteFrame 是否翻转 x 轴
  10793. @param flipX flipX
  10794. */
  10795. setFlipX(flipX: boolean): void;
  10796. /**
  10797. !#en Set whether the sprite frame is flip y axis in the texture.
  10798. !#zh 设置 SpriteFrame 是否翻转 y 轴
  10799. @param flipY flipY
  10800. */
  10801. setFlipY(flipY: boolean): void;
  10802. /**
  10803. !#en Returns the rect of the sprite frame in the texture.
  10804. !#zh 获取 SpriteFrame 的纹理矩形区域
  10805. */
  10806. getRect(): Rect;
  10807. /**
  10808. !#en Sets the rect of the sprite frame in the texture.
  10809. !#zh 设置 SpriteFrame 的纹理矩形区域
  10810. @param rect rect
  10811. */
  10812. setRect(rect: Rect): void;
  10813. /**
  10814. !#en Returns the original size of the trimmed image.
  10815. !#zh 获取修剪前的原始大小
  10816. */
  10817. getOriginalSize(): Size;
  10818. /**
  10819. !#en Sets the original size of the trimmed image.
  10820. !#zh 设置修剪前的原始大小
  10821. @param size size
  10822. */
  10823. setOriginalSize(size: Size): void;
  10824. /**
  10825. !#en Returns the texture of the frame.
  10826. !#zh 获取使用的纹理实例
  10827. */
  10828. getTexture(): Texture2D;
  10829. /**
  10830. !#en Returns the offset of the frame in the texture.
  10831. !#zh 获取偏移量
  10832. */
  10833. getOffset(): Vec2;
  10834. /**
  10835. !#en Sets the offset of the frame in the texture.
  10836. !#zh 设置偏移量
  10837. @param offsets offsets
  10838. */
  10839. setOffset(offsets: Vec2): void;
  10840. /**
  10841. !#en Clone the sprite frame.
  10842. !#zh 克隆 SpriteFrame
  10843. */
  10844. clone(): SpriteFrame;
  10845. /**
  10846. !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.<br/>
  10847. !#zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame。
  10848. @param texture texture
  10849. @param rect rect
  10850. @param rotated rotated
  10851. @param offset offset
  10852. @param originalSize originalSize
  10853. */
  10854. setTexture(texture: Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean;
  10855. /**
  10856. !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which
  10857. associated by user's custom Components in the scene, will not preload automatically.
  10858. These textures will be load when Sprite component is going to render the SpriteFrames.
  10859. You can call this method if you want to load the texture early.
  10860. !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。
  10861. 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。
  10862. @example
  10863. ```js
  10864. if (spriteFrame.textureLoaded()) {
  10865. this._onSpriteFrameLoaded();
  10866. }
  10867. else {
  10868. spriteFrame.once('load', this._onSpriteFrameLoaded, this);
  10869. spriteFrame.ensureLoadTexture();
  10870. }
  10871. ```
  10872. */
  10873. ensureLoadTexture(): void;
  10874. /**
  10875. !#en
  10876. 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.
  10877. !#zh
  10878. 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。
  10879. */
  10880. clearTexture(): void;
  10881. /**
  10882. !#en Checks whether the EventTarget object has any callback registered for a specific type of event.
  10883. !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。
  10884. @param type The type of event.
  10885. */
  10886. hasEventListener(type: string): boolean;
  10887. /**
  10888. !#en
  10889. Register an callback of a specific event type on the EventTarget.
  10890. This type of event should be triggered via `emit`.
  10891. !#zh
  10892. 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。
  10893. @param type A string representing the event type to listen for.
  10894. @param callback The callback that will be invoked when the event is dispatched.
  10895. The callback is ignored if it is a duplicate (the callbacks are unique).
  10896. @param target The target (this object) to invoke the callback, can be null
  10897. @example
  10898. ```js
  10899. eventTarget.on('fire', function () {
  10900. cc.log("fire in the hole");
  10901. }, node);
  10902. ```
  10903. */
  10904. on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
  10905. /**
  10906. !#en
  10907. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  10908. if only type is passed as parameter, all listeners registered with that type will be removed.
  10909. !#zh
  10910. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  10911. @param type A string representing the event type being removed.
  10912. @param callback The callback to remove.
  10913. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  10914. @example
  10915. ```js
  10916. // register fire eventListener
  10917. var callback = eventTarget.on('fire', function () {
  10918. cc.log("fire in the hole");
  10919. }, target);
  10920. // remove fire event listener
  10921. eventTarget.off('fire', callback, target);
  10922. // remove all fire event listeners
  10923. eventTarget.off('fire');
  10924. ```
  10925. */
  10926. off(type: string, callback?: Function, target?: any): void;
  10927. /**
  10928. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  10929. This is not for removing all listeners in the current event target,
  10930. and this is not for removing all listeners the target parameter have registered.
  10931. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  10932. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  10933. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  10934. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  10935. @param target The target to be searched for all related listeners
  10936. */
  10937. targetOff(target: any): void;
  10938. /**
  10939. !#en
  10940. Register an callback of a specific event type on the EventTarget,
  10941. the callback will remove itself after the first time it is triggered.
  10942. !#zh
  10943. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  10944. @param type A string representing the event type to listen for.
  10945. @param callback The callback that will be invoked when the event is dispatched.
  10946. The callback is ignored if it is a duplicate (the callbacks are unique).
  10947. @param target The target (this object) to invoke the callback, can be null
  10948. @example
  10949. ```js
  10950. eventTarget.once('fire', function () {
  10951. cc.log("this is the callback and will be invoked only once");
  10952. }, node);
  10953. ```
  10954. */
  10955. once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
  10956. /**
  10957. !#en
  10958. Send an event with the event object.
  10959. !#zh
  10960. 通过事件对象派发事件
  10961. @param event event
  10962. */
  10963. dispatchEvent(event: Event): void;
  10964. /**
  10965. !#en
  10966. Destroy all callbackInfos.
  10967. !#zh
  10968. 销毁记录的事件
  10969. */
  10970. clear(): void;
  10971. }
  10972. /** !#en Class for text file.
  10973. !#zh 文本资源类。 */
  10974. export class TextAsset extends Asset {
  10975. /** The text contents of the resource. */
  10976. text: string;
  10977. }
  10978. /** This class allows to easily create OpenGL or Canvas 2D textures from images or raw data. */
  10979. export class Texture2D extends Asset implements EventTarget {
  10980. /** !#en Sets whether generate mipmaps for the texture
  10981. !#zh 是否为纹理设置生成 mipmaps。 */
  10982. genMipmaps: boolean;
  10983. /** !#en
  10984. Sets whether texture can be packed into texture atlas.
  10985. If need use texture uv in custom Effect, please sets packable to false.
  10986. !#zh
  10987. 设置纹理是否允许参与合图。
  10988. 如果需要在自定义 Effect 中使用纹理 UV,需要禁止该选项。 */
  10989. packable: boolean;
  10990. /** !#en
  10991. Whether the texture is loaded or not
  10992. !#zh
  10993. 贴图是否已经成功加载 */
  10994. loaded: boolean;
  10995. /** !#en
  10996. Texture width in pixel
  10997. !#zh
  10998. 贴图像素宽度 */
  10999. width: number;
  11000. /** !#en
  11001. Texture height in pixel
  11002. !#zh
  11003. 贴图像素高度 */
  11004. height: number;
  11005. /**
  11006. !#en
  11007. Get renderer texture implementation object
  11008. extended from render.Texture2D
  11009. !#zh 返回渲染器内部贴图对象
  11010. */
  11011. getImpl(): void;
  11012. /**
  11013. Update texture options, not available in Canvas render mode.
  11014. image, format, premultiplyAlpha can not be updated in native.
  11015. @param options options
  11016. */
  11017. update(options: {image: DOMImageElement; genMipmaps: boolean; format: Texture2D.PixelFormat; minFilter: Texture2D.Filter; magFilter: Texture2D.Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void;
  11018. /**
  11019. !#en
  11020. Init with HTML element.
  11021. !#zh 用 HTML Image 或 Canvas 对象初始化贴图。
  11022. @param element element
  11023. @example
  11024. ```js
  11025. var img = new Image();
  11026. img.src = dataURL;
  11027. texture.initWithElement(img);
  11028. ```
  11029. */
  11030. initWithElement(element: HTMLImageElement|HTMLCanvasElement): void;
  11031. /**
  11032. !#en
  11033. Intializes with texture data in ArrayBufferView.
  11034. !#zh 使用一个存储在 ArrayBufferView 中的图像数据(raw data)初始化数据。
  11035. @param data data
  11036. @param pixelFormat pixelFormat
  11037. @param pixelsWidth pixelsWidth
  11038. @param pixelsHeight pixelsHeight
  11039. */
  11040. initWithData(data: ArrayBufferView, pixelFormat: number, pixelsWidth: number, pixelsHeight: number): boolean;
  11041. /**
  11042. !#en
  11043. HTMLElement Object getter, available only on web.<br/>
  11044. Note: texture is packed into texture atlas by default<br/>
  11045. you should set texture.packable as false before getting Html element object.
  11046. !#zh 获取当前贴图对应的 HTML Image 或 Canvas 对象,只在 Web 平台下有效。<br/>
  11047. 注意:<br/>
  11048. texture 默认参与动态合图,如果需要获取到正确的 Html 元素对象,需要先设置 texture.packable 为 false
  11049. */
  11050. getHtmlElementObj(): HTMLImageElement;
  11051. /**
  11052. !#en
  11053. Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)<br>
  11054. After destroy, this object is not usable anymore.
  11055. You can use cc.isValid(obj) to check whether the object is destroyed before accessing it.
  11056. !#zh
  11057. 销毁该贴图,并立即释放它对应的显存。(继承自 cc.Object.destroy)<br/>
  11058. 销毁后,该对象不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
  11059. */
  11060. destroy(): boolean;
  11061. /**
  11062. !#en
  11063. Pixel format of the texture.
  11064. !#zh 获取纹理的像素格式。
  11065. */
  11066. getPixelFormat(): number;
  11067. /**
  11068. !#en
  11069. Whether or not the texture has their Alpha premultiplied.
  11070. !#zh 检查纹理在上传 GPU 时预乘选项是否开启。
  11071. */
  11072. hasPremultipliedAlpha(): boolean;
  11073. /**
  11074. !#en
  11075. Handler of texture loaded event.
  11076. Since v2.0, you don't need to invoke this function, it will be invoked automatically after texture loaded.
  11077. !#zh 贴图加载事件处理器。v2.0 之后你将不在需要手动执行这个函数,它会在贴图加载成功之后自动执行。
  11078. @param premultiplied premultiplied
  11079. */
  11080. handleLoadedTexture(premultiplied?: boolean): void;
  11081. /**
  11082. !#en
  11083. Description of cc.Texture2D.
  11084. !#zh cc.Texture2D 描述。
  11085. */
  11086. description(): string;
  11087. /**
  11088. !#en
  11089. Release texture, please use destroy instead.
  11090. !#zh 释放纹理,请使用 destroy 替代。
  11091. */
  11092. releaseTexture(): void;
  11093. /**
  11094. !#en Sets the wrap s and wrap t options. <br/>
  11095. 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}.
  11096. !#zh 设置纹理包装模式。
  11097. 若纹理贴图尺寸是 NPOT(non power of 2),则只能使用 Texture2D.WrapMode.CLAMP_TO_EDGE。
  11098. @param wrapS wrapS
  11099. @param wrapT wrapT
  11100. */
  11101. setWrapMode(wrapS: Texture2D.WrapMode, wrapT: Texture2D.WrapMode): void;
  11102. /**
  11103. !#en Sets the minFilter and magFilter options
  11104. !#zh 设置纹理贴图缩小和放大过滤器算法选项。
  11105. @param minFilter minFilter
  11106. @param magFilter magFilter
  11107. */
  11108. setFilters(minFilter: Texture2D.Filter, magFilter: Texture2D.Filter): void;
  11109. /**
  11110. !#en
  11111. Sets the flipY options
  11112. !#zh 设置贴图的纵向翻转选项。
  11113. @param flipY flipY
  11114. */
  11115. setFlipY(flipY: boolean): void;
  11116. /**
  11117. !#en
  11118. Sets the premultiply alpha options
  11119. !#zh 设置贴图的预乘选项。
  11120. @param premultiply premultiply
  11121. */
  11122. setPremultiplyAlpha(premultiply: boolean): void;
  11123. /**
  11124. !#en Checks whether the EventTarget object has any callback registered for a specific type of event.
  11125. !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。
  11126. @param type The type of event.
  11127. */
  11128. hasEventListener(type: string): boolean;
  11129. /**
  11130. !#en
  11131. Register an callback of a specific event type on the EventTarget.
  11132. This type of event should be triggered via `emit`.
  11133. !#zh
  11134. 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。
  11135. @param type A string representing the event type to listen for.
  11136. @param callback The callback that will be invoked when the event is dispatched.
  11137. The callback is ignored if it is a duplicate (the callbacks are unique).
  11138. @param target The target (this object) to invoke the callback, can be null
  11139. @example
  11140. ```js
  11141. eventTarget.on('fire', function () {
  11142. cc.log("fire in the hole");
  11143. }, node);
  11144. ```
  11145. */
  11146. on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
  11147. /**
  11148. !#en
  11149. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  11150. if only type is passed as parameter, all listeners registered with that type will be removed.
  11151. !#zh
  11152. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  11153. @param type A string representing the event type being removed.
  11154. @param callback The callback to remove.
  11155. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  11156. @example
  11157. ```js
  11158. // register fire eventListener
  11159. var callback = eventTarget.on('fire', function () {
  11160. cc.log("fire in the hole");
  11161. }, target);
  11162. // remove fire event listener
  11163. eventTarget.off('fire', callback, target);
  11164. // remove all fire event listeners
  11165. eventTarget.off('fire');
  11166. ```
  11167. */
  11168. off(type: string, callback?: Function, target?: any): void;
  11169. /**
  11170. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  11171. This is not for removing all listeners in the current event target,
  11172. and this is not for removing all listeners the target parameter have registered.
  11173. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  11174. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  11175. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  11176. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  11177. @param target The target to be searched for all related listeners
  11178. */
  11179. targetOff(target: any): void;
  11180. /**
  11181. !#en
  11182. Register an callback of a specific event type on the EventTarget,
  11183. the callback will remove itself after the first time it is triggered.
  11184. !#zh
  11185. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  11186. @param type A string representing the event type to listen for.
  11187. @param callback The callback that will be invoked when the event is dispatched.
  11188. The callback is ignored if it is a duplicate (the callbacks are unique).
  11189. @param target The target (this object) to invoke the callback, can be null
  11190. @example
  11191. ```js
  11192. eventTarget.once('fire', function () {
  11193. cc.log("this is the callback and will be invoked only once");
  11194. }, node);
  11195. ```
  11196. */
  11197. once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
  11198. /**
  11199. !#en
  11200. Send an event with the event object.
  11201. !#zh
  11202. 通过事件对象派发事件
  11203. @param event event
  11204. */
  11205. dispatchEvent(event: Event): void;
  11206. /**
  11207. !#en
  11208. Destroy all callbackInfos.
  11209. !#zh
  11210. 销毁记录的事件
  11211. */
  11212. clear(): void;
  11213. }
  11214. /** !#en Class for video data handling.
  11215. !#zh 视频资源类。 */
  11216. export class VideoClip extends Asset implements EventTarget {
  11217. /**
  11218. !#en Checks whether the EventTarget object has any callback registered for a specific type of event.
  11219. !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。
  11220. @param type The type of event.
  11221. */
  11222. hasEventListener(type: string): boolean;
  11223. /**
  11224. !#en
  11225. Register an callback of a specific event type on the EventTarget.
  11226. This type of event should be triggered via `emit`.
  11227. !#zh
  11228. 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。
  11229. @param type A string representing the event type to listen for.
  11230. @param callback The callback that will be invoked when the event is dispatched.
  11231. The callback is ignored if it is a duplicate (the callbacks are unique).
  11232. @param target The target (this object) to invoke the callback, can be null
  11233. @example
  11234. ```js
  11235. eventTarget.on('fire', function () {
  11236. cc.log("fire in the hole");
  11237. }, node);
  11238. ```
  11239. */
  11240. on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
  11241. /**
  11242. !#en
  11243. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  11244. if only type is passed as parameter, all listeners registered with that type will be removed.
  11245. !#zh
  11246. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  11247. @param type A string representing the event type being removed.
  11248. @param callback The callback to remove.
  11249. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  11250. @example
  11251. ```js
  11252. // register fire eventListener
  11253. var callback = eventTarget.on('fire', function () {
  11254. cc.log("fire in the hole");
  11255. }, target);
  11256. // remove fire event listener
  11257. eventTarget.off('fire', callback, target);
  11258. // remove all fire event listeners
  11259. eventTarget.off('fire');
  11260. ```
  11261. */
  11262. off(type: string, callback?: Function, target?: any): void;
  11263. /**
  11264. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  11265. This is not for removing all listeners in the current event target,
  11266. and this is not for removing all listeners the target parameter have registered.
  11267. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  11268. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  11269. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  11270. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  11271. @param target The target to be searched for all related listeners
  11272. */
  11273. targetOff(target: any): void;
  11274. /**
  11275. !#en
  11276. Register an callback of a specific event type on the EventTarget,
  11277. the callback will remove itself after the first time it is triggered.
  11278. !#zh
  11279. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  11280. @param type A string representing the event type to listen for.
  11281. @param callback The callback that will be invoked when the event is dispatched.
  11282. The callback is ignored if it is a duplicate (the callbacks are unique).
  11283. @param target The target (this object) to invoke the callback, can be null
  11284. @example
  11285. ```js
  11286. eventTarget.once('fire', function () {
  11287. cc.log("this is the callback and will be invoked only once");
  11288. }, node);
  11289. ```
  11290. */
  11291. once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
  11292. /**
  11293. !#en
  11294. Send an event with the event object.
  11295. !#zh
  11296. 通过事件对象派发事件
  11297. @param event event
  11298. */
  11299. dispatchEvent(event: Event): void;
  11300. /**
  11301. !#en
  11302. Destroy all callbackInfos.
  11303. !#zh
  11304. 销毁记录的事件
  11305. */
  11306. clear(): void;
  11307. }
  11308. /** !#en
  11309. Representation of RGBA colors.
  11310. Each color component is a floating point value with a range from 0 to 255.
  11311. You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color.
  11312. !#zh
  11313. cc.Color 用于表示颜色。
  11314. 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。
  11315. 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */
  11316. export class Color extends ValueType {
  11317. /** !#en Solid white, RGBA is [255, 255, 255, 255].
  11318. !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */
  11319. static WHITE: Color;
  11320. /** !#en Solid black, RGBA is [0, 0, 0, 255].
  11321. !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */
  11322. static BLACK: Color;
  11323. /** !#en Transparent, RGBA is [0, 0, 0, 0].
  11324. !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */
  11325. static TRANSPARENT: Color;
  11326. /** !#en Grey, RGBA is [127.5, 127.5, 127.5].
  11327. !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */
  11328. static GRAY: Color;
  11329. /** !#en Solid red, RGBA is [255, 0, 0].
  11330. !#zh 纯红色,RGBA 是 [255, 0, 0]。 */
  11331. static RED: Color;
  11332. /** !#en Solid green, RGBA is [0, 255, 0].
  11333. !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */
  11334. static GREEN: Color;
  11335. /** !#en Solid blue, RGBA is [0, 0, 255].
  11336. !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */
  11337. static BLUE: Color;
  11338. /** !#en Yellow, RGBA is [255, 235, 4].
  11339. !#zh 黄色,RGBA 是 [255, 235, 4]。 */
  11340. static YELLOW: Color;
  11341. /** !#en Orange, RGBA is [255, 127, 0].
  11342. !#zh 橙色,RGBA 是 [255, 127, 0]。 */
  11343. static ORANGE: Color;
  11344. /** !#en Cyan, RGBA is [0, 255, 255].
  11345. !#zh 青色,RGBA 是 [0, 255, 255]。 */
  11346. static CYAN: Color;
  11347. /** !#en Magenta, RGBA is [255, 0, 255].
  11348. !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */
  11349. static MAGENTA: Color;
  11350. /**
  11351. Copy content of a color into another.
  11352. */
  11353. static copy (out: Color, a: Color): Color;
  11354. /**
  11355. Clone a new color.
  11356. */
  11357. static clone (a: Color): Color;
  11358. /**
  11359. Set the components of a color to the given values.
  11360. */
  11361. static set (out: Color, r?: number, g?: number, b?: number, a?: number): Color;
  11362. /**
  11363. Converts the hexadecimal formal color into rgb formal.
  11364. */
  11365. static fromHex (out: Color, hex: number): Color;
  11366. /**
  11367. Converts the hexadecimal formal color into rgb formal.
  11368. */
  11369. static fromHEX (out: Color, hex: string): Color;
  11370. /**
  11371. Add components of two colors, respectively.
  11372. */
  11373. static add (out: Color, a: Color, b: Color): Color;
  11374. /**
  11375. Subtract components of color b from components of color a, respectively.
  11376. */
  11377. static subtract (out: Color, a: Color, b: Color): Color;
  11378. /**
  11379. Multiply components of two colors, respectively.
  11380. */
  11381. static multiply (out: Color, a: Color, b: Color): Color;
  11382. /**
  11383. Divide components of color a by components of color b, respectively.
  11384. */
  11385. static divide (out: Color, a: Color, b: Color): Color;
  11386. /**
  11387. Scales a color by a number.
  11388. */
  11389. static scale (out: Color, a: Color, b: number): Color;
  11390. /**
  11391. Performs a linear interpolation between two colors.
  11392. */
  11393. static lerp (out: Color, a: Color, b: Color, t: number): Color;
  11394. /**
  11395. !#zh 颜色转数组
  11396. !#en Turn an array of colors
  11397. @param ofs 数组起始偏移量
  11398. */
  11399. static toArray <Out extends IWritableArrayLike<number>> (out: Out, a: IColorLike, ofs?: number): Out;
  11400. /**
  11401. !#zh 数组转颜色
  11402. !#en An array of colors turn
  11403. @param ofs 数组起始偏移量
  11404. */
  11405. static fromArray <Out extends IColorLike> (arr: IWritableArrayLike<number>, out: Out, ofs?: number): Out;
  11406. /**
  11407. !#zh 颜色 RGB 预乘 Alpha 通道
  11408. !#en RGB premultiply alpha channel
  11409. @param out 返回颜色
  11410. @param color 预乘处理的目标颜色
  11411. */
  11412. static premultiplyAlpha <Out extends IColorLike> (out: Out, a: IColorLike);
  11413. /**
  11414. @param r red component of the color, default value is 0.
  11415. @param g green component of the color, defualt value is 0.
  11416. @param b blue component of the color, default value is 0.
  11417. @param a alpha component of the color, default value is 255.
  11418. */
  11419. constructor(r?: number, g?: number, b?: number, a?: number);
  11420. /**
  11421. !#en Clone a new color from the current color.
  11422. !#zh 克隆当前颜色。
  11423. @example
  11424. ```js
  11425. var color = new cc.Color();
  11426. var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255}
  11427. ```
  11428. */
  11429. clone(): Color;
  11430. /**
  11431. !#en TODO
  11432. !#zh 判断两个颜色是否相等。
  11433. @param other other
  11434. @example
  11435. ```js
  11436. var color1 = cc.Color.WHITE;
  11437. var color2 = new cc.Color(255, 255, 255);
  11438. cc.log(color1.equals(color2)); // true;
  11439. color2 = cc.Color.RED;
  11440. cc.log(color2.equals(color1)); // false;
  11441. ```
  11442. */
  11443. equals(other: Color): boolean;
  11444. /**
  11445. !#en TODO
  11446. !#zh 线性插值
  11447. @param to to
  11448. @param ratio the interpolation coefficient.
  11449. @param out optional, the receiving vector.
  11450. @example
  11451. ```js
  11452. // Converts a white color to a black one trough time.
  11453. update: function (dt) {
  11454. var color = this.node.color;
  11455. if (color.equals(cc.Color.BLACK)) {
  11456. return;
  11457. }
  11458. this.ratio += dt * 0.1;
  11459. this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio);
  11460. }
  11461. ```
  11462. */
  11463. lerp(to: Color, ratio: number, out?: Color): Color;
  11464. /**
  11465. !#en TODO
  11466. !#zh 转换为方便阅读的字符串。
  11467. @example
  11468. ```js
  11469. var color = cc.Color.WHITE;
  11470. color.toString(); // "rgba(255, 255, 255, 255)"
  11471. ```
  11472. */
  11473. toString(): string;
  11474. /** !#en Get or set red channel value
  11475. !#zh 获取或者设置红色通道 */
  11476. r: number;
  11477. /** !#en Get or set green channel value
  11478. !#zh 获取或者设置绿色通道 */
  11479. g: number;
  11480. /** !#en Get or set blue channel value
  11481. !#zh 获取或者设置蓝色通道 */
  11482. b: number;
  11483. /** !#en Get or set alpha channel value
  11484. !#zh 获取或者设置透明通道 */
  11485. a: number;
  11486. /**
  11487. !#en Gets red channel value
  11488. !#zh 获取当前颜色的红色值。
  11489. */
  11490. getR(): number;
  11491. /**
  11492. !#en Sets red value and return the current color object
  11493. !#zh 设置当前的红色值,并返回当前对象。
  11494. @param red the new Red component.
  11495. @example
  11496. ```js
  11497. var color = new cc.Color();
  11498. color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255}
  11499. ```
  11500. */
  11501. setR(red: number): Color;
  11502. /**
  11503. !#en Gets green channel value
  11504. !#zh 获取当前颜色的绿色值。
  11505. */
  11506. getG(): number;
  11507. /**
  11508. !#en Sets green value and return the current color object
  11509. !#zh 设置当前的绿色值,并返回当前对象。
  11510. @param green the new Green component.
  11511. @example
  11512. ```js
  11513. var color = new cc.Color();
  11514. color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255}
  11515. ```
  11516. */
  11517. setG(green: number): Color;
  11518. /**
  11519. !#en Gets blue channel value
  11520. !#zh 获取当前颜色的蓝色值。
  11521. */
  11522. getB(): number;
  11523. /**
  11524. !#en Sets blue value and return the current color object
  11525. !#zh 设置当前的蓝色值,并返回当前对象。
  11526. @param blue the new Blue component.
  11527. @example
  11528. ```js
  11529. var color = new cc.Color();
  11530. color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255}
  11531. ```
  11532. */
  11533. setB(blue: number): Color;
  11534. /**
  11535. !#en Gets alpha channel value
  11536. !#zh 获取当前颜色的透明度值。
  11537. */
  11538. getA(): number;
  11539. /**
  11540. !#en Sets alpha value and return the current color object
  11541. !#zh 设置当前的透明度,并返回当前对象。
  11542. @param alpha the new Alpha component.
  11543. @example
  11544. ```js
  11545. var color = new cc.Color();
  11546. color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0}
  11547. ```
  11548. */
  11549. setA(alpha: number): Color;
  11550. /**
  11551. !#en Convert color to css format.
  11552. !#zh 转换为 CSS 格式。
  11553. @param opt "rgba", "rgb", "#rgb" or "#rrggbb".
  11554. @example
  11555. ```js
  11556. var color = cc.Color.BLACK;
  11557. color.toCSS(); // "rgba(0,0,0,1.00)";
  11558. color.toCSS("rgba"); // "rgba(0,0,0,1.00)";
  11559. color.toCSS("rgb"); // "rgba(0,0,0)";
  11560. color.toCSS("#rgb"); // "#000";
  11561. color.toCSS("#rrggbb"); // "#000000";
  11562. ```
  11563. */
  11564. toCSS(opt?: string): string;
  11565. /**
  11566. !#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb.
  11567. !#zh 读取 16 进制颜色。
  11568. @param hexString hexString
  11569. @example
  11570. ```js
  11571. var color = cc.Color.BLACK;
  11572. color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
  11573. ```
  11574. */
  11575. fromHEX(hexString: string): Color;
  11576. /**
  11577. !#en convert Color to HEX color string.
  11578. !#zh 转换为 16 进制。
  11579. @param fmt "#rgb", "#rrggbb" or "#rrggbbaa".
  11580. @example
  11581. ```js
  11582. var color = cc.Color.BLACK;
  11583. color.toHEX("#rgb"); // "000";
  11584. color.toHEX("#rrggbb"); // "000000";
  11585. ```
  11586. */
  11587. toHEX(fmt?: string): string;
  11588. /**
  11589. !#en Convert to 24bit rgb value.
  11590. !#zh 转换为 24bit 的 RGB 值。
  11591. @example
  11592. ```js
  11593. var color = cc.Color.YELLOW;
  11594. color.toRGBValue(); // 16771844;
  11595. ```
  11596. */
  11597. toRGBValue(): number;
  11598. /**
  11599. !#en Read HSV model color and convert to RGB color
  11600. !#zh 读取 HSV(色彩模型)格式。
  11601. @param h h
  11602. @param s s
  11603. @param v v
  11604. @example
  11605. ```js
  11606. var color = cc.Color.YELLOW;
  11607. color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255};
  11608. ```
  11609. */
  11610. fromHSV(h: number, s: number, v: number): Color;
  11611. /**
  11612. !#en Transform to HSV model color
  11613. !#zh 转换为 HSV(色彩模型)格式。
  11614. @example
  11615. ```js
  11616. var color = cc.Color.YELLOW;
  11617. color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1};
  11618. ```
  11619. */
  11620. toHSV(): any;
  11621. /**
  11622. !#en Set the color
  11623. !#zh 设置颜色
  11624. @param color color
  11625. */
  11626. set (color: Color): Color;
  11627. /**
  11628. !#en Multiplies the current color by the specified color
  11629. !#zh 将当前颜色乘以与指定颜色
  11630. @param other other
  11631. */
  11632. multiply(other: Color): Color;
  11633. }
  11634. /** Mathematical 3x3 matrix.
  11635. NOTE: we use column-major matrix for all matrix calculation.
  11636. This may lead to some confusion when referencing OpenGL documentation,
  11637. however, which represents out all matricies in column-major format.
  11638. This means that while in code a matrix may be typed out as:
  11639. [1, 0, 0, 0,
  11640. 0, 1, 0, 0,
  11641. 0, 0, 1, 0,
  11642. x, y, z, 0]
  11643. The same matrix in the [OpenGL documentation](https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTranslate.xml)
  11644. is written as:
  11645. 1 0 0 x
  11646. 0 1 0 y
  11647. 0 0 1 z
  11648. 0 0 0 0
  11649. Please rest assured, however, that they are the same thing!
  11650. This is not unique to glMatrix, either, as OpenGL developers have long been confused by the
  11651. apparent lack of consistency between the memory layout and the documentation. */
  11652. export class Mat3 extends ValueType {
  11653. /** Identity of Mat3 */
  11654. static IDENTITY: Mat3;
  11655. /**
  11656. !#zh 矩阵转数组
  11657. !#en Matrix transpose array
  11658. @param ofs 数组内的起始偏移量
  11659. */
  11660. static toArray <Out extends IWritableArrayLike<number>> (out: Out, mat: IMat3Like, ofs?: number): Out;
  11661. /**
  11662. !#zh 数组转矩阵
  11663. !#en Transfer matrix array
  11664. @param ofs 数组起始偏移量
  11665. */
  11666. static fromArray <Out extends IMat3Like> (out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out;
  11667. /** !#en Matrix Data
  11668. !#zh 矩阵数据 */
  11669. m: Float64Array|Float32Array;
  11670. constructor (m00?: number | Float32Array, m01?: number, m02?: number, m03?: number, m04?: number, m05?: number, m06?: number, m07?: number, m08?: number);
  11671. }
  11672. /** !#en Representation of 4*4 matrix.
  11673. !#zh 表示 4*4 矩阵 */
  11674. export class Mat4 extends ValueType {
  11675. /**
  11676. !#en Multiply the current matrix with another one
  11677. !#zh 将当前矩阵与指定矩阵相乘
  11678. @param other the second operand
  11679. @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
  11680. */
  11681. mul(other: Mat4, out?: Mat4): Mat4;
  11682. /**
  11683. !#en Multiply each element of the matrix by a scalar.
  11684. !#zh 将矩阵的每一个元素都乘以指定的缩放值。
  11685. @param number amount to scale the matrix's elements by
  11686. @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
  11687. */
  11688. mulScalar(number: number, out?: Mat4): Mat4;
  11689. /**
  11690. !#en Subtracts the current matrix with another one
  11691. !#zh 将当前矩阵与指定的矩阵相减
  11692. @param other the second operand
  11693. @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
  11694. */
  11695. sub(other: Mat4, out?: Mat4): Mat4;
  11696. /** Identity of Mat4 */
  11697. static IDENTITY: Mat4;
  11698. /**
  11699. !#zh 获得指定矩阵的拷贝
  11700. !#en Copy of the specified matrix to obtain
  11701. */
  11702. static clone<Out extends IMat4Like> (a: Out): Mat4;
  11703. /**
  11704. !#zh 复制目标矩阵
  11705. !#en Copy the target matrix
  11706. */
  11707. static copy<Out extends IMat4Like> (out: Out, a: Out): Out;
  11708. /**
  11709. !#zh 将目标赋值为单位矩阵
  11710. !#en The target of an assignment is the identity matrix
  11711. */
  11712. static identity<Out extends IMat4Like> (out: Out): Out;
  11713. /**
  11714. !#zh 转置矩阵
  11715. !#en Transposed matrix
  11716. */
  11717. static transpose<Out extends IMat4Like> (out: Out, a: Out): Out;
  11718. /**
  11719. !#zh 矩阵求逆
  11720. !#en Matrix inversion
  11721. */
  11722. static invert<Out extends IMat4Like> (out: Out, a: Out): Out;
  11723. /**
  11724. !#zh 矩阵行列式
  11725. !#en Matrix determinant
  11726. */
  11727. static determinant<Out extends IMat4Like> (a: Out): number;
  11728. /**
  11729. !#zh 矩阵乘法
  11730. !#en Matrix Multiplication
  11731. */
  11732. static multiply<Out extends IMat4Like> (out: Out, a: Out, b: Out): Out;
  11733. /**
  11734. !#zh 在给定矩阵变换基础上加入变换
  11735. !#en Was added in a given transformation matrix transformation on the basis of
  11736. */
  11737. static transform<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, a: Out, v: VecLike): Out;
  11738. /**
  11739. !#zh 在给定矩阵变换基础上加入新位移变换
  11740. !#en Add new displacement transducer in a matrix transformation on the basis of a given
  11741. */
  11742. static translate<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, a: Out, v: VecLike): Out;
  11743. /**
  11744. !#zh 在给定矩阵变换基础上加入新缩放变换
  11745. !#en Add new scaling transformation in a given matrix transformation on the basis of
  11746. */
  11747. static scale<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, a: Out, v: VecLike): Out;
  11748. /**
  11749. !#zh 在给定矩阵变换基础上加入新旋转变换
  11750. !#en Add a new rotational transform matrix transformation on the basis of a given
  11751. @param rad 旋转角度
  11752. @param axis 旋转轴
  11753. */
  11754. static rotate<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, a: Out, rad: number, axis: VecLike): Out;
  11755. /**
  11756. !#zh 在给定矩阵变换基础上加入绕 X 轴的旋转变换
  11757. !#en Add rotational transformation around the X axis at a given matrix transformation on the basis of
  11758. @param rad 旋转角度
  11759. */
  11760. static rotateX<Out extends IMat4Like> (out: Out, a: Out, rad: number): Out;
  11761. /**
  11762. !#zh 在给定矩阵变换基础上加入绕 Y 轴的旋转变换
  11763. !#en Add about the Y axis rotation transformation in a given matrix transformation on the basis of
  11764. @param rad 旋转角度
  11765. */
  11766. static rotateY<Out extends IMat4Like> (out: Out, a: Out, rad: number): Out;
  11767. /**
  11768. !#zh 在给定矩阵变换基础上加入绕 Z 轴的旋转变换
  11769. !#en Added about the Z axis at a given rotational transformation matrix transformation on the basis of
  11770. @param rad 旋转角度
  11771. */
  11772. static rotateZ<Out extends IMat4Like> (out: Out, a: Out, rad: number): Out;
  11773. /**
  11774. !#zh 计算位移矩阵
  11775. !#en Displacement matrix calculation
  11776. */
  11777. static fromTranslation<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, v: VecLike): Out;
  11778. /**
  11779. !#zh 计算缩放矩阵
  11780. !#en Scaling matrix calculation
  11781. */
  11782. static fromScaling<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, v: VecLike): Out;
  11783. /**
  11784. !#zh 计算旋转矩阵
  11785. !#en Calculates the rotation matrix
  11786. */
  11787. static fromRotation<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, rad: number, axis: VecLike): Out;
  11788. /**
  11789. !#zh 计算绕 X 轴的旋转矩阵
  11790. !#en Calculating rotation matrix about the X axis
  11791. */
  11792. static fromXRotation<Out extends IMat4Like> (out: Out, rad: number): Out;
  11793. /**
  11794. !#zh 计算绕 Y 轴的旋转矩阵
  11795. !#en Calculating rotation matrix about the Y axis
  11796. */
  11797. static fromYRotation<Out extends IMat4Like> (out: Out, rad: number): Out;
  11798. /**
  11799. !#zh 计算绕 Z 轴的旋转矩阵
  11800. !#en Calculating rotation matrix about the Z axis
  11801. */
  11802. static fromZRotation<Out extends IMat4Like> (out: Out, rad: number): Out;
  11803. /**
  11804. !#zh 根据旋转和位移信息计算矩阵
  11805. !#en The rotation and displacement information calculating matrix
  11806. */
  11807. static fromRT<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, q: Quat, v: VecLike): Out;
  11808. /**
  11809. !#zh 提取矩阵的位移信息, 默认矩阵中的变换以 S->R->T 的顺序应用
  11810. !#en Extracting displacement information of the matrix, the matrix transform to the default sequential application S-> R-> T is
  11811. */
  11812. static getTranslation<Out extends IMat4Like, VecLike extends IVec3Like> (out: VecLike, mat: Out): VecLike;
  11813. /**
  11814. !#zh 提取矩阵的缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用
  11815. !#en Scaling information extraction matrix, the matrix transform to the default sequential application S-> R-> T is
  11816. */
  11817. static getScaling<Out extends IMat4Like, VecLike extends IVec3Like> (out: VecLike, mat: Out): VecLike;
  11818. /**
  11819. !#zh 提取矩阵的旋转信息, 默认输入矩阵不含有缩放信息,如考虑缩放应使用 `toRTS` 函数。
  11820. !#en Rotation information extraction matrix, the matrix containing no default input scaling information, such as the use of `toRTS` should consider the scaling function.
  11821. */
  11822. static getRotation<Out extends IMat4Like> (out: Quat, mat: Out): Quat;
  11823. /**
  11824. !#zh 提取旋转、位移、缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用
  11825. !#en Extracting rotational displacement, zoom information, the default matrix transformation in order S-> R-> T applications
  11826. */
  11827. static toRTS<Out extends IMat4Like, VecLike extends IVec3Like> (mat: Out, q: Quat, v: VecLike, s: VecLike): void;
  11828. /**
  11829. !#zh 根据旋转、位移、缩放信息计算矩阵,以 S->R->T 的顺序应用
  11830. !#en The rotary displacement, the scaling matrix calculation information, the order S-> R-> T applications
  11831. */
  11832. static fromRTS<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, q: Quat, v: VecLike, s: VecLike): Out;
  11833. /**
  11834. !#zh 根据指定的旋转、位移、缩放及变换中心信息计算矩阵,以 S->R->T 的顺序应用
  11835. !#en According to the specified rotation, displacement, and scale conversion matrix calculation information center, order S-> R-> T applications
  11836. @param q 旋转值
  11837. @param v 位移值
  11838. @param s 缩放值
  11839. @param o 指定变换中心
  11840. */
  11841. static fromRTSOrigin<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, q: Quat, v: VecLike, s: VecLike, o: VecLike): Out;
  11842. /**
  11843. !#zh 根据指定的旋转信息计算矩阵
  11844. !#en The rotation matrix calculation information specified
  11845. */
  11846. static fromQuat<Out extends IMat4Like> (out: Out, q: Quat): Out;
  11847. /**
  11848. !#zh 根据指定的视锥体信息计算矩阵
  11849. !#en The matrix calculation information specified frustum
  11850. @param left 左平面距离
  11851. @param right 右平面距离
  11852. @param bottom 下平面距离
  11853. @param top 上平面距离
  11854. @param near 近平面距离
  11855. @param far 远平面距离
  11856. */
  11857. static frustum<Out extends IMat4Like> (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number): Out;
  11858. /**
  11859. !#zh 计算透视投影矩阵
  11860. !#en Perspective projection matrix calculation
  11861. @param fovy 纵向视角高度
  11862. @param aspect 长宽比
  11863. @param near 近平面距离
  11864. @param far 远平面距离
  11865. */
  11866. static perspective<Out extends IMat4Like> (out: Out, fovy: number, aspect: number, near: number, far: number): Out;
  11867. /**
  11868. !#zh 计算正交投影矩阵
  11869. !#en Computing orthogonal projection matrix
  11870. @param left 左平面距离
  11871. @param right 右平面距离
  11872. @param bottom 下平面距离
  11873. @param top 上平面距离
  11874. @param near 近平面距离
  11875. @param far 远平面距离
  11876. */
  11877. static ortho<Out extends IMat4Like> (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number): Out;
  11878. /**
  11879. !#zh 根据视点计算矩阵,注意 `eye - center` 不能为零向量或与 `up` 向量平行
  11880. !#en `Up` parallel vector or vector center` not be zero - the matrix calculation according to the viewpoint, note` eye
  11881. @param eye 当前位置
  11882. @param center 目标视点
  11883. @param up 视口上方向
  11884. */
  11885. static lookAt<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, eye: VecLike, center: VecLike, up: VecLike): Out;
  11886. /**
  11887. !#zh 计算逆转置矩阵
  11888. !#en Reversal matrix calculation
  11889. */
  11890. static inverseTranspose<Out extends IMat4Like> (out: Out, a: Out): Out;
  11891. /**
  11892. !#zh 逐元素矩阵加法
  11893. !#en Element by element matrix addition
  11894. */
  11895. static add<Out extends IMat4Like> (out: Out, a: Out, b: Out): Out;
  11896. /**
  11897. !#zh 逐元素矩阵减法
  11898. !#en Matrix element by element subtraction
  11899. */
  11900. static subtract<Out extends IMat4Like> (out: Out, a: Out, b: Out): Out;
  11901. /**
  11902. !#zh 矩阵标量乘法
  11903. !#en Matrix scalar multiplication
  11904. */
  11905. static multiplyScalar<Out extends IMat4Like> (out: Out, a: Out, b: number): Out;
  11906. /**
  11907. !#zh 逐元素矩阵标量乘加: A + B * scale
  11908. !#en Elements of the matrix by the scalar multiplication and addition: A + B * scale
  11909. */
  11910. static multiplyScalarAndAdd<Out extends IMat4Like> (out: Out, a: Out, b: Out, scale: number): Out;
  11911. /**
  11912. !#zh 矩阵等价判断
  11913. !#en Analyzing the equivalent matrix
  11914. */
  11915. static strictEquals<Out extends IMat4Like> (a: Out, b: Out): boolean;
  11916. /**
  11917. !#zh 排除浮点数误差的矩阵近似等价判断
  11918. !#en Negative floating point error is approximately equivalent to determining a matrix
  11919. */
  11920. static equals<Out extends IMat4Like> (a: Out, b: Out, epsilon?: number): boolean;
  11921. /**
  11922. !#zh 矩阵转数组
  11923. !#en Matrix transpose array
  11924. @param ofs 数组内的起始偏移量
  11925. */
  11926. static toArray <Out extends IWritableArrayLike<number>> (out: Out, mat: IMat4Like, ofs?: number): Out;
  11927. /**
  11928. !#zh 数组转矩阵
  11929. !#en Transfer matrix array
  11930. @param ofs 数组起始偏移量
  11931. */
  11932. static fromArray <Out extends IMat4Like> (out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out;
  11933. /** !#en Matrix Data
  11934. !#zh 矩阵数据 */
  11935. m: Float64Array|Float32Array;
  11936. /**
  11937. !#en
  11938. Constructor
  11939. see {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}}
  11940. !#zh
  11941. 构造函数,可查看 {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}}
  11942. */
  11943. constructor ( m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number);
  11944. /**
  11945. !#en clone a Mat4 object
  11946. !#zh 克隆一个 Mat4 对象
  11947. */
  11948. clone(): Mat4;
  11949. /**
  11950. !#en Sets the matrix with another one's value
  11951. !#zh 用另一个矩阵设置这个矩阵的值。
  11952. @param srcObj srcObj
  11953. */
  11954. set(srcObj: Mat4): Mat4;
  11955. /**
  11956. !#en Check whether two matrix equal
  11957. !#zh 当前的矩阵是否与指定的矩阵相等。
  11958. @param other other
  11959. */
  11960. equals(other: Mat4): boolean;
  11961. /**
  11962. !#en Check whether two matrix equal with default degree of variance.
  11963. !#zh
  11964. 近似判断两个矩阵是否相等。<br/>
  11965. 判断 2 个矩阵是否在默认误差范围之内,如果在则返回 true,反之则返回 false。
  11966. @param other other
  11967. */
  11968. fuzzyEquals(other: Mat4): boolean;
  11969. /**
  11970. !#en Transform to string with matrix informations
  11971. !#zh 转换为方便阅读的字符串。
  11972. */
  11973. toString(): string;
  11974. /**
  11975. Set the matrix to the identity matrix
  11976. */
  11977. identity(): Mat4;
  11978. /**
  11979. Transpose the values of a mat4
  11980. @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created.
  11981. */
  11982. transpose(out?: Mat4): Mat4;
  11983. /**
  11984. Inverts a mat4
  11985. @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created.
  11986. */
  11987. invert(out?: Mat4): Mat4;
  11988. /**
  11989. Calculates the adjugate of a mat4
  11990. @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created.
  11991. */
  11992. adjoint(out?: Mat4): Mat4;
  11993. /**
  11994. Calculates the determinant of a mat4
  11995. */
  11996. determinant(): number;
  11997. /**
  11998. Adds two Mat4
  11999. @param other the second operand
  12000. @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created.
  12001. */
  12002. add(other: Mat4, out?: Mat4): Mat4;
  12003. /**
  12004. Subtracts the current matrix with another one
  12005. @param other the second operand
  12006. */
  12007. subtract(other: Mat4): Mat4;
  12008. /**
  12009. Subtracts the current matrix with another one
  12010. @param other the second operand
  12011. */
  12012. multiply(other: Mat4): Mat4;
  12013. /**
  12014. Multiply each element of the matrix by a scalar.
  12015. @param number amount to scale the matrix's elements by
  12016. */
  12017. multiplyScalar(number: number): Mat4;
  12018. /**
  12019. Translate a mat4 by the given vector
  12020. @param v vector to translate by
  12021. @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
  12022. */
  12023. translate(v: Vec3, out?: Mat4): Mat4;
  12024. /**
  12025. Scales the mat4 by the dimensions in the given vec3
  12026. @param v vector to scale by
  12027. @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
  12028. */
  12029. scale(v: Vec3, out?: Mat4): Mat4;
  12030. /**
  12031. Rotates a mat4 by the given angle around the given axis
  12032. @param rad the angle to rotate the matrix by
  12033. @param axis the axis to rotate around
  12034. @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
  12035. */
  12036. rotate(rad: number, axis: Vec3, out?: Mat4): Mat4;
  12037. /**
  12038. Returns the translation vector component of a transformation matrix.
  12039. @param out Vector to receive translation component, if not provided, a new vec3 will be created
  12040. */
  12041. getTranslation(out: Vec3): Vec3;
  12042. /**
  12043. Returns the scale factor component of a transformation matrix
  12044. @param out Vector to receive scale component, if not provided, a new vec3 will be created
  12045. */
  12046. getScale(out: Vec3): Vec3;
  12047. /**
  12048. Returns the rotation factor component of a transformation matrix
  12049. @param out Vector to receive rotation component, if not provided, a new quaternion object will be created
  12050. */
  12051. getRotation(out: Quat): Quat;
  12052. /**
  12053. Restore the matrix values from a quaternion rotation, vector translation and vector scale
  12054. @param q Rotation quaternion
  12055. @param v Translation vector
  12056. @param s Scaling vector
  12057. */
  12058. fromRTS(q: Quat, v: Vec3, s: Vec3): Mat4;
  12059. /**
  12060. Restore the matrix values from a quaternion rotation
  12061. @param q Rotation quaternion
  12062. */
  12063. fromQuat(q: Quat): Mat4;
  12064. }
  12065. /** !#en Representation of 2D vectors and points.
  12066. !#zh 表示 2D 向量和坐标 */
  12067. export class Quat extends ValueType {
  12068. /**
  12069. !#en
  12070. Constructor
  12071. see {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}}
  12072. !#zh
  12073. 构造函数,可查看 {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}}
  12074. @param x x
  12075. @param y y
  12076. @param z z
  12077. @param w w
  12078. */
  12079. constructor(x?: number, y?: number, z?: number, w?: number);
  12080. /**
  12081. !#en Calculate the multiply result between this quaternion and another one
  12082. !#zh 计算四元数乘积的结果
  12083. @param other other
  12084. @param out out
  12085. */
  12086. mul(other: Quat, out?: Quat): Quat;
  12087. /**
  12088. !#zh 获得指定四元数的拷贝
  12089. !#en Obtaining copy specified quaternion
  12090. */
  12091. static clone<Out extends IQuatLike> (a: Out): Quat;
  12092. /**
  12093. !#zh 复制目标四元数
  12094. !#en Copy quaternion target
  12095. */
  12096. static copy<Out extends IQuatLike, QuatLike extends IQuatLike> (out: Out, a: QuatLike): Out;
  12097. /**
  12098. !#zh 设置四元数值
  12099. !#en Provided Quaternion Value
  12100. */
  12101. static set<Out extends IQuatLike> (out: Out, x: number, y: number, z: number, w: number): Out;
  12102. /**
  12103. !#zh 将目标赋值为单位四元数
  12104. !#en The target of an assignment as a unit quaternion
  12105. */
  12106. static identity<Out extends IQuatLike> (out: Out): Out;
  12107. /**
  12108. !#zh 设置四元数为两向量间的最短路径旋转,默认两向量都已归一化
  12109. !#en Set quaternion rotation is the shortest path between two vectors, the default two vectors are normalized
  12110. */
  12111. static rotationTo<Out extends IQuatLike, VecLike extends IVec3Like> (out: Out, a: VecLike, b: VecLike): Out;
  12112. /**
  12113. !#zh 获取四元数的旋转轴和旋转弧度
  12114. !#en Get the rotary shaft and the arc of rotation quaternion
  12115. @param outAxis 旋转轴输出
  12116. @param q 源四元数
  12117. */
  12118. static getAxisAngle<Out extends IQuatLike, VecLike extends IVec3Like> (outAxis: VecLike, q: Out): number;
  12119. /**
  12120. !#zh 四元数乘法
  12121. !#en Quaternion multiplication
  12122. */
  12123. static multiply<Out extends IQuatLike, QuatLike_1 extends IQuatLike, QuatLike_2 extends IQuatLike> (out: Out, a: QuatLike_1, b: QuatLike_2): Out;
  12124. /**
  12125. !#zh 四元数标量乘法
  12126. !#en Quaternion scalar multiplication
  12127. */
  12128. static multiplyScalar<Out extends IQuatLike> (out: Out, a: Out, b: number): Out;
  12129. /**
  12130. !#zh 四元数乘加:A + B * scale
  12131. !#en Quaternion multiplication and addition: A + B * scale
  12132. */
  12133. static scaleAndAdd<Out extends IQuatLike> (out: Out, a: Out, b: Out, scale: number): Out;
  12134. /**
  12135. !#zh 绕 X 轴旋转指定四元数
  12136. !#en About the X axis specified quaternion
  12137. @param rad 旋转弧度
  12138. */
  12139. static rotateX<Out extends IQuatLike> (out: Out, a: Out, rad: number): Out;
  12140. /**
  12141. !#zh 绕 Y 轴旋转指定四元数
  12142. !#en Rotation about the Y axis designated quaternion
  12143. @param rad 旋转弧度
  12144. */
  12145. static rotateY<Out extends IQuatLike> (out: Out, a: Out, rad: number): Out;
  12146. /**
  12147. !#zh 绕 Z 轴旋转指定四元数
  12148. !#en Around the Z axis specified quaternion
  12149. @param rad 旋转弧度
  12150. */
  12151. static rotateZ<Out extends IQuatLike> (out: Out, a: Out, rad: number): Out;
  12152. /**
  12153. !#zh 绕世界空间下指定轴旋转四元数
  12154. !#en Space around the world at a given axis of rotation quaternion
  12155. @param axis 旋转轴,默认已归一化
  12156. @param rad 旋转弧度
  12157. */
  12158. static rotateAround<Out extends IQuatLike, VecLike extends IVec3Like> (out: Out, rot: Out, axis: VecLike, rad: number): Out;
  12159. /**
  12160. !#zh 绕本地空间下指定轴旋转四元数
  12161. !#en Local space around the specified axis rotation quaternion
  12162. @param axis 旋转轴
  12163. @param rad 旋转弧度
  12164. */
  12165. static rotateAroundLocal<Out extends IQuatLike, VecLike extends IVec3Like> (out: Out, rot: Out, axis: VecLike, rad: number): Out;
  12166. /**
  12167. !#zh 根据 xyz 分量计算 w 分量,默认已归一化
  12168. !#en The component w xyz components calculated, normalized by default
  12169. */
  12170. static calculateW<Out extends IQuatLike> (out: Out, a: Out): Out;
  12171. /**
  12172. !#zh 四元数点积(数量积)
  12173. !#en Quaternion dot product (scalar product)
  12174. */
  12175. static dot<Out extends IQuatLike> (a: Out, b: Out): number;
  12176. /**
  12177. !#zh 逐元素线性插值: A + t * (B - A)
  12178. !#en Element by element linear interpolation: A + t * (B - A)
  12179. */
  12180. static lerp<Out extends IQuatLike> (out: Out, a: Out, b: Out, t: number): Out;
  12181. /**
  12182. !#zh 四元数球面插值
  12183. !#en Spherical quaternion interpolation
  12184. */
  12185. static slerp<Out extends IQuatLike, QuatLike_1 extends IQuatLike, QuatLike_2 extends IQuatLike>(out: Out, a: QuatLike_1, b: QuatLike_2, t: number): Out;
  12186. /**
  12187. !#zh 带两个控制点的四元数球面插值
  12188. !#en Quaternion with two spherical interpolation control points
  12189. */
  12190. static sqlerp<Out extends IQuatLike> (out: Out, a: Out, b: Out, c: Out, d: Out, t: number): Out;
  12191. /**
  12192. !#zh 四元数求逆
  12193. !#en Quaternion inverse
  12194. */
  12195. static invert<Out extends IQuatLike, QuatLike extends IQuatLike> (out: Out, a: QuatLike): Out;
  12196. /**
  12197. !#zh 求共轭四元数,对单位四元数与求逆等价,但更高效
  12198. !#en Conjugating a quaternion, and the unit quaternion equivalent to inversion, but more efficient
  12199. */
  12200. static conjugate<Out extends IQuatLike> (out: Out, a: Out): Out;
  12201. /**
  12202. !#zh 求四元数长度
  12203. !#en Seek length quaternion
  12204. */
  12205. static len<Out extends IQuatLike> (a: Out): number;
  12206. /**
  12207. !#zh 求四元数长度平方
  12208. !#en Seeking quaternion square of the length
  12209. */
  12210. static lengthSqr<Out extends IQuatLike> (a: Out): number;
  12211. /**
  12212. !#zh 归一化四元数
  12213. !#en Normalized quaternions
  12214. */
  12215. static normalize<Out extends IQuatLike> (out: Out, a: Out): Out;
  12216. /**
  12217. !#zh 根据本地坐标轴朝向计算四元数,默认三向量都已归一化且相互垂直
  12218. !#en Calculated according to the local orientation quaternion coordinate axis, the default three vectors are normalized and mutually perpendicular
  12219. */
  12220. static fromAxes<Out extends IQuatLike, VecLike extends IVec3Like> (out: Out, xAxis: VecLike, yAxis: VecLike, zAxis: VecLike): Out;
  12221. /**
  12222. !#zh 根据视口的前方向和上方向计算四元数
  12223. !#en The forward direction and the direction of the viewport computing quaternion
  12224. @param view 视口面向的前方向,必须归一化
  12225. @param up 视口的上方向,必须归一化,默认为 (0, 1, 0)
  12226. */
  12227. static fromViewUp<Out extends IQuatLike> (out: Out, view: Vec3, up?: Vec3): Out;
  12228. /**
  12229. !#zh 根据旋转轴和旋转弧度计算四元数
  12230. !#en The quaternion calculated and the arc of rotation of the rotary shaft
  12231. */
  12232. static fromAxisAngle<Out extends IQuatLike, VecLike extends IVec3Like> (out: Out, axis: VecLike, rad: number): Out;
  12233. /**
  12234. !#zh 根据三维矩阵信息计算四元数,默认输入矩阵不含有缩放信息
  12235. !#en Calculating the three-dimensional quaternion matrix information, default zoom information input matrix does not contain
  12236. */
  12237. static fromMat3<Out extends IQuatLike> (out: Out, mat: Mat3): Out;
  12238. /**
  12239. !#zh 根据欧拉角信息计算四元数,旋转顺序为 YZX
  12240. !#en The quaternion calculated Euler angle information, rotation order YZX
  12241. */
  12242. static fromEuler<Out extends IQuatLike> (out: Out, x: number, y: number, z: number): Out;
  12243. /**
  12244. !#zh 返回定义此四元数的坐标系 X 轴向量
  12245. !#en This returns the result of the quaternion coordinate system X-axis vector
  12246. */
  12247. static toAxisX<Out extends IQuatLike, VecLike extends IVec3Like> (out: VecLike, q: Out): VecLike;
  12248. /**
  12249. !#zh 返回定义此四元数的坐标系 Y 轴向量
  12250. !#en This returns the result of the quaternion coordinate system Y axis vector
  12251. */
  12252. static toAxisY<Out extends IQuatLike, VecLike extends IVec3Like> (out: VecLike, q: Out): VecLike;
  12253. /**
  12254. !#zh 返回定义此四元数的坐标系 Z 轴向量
  12255. !#en This returns the result of the quaternion coordinate system the Z-axis vector
  12256. */
  12257. static toAxisZ<Out extends IQuatLike, VecLike extends IVec3Like> (out: VecLike, q: Out): VecLike;
  12258. /**
  12259. !#zh 根据四元数计算欧拉角,返回角度 x, y 在 [-180, 180] 区间内, z 默认在 [-90, 90] 区间内,旋转顺序为 YZX
  12260. !#en The quaternion calculated Euler angles, return angle x, y in the [-180, 180] interval, z default the range [-90, 90] interval, the rotation order YZX
  12261. @param outerZ z 取值范围区间改为 [-180, -90] U [90, 180]
  12262. */
  12263. static toEuler<Out extends IVec3Like> (out: Out, q: IQuatLike, outerZ?: boolean): Out;
  12264. /**
  12265. !#zh 四元数等价判断
  12266. !#en Analyzing quaternion equivalent
  12267. */
  12268. static strictEquals<Out extends IQuatLike> (a: Out, b: Out): boolean;
  12269. /**
  12270. !#zh 排除浮点数误差的四元数近似等价判断
  12271. !#en Negative floating point error quaternion approximately equivalent Analyzing
  12272. */
  12273. static equals<Out extends IQuatLike> (a: Out, b: Out, epsilon?: number): boolean;
  12274. /**
  12275. !#zh 四元数转数组
  12276. !#en Quaternion rotation array
  12277. @param ofs 数组内的起始偏移量
  12278. */
  12279. static toArray <Out extends IWritableArrayLike<number>> (out: Out, q: IQuatLike, ofs?: number): Out;
  12280. /**
  12281. !#zh 数组转四元数
  12282. !#en Array to a quaternion
  12283. @param ofs 数组起始偏移量
  12284. */
  12285. static fromArray <Out extends IQuatLike> (out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out;
  12286. x: number;
  12287. y: number;
  12288. z: number;
  12289. w: number;
  12290. /**
  12291. !#en clone a Quat object and return the new object
  12292. !#zh 克隆一个四元数并返回
  12293. */
  12294. clone(): Quat;
  12295. /**
  12296. !#en Set values with another quaternion
  12297. !#zh 用另一个四元数的值设置到当前对象上。
  12298. @param newValue !#en new value to set. !#zh 要设置的新值
  12299. */
  12300. set(newValue: Quat): Quat;
  12301. /**
  12302. !#en Check whether current quaternion equals another
  12303. !#zh 当前的四元数是否与指定的四元数相等。
  12304. @param other other
  12305. */
  12306. equals(other: Quat): boolean;
  12307. /**
  12308. !#en Convert quaternion to euler
  12309. !#zh 转换四元数到欧拉角
  12310. @param out out
  12311. */
  12312. toEuler(out: Vec3): Vec3;
  12313. /**
  12314. !#en Convert euler to quaternion
  12315. !#zh 转换欧拉角到四元数
  12316. @param euler euler
  12317. */
  12318. fromEuler(euler: Vec3): Quat;
  12319. /**
  12320. !#en Calculate the interpolation result between this quaternion and another one with given ratio
  12321. !#zh 计算四元数的插值结果
  12322. @param to to
  12323. @param ratio ratio
  12324. @param out out
  12325. */
  12326. lerp(to: Quat, ratio: number, out?: Quat): Quat;
  12327. /**
  12328. !#en Calculate the multiply result between this quaternion and another one
  12329. !#zh 计算四元数乘积的结果
  12330. @param other other
  12331. */
  12332. multiply(other: Quat): Quat;
  12333. /**
  12334. !#en Rotates a quaternion by the given angle (in radians) about a world space axis.
  12335. !#zh 围绕世界空间轴按给定弧度旋转四元数
  12336. @param rot Quaternion to rotate
  12337. @param axis The axis around which to rotate in world space
  12338. @param rad Angle (in radians) to rotate
  12339. @param out Quaternion to store result
  12340. */
  12341. rotateAround(rot: Quat, axis: Vec3, rad: number, out?: Quat): Quat;
  12342. }
  12343. /** !#en A 2D rectangle defined by x, y position and width, height.
  12344. !#zh 通过位置和宽高定义的 2D 矩形。 */
  12345. export class Rect extends ValueType {
  12346. /**
  12347. !#en
  12348. Constructor of Rect class.
  12349. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  12350. !#zh
  12351. Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  12352. @param x x
  12353. @param y y
  12354. @param w w
  12355. @param h h
  12356. */
  12357. constructor(x?: number, y?: number, w?: number, h?: number);
  12358. /**
  12359. !#en Creates a rectangle from two coordinate values.
  12360. !#zh 根据指定 2 个坐标创建出一个矩形区域。
  12361. @param v1 v1
  12362. @param v2 v2
  12363. @example
  12364. ```js
  12365. cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10};
  12366. ```
  12367. */
  12368. static fromMinMax(v1: Vec2, v2: Vec2): Rect;
  12369. x: number;
  12370. y: number;
  12371. width: number;
  12372. height: number;
  12373. /**
  12374. !#en TODO
  12375. !#zh 克隆一个新的 Rect。
  12376. @example
  12377. ```js
  12378. var a = new cc.Rect(0, 0, 10, 10);
  12379. a.clone();// Rect {x: 0, y: 0, width: 10, height: 10}
  12380. ```
  12381. */
  12382. clone(): Rect;
  12383. /**
  12384. !#en TODO
  12385. !#zh 是否等于指定的矩形。
  12386. @param other other
  12387. @example
  12388. ```js
  12389. var a = new cc.Rect(0, 0, 10, 10);
  12390. var b = new cc.Rect(0, 0, 10, 10);
  12391. a.equals(b);// true;
  12392. ```
  12393. */
  12394. equals(other: Rect): boolean;
  12395. /**
  12396. !#en TODO
  12397. !#zh 线性插值
  12398. @param to to
  12399. @param ratio the interpolation coefficient.
  12400. @param out optional, the receiving vector.
  12401. @example
  12402. ```js
  12403. var a = new cc.Rect(0, 0, 10, 10);
  12404. var b = new cc.Rect(50, 50, 100, 100);
  12405. update (dt) {
  12406. // method 1;
  12407. var c = a.lerp(b, dt * 0.1);
  12408. // method 2;
  12409. a.lerp(b, dt * 0.1, c);
  12410. }
  12411. ```
  12412. */
  12413. lerp(to: Rect, ratio: number, out?: Rect): Rect;
  12414. /**
  12415. !#en Check whether the current rectangle intersects with the given one
  12416. !#zh 当前矩形与指定矩形是否相交。
  12417. @param rect rect
  12418. @example
  12419. ```js
  12420. var a = new cc.Rect(0, 0, 10, 10);
  12421. var b = new cc.Rect(0, 0, 20, 20);
  12422. a.intersects(b);// true
  12423. ```
  12424. */
  12425. intersects(rect: Rect): boolean;
  12426. /**
  12427. !#en Returns the overlapping portion of 2 rectangles.
  12428. !#zh 返回 2 个矩形重叠的部分。
  12429. @param out Stores the result
  12430. @param rectB rectB
  12431. @example
  12432. ```js
  12433. var a = new cc.Rect(0, 10, 20, 20);
  12434. var b = new cc.Rect(0, 10, 10, 10);
  12435. var intersection = new cc.Rect();
  12436. a.intersection(intersection, b); // intersection {x: 0, y: 10, width: 10, height: 10};
  12437. ```
  12438. */
  12439. intersection(out: Rect, rectB: Rect): Rect;
  12440. /**
  12441. !#en Check whether the current rect contains the given point
  12442. !#zh 当前矩形是否包含指定坐标点。
  12443. Returns true if the point inside this rectangle.
  12444. @param point point
  12445. @example
  12446. ```js
  12447. var a = new cc.Rect(0, 0, 10, 10);
  12448. var b = new cc.Vec2(0, 5);
  12449. a.contains(b);// true
  12450. ```
  12451. */
  12452. contains(point: Vec2): boolean;
  12453. /**
  12454. !#en Returns true if the other rect totally inside this rectangle.
  12455. !#zh 当前矩形是否包含指定矩形。
  12456. @param rect rect
  12457. @example
  12458. ```js
  12459. var a = new cc.Rect(0, 0, 20, 20);
  12460. var b = new cc.Rect(0, 0, 10, 10);
  12461. a.containsRect(b);// true
  12462. ```
  12463. */
  12464. containsRect(rect: Rect): boolean;
  12465. /**
  12466. !#en Returns the smallest rectangle that contains the current rect and the given rect.
  12467. !#zh 返回一个包含当前矩形和指定矩形的最小矩形。
  12468. @param out Stores the result
  12469. @param rectB rectB
  12470. @example
  12471. ```js
  12472. var a = new cc.Rect(0, 10, 20, 20);
  12473. var b = new cc.Rect(0, 10, 10, 10);
  12474. var union = new cc.Rect();
  12475. a.union(union, b); // union {x: 0, y: 10, width: 20, height: 20};
  12476. ```
  12477. */
  12478. union(out: Rect, rectB: Rect): Rect;
  12479. /**
  12480. !#en Apply matrix4 to the rect.
  12481. !#zh 使用 mat4 对矩形进行矩阵转换。
  12482. @param out The output rect
  12483. @param mat The matrix4
  12484. */
  12485. transformMat4(out: Rect, mat: Mat4): void;
  12486. /**
  12487. !#en Output rect informations to string
  12488. !#zh 转换为方便阅读的字符串
  12489. @example
  12490. ```js
  12491. var a = new cc.Rect(0, 0, 10, 10);
  12492. a.toString();// "(0.00, 0.00, 10.00, 10.00)";
  12493. ```
  12494. */
  12495. toString(): string;
  12496. /** !#en The minimum x value, equals to rect.x
  12497. !#zh 矩形 x 轴上的最小值,等价于 rect.x。 */
  12498. xMin: number;
  12499. /** !#en The minimum y value, equals to rect.y
  12500. !#zh 矩形 y 轴上的最小值。 */
  12501. yMin: number;
  12502. /** !#en The maximum x value.
  12503. !#zh 矩形 x 轴上的最大值。 */
  12504. xMax: number;
  12505. /** !#en The maximum y value.
  12506. !#zh 矩形 y 轴上的最大值。 */
  12507. yMax: number;
  12508. /** !#en The position of the center of the rectangle.
  12509. !#zh 矩形的中心点。 */
  12510. center: Vec2;
  12511. /** !#en The X and Y position of the rectangle.
  12512. !#zh 矩形的 x 和 y 坐标。 */
  12513. origin: Vec2;
  12514. /** !#en Width and height of the rectangle.
  12515. !#zh 矩形的大小。 */
  12516. size: Size;
  12517. }
  12518. /** !#en
  12519. cc.Size is the class for size object,<br/>
  12520. please do not use its constructor to create sizes,<br/>
  12521. use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.<br/>
  12522. It will be deprecated soon, please use cc.Vec2 instead.
  12523. !#zh
  12524. cc.Size 是 size 对象的类。<br/>
  12525. 请不要使用它的构造函数创建的 size,<br/>
  12526. 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。<br/>
  12527. 它不久将被取消,请使用cc.Vec2代替。 */
  12528. export class Size {
  12529. /**
  12530. @param width width
  12531. @param height height
  12532. */
  12533. constructor(width: number|Size, height?: number);
  12534. /** !#en return a Size object with width = 0 and height = 0.
  12535. !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */
  12536. static ZERO: Size;
  12537. width: number;
  12538. height: number;
  12539. /**
  12540. !#en TODO
  12541. !#zh 克隆 size 对象。
  12542. @example
  12543. ```js
  12544. var a = new cc.size(10, 10);
  12545. a.clone();// return Size {width: 0, height: 0};
  12546. ```
  12547. */
  12548. clone(): Size;
  12549. /**
  12550. !#en TODO
  12551. !#zh 当前 Size 对象是否等于指定 Size 对象。
  12552. @param other other
  12553. @example
  12554. ```js
  12555. var a = new cc.size(10, 10);
  12556. a.equals(new cc.size(10, 10));// return true;
  12557. ```
  12558. */
  12559. equals(other: Size): boolean;
  12560. /**
  12561. !#en TODO
  12562. !#zh 线性插值。
  12563. @param to to
  12564. @param ratio the interpolation coefficient.
  12565. @param out optional, the receiving vector.
  12566. @example
  12567. ```js
  12568. var a = new cc.size(10, 10);
  12569. var b = new cc.rect(50, 50, 100, 100);
  12570. update (dt) {
  12571. // method 1;
  12572. var c = a.lerp(b, dt * 0.1);
  12573. // method 2;
  12574. a.lerp(b, dt * 0.1, c);
  12575. }
  12576. ```
  12577. */
  12578. lerp(to: Rect, ratio: number, out?: Size): Size;
  12579. /**
  12580. !#en TODO
  12581. !#zh 转换为方便阅读的字符串。
  12582. @example
  12583. ```js
  12584. var a = new cc.size(10, 10);
  12585. a.toString();// return "(10.00, 10.00)";
  12586. ```
  12587. */
  12588. toString(): string;
  12589. }
  12590. /** !#en The base class of all value types.
  12591. !#zh 所有值类型的基类。 */
  12592. export class ValueType {
  12593. /**
  12594. !#en This method returns an exact copy of current value.
  12595. !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。
  12596. */
  12597. clone(): ValueType;
  12598. /**
  12599. !#en Compares this object with the other one.
  12600. !#zh 当前对象是否等于指定对象。
  12601. @param other other
  12602. */
  12603. equals(other: ValueType): boolean;
  12604. /**
  12605. !#en
  12606. Linearly interpolates between this value to to value by ratio which is in the range [0, 1].
  12607. When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to.
  12608. !#zh
  12609. 线性插值。<br/>
  12610. 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。
  12611. @param to the to value
  12612. @param ratio the interpolation coefficient
  12613. */
  12614. lerp(to: ValueType, ratio: number): ValueType;
  12615. /**
  12616. !#en
  12617. Copys all the properties from another given object to this value.
  12618. !#zh
  12619. 从其它对象把所有属性复制到当前对象。
  12620. @param source the source to copy
  12621. */
  12622. set(source: ValueType): void;
  12623. /**
  12624. !#en Convert to a readable string.
  12625. !#zh 转换为方便阅读的字符串。
  12626. */
  12627. toString(): string;
  12628. }
  12629. /** !#en Representation of 2D vectors and points.
  12630. !#zh 表示 2D 向量和坐标 */
  12631. export class Vec2 extends ValueType {
  12632. /**
  12633. !#en Returns the length of this vector.
  12634. !#zh 返回该向量的长度。
  12635. @example
  12636. ```js
  12637. var v = cc.v2(10, 10);
  12638. v.mag(); // return 14.142135623730951;
  12639. ```
  12640. */
  12641. mag(): number;
  12642. /**
  12643. !#en Returns the squared length of this vector.
  12644. !#zh 返回该向量的长度平方。
  12645. @example
  12646. ```js
  12647. var v = cc.v2(10, 10);
  12648. v.magSqr(); // return 200;
  12649. ```
  12650. */
  12651. magSqr(): number;
  12652. /**
  12653. !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead.
  12654. !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。
  12655. @param vector vector
  12656. @example
  12657. ```js
  12658. var v = cc.v2(10, 10);
  12659. v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5};
  12660. ```
  12661. */
  12662. subSelf(vector: Vec2): Vec2;
  12663. /**
  12664. !#en Subtracts one vector from this, and returns the new result.
  12665. !#zh 向量减法,并返回新结果。
  12666. @param vector vector
  12667. @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
  12668. @example
  12669. ```js
  12670. var v = cc.v2(10, 10);
  12671. v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5};
  12672. var v1 = new Vec2;
  12673. v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5};
  12674. ```
  12675. */
  12676. sub(vector: Vec2, out?: Vec2): Vec2;
  12677. /**
  12678. !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead.
  12679. !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。
  12680. @param num num
  12681. @example
  12682. ```js
  12683. var v = cc.v2(10, 10);
  12684. v.mulSelf(5);// return Vec2 {x: 50, y: 50};
  12685. ```
  12686. */
  12687. mulSelf(num: number): Vec2;
  12688. /**
  12689. !#en Multiplies by a number, and returns the new result.
  12690. !#zh 缩放向量,并返回新结果。
  12691. @param num num
  12692. @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
  12693. @example
  12694. ```js
  12695. var v = cc.v2(10, 10);
  12696. v.mul(5); // return Vec2 {x: 50, y: 50};
  12697. var v1 = new Vec2;
  12698. v.mul(5, v1); // return Vec2 {x: 50, y: 50};
  12699. ```
  12700. */
  12701. mul(num: number, out?: Vec2): Vec2;
  12702. /**
  12703. !#en Divides by a number. If you want to save result to another vector, use div() instead.
  12704. !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。
  12705. @param num num
  12706. @example
  12707. ```js
  12708. var v = cc.v2(10, 10);
  12709. v.divSelf(5); // return Vec2 {x: 2, y: 2};
  12710. ```
  12711. */
  12712. divSelf(num: number): Vec2;
  12713. /**
  12714. !#en Divides by a number, and returns the new result.
  12715. !#zh 向量除法,并返回新的结果。
  12716. @param num num
  12717. @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
  12718. @example
  12719. ```js
  12720. var v = cc.v2(10, 10);
  12721. v.div(5); // return Vec2 {x: 2, y: 2};
  12722. var v1 = new Vec2;
  12723. v.div(5, v1); // return Vec2 {x: 2, y: 2};
  12724. ```
  12725. */
  12726. div(num: number, out?: Vec2): Vec2;
  12727. /**
  12728. !#en Multiplies two vectors.
  12729. !#zh 分量相乘。
  12730. @param vector vector
  12731. @example
  12732. ```js
  12733. var v = cc.v2(10, 10);
  12734. v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50};
  12735. ```
  12736. */
  12737. scaleSelf(vector: Vec2): Vec2;
  12738. /**
  12739. !#en Multiplies two vectors, and returns the new result.
  12740. !#zh 分量相乘,并返回新的结果。
  12741. @param vector vector
  12742. @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
  12743. @example
  12744. ```js
  12745. var v = cc.v2(10, 10);
  12746. v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50};
  12747. var v1 = new Vec2;
  12748. v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50};
  12749. ```
  12750. */
  12751. scale(vector: Vec2, out?: Vec2): Vec2;
  12752. /**
  12753. !#en Negates the components. If you want to save result to another vector, use neg() instead.
  12754. !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。
  12755. @example
  12756. ```js
  12757. var v = cc.v2(10, 10);
  12758. v.negSelf(); // return Vec2 {x: -10, y: -10};
  12759. ```
  12760. */
  12761. negSelf(): Vec2;
  12762. /**
  12763. !#en Negates the components, and returns the new result.
  12764. !#zh 返回取反后的新向量。
  12765. @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
  12766. @example
  12767. ```js
  12768. var v = cc.v2(10, 10);
  12769. var v1 = new Vec2;
  12770. v.neg(v1); // return Vec2 {x: -10, y: -10};
  12771. ```
  12772. */
  12773. neg(out?: Vec2): Vec2;
  12774. /** !#en return a Vec2 object with x = 1 and y = 1.
  12775. !#zh 新 Vec2 对象。 */
  12776. static ONE: Vec2;
  12777. /** !#en return a Vec2 object with x = 0 and y = 0.
  12778. !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */
  12779. static ZERO: Vec2;
  12780. /** !#en return a readonly Vec2 object with x = 0 and y = 0.
  12781. !#zh 返回一个 x = 0 和 y = 0 的 Vec2 只读对象。 */
  12782. static ZERO_R: Vec2;
  12783. /** !#en return a Vec2 object with x = 0 and y = 1.
  12784. !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */
  12785. static UP: Vec2;
  12786. /** !#en return a readonly Vec2 object with x = 0 and y = 1.
  12787. !#zh 返回 x = 0 和 y = 1 的 Vec2 只读对象。 */
  12788. static UP_R: Vec2;
  12789. /** !#en return a readonly Vec2 object with x = 1 and y = 0.
  12790. !#zh 返回 x = 1 和 y = 0 的 Vec2 只读对象。 */
  12791. static RIGHT: Vec2;
  12792. /** !#en return a Vec2 object with x = 1 and y = 0.
  12793. !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */
  12794. static RIGHT_R: Vec2;
  12795. /**
  12796. !#zh 获得指定向量的拷贝
  12797. */
  12798. static clone <Out extends IVec2Like> (a: Out): Vec2;
  12799. /**
  12800. !#zh 复制指定向量的值
  12801. */
  12802. static copy <Out extends IVec2Like> (out: Out, a: Out): Out;
  12803. /**
  12804. !#zh 设置向量值
  12805. */
  12806. static set <Out extends IVec2Like> (out: Out, x: number, y: number): Out;
  12807. /**
  12808. !#zh 逐元素向量加法
  12809. */
  12810. static add <Out extends IVec2Like> (out: Out, a: Out, b: Out): Out;
  12811. /**
  12812. !#zh 逐元素向量减法
  12813. */
  12814. static subtract <Out extends IVec2Like> (out: Out, a: Out, b: Out): Out;
  12815. /**
  12816. !#zh 逐元素向量乘法
  12817. */
  12818. static multiply <Out extends IVec2Like> (out: Out, a: Out, b: Out): Out;
  12819. /**
  12820. !#zh 逐元素向量除法
  12821. */
  12822. static divide <Out extends IVec2Like> (out: Out, a: Out, b: Out): Out;
  12823. /**
  12824. !#zh 逐元素向量向上取整
  12825. */
  12826. static ceil <Out extends IVec2Like> (out: Out, a: Out): Out;
  12827. /**
  12828. !#zh 逐元素向量向下取整
  12829. */
  12830. static floor <Out extends IVec2Like> (out: Out, a: Out): Out;
  12831. /**
  12832. !#zh 逐元素向量最小值
  12833. */
  12834. static min <Out extends IVec2Like> (out: Out, a: Out, b: Out): Out;
  12835. /**
  12836. !#zh 逐元素向量最大值
  12837. */
  12838. static max <Out extends IVec2Like> (out: Out, a: Out, b: Out): Out;
  12839. /**
  12840. !#zh 逐元素向量四舍五入取整
  12841. */
  12842. static round <Out extends IVec2Like> (out: Out, a: Out): Out;
  12843. /**
  12844. !#zh 向量标量乘法
  12845. */
  12846. static multiplyScalar <Out extends IVec2Like> (out: Out, a: Out, b: number): Out;
  12847. /**
  12848. !#zh 逐元素向量乘加: A + B * scale
  12849. */
  12850. static scaleAndAdd <Out extends IVec2Like> (out: Out, a: Out, b: Out, scale: number): Out;
  12851. /**
  12852. !#zh 求两向量的欧氏距离
  12853. */
  12854. static distance <Out extends IVec2Like> (a: Out, b: Out): number;
  12855. /**
  12856. !#zh 求两向量的欧氏距离平方
  12857. */
  12858. static squaredDistance <Out extends IVec2Like> (a: Out, b: Out): number;
  12859. /**
  12860. !#zh 求向量长度
  12861. */
  12862. static len <Out extends IVec2Like> (a: Out): number;
  12863. /**
  12864. !#zh 求向量长度平方
  12865. */
  12866. static lengthSqr <Out extends IVec2Like> (a: Out): number;
  12867. /**
  12868. !#zh 逐元素向量取负
  12869. */
  12870. static negate <Out extends IVec2Like> (out: Out, a: Out): Out;
  12871. /**
  12872. !#zh 逐元素向量取倒数,接近 0 时返回 Infinity
  12873. */
  12874. static inverse <Out extends IVec2Like> (out: Out, a: Out): Out;
  12875. /**
  12876. !#zh 逐元素向量取倒数,接近 0 时返回 0
  12877. */
  12878. static inverseSafe <Out extends IVec2Like> (out: Out, a: Out): Out;
  12879. /**
  12880. !#zh 归一化向量
  12881. */
  12882. static normalize <Out extends IVec2Like, Vec2Like extends IVec2Like> (out: Out, a: Vec2Like): Out;
  12883. /**
  12884. !#zh 向量点积(数量积)
  12885. */
  12886. static dot <Out extends IVec2Like> (a: Out, b: Out): number;
  12887. /**
  12888. !#zh 向量叉积(向量积),注意二维向量的叉积为与 Z 轴平行的三维向量
  12889. */
  12890. static cross <Out extends IVec2Like> (out: Vec2, a: Out, b: Out): Vec2;
  12891. /**
  12892. !#zh 逐元素向量线性插值: A + t * (B - A)
  12893. */
  12894. static lerp <Out extends IVec2Like> (out: Out, a: Out, b: Out, t: number): Out;
  12895. /**
  12896. !#zh 生成一个在单位圆上均匀分布的随机向量
  12897. */
  12898. static random <Out extends IVec2Like> (out: Out, scale?: number): Out;
  12899. /**
  12900. !#zh 向量与三维矩阵乘法,默认向量第三位为 1。
  12901. */
  12902. static transformMat3 <Out extends IVec2Like, MatLike extends IMat3Like> (out: Out, a: Out, mat: IMat3Like): Out;
  12903. /**
  12904. !#zh 向量与四维矩阵乘法,默认向量第三位为 0,第四位为 1。
  12905. */
  12906. static transformMat4 <Out extends IVec2Like, MatLike extends IMat4Like> (out: Out, a: Out, mat: MatLike): Out;
  12907. /**
  12908. !#zh 向量等价判断
  12909. */
  12910. static strictEquals <Out extends IVec2Like> (a: Out, b: Out): boolean;
  12911. /**
  12912. !#zh 排除浮点数误差的向量近似等价判断
  12913. */
  12914. static equals <Out extends IVec2Like> (a: Out, b: Out, epsilon?: number): boolean;
  12915. /**
  12916. !#zh 排除浮点数误差的向量近似等价判断
  12917. */
  12918. static angle <Out extends IVec2Like> (a: Out, b: Out): number;
  12919. /**
  12920. !#zh 向量转数组
  12921. */
  12922. static toArray <Out extends IWritableArrayLike<number>> (out: Out, v: IVec2Like, ofs?: number): Out;
  12923. /**
  12924. !#zh 数组转向量
  12925. */
  12926. static fromArray <Out extends IVec2Like> (out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out;
  12927. x: number;
  12928. y: number;
  12929. /**
  12930. !#en
  12931. Constructor
  12932. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  12933. !#zh
  12934. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  12935. @param x x
  12936. @param y y
  12937. */
  12938. constructor(x?: number, y?: number);
  12939. /**
  12940. !#en clone a Vec2 object
  12941. !#zh 克隆一个 Vec2 对象
  12942. */
  12943. clone(): Vec2;
  12944. /**
  12945. !#en Sets vector with another's value
  12946. !#zh 设置向量值。
  12947. @param newValue !#en new value to set. !#zh 要设置的新值
  12948. */
  12949. set(newValue: Vec2): Vec2;
  12950. /**
  12951. !#en Check whether two vector equal
  12952. !#zh 当前的向量是否与指定的向量相等。
  12953. @param other other
  12954. */
  12955. equals(other: Vec2): boolean;
  12956. /**
  12957. !#en Check whether two vector equal with some degree of variance.
  12958. !#zh
  12959. 近似判断两个点是否相等。<br/>
  12960. 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。
  12961. @param other other
  12962. @param variance variance
  12963. */
  12964. fuzzyEquals(other: Vec2, variance: number): boolean;
  12965. /**
  12966. !#en Transform to string with vector informations
  12967. !#zh 转换为方便阅读的字符串。
  12968. */
  12969. toString(): string;
  12970. /**
  12971. !#en Calculate linear interpolation result between this vector and another one with given ratio
  12972. !#zh 线性插值。
  12973. @param to to
  12974. @param ratio the interpolation coefficient
  12975. @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
  12976. */
  12977. lerp(to: Vec2, ratio: number, out?: Vec2): Vec2;
  12978. /**
  12979. !#en Clamp the vector between from float and to float.
  12980. !#zh
  12981. 返回指定限制区域后的向量。<br/>
  12982. 向量大于 max_inclusive 则返回 max_inclusive。<br/>
  12983. 向量小于 min_inclusive 则返回 min_inclusive。<br/>
  12984. 否则返回自身。
  12985. @param min_inclusive min_inclusive
  12986. @param max_inclusive max_inclusive
  12987. @example
  12988. ```js
  12989. var min_inclusive = cc.v2(0, 0);
  12990. var max_inclusive = cc.v2(20, 20);
  12991. var v1 = cc.v2(20, 20).clampf(min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20};
  12992. var v2 = cc.v2(0, 0).clampf(min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0};
  12993. var v3 = cc.v2(10, 10).clampf(min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10};
  12994. ```
  12995. */
  12996. clampf(min_inclusive: Vec2, max_inclusive: Vec2): Vec2;
  12997. /**
  12998. !#en Adds this vector.
  12999. !#zh 向量加法。
  13000. @param vector vector
  13001. @param out out
  13002. @example
  13003. ```js
  13004. var v = cc.v2(10, 10);
  13005. v.add(cc.v2(5, 5));// return Vec2 {x: 15, y: 15};
  13006. ```
  13007. */
  13008. add(vector: Vec2, out?: Vec2): Vec2;
  13009. /**
  13010. !#en Adds this vector. If you want to save result to another vector, use add() instead.
  13011. !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。
  13012. @param vector vector
  13013. */
  13014. addSelf(vector: Vec2): Vec2;
  13015. /**
  13016. !#en Subtracts one vector from this.
  13017. !#zh 向量减法。
  13018. @param vector vector
  13019. @example
  13020. ```js
  13021. var v = cc.v2(10, 10);
  13022. v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5};
  13023. ```
  13024. */
  13025. subtract(vector: Vec2): Vec2;
  13026. /**
  13027. !#en Multiplies this by a number.
  13028. !#zh 缩放当前向量。
  13029. @param num num
  13030. @example
  13031. ```js
  13032. var v = cc.v2(10, 10);
  13033. v.multiply(5);// return Vec2 {x: 50, y: 50};
  13034. ```
  13035. */
  13036. multiplyScalar(num: number): Vec2;
  13037. /**
  13038. !#en Multiplies two vectors.
  13039. !#zh 分量相乘。
  13040. @param vector vector
  13041. @example
  13042. ```js
  13043. var v = cc.v2(10, 10);
  13044. v.multiply(cc.v2(5, 5));// return Vec2 {x: 50, y: 50};
  13045. ```
  13046. */
  13047. multiply(vector: Vec2): Vec2;
  13048. /**
  13049. !#en Divides by a number.
  13050. !#zh 向量除法。
  13051. @param num num
  13052. @example
  13053. ```js
  13054. var v = cc.v2(10, 10);
  13055. v.divide(5); // return Vec2 {x: 2, y: 2};
  13056. ```
  13057. */
  13058. divide(num: number): Vec2;
  13059. /**
  13060. !#en Negates the components.
  13061. !#zh 向量取反。
  13062. @example
  13063. ```js
  13064. var v = cc.v2(10, 10);
  13065. v.negate(); // return Vec2 {x: -10, y: -10};
  13066. ```
  13067. */
  13068. negate(): Vec2;
  13069. /**
  13070. !#en Dot product
  13071. !#zh 当前向量与指定向量进行点乘。
  13072. @param vector vector
  13073. @example
  13074. ```js
  13075. var v = cc.v2(10, 10);
  13076. v.dot(cc.v2(5, 5)); // return 100;
  13077. ```
  13078. */
  13079. dot(vector?: Vec2): number;
  13080. /**
  13081. !#en Cross product
  13082. !#zh 当前向量与指定向量进行叉乘。
  13083. @param vector vector
  13084. @example
  13085. ```js
  13086. var v = cc.v2(10, 10);
  13087. v.cross(cc.v2(5, 5)); // return 0;
  13088. ```
  13089. */
  13090. cross(vector?: Vec2): number;
  13091. /**
  13092. !#en Returns the length of this vector.
  13093. !#zh 返回该向量的长度。
  13094. @example
  13095. ```js
  13096. var v = cc.v2(10, 10);
  13097. v.len(); // return 14.142135623730951;
  13098. ```
  13099. */
  13100. len(): number;
  13101. /**
  13102. !#en Returns the squared length of this vector.
  13103. !#zh 返回该向量的长度平方。
  13104. @example
  13105. ```js
  13106. var v = cc.v2(10, 10);
  13107. v.lengthSqr(); // return 200;
  13108. ```
  13109. */
  13110. lengthSqr(): number;
  13111. /**
  13112. !#en Make the length of this vector to 1.
  13113. !#zh 向量归一化,让这个向量的长度为 1。
  13114. @example
  13115. ```js
  13116. var v = cc.v2(10, 10);
  13117. v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
  13118. ```
  13119. */
  13120. normalizeSelf(): Vec2;
  13121. /**
  13122. !#en
  13123. Returns this vector with a magnitude of 1.<br/>
  13124. <br/>
  13125. 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.
  13126. !#zh
  13127. 返回归一化后的向量。<br/>
  13128. <br/>
  13129. 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。
  13130. @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
  13131. */
  13132. normalize(out?: Vec2): Vec2;
  13133. /**
  13134. !#en Get angle in radian between this and vector.
  13135. !#zh 夹角的弧度。
  13136. @param vector vector
  13137. */
  13138. angle(vector: Vec2): number;
  13139. /**
  13140. !#en Get angle in radian between this and vector with direction.
  13141. !#zh 带方向的夹角的弧度。
  13142. @param vector vector
  13143. */
  13144. signAngle(vector: Vec2): number;
  13145. /**
  13146. !#en rotate
  13147. !#zh 返回旋转给定弧度后的新向量。
  13148. @param radians radians
  13149. @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
  13150. */
  13151. rotate(radians: number, out?: Vec2): Vec2;
  13152. /**
  13153. !#en rotate self
  13154. !#zh 按指定弧度旋转向量。
  13155. @param radians radians
  13156. */
  13157. rotateSelf(radians: number): Vec2;
  13158. /**
  13159. !#en Calculates the projection of the current vector over the given vector.
  13160. !#zh 返回当前向量在指定 vector 向量上的投影向量。
  13161. @param vector vector
  13162. @example
  13163. ```js
  13164. var v1 = cc.v2(20, 20);
  13165. var v2 = cc.v2(5, 5);
  13166. v1.project(v2); // Vec2 {x: 20, y: 20};
  13167. ```
  13168. */
  13169. project(vector: Vec2): Vec2;
  13170. /**
  13171. Transforms the vec2 with a mat4. 3rd vector component is implicitly '0', 4th vector component is implicitly '1'
  13172. @param m matrix to transform with
  13173. @param out the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
  13174. */
  13175. transformMat4(m: Mat4, out?: Vec2): Vec2;
  13176. /**
  13177. Returns the maximum value in x, y.
  13178. */
  13179. maxAxis(): number;
  13180. }
  13181. /** !#en Representation of 3D vectors and points.
  13182. !#zh 表示 3D 向量和坐标 */
  13183. export class Vec3 extends ValueType {
  13184. /**
  13185. !#en Returns the length of this vector.
  13186. !#zh 返回该向量的长度。
  13187. @example
  13188. ```js
  13189. var v = cc.v3(10, 10, 10);
  13190. v.mag(); // return 17.320508075688775;
  13191. ```
  13192. */
  13193. mag(): number;
  13194. /**
  13195. !#en Returns the squared length of this vector.
  13196. !#zh 返回该向量的长度平方。
  13197. */
  13198. magSqr(): number;
  13199. /**
  13200. !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead.
  13201. !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。
  13202. @param vector vector
  13203. */
  13204. subSelf(vector: Vec3): Vec3;
  13205. /**
  13206. !#en Subtracts one vector from this, and returns the new result.
  13207. !#zh 向量减法,并返回新结果。
  13208. @param vector vector
  13209. @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
  13210. */
  13211. sub(vector: Vec3, out?: Vec3): Vec3;
  13212. /**
  13213. !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead.
  13214. !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。
  13215. @param num num
  13216. */
  13217. mulSelf(num: number): Vec3;
  13218. /**
  13219. !#en Multiplies by a number, and returns the new result.
  13220. !#zh 缩放向量,并返回新结果。
  13221. @param num num
  13222. @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
  13223. */
  13224. mul(num: number, out?: Vec3): Vec3;
  13225. /**
  13226. !#en Divides by a number. If you want to save result to another vector, use div() instead.
  13227. !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。
  13228. @param num num
  13229. */
  13230. divSelf(num: number): Vec3;
  13231. /**
  13232. !#en Divides by a number, and returns the new result.
  13233. !#zh 向量除法,并返回新的结果。
  13234. @param num num
  13235. @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
  13236. */
  13237. div(num: number, out?: Vec3): Vec3;
  13238. /**
  13239. !#en Multiplies two vectors.
  13240. !#zh 分量相乘。
  13241. @param vector vector
  13242. */
  13243. scaleSelf(vector: Vec3): Vec3;
  13244. /**
  13245. !#en Multiplies two vectors, and returns the new result.
  13246. !#zh 分量相乘,并返回新的结果。
  13247. @param vector vector
  13248. @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
  13249. */
  13250. scale(vector: Vec3, out?: Vec3): Vec3;
  13251. /**
  13252. !#en Negates the components. If you want to save result to another vector, use neg() instead.
  13253. !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。
  13254. */
  13255. negSelf(): Vec3;
  13256. /**
  13257. !#en Negates the components, and returns the new result.
  13258. !#zh 返回取反后的新向量。
  13259. @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
  13260. */
  13261. neg(out?: Vec3): Vec3;
  13262. /** !#en return a Vec3 object with x = 1, y = 1, z = 1.
  13263. !#zh 新 Vec3 对象。 */
  13264. static ONE: Vec3;
  13265. /** !#en return a Vec3 object with x = 0, y = 0, z = 0.
  13266. !#zh 返回 x = 0,y = 0,z = 0 的 Vec3 对象。 */
  13267. static ZERO: Vec3;
  13268. /** !#en return a Vec3 object with x = 0, y = 1, z = 0.
  13269. !#zh 返回 x = 0, y = 1, z = 0 的 Vec3 对象。 */
  13270. static UP: Vec3;
  13271. /** !#en return a Vec3 object with x = 1, y = 0, z = 0.
  13272. !#zh 返回 x = 1,y = 0,z = 0 的 Vec3 对象。 */
  13273. static RIGHT: Vec3;
  13274. /** !#en return a Vec3 object with x = 0, y = 0, z = 1.
  13275. !#zh 返回 x = 0,y = 0,z = 1 的 Vec3 对象。 */
  13276. static FORWARD: Vec3;
  13277. /**
  13278. !#zh 将目标赋值为零向量
  13279. !#en The target of an assignment zero vector
  13280. */
  13281. static zero<Out extends IVec3Like> (out: Out): Out;
  13282. /**
  13283. !#zh 获得指定向量的拷贝
  13284. !#en Obtaining copy vectors designated
  13285. */
  13286. static clone<Out extends IVec3Like> (a: Out): Vec3;
  13287. /**
  13288. !#zh 复制目标向量
  13289. !#en Copy the target vector
  13290. */
  13291. static copy<Out extends IVec3Like, Vec3Like extends IVec3Like> (out: Out, a: Vec3Like): Out;
  13292. /**
  13293. !#zh 设置向量值
  13294. !#en Set to value
  13295. */
  13296. static set<Out extends IVec3Like> (out: Out, x: number, y: number, z: number): Out;
  13297. /**
  13298. !#zh 逐元素向量加法
  13299. !#en Element-wise vector addition
  13300. */
  13301. static add<Out extends IVec3Like> (out: Out, a: Out, b: Out): Out;
  13302. /**
  13303. !#zh 逐元素向量减法
  13304. !#en Element-wise vector subtraction
  13305. */
  13306. static subtract<Out extends IVec3Like> (out: Out, a: Out, b: Out): Out;
  13307. /**
  13308. !#zh 逐元素向量乘法 (分量积)
  13309. !#en Element-wise vector multiplication (product component)
  13310. */
  13311. static multiply<Out extends IVec3Like, Vec3Like_1 extends IVec3Like, Vec3Like_2 extends IVec3Like> (out: Out, a: Vec3Like_1, b: Vec3Like_2): Out;
  13312. /**
  13313. !#zh 逐元素向量除法
  13314. !#en Element-wise vector division
  13315. */
  13316. static divide<Out extends IVec3Like> (out: Out, a: Out, b: Out): Out;
  13317. /**
  13318. !#zh 逐元素向量向上取整
  13319. !#en Rounding up by elements of the vector
  13320. */
  13321. static ceil<Out extends IVec3Like> (out: Out, a: Out): Out;
  13322. /**
  13323. !#zh 逐元素向量向下取整
  13324. !#en Element vector by rounding down
  13325. */
  13326. static floor<Out extends IVec3Like> (out: Out, a: Out): Out;
  13327. /**
  13328. !#zh 逐元素向量最小值
  13329. !#en The minimum by-element vector
  13330. */
  13331. static min<Out extends IVec3Like> (out: Out, a: Out, b: Out): Out;
  13332. /**
  13333. !#zh 逐元素向量最大值
  13334. !#en The maximum value of the element-wise vector
  13335. */
  13336. static max<Out extends IVec3Like> (out: Out, a: Out, b: Out): Out;
  13337. /**
  13338. !#zh 逐元素向量四舍五入取整
  13339. !#en Element-wise vector of rounding to whole
  13340. */
  13341. static round<Out extends IVec3Like> (out: Out, a: Out): Out;
  13342. /**
  13343. !#zh 向量标量乘法
  13344. !#en Vector scalar multiplication
  13345. */
  13346. static multiplyScalar<Out extends IVec3Like, Vec3Like extends IVec3Like> (out: Out, a: Vec3Like, b: number): Out;
  13347. /**
  13348. !#zh 逐元素向量乘加: A + B * scale
  13349. !#en Element-wise vector multiply add: A + B * scale
  13350. */
  13351. static scaleAndAdd<Out extends IVec3Like> (out: Out, a: Out, b: Out, scale: number): Out;
  13352. /**
  13353. !#zh 求两向量的欧氏距离
  13354. !#en Seeking two vectors Euclidean distance
  13355. */
  13356. static distance<Out extends IVec3Like> (a: Out, b: Out): number;
  13357. /**
  13358. !#zh 求两向量的欧氏距离平方
  13359. !#en Euclidean distance squared seeking two vectors
  13360. */
  13361. static squaredDistance<Out extends IVec3Like> (a: Out, b: Out): number;
  13362. /**
  13363. !#zh 求向量长度
  13364. !#en Seeking vector length
  13365. */
  13366. static len<Out extends IVec3Like> (a: Out): number;
  13367. /**
  13368. !#zh 求向量长度平方
  13369. !#en Seeking squared vector length
  13370. */
  13371. static lengthSqr<Out extends IVec3Like> (a: Out): number;
  13372. /**
  13373. !#zh 逐元素向量取负
  13374. !#en By taking the negative elements of the vector
  13375. */
  13376. static negate<Out extends IVec3Like> (out: Out, a: Out): Out;
  13377. /**
  13378. !#zh 逐元素向量取倒数,接近 0 时返回 Infinity
  13379. !#en Element vector by taking the inverse, return near 0 Infinity
  13380. */
  13381. static inverse<Out extends IVec3Like> (out: Out, a: Out): Out;
  13382. /**
  13383. !#zh 逐元素向量取倒数,接近 0 时返回 0
  13384. !#en Element vector by taking the inverse, return near 0 0
  13385. */
  13386. static inverseSafe<Out extends IVec3Like> (out: Out, a: Out): Out;
  13387. /**
  13388. !#zh 归一化向量
  13389. !#en Normalized vector
  13390. */
  13391. static normalize<Out extends IVec3Like, Vec3Like extends IVec3Like> (out: Out, a: Vec3Like): Out;
  13392. /**
  13393. !#zh 向量点积(数量积)
  13394. !#en Vector dot product (scalar product)
  13395. */
  13396. static dot<Out extends IVec3Like> (a: Out, b: Out): number;
  13397. /**
  13398. !#zh 向量叉积(向量积)
  13399. !#en Vector cross product (vector product)
  13400. */
  13401. static cross<Out extends IVec3Like, Vec3Like_1 extends IVec3Like, Vec3Like_2 extends IVec3Like> (out: Out, a: Vec3Like_1, b: Vec3Like_2): Out;
  13402. /**
  13403. !#zh 逐元素向量线性插值: A + t * (B - A)
  13404. !#en Vector element by element linear interpolation: A + t * (B - A)
  13405. */
  13406. static lerp<Out extends IVec3Like> (out: Out, a: Out, b: Out, t: number): Out;
  13407. /**
  13408. !#zh 生成一个在单位球体上均匀分布的随机向量
  13409. !#en Generates a uniformly distributed random vectors on the unit sphere
  13410. @param scale 生成的向量长度
  13411. */
  13412. static random<Out extends IVec3Like> (out: Out, scale?: number): Out;
  13413. /**
  13414. !#zh 向量与四维矩阵乘法,默认向量第四位为 1。
  13415. !#en Four-dimensional vector and matrix multiplication, the default vectors fourth one.
  13416. */
  13417. static transformMat4<Out extends IVec3Like, Vec3Like extends IVec3Like, MatLike extends IMat4Like> (out: Out, a: Vec3Like, mat: MatLike): Out;
  13418. /**
  13419. !#zh 向量与四维矩阵乘法,默认向量第四位为 0。
  13420. !#en Four-dimensional vector and matrix multiplication, vector fourth default is 0.
  13421. */
  13422. static transformMat4Normal<Out extends IVec3Like, MatLike extends IMat4Like> (out: Out, a: Out, mat: MatLike): Out;
  13423. /**
  13424. !#zh 向量与三维矩阵乘法
  13425. !#en Dimensional vector matrix multiplication
  13426. */
  13427. static transformMat3<Out extends IVec3Like, MatLike extends IMat3Like> (out: Out, a: Out, mat: MatLike): Out;
  13428. /**
  13429. !#zh 向量仿射变换
  13430. !#en Affine transformation vector
  13431. */
  13432. static transformAffine<Out extends IVec3Like, VecLike extends IVec3Like, MatLike extends IMat4Like>(out: Out, v: VecLike, mat: MatLike): Out;
  13433. /**
  13434. !#zh 向量四元数乘法
  13435. !#en Vector quaternion multiplication
  13436. */
  13437. static transformQuat<Out extends IVec3Like, VecLike extends IVec3Like, QuatLike extends IQuatLike> (out: Out, a: VecLike, q: QuatLike): Out;
  13438. /**
  13439. !#zh 以缩放 -> 旋转 -> 平移顺序变换向量
  13440. !#en To scale -> rotation -> transformation vector sequence translation
  13441. */
  13442. static transformRTS<Out extends IVec3Like, VecLike extends IVec3Like, QuatLike extends IQuatLike>(out: Out, a: VecLike, r: QuatLike, t: VecLike, s: VecLike): Out;
  13443. /**
  13444. !#zh 以平移 -> 旋转 -> 缩放顺序逆变换向量
  13445. !#en Translational -> rotation -> Zoom inverse transformation vector sequence
  13446. */
  13447. static transformInverseRTS<Out extends IVec3Like, VecLike extends IVec3Like, QuatLike extends IQuatLike>(out: Out, a: VecLike, r: QuatLike, t: VecLike, s: VecLike): Out;
  13448. /**
  13449. !#zh 绕 X 轴旋转向量指定弧度
  13450. !#en Rotation vector specified angle about the X axis
  13451. @param v 待旋转向量
  13452. @param o 旋转中心
  13453. @param a 旋转弧度
  13454. */
  13455. static rotateX<Out extends IVec3Like> (out: Out, v: Out, o: Out, a: number): Out;
  13456. /**
  13457. !#zh 绕 Y 轴旋转向量指定弧度
  13458. !#en Rotation vector specified angle around the Y axis
  13459. @param v 待旋转向量
  13460. @param o 旋转中心
  13461. @param a 旋转弧度
  13462. */
  13463. static rotateY<Out extends IVec3Like> (out: Out, v: Out, o: Out, a: number): Out;
  13464. /**
  13465. !#zh 绕 Z 轴旋转向量指定弧度
  13466. !#en Around the Z axis specified angle vector
  13467. @param v 待旋转向量
  13468. @param o 旋转中心
  13469. @param a 旋转弧度
  13470. */
  13471. static rotateZ<Out extends IVec3Like> (out: Out, v: Out, o: Out, a: number): Out;
  13472. /**
  13473. !#zh 向量等价判断
  13474. !#en Equivalent vectors Analyzing
  13475. */
  13476. static strictEquals<Out extends IVec3Like> (a: Out, b: Out): boolean;
  13477. /**
  13478. !#zh 排除浮点数误差的向量近似等价判断
  13479. !#en Negative error vector floating point approximately equivalent Analyzing
  13480. */
  13481. static equals<Out extends IVec3Like> (a: Out, b: Out, epsilon?: number): boolean;
  13482. /**
  13483. !#zh 求两向量夹角弧度
  13484. !#en Radian angle between two vectors seek
  13485. */
  13486. static angle<Out extends IVec3Like> (a: Out, b: Out): number;
  13487. /**
  13488. !#zh 计算向量在指定平面上的投影
  13489. !#en Calculating a projection vector in the specified plane
  13490. @param a 待投影向量
  13491. @param n 指定平面的法线
  13492. */
  13493. static projectOnPlane<Out extends IVec3Like> (out: Out, a: Out, n: Out): Out;
  13494. /**
  13495. !#zh 计算向量在指定向量上的投影
  13496. !#en Projection vector calculated in the vector designated
  13497. @param a 待投影向量
  13498. @param n 目标向量
  13499. */
  13500. static project<Out extends IVec3Like> (out: Out, a: Out, b: Out): Out;
  13501. /**
  13502. !#zh 向量转数组
  13503. !#en Vector transfer array
  13504. @param ofs 数组起始偏移量
  13505. */
  13506. static toArray <Out extends IWritableArrayLike<number>> (out: Out, v: IVec3Like, ofs?: number): Out;
  13507. /**
  13508. !#zh 数组转向量
  13509. !#en Array steering amount
  13510. @param ofs 数组起始偏移量
  13511. */
  13512. static fromArray <Out extends IVec3Like> (out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out;
  13513. x: number;
  13514. y: number;
  13515. z: number;
  13516. /**
  13517. !#en
  13518. Constructor
  13519. see {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}}
  13520. !#zh
  13521. 构造函数,可查看 {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}}
  13522. @param x x
  13523. @param y y
  13524. @param z z
  13525. */
  13526. constructor(x?: Vec3|number, y?: number, z?: number);
  13527. /**
  13528. !#en clone a Vec3 value
  13529. !#zh 克隆一个 Vec3 值
  13530. */
  13531. clone(): Vec3;
  13532. /**
  13533. !#en Set the current vector value with the given vector.
  13534. !#zh 用另一个向量设置当前的向量对象值。
  13535. @param newValue !#en new value to set. !#zh 要设置的新值
  13536. */
  13537. set(newValue: Vec3): Vec3;
  13538. /**
  13539. !#en Check whether the vector equals another one
  13540. !#zh 当前的向量是否与指定的向量相等。
  13541. @param other other
  13542. */
  13543. equals(other: Vec3): boolean;
  13544. /**
  13545. !#en Check whether two vector equal with some degree of variance.
  13546. !#zh
  13547. 近似判断两个点是否相等。<br/>
  13548. 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。
  13549. @param other other
  13550. @param variance variance
  13551. */
  13552. fuzzyEquals(other: Vec3, variance: number): boolean;
  13553. /**
  13554. !#en Transform to string with vector informations
  13555. !#zh 转换为方便阅读的字符串。
  13556. */
  13557. toString(): string;
  13558. /**
  13559. !#en Calculate linear interpolation result between this vector and another one with given ratio
  13560. !#zh 线性插值。
  13561. @param to to
  13562. @param ratio the interpolation coefficient
  13563. @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
  13564. */
  13565. lerp(to: Vec3, ratio: number, out?: Vec3): Vec3;
  13566. /**
  13567. !#en Clamp the vector between from float and to float.
  13568. !#zh
  13569. 返回指定限制区域后的向量。<br/>
  13570. 向量大于 max_inclusive 则返回 max_inclusive。<br/>
  13571. 向量小于 min_inclusive 则返回 min_inclusive。<br/>
  13572. 否则返回自身。
  13573. @param min_inclusive min_inclusive
  13574. @param max_inclusive max_inclusive
  13575. */
  13576. clampf(min_inclusive: Vec3, max_inclusive: Vec3): Vec3;
  13577. /**
  13578. !#en Adds this vector. If you want to save result to another vector, use add() instead.
  13579. !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。
  13580. @param vector vector
  13581. */
  13582. addSelf(vector: Vec3): Vec3;
  13583. /**
  13584. !#en Adds two vectors, and returns the new result.
  13585. !#zh 向量加法,并返回新结果。
  13586. @param vector vector
  13587. @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
  13588. */
  13589. add(vector: Vec3, out?: Vec3): Vec3;
  13590. /**
  13591. !#en Subtracts one vector from this.
  13592. !#zh 向量减法。
  13593. @param vector vector
  13594. */
  13595. subtract(vector: Vec3): Vec3;
  13596. /**
  13597. !#en Multiplies this by a number.
  13598. !#zh 缩放当前向量。
  13599. @param num num
  13600. */
  13601. multiplyScalar(num: number): Vec3;
  13602. /**
  13603. !#en Multiplies two vectors.
  13604. !#zh 分量相乘。
  13605. @param vector vector
  13606. */
  13607. multiply(vector: Vec3): Vec3;
  13608. /**
  13609. !#en Divides by a number.
  13610. !#zh 向量除法。
  13611. @param num num
  13612. */
  13613. divide(num: number): Vec3;
  13614. /**
  13615. !#en Negates the components.
  13616. !#zh 向量取反。
  13617. */
  13618. negate(): Vec3;
  13619. /**
  13620. !#en Dot product
  13621. !#zh 当前向量与指定向量进行点乘。
  13622. @param vector vector
  13623. */
  13624. dot(vector?: Vec3): number;
  13625. /**
  13626. !#en Cross product
  13627. !#zh 当前向量与指定向量进行叉乘。
  13628. @param vector vector
  13629. @param out out
  13630. */
  13631. cross(vector: Vec3, out?: Vec3): Vec3;
  13632. /**
  13633. !#en Returns the length of this vector.
  13634. !#zh 返回该向量的长度。
  13635. @example
  13636. ```js
  13637. var v = cc.v3(10, 10, 10);
  13638. v.len(); // return 17.320508075688775;
  13639. ```
  13640. */
  13641. len(): number;
  13642. /**
  13643. !#en Returns the squared length of this vector.
  13644. !#zh 返回该向量的长度平方。
  13645. */
  13646. lengthSqr(): number;
  13647. /**
  13648. !#en Make the length of this vector to 1.
  13649. !#zh 向量归一化,让这个向量的长度为 1。
  13650. */
  13651. normalizeSelf(): Vec3;
  13652. /**
  13653. !#en
  13654. Returns this vector with a magnitude of 1.<br/>
  13655. <br/>
  13656. 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.
  13657. !#zh
  13658. 返回归一化后的向量。<br/>
  13659. <br/>
  13660. 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。
  13661. @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
  13662. */
  13663. normalize(out?: Vec3): Vec3;
  13664. /**
  13665. Transforms the vec3 with a mat4. 4th vector component is implicitly '1'
  13666. @param m matrix to transform with
  13667. @param out the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
  13668. */
  13669. transformMat4(m: Mat4, out?: Vec3): Vec3;
  13670. /**
  13671. Returns the maximum value in x, y, and z
  13672. */
  13673. maxAxis(): number;
  13674. /**
  13675. !#en Get angle in radian between this and vector.
  13676. !#zh 夹角的弧度。
  13677. @param vector vector
  13678. */
  13679. angle(vector: Vec3): number;
  13680. /**
  13681. !#en Calculates the projection of the current vector over the given vector.
  13682. !#zh 返回当前向量在指定 vector 向量上的投影向量。
  13683. @param vector vector
  13684. @example
  13685. ```js
  13686. var v1 = cc.v3(20, 20, 20);
  13687. var v2 = cc.v3(5, 5, 5);
  13688. v1.project(v2); // Vec3 {x: 20, y: 20, z: 20};
  13689. ```
  13690. */
  13691. project(vector: Vec3): Vec3;
  13692. /**
  13693. !#en Get angle in radian between this and vector with direction. <br/>
  13694. In order to compatible with the vec2 API.
  13695. !#zh 带方向的夹角的弧度。该方法仅用做兼容 2D 计算。
  13696. @param vector vector
  13697. */
  13698. signAngle(vector: Vec3|Vec2): number;
  13699. /**
  13700. !#en rotate. In order to compatible with the vec2 API.
  13701. !#zh 返回旋转给定弧度后的新向量。该方法仅用做兼容 2D 计算。
  13702. @param radians radians
  13703. @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
  13704. */
  13705. rotate(radians: number, out?: Vec3): Vec2;
  13706. /**
  13707. !#en rotate self. In order to compatible with the vec2 API.
  13708. !#zh 按指定弧度旋转向量。该方法仅用做兼容 2D 计算。
  13709. @param radians radians
  13710. */
  13711. rotateSelf(radians: number): Vec3;
  13712. }
  13713. /** !#en Representation of 3D vectors and points.
  13714. !#zh 表示 3D 向量和坐标 */
  13715. export class Vec4 extends ValueType {
  13716. /**
  13717. !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead.
  13718. !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。
  13719. @param vector vector
  13720. */
  13721. subSelf(vector: Vec4): Vec4;
  13722. /**
  13723. !#en Subtracts one vector from this, and returns the new result.
  13724. !#zh 向量减法,并返回新结果。
  13725. @param vector vector
  13726. @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
  13727. */
  13728. sub(vector: Vec4, out?: Vec4): Vec4;
  13729. /**
  13730. !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead.
  13731. !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。
  13732. @param num num
  13733. */
  13734. mulSelf(num: number): Vec4;
  13735. /**
  13736. !#en Multiplies by a number, and returns the new result.
  13737. !#zh 缩放向量,并返回新结果。
  13738. @param num num
  13739. @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
  13740. */
  13741. mul(num: number, out?: Vec4): Vec4;
  13742. /**
  13743. !#en Divides by a number. If you want to save result to another vector, use div() instead.
  13744. !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。
  13745. @param num num
  13746. */
  13747. divSelf(num: number): Vec4;
  13748. /**
  13749. !#en Divides by a number, and returns the new result.
  13750. !#zh 向量除法,并返回新的结果。
  13751. @param num num
  13752. @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
  13753. */
  13754. div(num: number, out?: Vec4): Vec4;
  13755. /**
  13756. !#en Multiplies two vectors.
  13757. !#zh 分量相乘。
  13758. @param vector vector
  13759. */
  13760. scaleSelf(vector: Vec4): Vec4;
  13761. /**
  13762. !#en Multiplies two vectors, and returns the new result.
  13763. !#zh 分量相乘,并返回新的结果。
  13764. @param vector vector
  13765. @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
  13766. */
  13767. scale(vector: Vec4, out?: Vec4): Vec4;
  13768. /**
  13769. !#en Negates the components. If you want to save result to another vector, use neg() instead.
  13770. !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。
  13771. */
  13772. negSelf(): Vec4;
  13773. /**
  13774. !#en Negates the components, and returns the new result.
  13775. !#zh 返回取反后的新向量。
  13776. @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
  13777. */
  13778. neg(out?: Vec4): Vec4;
  13779. /**
  13780. !#zh 获得指定向量的拷贝
  13781. !#en Obtaining copy vectors designated
  13782. */
  13783. static clone <Out extends IVec4Like> (a: Out): Vec4;
  13784. /**
  13785. !#zh 复制目标向量
  13786. !#en Copy the target vector
  13787. */
  13788. static copy <Out extends IVec4Like> (out: Out, a: Out): Out;
  13789. /**
  13790. !#zh 设置向量值
  13791. !#en Set to value
  13792. */
  13793. static set <Out extends IVec4Like> (out: Out, x: number, y: number, z: number, w: number): Out;
  13794. /**
  13795. !#zh 逐元素向量加法
  13796. !#en Element-wise vector addition
  13797. */
  13798. static add <Out extends IVec4Like> (out: Out, a: Out, b: Out): Out;
  13799. /**
  13800. !#zh 逐元素向量减法
  13801. !#en Element-wise vector subtraction
  13802. */
  13803. static subtract <Out extends IVec4Like> (out: Out, a: Out, b: Out): Out;
  13804. /**
  13805. !#zh 逐元素向量乘法
  13806. !#en Element-wise vector multiplication
  13807. */
  13808. static multiply <Out extends IVec4Like> (out: Out, a: Out, b: Out): Out;
  13809. /**
  13810. !#zh 逐元素向量除法
  13811. !#en Element-wise vector division
  13812. */
  13813. static divide <Out extends IVec4Like> (out: Out, a: Out, b: Out): Out;
  13814. /**
  13815. !#zh 逐元素向量向上取整
  13816. !#en Rounding up by elements of the vector
  13817. */
  13818. static ceil <Out extends IVec4Like> (out: Out, a: Out): Out;
  13819. /**
  13820. !#zh 逐元素向量向下取整
  13821. !#en Element vector by rounding down
  13822. */
  13823. static floor <Out extends IVec4Like> (out: Out, a: Out): Out;
  13824. /**
  13825. !#zh 逐元素向量最小值
  13826. !#en The minimum by-element vector
  13827. */
  13828. static min <Out extends IVec4Like> (out: Out, a: Out, b: Out): Out;
  13829. /**
  13830. !#zh 逐元素向量最大值
  13831. !#en The maximum value of the element-wise vector
  13832. */
  13833. static max <Out extends IVec4Like> (out: Out, a: Out, b: Out): Out;
  13834. /**
  13835. !#zh 逐元素向量四舍五入取整
  13836. !#en Element-wise vector of rounding to whole
  13837. */
  13838. static round <Out extends IVec4Like> (out: Out, a: Out): Out;
  13839. /**
  13840. !#zh 向量标量乘法
  13841. !#en Vector scalar multiplication
  13842. */
  13843. static multiplyScalar <Out extends IVec4Like> (out: Out, a: Out, b: number): Out;
  13844. /**
  13845. !#zh 逐元素向量乘加: A + B * scale
  13846. !#en Element-wise vector multiply add: A + B * scale
  13847. */
  13848. static scaleAndAdd <Out extends IVec4Like> (out: Out, a: Out, b: Out, scale: number): Out;
  13849. /**
  13850. !#zh 求两向量的欧氏距离
  13851. !#en Seeking two vectors Euclidean distance
  13852. */
  13853. static distance <Out extends IVec4Like> (a: Out, b: Out): number;
  13854. /**
  13855. !#zh 求两向量的欧氏距离平方
  13856. !#en Euclidean distance squared seeking two vectors
  13857. */
  13858. static squaredDistance <Out extends IVec4Like> (a: Out, b: Out): number;
  13859. /**
  13860. !#zh 求向量长度
  13861. !#en Seeking vector length
  13862. */
  13863. static len <Out extends IVec4Like> (a: Out): number;
  13864. /**
  13865. !#zh 求向量长度平方
  13866. !#en Seeking squared vector length
  13867. */
  13868. static lengthSqr <Out extends IVec4Like> (a: Out): number;
  13869. /**
  13870. !#zh 逐元素向量取负
  13871. !#en By taking the negative elements of the vector
  13872. */
  13873. static negate <Out extends IVec4Like> (out: Out, a: Out): Out;
  13874. /**
  13875. !#zh 逐元素向量取倒数,接近 0 时返回 Infinity
  13876. !#en Element vector by taking the inverse, return near 0 Infinity
  13877. */
  13878. static inverse <Out extends IVec4Like> (out: Out, a: Out): Out;
  13879. /**
  13880. !#zh 逐元素向量取倒数,接近 0 时返回 0
  13881. !#en Element vector by taking the inverse, return near 0 0
  13882. */
  13883. static inverseSafe <Out extends IVec4Like> (out: Out, a: Out): Out;
  13884. /**
  13885. !#zh 归一化向量
  13886. !#en Normalized vector
  13887. */
  13888. static normalize <Out extends IVec4Like> (out: Out, a: Out): Out;
  13889. /**
  13890. !#zh 向量点积(数量积)
  13891. !#en Vector dot product (scalar product)
  13892. */
  13893. static dot <Out extends IVec4Like> (a: Out, b: Out): number;
  13894. /**
  13895. !#zh 逐元素向量线性插值: A + t * (B - A)
  13896. !#en Vector element by element linear interpolation: A + t * (B - A)
  13897. */
  13898. static lerp <Out extends IVec4Like> (out: Out, a: Out, b: Out, t: number): Out;
  13899. /**
  13900. !#zh 生成一个在单位球体上均匀分布的随机向量
  13901. !#en Generates a uniformly distributed random vectors on the unit sphere
  13902. @param scale 生成的向量长度
  13903. */
  13904. static random <Out extends IVec4Like> (out: Out, scale?: number): Out;
  13905. /**
  13906. !#zh 向量矩阵乘法
  13907. !#en Vector matrix multiplication
  13908. */
  13909. static transformMat4 <Out extends IVec4Like, MatLike extends IMat4Like> (out: Out, a: Out, mat: MatLike): Out;
  13910. /**
  13911. !#zh 向量仿射变换
  13912. !#en Affine transformation vector
  13913. */
  13914. static transformAffine<Out extends IVec4Like, VecLike extends IVec4Like, MatLike extends IMat4Like>(out: Out, v: VecLike, mat: MatLike): Out;
  13915. /**
  13916. !#zh 向量四元数乘法
  13917. !#en Vector quaternion multiplication
  13918. */
  13919. static transformQuat <Out extends IVec4Like, QuatLike extends IQuatLike> (out: Out, a: Out, q: QuatLike): Out;
  13920. /**
  13921. !#zh 向量等价判断
  13922. !#en Equivalent vectors Analyzing
  13923. */
  13924. static strictEquals <Out extends IVec4Like> (a: Out, b: Out): boolean;
  13925. /**
  13926. !#zh 排除浮点数误差的向量近似等价判断
  13927. !#en Negative error vector floating point approximately equivalent Analyzing
  13928. */
  13929. static equals <Out extends IVec4Like> (a: Out, b: Out, epsilon?: number): boolean;
  13930. /**
  13931. !#zh 向量转数组
  13932. !#en Vector transfer array
  13933. @param ofs 数组起始偏移量
  13934. */
  13935. static toArray <Out extends IWritableArrayLike<number>> (out: Out, v: IVec4Like, ofs?: number): Out;
  13936. /**
  13937. !#zh 数组转向量
  13938. !#en Array steering amount
  13939. @param ofs 数组起始偏移量
  13940. */
  13941. static fromArray <Out extends IVec4Like> (out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out;
  13942. x: number;
  13943. y: number;
  13944. z: number;
  13945. w: number;
  13946. /**
  13947. !#en
  13948. Constructor
  13949. see {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}}
  13950. !#zh
  13951. 构造函数,可查看 {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}}
  13952. @param x x
  13953. @param y y
  13954. @param z z
  13955. @param w w
  13956. */
  13957. constructor(x?: number, y?: number, z?: number, w?: number);
  13958. /**
  13959. !#en clone a Vec4 value
  13960. !#zh 克隆一个 Vec4 值
  13961. */
  13962. clone(): Vec4;
  13963. /**
  13964. !#en Set the current vector value with the given vector.
  13965. !#zh 用另一个向量设置当前的向量对象值。
  13966. @param newValue !#en new value to set. !#zh 要设置的新值
  13967. */
  13968. set(newValue: Vec4): Vec4;
  13969. /**
  13970. !#en Check whether the vector equals another one
  13971. !#zh 当前的向量是否与指定的向量相等。
  13972. @param other other
  13973. @param epsilon epsilon
  13974. */
  13975. equals(other: Vec4, epsilon?: number): boolean;
  13976. /**
  13977. !#en Check whether the vector equals another one
  13978. !#zh 判断当前向量是否在误差范围内与指定分量的向量相等。
  13979. @param x 相比较的向量的 x 分量。
  13980. @param y 相比较的向量的 y 分量。
  13981. @param z 相比较的向量的 z 分量。
  13982. @param w 相比较的向量的 w 分量。
  13983. @param epsilon 允许的误差,应为非负数。
  13984. */
  13985. equals4f(x: number, y: number, z: number, w: number, epsilon?: number): boolean;
  13986. /**
  13987. !#en Check whether strict equals other Vec4
  13988. !#zh 判断当前向量是否与指定向量相等。两向量的各分量都分别相等时返回 `true`;否则返回 `false`。
  13989. @param other 相比较的向量。
  13990. */
  13991. strictEquals(other: Vec4): boolean;
  13992. /**
  13993. !#en Check whether strict equals other Vec4
  13994. !#zh 判断当前向量是否与指定分量的向量相等。两向量的各分量都分别相等时返回 `true`;否则返回 `false`。
  13995. @param x 指定向量的 x 分量。
  13996. @param y 指定向量的 y 分量。
  13997. @param z 指定向量的 z 分量。
  13998. @param w 指定向量的 w 分量。
  13999. */
  14000. strictEquals4f(x: number, y: number, z: number, w: number): boolean;
  14001. /**
  14002. !#en Calculate linear interpolation result between this vector and another one with given ratio
  14003. !#zh 根据指定的插值比率,从当前向量到目标向量之间做插值。
  14004. @param to 目标向量。
  14005. @param ratio 插值比率,范围为 [0,1]。
  14006. */
  14007. lerp(to: Vec4, ratio: number): Vec4;
  14008. /**
  14009. !#en Transform to string with vector informations
  14010. !#zh 返回当前向量的字符串表示。
  14011. */
  14012. toString(): string;
  14013. /**
  14014. !#en Clamp the vector between minInclusive and maxInclusive.
  14015. !#zh 设置当前向量的值,使其各个分量都处于指定的范围内。
  14016. @param minInclusive 每个分量都代表了对应分量允许的最小值。
  14017. @param maxInclusive 每个分量都代表了对应分量允许的最大值。
  14018. */
  14019. clampf(minInclusive: Vec4, maxInclusive: Vec4): Vec4;
  14020. /**
  14021. !#en Adds this vector. If you want to save result to another vector, use add() instead.
  14022. !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。
  14023. @param vector vector
  14024. */
  14025. addSelf(vector: Vec4): Vec4;
  14026. /**
  14027. !#en Adds two vectors, and returns the new result.
  14028. !#zh 向量加法,并返回新结果。
  14029. @param vector vector
  14030. @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
  14031. */
  14032. add(vector: Vec4, out?: Vec4): Vec4;
  14033. /**
  14034. !#en Subtracts one vector from this, and returns the new result.
  14035. !#zh 向量减法,并返回新结果。
  14036. @param vector vector
  14037. @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
  14038. */
  14039. subtract(vector: Vec4, out?: Vec4): Vec4;
  14040. /**
  14041. !#en Multiplies this by a number.
  14042. !#zh 缩放当前向量。
  14043. @param num num
  14044. */
  14045. multiplyScalar(num: number): Vec4;
  14046. /**
  14047. !#en Multiplies two vectors.
  14048. !#zh 分量相乘。
  14049. @param vector vector
  14050. */
  14051. multiply(vector: Vec4): Vec4;
  14052. /**
  14053. !#en Divides by a number.
  14054. !#zh 向量除法。
  14055. @param num num
  14056. */
  14057. divide(num: number): Vec4;
  14058. /**
  14059. !#en Negates the components.
  14060. !#zh 向量取反
  14061. */
  14062. negate(): Vec4;
  14063. /**
  14064. !#en Dot product
  14065. !#zh 当前向量与指定向量进行点乘。
  14066. @param vector vector
  14067. */
  14068. dot(vector?: Vec4): number;
  14069. /**
  14070. !#en Cross product
  14071. !#zh 当前向量与指定向量进行叉乘。
  14072. @param vector vector
  14073. @param out out
  14074. */
  14075. cross(vector: Vec4, out?: Vec4): Vec4;
  14076. /**
  14077. !#en Returns the length of this vector.
  14078. !#zh 返回该向量的长度。
  14079. @example
  14080. ```js
  14081. var v = cc.v4(10, 10);
  14082. v.len(); // return 14.142135623730951;
  14083. ```
  14084. */
  14085. len(): number;
  14086. /**
  14087. !#en Returns the squared length of this vector.
  14088. !#zh 返回该向量的长度平方。
  14089. */
  14090. lengthSqr(): number;
  14091. /**
  14092. !#en Make the length of this vector to 1.
  14093. !#zh 向量归一化,让这个向量的长度为 1。
  14094. */
  14095. normalizeSelf(): Vec4;
  14096. /**
  14097. !#en
  14098. Returns this vector with a magnitude of 1.<br/>
  14099. <br/>
  14100. 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.
  14101. !#zh
  14102. 返回归一化后的向量。<br/>
  14103. <br/>
  14104. 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。
  14105. @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
  14106. */
  14107. normalize(out?: Vec4): Vec4;
  14108. /**
  14109. Transforms the vec4 with a mat4. 4th vector component is implicitly '1'
  14110. @param m matrix to transform with
  14111. @param out the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
  14112. */
  14113. transformMat4(m: Mat4, out?: Vec4): Vec4;
  14114. /**
  14115. Returns the maximum value in x, y, z, w.
  14116. */
  14117. maxAxis(): number;
  14118. }
  14119. /** !#en
  14120. AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.<br/>
  14121. !#zh
  14122. AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。<br/> */
  14123. export class AffineTransform {
  14124. /**
  14125. !#en Create a AffineTransform object with all contents in the matrix.
  14126. !#zh 用在矩阵中的所有内容创建一个 AffineTransform 对象。
  14127. @param a a
  14128. @param b b
  14129. @param c c
  14130. @param d d
  14131. @param tx tx
  14132. @param ty ty
  14133. */
  14134. static create(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform;
  14135. /**
  14136. !#en
  14137. Create a identity transformation matrix: <br/>
  14138. [ 1, 0, 0, <br/>
  14139. 0, 1, 0 ]
  14140. !#zh
  14141. 单位矩阵:<br/>
  14142. [ 1, 0, 0, <br/>
  14143. 0, 1, 0 ]
  14144. */
  14145. static identity(): AffineTransform;
  14146. /**
  14147. !#en Clone a AffineTransform object from the specified transform.
  14148. !#zh 克隆指定的 AffineTransform 对象。
  14149. @param t t
  14150. */
  14151. static clone(t: AffineTransform): AffineTransform;
  14152. /**
  14153. !#en
  14154. Concatenate a transform matrix to another
  14155. The results are reflected in the out affine transform
  14156. out = t1 * t2
  14157. This function is memory free, you should create the output affine transform by yourself and manage its memory.
  14158. !#zh
  14159. 拼接两个矩阵,将结果保存到 out 矩阵。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。
  14160. out = t1 * t2
  14161. @param out Out object to store the concat result
  14162. @param t1 The first transform object.
  14163. @param t2 The transform object to concatenate.
  14164. */
  14165. static concat(out: AffineTransform, t1: AffineTransform, t2: AffineTransform): AffineTransform;
  14166. /**
  14167. !#en Get the invert transform of an AffineTransform object.
  14168. This function is memory free, you should create the output affine transform by yourself and manage its memory.
  14169. !#zh 求逆矩阵。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。
  14170. @param out out
  14171. @param t t
  14172. */
  14173. static invert(out: AffineTransform, t: AffineTransform): AffineTransform;
  14174. /**
  14175. !#en Get an AffineTransform object from a given matrix 4x4.
  14176. This function is memory free, you should create the output affine transform by yourself and manage its memory.
  14177. !#zh 从一个 4x4 Matrix 获取 AffineTransform 对象。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。
  14178. @param out out
  14179. @param mat mat
  14180. */
  14181. static invert(out: AffineTransform, mat: Mat4): AffineTransform;
  14182. /**
  14183. !#en Apply the affine transformation on a point.
  14184. This function is memory free, you should create the output Vec2 by yourself and manage its memory.
  14185. !#zh 对一个点应用矩阵变换。这个函数不创建任何内存,你需要先创建一个 Vec2 对象用来存储结果,并作为第一个参数传入函数。
  14186. @param out The output point to store the result
  14187. @param point Point to apply transform or x.
  14188. @param transOrY transform matrix or y.
  14189. @param t transform matrix.
  14190. */
  14191. static transformVec2(out: Vec2, point: Vec2|number, transOrY: AffineTransform|number, t?: AffineTransform): Vec2;
  14192. /**
  14193. !#en Apply the affine transformation on a size.
  14194. This function is memory free, you should create the output Size by yourself and manage its memory.
  14195. !#zh 应用仿射变换矩阵到 Size 上。这个函数不创建任何内存,你需要先创建一个 Size 对象用来存储结果,并作为第一个参数传入函数。
  14196. @param out The output point to store the result
  14197. @param size size
  14198. @param t t
  14199. */
  14200. static transformSize(out: Size, size: Size, t: AffineTransform): Size;
  14201. /**
  14202. !#en Apply the affine transformation on a rect.
  14203. This function is memory free, you should create the output Rect by yourself and manage its memory.
  14204. !#zh 应用仿射变换矩阵到 Rect 上。这个函数不创建任何内存,你需要先创建一个 Rect 对象用来存储结果,并作为第一个参数传入函数。
  14205. @param out out
  14206. @param rect rect
  14207. @param anAffineTransform anAffineTransform
  14208. */
  14209. static transformRect(out: Rect, rect: Rect, anAffineTransform: AffineTransform): Rect;
  14210. /**
  14211. !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box.
  14212. This function is memory free, you should create the output vectors by yourself and manage their memory.
  14213. !#zh 应用仿射变换矩阵到 Rect 上, 并转换为有向包围盒。这个函数不创建任何内存,你需要先创建包围盒的四个 Vector 对象用来存储结果,并作为前四个参数传入函数。
  14214. @param out_bl out_bl
  14215. @param out_tl out_tl
  14216. @param out_tr out_tr
  14217. @param out_br out_br
  14218. @param rect rect
  14219. @param anAffineTransform anAffineTransform
  14220. */
  14221. static transformObb(out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2, rect: Rect, anAffineTransform: AffineTransform): void;
  14222. }
  14223. /** !#en The module provides utilities for working with file and directory paths
  14224. !#zh 用于处理文件与目录的路径的模块 */
  14225. export class path {
  14226. /**
  14227. !#en Join strings to be a path.
  14228. !#zh 拼接字符串为 Path
  14229. @example
  14230. ```js
  14231. ------------------------------
  14232. cc.path.join("a", "b.png"); //-->"a/b.png"
  14233. cc.path.join("a", "b", "c.png"); //-->"a/b/c.png"
  14234. cc.path.join("a", "b"); //-->"a/b"
  14235. cc.path.join("a", "b", "/"); //-->"a/b/"
  14236. cc.path.join("a", "b/", "/"); //-->"a/b/"
  14237. ```
  14238. */
  14239. static join(): string;
  14240. /**
  14241. !#en Get the ext name of a path including '.', like '.png'.
  14242. !#zh 返回 Path 的扩展名,包括 '.',例如 '.png'。
  14243. @param pathStr pathStr
  14244. @example
  14245. ```js
  14246. ---------------------------
  14247. cc.path.extname("a/b.png"); //-->".png"
  14248. cc.path.extname("a/b.png?a=1&b=2"); //-->".png"
  14249. cc.path.extname("a/b"); //-->null
  14250. cc.path.extname("a/b?a=1&b=2"); //-->null
  14251. ```
  14252. */
  14253. static extname(pathStr: string): any;
  14254. /**
  14255. !#en Get the main name of a file name
  14256. !#zh 获取文件名的主名称
  14257. @param fileName fileName
  14258. */
  14259. static mainFileName(fileName: string): string;
  14260. /**
  14261. !#en Get the file name of a file path.
  14262. !#zh 获取文件路径的文件名。
  14263. @param pathStr pathStr
  14264. @param extname extname
  14265. @example
  14266. ```js
  14267. ---------------------------------
  14268. cc.path.basename("a/b.png"); //-->"b.png"
  14269. cc.path.basename("a/b.png?a=1&b=2"); //-->"b.png"
  14270. cc.path.basename("a/b.png", ".png"); //-->"b"
  14271. cc.path.basename("a/b.png?a=1&b=2", ".png"); //-->"b"
  14272. cc.path.basename("a/b.png", ".txt"); //-->"b.png"
  14273. ```
  14274. */
  14275. static basename(pathStr: string, extname?: string): any;
  14276. /**
  14277. !#en Get dirname of a file path.
  14278. !#zh 获取文件路径的目录名。
  14279. @param pathStr pathStr
  14280. @example
  14281. ```js
  14282. ---------------------------------
  14283. * unix
  14284. cc.path.driname("a/b/c.png"); //-->"a/b"
  14285. cc.path.driname("a/b/c.png?a=1&b=2"); //-->"a/b"
  14286. cc.path.dirname("a/b/"); //-->"a/b"
  14287. cc.path.dirname("c.png"); //-->""
  14288. * windows
  14289. cc.path.driname("a\\b\\c.png"); //-->"a\b"
  14290. cc.path.driname("a\\b\\c.png?a=1&b=2"); //-->"a\b"
  14291. ```
  14292. */
  14293. static dirname(pathStr: string): any;
  14294. /**
  14295. !#en Change extname of a file path.
  14296. !#zh 更改文件路径的扩展名。
  14297. @param pathStr pathStr
  14298. @param extname extname
  14299. @example
  14300. ```js
  14301. ---------------------------------
  14302. cc.path.changeExtname("a/b.png", ".plist"); //-->"a/b.plist"
  14303. cc.path.changeExtname("a/b.png?a=1&b=2", ".plist"); //-->"a/b.plist?a=1&b=2"
  14304. ```
  14305. */
  14306. static changeExtname(pathStr: string, extname?: string): string;
  14307. }
  14308. /** A base node for CCNode, it will:
  14309. - maintain scene hierarchy and active logic
  14310. - notifications if some properties changed
  14311. - define some interfaces shares between CCNode
  14312. - define machanisms for Enity Component Systems
  14313. - define prefab and serialize functions */
  14314. export class _BaseNode extends Object implements EventTarget {
  14315. /** !#en Name of node.
  14316. !#zh 该节点名称。 */
  14317. name: string;
  14318. /** !#en The uuid for editor, will be stripped before building project.
  14319. !#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */
  14320. uuid: string;
  14321. /** !#en All children nodes.
  14322. !#zh 节点的所有子节点。 */
  14323. children: Node[];
  14324. /** !#en All children nodes.
  14325. !#zh 节点的子节点数量。 */
  14326. childrenCount: number;
  14327. /** !#en
  14328. The local active state of this node.<br/>
  14329. Note that a Node may be inactive because a parent is not active, even if this returns true.<br/>
  14330. Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene.
  14331. !#zh
  14332. 当前节点的自身激活状态。<br/>
  14333. 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。<br/>
  14334. 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */
  14335. active: boolean;
  14336. /** !#en Indicates whether this node is active in the scene.
  14337. !#zh 表示此节点是否在场景中激活。 */
  14338. activeInHierarchy: boolean;
  14339. /**
  14340. @param name name
  14341. */
  14342. constructor(name?: string);
  14343. /** !#en The parent of the node.
  14344. !#zh 该节点的父节点。 */
  14345. parent: Node;
  14346. /**
  14347. !#en Get parent of the node.
  14348. !#zh 获取该节点的父节点。
  14349. @example
  14350. ```js
  14351. var parent = this.node.getParent();
  14352. ```
  14353. */
  14354. getParent(): Node;
  14355. /**
  14356. !#en Set parent of the node.
  14357. !#zh 设置该节点的父节点。
  14358. @param value value
  14359. @example
  14360. ```js
  14361. node.setParent(newNode);
  14362. ```
  14363. */
  14364. setParent(value: Node): void;
  14365. /**
  14366. !#en
  14367. Properties configuration function <br/>
  14368. All properties in attrs will be set to the node, <br/>
  14369. when the setter of the node is available, <br/>
  14370. the property will be set via setter function.<br/>
  14371. !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。
  14372. @param attrs Properties to be set to node
  14373. @example
  14374. ```js
  14375. var attrs = { key: 0, num: 100 };
  14376. node.attr(attrs);
  14377. ```
  14378. */
  14379. attr(attrs: any): void;
  14380. /**
  14381. !#en Returns a child from the container given its uuid.
  14382. !#zh 通过 uuid 获取节点的子节点。
  14383. @param uuid The uuid to find the child node.
  14384. @example
  14385. ```js
  14386. var child = node.getChildByUuid(uuid);
  14387. ```
  14388. */
  14389. getChildByUuid(uuid: string): Node;
  14390. /**
  14391. !#en Returns a child from the container given its name.
  14392. !#zh 通过名称获取节点的子节点。
  14393. @param name A name to find the child node.
  14394. @example
  14395. ```js
  14396. var child = node.getChildByName("Test Node");
  14397. ```
  14398. */
  14399. getChildByName(name: string): Node;
  14400. /**
  14401. !#en
  14402. Inserts a child to the node at a specified index.
  14403. !#zh
  14404. 插入子节点到指定位置
  14405. @param child the child node to be inserted
  14406. @param siblingIndex the sibling index to place the child in
  14407. @example
  14408. ```js
  14409. node.insertChild(child, 2);
  14410. ```
  14411. */
  14412. insertChild(child: Node, siblingIndex: number): void;
  14413. /**
  14414. !#en Get the sibling index.
  14415. !#zh 获取同级索引。
  14416. @example
  14417. ```js
  14418. var index = node.getSiblingIndex();
  14419. ```
  14420. */
  14421. getSiblingIndex(): number;
  14422. /**
  14423. !#en Set the sibling index of this node.
  14424. !#zh 设置节点同级索引。
  14425. @param index index
  14426. @example
  14427. ```js
  14428. node.setSiblingIndex(1);
  14429. ```
  14430. */
  14431. setSiblingIndex(index: number): void;
  14432. /**
  14433. !#en Walk though the sub children tree of the current node.
  14434. Each node, including the current node, in the sub tree will be visited two times, before all children and after all children.
  14435. This function call is not recursive, it's based on stack.
  14436. Please don't walk any other node inside the walk process.
  14437. !#zh 遍历该节点的子树里的所有节点并按规则执行回调函数。
  14438. 对子树中的所有节点,包含当前节点,会执行两次回调,prefunc 会在访问它的子节点之前调用,postfunc 会在访问所有子节点之后调用。
  14439. 这个函数的实现不是基于递归的,而是基于栈展开递归的方式。
  14440. 请不要在 walk 过程中对任何其他的节点嵌套执行 walk。
  14441. @param prefunc The callback to process node when reach the node for the first time
  14442. @param postfunc The callback to process node when re-visit the node after walked all children in its sub tree
  14443. @example
  14444. ```js
  14445. node.walk(function (target) {
  14446. console.log('Walked through node ' + target.name + ' for the first time');
  14447. }, function (target) {
  14448. console.log('Walked through node ' + target.name + ' after walked all children in its sub tree');
  14449. });
  14450. ```
  14451. */
  14452. walk(prefunc: (target: _BaseNode) => void, postfunc: (target: _BaseNode) => void): void;
  14453. /**
  14454. !#en
  14455. Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions. <br/>
  14456. 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/>
  14457. If the node orphan, then nothing happens.
  14458. !#zh
  14459. 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。<br/>
  14460. 因此建议调用这个 API 时总是传入 `false` 参数。<br/>
  14461. 如果这个节点是一个孤节点,那么什么都不会发生。
  14462. @param cleanup true if all actions and callbacks on this node should be removed, false otherwise.
  14463. @example
  14464. ```js
  14465. node.removeFromParent();
  14466. node.removeFromParent(false);
  14467. ```
  14468. */
  14469. removeFromParent(cleanup?: boolean): void;
  14470. /**
  14471. !#en
  14472. Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. </p>
  14473. If the cleanup parameter is not passed, it will force a cleanup. <br/>
  14474. "remove" logic MUST only be on this method <br/>
  14475. If a class wants to extend the 'removeChild' behavior it only needs <br/>
  14476. to override this method.
  14477. !#zh
  14478. 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  14479. 如果 cleanup 参数不传入,默认为 true 表示清理。<br/>
  14480. @param child The child node which will be removed.
  14481. @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
  14482. @example
  14483. ```js
  14484. node.removeChild(newNode);
  14485. node.removeChild(newNode, false);
  14486. ```
  14487. */
  14488. removeChild(child: Node, cleanup?: boolean): void;
  14489. /**
  14490. !#en
  14491. Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. <br/>
  14492. If the cleanup parameter is not passed, it will force a cleanup.
  14493. !#zh
  14494. 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  14495. 如果 cleanup 参数不传入,默认为 true 表示清理。
  14496. @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise.
  14497. @example
  14498. ```js
  14499. node.removeAllChildren();
  14500. node.removeAllChildren(false);
  14501. ```
  14502. */
  14503. removeAllChildren(cleanup?: boolean): void;
  14504. /**
  14505. !#en Is this node a child of the given node?
  14506. !#zh 是否是指定节点的子节点?
  14507. @param parent parent
  14508. @example
  14509. ```js
  14510. node.isChildOf(newNode);
  14511. ```
  14512. */
  14513. isChildOf(parent: Node): boolean;
  14514. /**
  14515. !#en
  14516. Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
  14517. You can also get component in the node by passing in the name of the script.
  14518. !#zh
  14519. 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。<br/>
  14520. 传入参数也可以是脚本的名称。
  14521. @param typeOrClassName typeOrClassName
  14522. @example
  14523. ```js
  14524. // get sprite component
  14525. var sprite = node.getComponent(cc.Sprite);
  14526. // get custom test class
  14527. var test = node.getComponent("Test");
  14528. ```
  14529. */
  14530. getComponent<T extends Component>(type: {prototype: T}): T;
  14531. getComponent(className: string): any;
  14532. /**
  14533. !#en Returns all components of supplied type in the node.
  14534. !#zh 返回节点上指定类型的所有组件。
  14535. @param typeOrClassName typeOrClassName
  14536. @example
  14537. ```js
  14538. var sprites = node.getComponents(cc.Sprite);
  14539. var tests = node.getComponents("Test");
  14540. ```
  14541. */
  14542. getComponents<T extends Component>(type: {prototype: T}): T[];
  14543. getComponents(className: string): any[];
  14544. /**
  14545. !#en Returns the component of supplied type in any of its children using depth first search.
  14546. !#zh 递归查找所有子节点中第一个匹配指定类型的组件。
  14547. @param typeOrClassName typeOrClassName
  14548. @example
  14549. ```js
  14550. var sprite = node.getComponentInChildren(cc.Sprite);
  14551. var Test = node.getComponentInChildren("Test");
  14552. ```
  14553. */
  14554. getComponentInChildren<T extends Component>(type: {prototype: T}): T;
  14555. getComponentInChildren(className: string): any;
  14556. /**
  14557. !#en Returns all components of supplied type in self or any of its children.
  14558. !#zh 递归查找自身或所有子节点中指定类型的组件
  14559. @param typeOrClassName typeOrClassName
  14560. @example
  14561. ```js
  14562. var sprites = node.getComponentsInChildren(cc.Sprite);
  14563. var tests = node.getComponentsInChildren("Test");
  14564. ```
  14565. */
  14566. getComponentsInChildren<T extends Component>(type: {prototype: T}): T[];
  14567. getComponentsInChildren(className: string): any[];
  14568. /**
  14569. !#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
  14570. !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。
  14571. @param typeOrClassName The constructor or the class name of the component to add
  14572. @example
  14573. ```js
  14574. var sprite = node.addComponent(cc.Sprite);
  14575. var test = node.addComponent("Test");
  14576. ```
  14577. */
  14578. addComponent<T extends Component>(type: {new(): T}): T;
  14579. addComponent(className: string): any;
  14580. /**
  14581. !#en
  14582. Removes a component identified by the given name or removes the component object given.
  14583. You can also use component.destroy() if you already have the reference.
  14584. !#zh
  14585. 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。
  14586. 如果你已经获得组件引用,你也可以直接调用 component.destroy()
  14587. @param component The need remove component.
  14588. @example
  14589. ```js
  14590. node.removeComponent(cc.Sprite);
  14591. var Test = require("Test");
  14592. node.removeComponent(Test);
  14593. ```
  14594. */
  14595. removeComponent(component: string|Function|Component): void;
  14596. /**
  14597. !#en
  14598. Destroy all children from the node, and release all their own references to other objects.<br/>
  14599. Actual destruct operation will delayed until before rendering.
  14600. !#zh
  14601. 销毁所有子节点,并释放所有它们对其它对象的引用。<br/>
  14602. 实际销毁操作会延迟到当前帧渲染前执行。
  14603. @example
  14604. ```js
  14605. node.destroyAllChildren();
  14606. ```
  14607. */
  14608. destroyAllChildren(): void;
  14609. /**
  14610. !#en Checks whether the EventTarget object has any callback registered for a specific type of event.
  14611. !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。
  14612. @param type The type of event.
  14613. */
  14614. hasEventListener(type: string): boolean;
  14615. /**
  14616. !#en
  14617. Register an callback of a specific event type on the EventTarget.
  14618. This type of event should be triggered via `emit`.
  14619. !#zh
  14620. 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。
  14621. @param type A string representing the event type to listen for.
  14622. @param callback The callback that will be invoked when the event is dispatched.
  14623. The callback is ignored if it is a duplicate (the callbacks are unique).
  14624. @param target The target (this object) to invoke the callback, can be null
  14625. @example
  14626. ```js
  14627. eventTarget.on('fire', function () {
  14628. cc.log("fire in the hole");
  14629. }, node);
  14630. ```
  14631. */
  14632. on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
  14633. /**
  14634. !#en
  14635. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  14636. if only type is passed as parameter, all listeners registered with that type will be removed.
  14637. !#zh
  14638. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  14639. @param type A string representing the event type being removed.
  14640. @param callback The callback to remove.
  14641. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  14642. @example
  14643. ```js
  14644. // register fire eventListener
  14645. var callback = eventTarget.on('fire', function () {
  14646. cc.log("fire in the hole");
  14647. }, target);
  14648. // remove fire event listener
  14649. eventTarget.off('fire', callback, target);
  14650. // remove all fire event listeners
  14651. eventTarget.off('fire');
  14652. ```
  14653. */
  14654. off(type: string, callback?: Function, target?: any): void;
  14655. /**
  14656. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  14657. This is not for removing all listeners in the current event target,
  14658. and this is not for removing all listeners the target parameter have registered.
  14659. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  14660. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  14661. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  14662. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  14663. @param target The target to be searched for all related listeners
  14664. */
  14665. targetOff(target: any): void;
  14666. /**
  14667. !#en
  14668. Register an callback of a specific event type on the EventTarget,
  14669. the callback will remove itself after the first time it is triggered.
  14670. !#zh
  14671. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  14672. @param type A string representing the event type to listen for.
  14673. @param callback The callback that will be invoked when the event is dispatched.
  14674. The callback is ignored if it is a duplicate (the callbacks are unique).
  14675. @param target The target (this object) to invoke the callback, can be null
  14676. @example
  14677. ```js
  14678. eventTarget.once('fire', function () {
  14679. cc.log("this is the callback and will be invoked only once");
  14680. }, node);
  14681. ```
  14682. */
  14683. once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
  14684. /**
  14685. !#en
  14686. Send an event with the event object.
  14687. !#zh
  14688. 通过事件对象派发事件
  14689. @param event event
  14690. */
  14691. dispatchEvent(event: Event): void;
  14692. /**
  14693. !#en
  14694. Destroy all callbackInfos.
  14695. !#zh
  14696. 销毁记录的事件
  14697. */
  14698. clear(): void;
  14699. }
  14700. /** !#en
  14701. Helper class for setting material blend function.
  14702. !#zh
  14703. 设置材质混合模式的辅助类。 */
  14704. export class BlendFunc {
  14705. /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost.
  14706. !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */
  14707. srcBlendFactor: macro.BlendFactor;
  14708. /** !#en specify the destination Blend Factor.
  14709. !#zh 指定目标的混合模式 */
  14710. dstBlendFactor: macro.BlendFactor;
  14711. }
  14712. /** An internal helper class for switching render component's material between normal sprite material and gray sprite material. */
  14713. export class GraySpriteState {
  14714. /** !#en The normal material.
  14715. !#zh 正常状态的材质。 */
  14716. normalMaterial: Material;
  14717. /** !#en The gray material.
  14718. !#zh 置灰状态的材质。 */
  14719. grayMaterial: Material;
  14720. }
  14721. /** misc utilities */
  14722. export class misc {
  14723. /**
  14724. !#en Clamp a value between from and to.
  14725. !#zh
  14726. 限定浮点数的最大最小值。<br/>
  14727. 数值大于 max_inclusive 则返回 max_inclusive。<br/>
  14728. 数值小于 min_inclusive 则返回 min_inclusive。<br/>
  14729. 否则返回自身。
  14730. @param value value
  14731. @param min_inclusive min_inclusive
  14732. @param max_inclusive max_inclusive
  14733. @example
  14734. ```js
  14735. var v1 = cc.misc.clampf(20, 0, 20); // 20;
  14736. var v2 = cc.misc.clampf(-1, 0, 20); // 0;
  14737. var v3 = cc.misc.clampf(10, 0, 20); // 10;
  14738. ```
  14739. */
  14740. static clampf(value: number, min_inclusive: number, max_inclusive: number): number;
  14741. /**
  14742. !#en Clamp a value between 0 and 1.
  14743. !#zh 限定浮点数的取值范围为 0 ~ 1 之间。
  14744. @param value value
  14745. @example
  14746. ```js
  14747. var v1 = cc.misc.clamp01(20); // 1;
  14748. var v2 = cc.misc.clamp01(-1); // 0;
  14749. var v3 = cc.misc.clamp01(0.5); // 0.5;
  14750. ```
  14751. */
  14752. static clamp01(value: number): number;
  14753. /**
  14754. Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end
  14755. @param a number A
  14756. @param b number B
  14757. @param r ratio between 0 and 1
  14758. @example
  14759. ```js
  14760. ----
  14761. lerp
  14762. cc.misc.lerp(2,10,0.5)//returns 6
  14763. cc.misc.lerp(2,10,0.2)//returns 3.6
  14764. ```
  14765. */
  14766. static lerp(a: number, b: number, r: number): number;
  14767. /**
  14768. converts degrees to radians
  14769. @param angle angle
  14770. */
  14771. static degreesToRadians(angle: number): number;
  14772. /**
  14773. converts radians to degrees
  14774. @param angle angle
  14775. */
  14776. static radiansToDegrees(angle: number): number;
  14777. }
  14778. /** !#en The animation curve of 3d particle.
  14779. !#zh 3D 粒子动画曲线 */
  14780. export class AnimationCurve {
  14781. /** !#en Array of key value.
  14782. !#zh 关键值列表。 */
  14783. keyFrames: Keyframe[];
  14784. /** !#en Pre-wrap mode.
  14785. !#zh 前置循环模式。 */
  14786. preWrapMode: WrapMode;
  14787. /** !#en Post-wrap mode.
  14788. !#zh 后置循环模式。 */
  14789. postWrapMode: WrapMode;
  14790. }
  14791. /** !#en The burst of 3d particle.
  14792. !#zh 3D 粒子发射时的爆发个数 */
  14793. export class Burst {
  14794. /** !#en Time between the start of the particle system and the trigger of this Brust
  14795. !#zh 粒子系统开始运行到触发此次 Brust 的时间 */
  14796. time: number;
  14797. /** !#en Minimum number of emitted particles
  14798. !#zh 发射粒子的最小数量 */
  14799. minCount: number;
  14800. /** !#en Maximum number of emitted particles
  14801. !#zh 发射粒子的最大数量 */
  14802. maxCount: number;
  14803. /** !#en The number of times Burst was triggered.
  14804. !#zh Burst 的触发次数 */
  14805. repeatCount: number;
  14806. /** !#en Interval of each trigger
  14807. !#zh 每次触发的间隔时间 */
  14808. repeatInterval: number;
  14809. /** !#en Number of particles emitted
  14810. !#zh 发射的粒子的数量 */
  14811. count: CurveRange;
  14812. }
  14813. /** !#en The ParticleSystem3D Component.
  14814. !#zh 3D 粒子组件 */
  14815. export class ParticleSystem3D extends RenderComponent {
  14816. /** !#en The run time of particle.
  14817. !#zh 粒子系统运行时间 */
  14818. duration: number;
  14819. /** !#en The maximum number of particles that a particle system can generate.
  14820. !#zh 粒子系统能生成的最大粒子数量 */
  14821. capacity: number;
  14822. /** !#en Whether the particle system loops.
  14823. !#zh 粒子系统是否循环播放 */
  14824. loop: boolean;
  14825. /** !#en Whether the particles start playing automatically after loaded.
  14826. !#zh 粒子系统加载后是否自动开始播放 */
  14827. playOnAwake: boolean;
  14828. /** !#en When selected, the particle system will start playing after one round has been played (only effective when loop is enabled).
  14829. !#zh 选中之后,粒子系统会以已播放完一轮之后的状态开始播放(仅当循环播放启用时有效) */
  14830. prewarm: boolean;
  14831. /** !#en The coordinate system in which the particle system is located.<br>
  14832. World coordinates (does not change when the position of other objects changes)<br>
  14833. Local coordinates (moving as the position of the parent node changes)<br>
  14834. Custom coordinates (moving with the position of a custom node)
  14835. !#zh 选择粒子系统所在的坐标系<br>
  14836. 世界坐标(不随其他物体位置改变而变换)<br>
  14837. 局部坐标(跟随父节点位置改变而移动)<br>
  14838. 自定坐标(跟随自定义节点的位置改变而移动) */
  14839. simulationSpace: ParticleSystem3DAssembler.Space;
  14840. /** !#en Controlling the update speed of the entire particle system.
  14841. !#zh 控制整个粒子系统的更新速度。 */
  14842. simulationSpeed: number;
  14843. /** !#en Delay particle emission time after particle system starts running.
  14844. !#zh 粒子系统开始运行后,延迟粒子发射的时间。 */
  14845. startDelay: CurveRange;
  14846. /** !#en Particle life cycle。
  14847. !#zh 粒子生命周期。 */
  14848. startLifetime: CurveRange;
  14849. /** !#en Particle initial color
  14850. !#zh 粒子初始颜色 */
  14851. startColor: GradientRange;
  14852. /** !#en Particle scale space
  14853. !#zh 缩放空间 */
  14854. scaleSpace: ParticleSystem3DAssembler.Space;
  14855. /** !#en Initial particle size
  14856. !#zh 粒子初始大小 */
  14857. startSize: CurveRange;
  14858. /** !#en Initial particle speed
  14859. !#zh 粒子初始速度 */
  14860. startSpeed: CurveRange;
  14861. /** !#en Particle initial rotation angle
  14862. !#zh 粒子初始旋转角度 */
  14863. startRotation: CurveRange;
  14864. /** !#en Gravity coefficient of particles affected by gravity
  14865. !#zh 粒子受重力影响的重力系数 */
  14866. gravityModifier: CurveRange;
  14867. /** !#en Particles emitted per second
  14868. !#zh 每秒发射的粒子数 */
  14869. rateOverTime: CurveRange;
  14870. /** !#en Number of particles emitted per unit distance moved
  14871. !#zh 每移动单位距离发射的粒子数 */
  14872. rateOverDistance: CurveRange;
  14873. /** !#en The number of Brusts that emit a specified number of particles at a specified time
  14874. !#zh 设定在指定时间发射指定数量的粒子的 Brust 的数量 */
  14875. bursts: Burst[];
  14876. /** !#en Particle emitter module
  14877. !#zh 粒子发射器模块 */
  14878. shapeModule: ShapeModule;
  14879. /** !#en Color control module
  14880. !#zh 颜色控制模块 */
  14881. colorOverLifetimeModule: ColorOverLifetimeModule;
  14882. /** !#en Particle size module
  14883. !#zh 粒子大小模块 */
  14884. sizeOvertimeModule: SizeOvertimeModule;
  14885. /** !#en Particle speed module
  14886. !#zh 粒子速度模块 */
  14887. velocityOvertimeModule: VelocityOvertimeModule;
  14888. /** !#en Particle acceleration module
  14889. !#zh 粒子加速度模块 */
  14890. forceOvertimeModule: ForceOvertimeModule;
  14891. /** !#en Particle limit speed module (only CPU particles are supported)
  14892. !#zh 粒子限制速度模块(只支持 CPU 粒子) */
  14893. limitVelocityOvertimeModule: LimitVelocityOvertimeModule;
  14894. /** !#en Particle rotation module
  14895. !#zh 粒子旋转模块 */
  14896. rotationOvertimeModule: RotationOvertimeModule;
  14897. /** !#en Texture Animation Module
  14898. !#zh 贴图动画模块 */
  14899. textureAnimationModule: TextureAnimationModule;
  14900. /** !#en Particle Trajectory Module
  14901. !#zh 粒子轨迹模块 */
  14902. trailModule: TrailModule;
  14903. /** !#en Particle generation mode
  14904. !#zh 设定粒子生成模式 */
  14905. renderMode: ParticleSystem3DAssembler.RenderMode;
  14906. /** !#en When the particle generation mode is StrecthedBillboard, in the direction of movement of the particles is stretched by velocity magnitude
  14907. !#zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按速度大小进行拉伸 */
  14908. velocityScale: number;
  14909. /** !#en When the particle generation method is StrecthedBillboard, the particles are stretched according to the particle size in the direction of motion
  14910. !#zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按粒子大小进行拉伸 */
  14911. lengthScale: number;
  14912. /** !#en Particle model
  14913. !#zh 粒子模型 */
  14914. mesh: Mesh;
  14915. /** !#en Particle material
  14916. !#zh 粒子材质 */
  14917. particleMaterial: Material;
  14918. /** !#en Particle trail material
  14919. !#zh 粒子轨迹材质 */
  14920. trailMaterial: Material;
  14921. /**
  14922. !#en Playing particle effects
  14923. !#zh 播放粒子效果
  14924. */
  14925. play(): void;
  14926. /**
  14927. !#en Pause particle effect
  14928. !#zh 暂停播放粒子效果
  14929. */
  14930. pause(): void;
  14931. /**
  14932. !#en Stop particle effect
  14933. !#zh 停止播放粒子效果
  14934. */
  14935. stop(): void;
  14936. /**
  14937. !#en Remove all particle effect
  14938. !#zh 将所有粒子从粒子系统中清除
  14939. */
  14940. clear(): void;
  14941. }
  14942. /** !#en
  14943. Helper class for ES5 Map.
  14944. !#zh
  14945. ES5 Map 辅助类。 */
  14946. export class MapUtils {
  14947. }
  14948. /** !#en .
  14949. !#zh 。 */
  14950. export class SkeletonAnimation extends Animation {
  14951. }
  14952. /** !#en
  14953. Skinned Mesh Renderer
  14954. !#zh
  14955. 蒙皮渲染组件 */
  14956. export class SkinnedMeshRenderer extends MeshRenderer {
  14957. /** !#en
  14958. Skeleton Asset
  14959. !#zh
  14960. 骨骼资源 */
  14961. skeleton: sp.Skeleton;
  14962. /** !#en
  14963. Root Bone
  14964. !#zh
  14965. 骨骼根节点 */
  14966. rootBone: Node;
  14967. }
  14968. /** !#en SkeletonAnimationClip Asset.
  14969. !#zh 骨骼动画剪辑。 */
  14970. export class SkeletonAnimationClip extends AnimationClip {
  14971. }
  14972. /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users.
  14973. !#zh EditBox 组件,用于获取用户的输入文本。 */
  14974. export class EditBox extends Component {
  14975. /** !#en Input string of EditBox.
  14976. !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */
  14977. string: string;
  14978. /** !#en The Label component attached to the node for EditBox's input text label
  14979. !#zh 输入框输入文本节点上挂载的 Label 组件对象 */
  14980. textLabel: Label;
  14981. /** !#en The Label component attached to the node for EditBox's placeholder text label
  14982. !#zh 输入框占位符节点上挂载的 Label 组件对象 */
  14983. placeholderLabel: Label;
  14984. /** !#en The Sprite component attached to the node for EditBox's background
  14985. !#zh 输入框背景节点上挂载的 Sprite 组件对象 */
  14986. background: Sprite;
  14987. /** !#en The background image of EditBox. This property will be removed in the future, use editBox.background instead please.
  14988. !#zh 输入框的背景图片。 该属性会在将来的版本中移除,请用 editBox.background */
  14989. backgroundImage: SpriteFrame;
  14990. /** !#en
  14991. The return key type of EditBox.
  14992. Note: it is meaningless for web platforms and desktop platforms.
  14993. !#zh
  14994. 指定移动设备上面回车按钮的样式。
  14995. 注意:这个选项对 web 平台与 desktop 平台无效。 */
  14996. returnType: EditBox.KeyboardReturnType;
  14997. /** !#en Set the input flags that are to be applied to the EditBox.
  14998. !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */
  14999. inputFlag: EditBox.InputFlag;
  15000. /** !#en
  15001. Set the input mode of the edit box.
  15002. If you pass ANY, it will create a multiline EditBox.
  15003. !#zh
  15004. 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */
  15005. inputMode: EditBox.InputMode;
  15006. /** !#en Font size of the input text. This property will be removed in the future, use editBox.textLabel.fontSize instead please.
  15007. !#zh 输入框文本的字体大小。 该属性会在将来的版本中移除,请使用 editBox.textLabel.fontSize。 */
  15008. fontSize: number;
  15009. /** !#en Change the lineHeight of displayed text. This property will be removed in the future, use editBox.textLabel.lineHeight instead.
  15010. !#zh 输入框文本的行高。该属性会在将来的版本中移除,请使用 editBox.textLabel.lineHeight */
  15011. lineHeight: number;
  15012. /** !#en Font color of the input text. This property will be removed in the future, use editBox.textLabel.node.color instead.
  15013. !#zh 输入框文本的颜色。该属性会在将来的版本中移除,请使用 editBox.textLabel.node.color */
  15014. fontColor: Color;
  15015. /** !#en The display text of placeholder.
  15016. !#zh 输入框占位符的文本内容。 */
  15017. placeholder: string;
  15018. /** !#en The font size of placeholder. This property will be removed in the future, use editBox.placeholderLabel.fontSize instead.
  15019. !#zh 输入框占位符的字体大小。该属性会在将来的版本中移除,请使用 editBox.placeholderLabel.fontSize */
  15020. placeholderFontSize: number;
  15021. /** !#en The font color of placeholder. This property will be removed in the future, use editBox.placeholderLabel.node.color instead.
  15022. !#zh 输入框占位符的字体颜色。该属性会在将来的版本中移除,请使用 editBox.placeholderLabel.node.color */
  15023. placeholderFontColor: Color;
  15024. /** !#en The maximize input length of EditBox.
  15025. - If pass a value less than 0, it won't limit the input number of characters.
  15026. - If pass 0, it doesn't allow input any characters.
  15027. !#zh 输入框最大允许输入的字符个数。
  15028. - 如果值为小于 0 的值,则不会限制输入字符个数。
  15029. - 如果值为 0,则不允许用户进行任何输入。 */
  15030. maxLength: number;
  15031. /** !#en The input is always visible and be on top of the game view (only useful on Web), this property will be removed on v2.1
  15032. !zh 输入框总是可见,并且永远在游戏视图的上面(这个属性只有在 Web 上面修改有意义),该属性会在 v2.1 中移除
  15033. Note: only available on Web at the moment. */
  15034. stayOnTop: boolean;
  15035. /** !#en Set the tabIndex of the DOM input element (only useful on Web).
  15036. !#zh 修改 DOM 输入元素的 tabIndex(这个属性只有在 Web 上面修改有意义)。 */
  15037. tabIndex: number;
  15038. /** !#en The event handler to be called when EditBox began to edit text.
  15039. !#zh 开始编辑文本输入框触发的事件回调。 */
  15040. editingDidBegan: Component.EventHandler[];
  15041. /** !#en The event handler to be called when EditBox text changes.
  15042. !#zh 编辑文本输入框时触发的事件回调。 */
  15043. textChanged: Component.EventHandler[];
  15044. /** !#en The event handler to be called when EditBox edit ends.
  15045. !#zh 结束编辑文本输入框时触发的事件回调。 */
  15046. editingDidEnded: Component.EventHandler[];
  15047. /** !#en The event handler to be called when return key is pressed. Windows is not supported.
  15048. !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */
  15049. editingReturn: Component.EventHandler[];
  15050. /**
  15051. !#en Let the EditBox get focus, this method will be removed on v2.1
  15052. !#zh 让当前 EditBox 获得焦点, 这个方法会在 v2.1 中移除
  15053. */
  15054. setFocus(): void;
  15055. /**
  15056. !#en Let the EditBox get focus
  15057. !#zh 让当前 EditBox 获得焦点
  15058. */
  15059. focus(): void;
  15060. /**
  15061. !#en Let the EditBox lose focus
  15062. !#zh 让当前 EditBox 失去焦点
  15063. */
  15064. blur(): void;
  15065. /**
  15066. !#en Determine whether EditBox is getting focus or not.
  15067. !#zh 判断 EditBox 是否获得了焦点
  15068. */
  15069. isFocused(): void;
  15070. /**
  15071. !#en if you don't need the EditBox and it isn't in any running Scene, you should
  15072. call the destroy method on this component or the associated node explicitly.
  15073. Otherwise, the created DOM element won't be removed from web page.
  15074. !#zh
  15075. 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  15076. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  15077. @example
  15078. ```js
  15079. editbox.node.parent = null; // or editbox.node.removeFromParent(false);
  15080. // when you don't need editbox anymore
  15081. editbox.node.destroy();
  15082. ```
  15083. */
  15084. destroy(): boolean;
  15085. }
  15086. /** undefined */
  15087. export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle {
  15088. /** !#en Position offset
  15089. !#zh 位置偏移量 */
  15090. offset: Vec2;
  15091. /** !#en Circle radius
  15092. !#zh 圆形半径 */
  15093. radius: number;
  15094. }
  15095. /** undefined */
  15096. export class PhysicsChainCollider extends PolygonCollider {
  15097. /** !#en Whether the chain is loop
  15098. !#zh 链条是否首尾相连 */
  15099. loop: boolean;
  15100. /** !#en Chain points
  15101. !#zh 链条顶点数组 */
  15102. points: Vec2[];
  15103. }
  15104. /** undefined */
  15105. export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box {
  15106. /** !#en Position offset
  15107. !#zh 位置偏移量 */
  15108. offset: Vec2;
  15109. /** !#en Box size
  15110. !#zh 包围盒大小 */
  15111. size: Size;
  15112. }
  15113. /** undefined */
  15114. export class PhysicsCollider extends Collider {
  15115. /** !#en
  15116. The density.
  15117. !#zh
  15118. 密度 */
  15119. density: number;
  15120. /** !#en
  15121. A sensor collider collects contact information but never generates a collision response
  15122. !#zh
  15123. 一个传感器类型的碰撞体会产生碰撞回调,但是不会发生物理碰撞效果。 */
  15124. sensor: boolean;
  15125. /** !#en
  15126. The friction coefficient, usually in the range [0,1].
  15127. !#zh
  15128. 摩擦系数,取值一般在 [0, 1] 之间 */
  15129. friction: number;
  15130. /** !#en
  15131. The restitution (elasticity) usually in the range [0,1].
  15132. !#zh
  15133. 弹性系数,取值一般在 [0, 1]之间 */
  15134. restitution: number;
  15135. /** !#en
  15136. Physics collider will find the rigidbody component on the node and set to this property.
  15137. !#zh
  15138. 碰撞体会在初始化时查找节点上是否存在刚体,如果查找成功则赋值到这个属性上。 */
  15139. body: RigidBody;
  15140. /**
  15141. !#en
  15142. Apply current changes to collider, this will regenerate inner box2d fixtures.
  15143. !#zh
  15144. 应用当前 collider 中的修改,调用此函数会重新生成内部 box2d 的夹具。
  15145. */
  15146. apply(): void;
  15147. /**
  15148. !#en
  15149. Get the world aabb of the collider
  15150. !#zh
  15151. 获取碰撞体的世界坐标系下的包围盒
  15152. */
  15153. getAABB(): void;
  15154. }
  15155. /** undefined */
  15156. export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon {
  15157. /** !#en Position offset
  15158. !#zh 位置偏移量 */
  15159. offset: Vec2;
  15160. /** !#en Polygon points
  15161. !#zh 多边形顶点数组 */
  15162. points: Vec2[];
  15163. }
  15164. /** !#en
  15165. A distance joint constrains two points on two bodies
  15166. to remain at a fixed distance from each other. You can view
  15167. this as a massless, rigid rod.
  15168. !#zh
  15169. 距离关节通过一个固定的长度来约束关节链接的两个刚体。你可以将它想象成一个无质量,坚固的木棍。 */
  15170. export class DistanceJoint extends Joint {
  15171. /** !#en
  15172. The distance separating the two ends of the joint.
  15173. !#zh
  15174. 关节两端的距离 */
  15175. distance: number;
  15176. /** !#en
  15177. The spring frequency.
  15178. !#zh
  15179. 弹性系数。 */
  15180. frequency: number;
  15181. /** !#en
  15182. The damping ratio.
  15183. !#zh
  15184. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  15185. dampingRatio: number;
  15186. }
  15187. /** !#en
  15188. A motor joint is used to control the relative motion
  15189. between two bodies. A typical usage is to control the movement
  15190. of a dynamic body with respect to the ground.
  15191. !#zh
  15192. 马达关节被用来控制两个刚体间的相对运动。
  15193. 一个典型的例子是用来控制一个动态刚体相对于地面的运动。 */
  15194. export class MotorJoint extends Joint {
  15195. /** !#en
  15196. The anchor of the rigidbody.
  15197. !#zh
  15198. 刚体的锚点。 */
  15199. anchor: Vec2;
  15200. /** !#en
  15201. The anchor of the connected rigidbody.
  15202. !#zh
  15203. 关节另一端刚体的锚点。 */
  15204. connectedAnchor: Vec2;
  15205. /** !#en
  15206. The linear offset from connected rigidbody to rigidbody.
  15207. !#zh
  15208. 关节另一端的刚体相对于起始端刚体的位置偏移量 */
  15209. linearOffset: Vec2;
  15210. /** !#en
  15211. The angular offset from connected rigidbody to rigidbody.
  15212. !#zh
  15213. 关节另一端的刚体相对于起始端刚体的角度偏移量 */
  15214. angularOffset: number;
  15215. /** !#en
  15216. The maximum force can be applied to rigidbody.
  15217. !#zh
  15218. 可以应用于刚体的最大的力值 */
  15219. maxForce: number;
  15220. /** !#en
  15221. The maximum torque can be applied to rigidbody.
  15222. !#zh
  15223. 可以应用于刚体的最大扭矩值 */
  15224. maxTorque: number;
  15225. /** !#en
  15226. The position correction factor in the range [0,1].
  15227. !#zh
  15228. 位置矫正系数,范围为 [0, 1] */
  15229. correctionFactor: number;
  15230. }
  15231. /** !#en
  15232. Base class for joints to connect rigidbody.
  15233. !#zh
  15234. 关节类的基类 */
  15235. export class Joint extends Component {
  15236. /** !#en
  15237. The anchor of the rigidbody.
  15238. !#zh
  15239. 刚体的锚点。 */
  15240. anchor: Vec2;
  15241. /** !#en
  15242. The anchor of the connected rigidbody.
  15243. !#zh
  15244. 关节另一端刚体的锚点。 */
  15245. connectedAnchor: Vec2;
  15246. /** !#en
  15247. The rigidbody to which the other end of the joint is attached.
  15248. !#zh
  15249. 关节另一端链接的刚体 */
  15250. connectedBody: RigidBody;
  15251. /** !#en
  15252. Should the two rigid bodies connected with this joint collide with each other?
  15253. !#zh
  15254. 链接到关节上的两个刚体是否应该相互碰撞? */
  15255. collideConnected: boolean;
  15256. /**
  15257. !#en
  15258. Apply current changes to joint, this will regenerate inner box2d joint.
  15259. !#zh
  15260. 应用当前关节中的修改,调用此函数会重新生成内部 box2d 的关节。
  15261. */
  15262. apply(): void;
  15263. /**
  15264. !#en
  15265. Get the anchor point on rigidbody in world coordinates.
  15266. !#zh
  15267. 获取刚体世界坐标系下的锚点。
  15268. */
  15269. getWorldAnchor(): Vec2;
  15270. /**
  15271. !#en
  15272. Get the anchor point on connected rigidbody in world coordinates.
  15273. !#zh
  15274. 获取链接刚体世界坐标系下的锚点。
  15275. */
  15276. getWorldConnectedAnchor(): Vec2;
  15277. /**
  15278. !#en
  15279. Gets the reaction force of the joint.
  15280. !#zh
  15281. 获取关节的反作用力。
  15282. @param timeStep The time to calculate the reaction force for.
  15283. */
  15284. getReactionForce(timeStep: number): Vec2;
  15285. /**
  15286. !#en
  15287. Gets the reaction torque of the joint.
  15288. !#zh
  15289. 获取关节的反扭矩。
  15290. @param timeStep The time to calculate the reaction torque for.
  15291. */
  15292. getReactionTorque(timeStep: number): number;
  15293. }
  15294. /** !#en
  15295. A mouse joint is used to make a point on a body track a
  15296. specified world point. This a soft constraint with a maximum
  15297. force. This allows the constraint to stretch and without
  15298. applying huge forces.
  15299. Mouse Joint will auto register the touch event with the mouse region node,
  15300. and move the choosed rigidbody in touch move event.
  15301. Note : generally mouse joint only used in test bed.
  15302. !#zh
  15303. 鼠标关节用于使刚体上的一个点追踪一个指定的世界坐标系下的位置。
  15304. 鼠标关节可以指定一个最大的力来施加一个柔和的约束。
  15305. 鼠标关节会自动使用 mouse region 节点来注册鼠标事件,并且在触摸移动事件中移动选中的刚体。
  15306. 注意:一般鼠标关节只在测试环境中使用。 */
  15307. export class MouseJoint extends Joint {
  15308. /** !#en
  15309. The anchor of the rigidbody.
  15310. !#zh
  15311. 刚体的锚点。 */
  15312. anchor: Vec2;
  15313. /** !#en
  15314. The anchor of the connected rigidbody.
  15315. !#zh
  15316. 关节另一端刚体的锚点。 */
  15317. connectedAnchor: Vec2;
  15318. /** !#en
  15319. The node used to register touch evnet.
  15320. If this is null, it will be the joint's node.
  15321. !#zh
  15322. 用于注册触摸事件的节点。
  15323. 如果没有设置这个值,那么将会使用关节的节点来注册事件。 */
  15324. mouseRegion: Node;
  15325. /** !#en
  15326. The target point.
  15327. The mouse joint will move choosed rigidbody to target point.
  15328. !#zh
  15329. 目标点,鼠标关节将会移动选中的刚体到指定的目标点 */
  15330. target: Vec2;
  15331. /** !#en
  15332. The spring frequency.
  15333. !#zh
  15334. 弹簧系数。 */
  15335. frequency: number;
  15336. /** !#en
  15337. The damping ratio.
  15338. !#zh
  15339. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  15340. 0: number;
  15341. /** !#en
  15342. The maximum force
  15343. !#zh
  15344. 最大阻力值 */
  15345. maxForce: number;
  15346. }
  15347. /** !#en
  15348. A prismatic joint. This joint provides one degree of freedom: translation
  15349. along an axis fixed in rigidbody. Relative rotation is prevented. You can
  15350. use a joint limit to restrict the range of motion and a joint motor to
  15351. drive the motion or to model joint friction.
  15352. !#zh
  15353. 移动关节指定了只能在一个方向上移动刚体。
  15354. 你可以开启关节限制来设置刚体运行移动的间距,也可以开启马达来使用关节马达驱动刚体的运行。 */
  15355. export class PrismaticJoint extends Joint {
  15356. /** !#en
  15357. The local joint axis relative to rigidbody.
  15358. !#zh
  15359. 指定刚体可以移动的方向。 */
  15360. localAxisA: Vec2;
  15361. /** !#en
  15362. The reference angle.
  15363. !#zh
  15364. 相对角度 */
  15365. referenceAngle: number;
  15366. /** !#en
  15367. Enable joint distance limit?
  15368. !#zh
  15369. 是否开启关节的距离限制? */
  15370. enableLimit: boolean;
  15371. /** !#en
  15372. Enable joint motor?
  15373. !#zh
  15374. 是否开启关节马达? */
  15375. enableMotor: boolean;
  15376. /** !#en
  15377. The lower joint limit.
  15378. !#zh
  15379. 刚体能够移动的最小值 */
  15380. lowerLimit: number;
  15381. /** !#en
  15382. The upper joint limit.
  15383. !#zh
  15384. 刚体能够移动的最大值 */
  15385. upperLimit: number;
  15386. /** !#en
  15387. The maxium force can be applied to rigidbody to rearch the target motor speed.
  15388. !#zh
  15389. 可以施加到刚体的最大力。 */
  15390. maxMotorForce: number;
  15391. /** !#en
  15392. The expected motor speed.
  15393. !#zh
  15394. 期望的马达速度。 */
  15395. motorSpeed: number;
  15396. }
  15397. /** !#en
  15398. A revolute joint constrains two bodies to share a common point while they
  15399. are free to rotate about the point. The relative rotation about the shared
  15400. point is the joint angle. You can limit the relative rotation with
  15401. a joint limit that specifies a lower and upper angle. You can use a motor
  15402. to drive the relative rotation about the shared point. A maximum motor torque
  15403. is provided so that infinite forces are not generated.
  15404. !#zh
  15405. 旋转关节可以约束两个刚体围绕一个点来进行旋转。
  15406. 你可以通过开启关节限制来限制旋转的最大角度和最小角度。
  15407. 你可以通过开启马达来施加一个扭矩力来驱动这两个刚体在这一点上的相对速度。 */
  15408. export class RevoluteJoint extends Joint {
  15409. /** !#en
  15410. The reference angle.
  15411. An angle between bodies considered to be zero for the joint angle.
  15412. !#zh
  15413. 相对角度。
  15414. 两个物体之间角度为零时可以看作相等于关节角度 */
  15415. referenceAngle: number;
  15416. /** !#en
  15417. The lower angle.
  15418. !#zh
  15419. 角度的最低限制。 */
  15420. lowerAngle: number;
  15421. /** !#en
  15422. The upper angle.
  15423. !#zh
  15424. 角度的最高限制。 */
  15425. upperAngle: number;
  15426. /** !#en
  15427. The maxium torque can be applied to rigidbody to rearch the target motor speed.
  15428. !#zh
  15429. 可以施加到刚体的最大扭矩。 */
  15430. maxMotorTorque: number;
  15431. /** !#en
  15432. The expected motor speed.
  15433. !#zh
  15434. 期望的马达速度。 */
  15435. motorSpeed: number;
  15436. /** !#en
  15437. Enable joint limit?
  15438. !#zh
  15439. 是否开启关节的限制? */
  15440. enableLimit: boolean;
  15441. /** !#en
  15442. Enable joint motor?
  15443. !#zh
  15444. 是否开启关节马达? */
  15445. enableMotor: boolean;
  15446. /**
  15447. !#en
  15448. Get the joint angle.
  15449. !#zh
  15450. 获取关节角度。
  15451. */
  15452. getJointAngle(): number;
  15453. }
  15454. /** !#en
  15455. A rope joint enforces a maximum distance between two points
  15456. on two bodies. It has no other effect.
  15457. Warning: if you attempt to change the maximum length during
  15458. the simulation you will get some non-physical behavior.
  15459. !#zh
  15460. 绳子关节只指定两个刚体间的最大距离,没有其他的效果。
  15461. 注意:如果你试图动态修改关节的长度,这有可能会得到一些意外的效果。 */
  15462. export class RopeJoint extends Joint {
  15463. /** !#en
  15464. The max length.
  15465. !#zh
  15466. 最大长度。 */
  15467. maxLength: number;
  15468. }
  15469. /** !#en
  15470. A wheel joint. This joint provides two degrees of freedom: translation
  15471. along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive
  15472. the rotation or to model rotational friction.
  15473. This joint is designed for vehicle suspensions.
  15474. !#zh
  15475. 轮子关节提供两个维度的自由度:旋转和沿着指定方向上位置的移动。
  15476. 你可以通过开启关节马达来使用马达驱动刚体的旋转。
  15477. 轮组关节是专门为机动车类型设计的。 */
  15478. export class WheelJoint extends Joint {
  15479. /** !#en
  15480. The local joint axis relative to rigidbody.
  15481. !#zh
  15482. 指定刚体可以移动的方向。 */
  15483. localAxisA: Vec2;
  15484. /** !#en
  15485. The maxium torque can be applied to rigidbody to rearch the target motor speed.
  15486. !#zh
  15487. 可以施加到刚体的最大扭矩。 */
  15488. maxMotorTorque: number;
  15489. /** !#en
  15490. The expected motor speed.
  15491. !#zh
  15492. 期望的马达速度。 */
  15493. motorSpeed: number;
  15494. /** !#en
  15495. Enable joint motor?
  15496. !#zh
  15497. 是否开启关节马达? */
  15498. enableMotor: boolean;
  15499. /** !#en
  15500. The spring frequency.
  15501. !#zh
  15502. 弹性系数。 */
  15503. frequency: number;
  15504. /** !#en
  15505. The damping ratio.
  15506. !#zh
  15507. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  15508. dampingRatio: number;
  15509. }
  15510. /** !#en
  15511. A weld joint essentially glues two bodies together. A weld joint may
  15512. distort somewhat because the island constraint solver is approximate.
  15513. !#zh
  15514. 熔接关节相当于将两个刚体粘在了一起。
  15515. 熔接关节可能会使某些东西失真,因为约束求解器算出的都是近似值。 */
  15516. export class WeldJoint extends Joint {
  15517. /** !#en
  15518. The reference angle.
  15519. !#zh
  15520. 相对角度。 */
  15521. referenceAngle: number;
  15522. /** !#en
  15523. The frequency.
  15524. !#zh
  15525. 弹性系数。 */
  15526. frequency: number;
  15527. /** !#en
  15528. The damping ratio.
  15529. !#zh
  15530. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  15531. dampingRatio: number;
  15532. }
  15533. /** !#en Effect Asset.
  15534. !#zh Effect 资源类型。 */
  15535. export class EffectAsset extends Asset {
  15536. }
  15537. /** !#en Material Asset.
  15538. !#zh 材质资源类。 */
  15539. export class Material extends Asset {
  15540. /**
  15541. !#en Get built-in materials
  15542. !#zh 获取内置材质
  15543. @param name name
  15544. */
  15545. static getBuiltinMaterial(name: string): Material;
  15546. /**
  15547. !#en Creates a Material with builtin Effect.
  15548. !#zh 使用内建 Effect 创建一个材质。
  15549. @param effectName effectName
  15550. @param techniqueIndex techniqueIndex
  15551. */
  15552. static createWithBuiltin(effectName: string, techniqueIndex?: number): Material;
  15553. /**
  15554. !#en Creates a Material.
  15555. !#zh 创建一个材质。
  15556. @param effectAsset effectAsset
  15557. @param techniqueIndex techniqueIndex
  15558. */
  15559. static create(effectAsset: EffectAsset, techniqueIndex?: number): Material;
  15560. /**
  15561. !#en Sets the Material property
  15562. !#zh 设置材质的属性
  15563. @param name name
  15564. @param val val
  15565. @param passIdx passIdx
  15566. @param directly directly
  15567. */
  15568. setProperty(name: string, val: any, passIdx?: number, directly?: boolean): void;
  15569. /**
  15570. !#en Gets the Material property.
  15571. !#zh 获取材质的属性。
  15572. @param name name
  15573. @param passIdx passIdx
  15574. */
  15575. getProperty(name: string, passIdx: number): any;
  15576. /**
  15577. !#en Sets the Material define.
  15578. !#zh 设置材质的宏定义。
  15579. @param name name
  15580. @param val val
  15581. @param passIdx passIdx
  15582. @param force force
  15583. */
  15584. define(name: string, val: boolean|number, passIdx?: number, force?: boolean): void;
  15585. /**
  15586. !#en Gets the Material define.
  15587. !#zh 获取材质的宏定义。
  15588. @param name name
  15589. @param passIdx passIdx
  15590. */
  15591. getDefine(name: string, passIdx?: number): boolean;
  15592. /**
  15593. !#en Sets the Material cull mode.
  15594. !#zh 设置材质的裁减模式。
  15595. @param cullMode cullMode
  15596. @param passIdx passIdx
  15597. */
  15598. setCullMode(cullMode: number, passIdx: number): void;
  15599. /**
  15600. !#en Sets the Material depth states.
  15601. !#zh 设置材质的深度渲染状态。
  15602. @param depthTest depthTest
  15603. @param depthWrite depthWrite
  15604. @param depthFunc depthFunc
  15605. @param passIdx passIdx
  15606. */
  15607. setDepth(depthTest: boolean, depthWrite: boolean, depthFunc: number, passIdx: number): void;
  15608. /**
  15609. !#en Sets the Material blend states.
  15610. !#zh 设置材质的混合渲染状态。
  15611. @param enabled enabled
  15612. @param blendEq blendEq
  15613. @param blendSrc blendSrc
  15614. @param blendDst blendDst
  15615. @param blendAlphaEq blendAlphaEq
  15616. @param blendSrcAlpha blendSrcAlpha
  15617. @param blendDstAlpha blendDstAlpha
  15618. @param blendColor blendColor
  15619. @param passIdx passIdx
  15620. */
  15621. setBlend(enabled: boolean, blendEq: number, blendSrc: number, blendDst: number, blendAlphaEq: number, blendSrcAlpha: number, blendDstAlpha: number, blendColor: number, passIdx: number): void;
  15622. /**
  15623. !#en Sets whether enable the stencil test.
  15624. !#zh 设置是否开启模板测试。
  15625. @param stencilTest stencilTest
  15626. @param passIdx passIdx
  15627. */
  15628. setStencilEnabled(stencilTest: number, passIdx: number): void;
  15629. /**
  15630. !#en Sets the Material stencil render states.
  15631. !#zh 设置材质的模板测试渲染参数。
  15632. @param stencilTest stencilTest
  15633. @param stencilFunc stencilFunc
  15634. @param stencilRef stencilRef
  15635. @param stencilMask stencilMask
  15636. @param stencilFailOp stencilFailOp
  15637. @param stencilZFailOp stencilZFailOp
  15638. @param stencilZPassOp stencilZPassOp
  15639. @param stencilWriteMask stencilWriteMask
  15640. @param passIdx passIdx
  15641. */
  15642. setStencil(stencilTest: number, stencilFunc: number, stencilRef: number, stencilMask: number, stencilFailOp: number, stencilZFailOp: number, stencilZPassOp: number, stencilWriteMask: number, passIdx: number): void;
  15643. }
  15644. /** !#en
  15645. Material Variant is an extension of the Material Asset.
  15646. Changes to Material Variant do not affect other Material Variant or Material Asset,
  15647. and changes to Material Asset are synchronized to the Material Variant.
  15648. However, when a Material Variant had already modifies a state, the Material Asset state is not synchronized to the Material Variant.
  15649. !#zh
  15650. 材质变体是材质资源的一个延伸。
  15651. 材质变体的修改不会影响到其他的材质变体或者材质资源,而材质资源的修改会同步体现到材质变体上,
  15652. 但是当材质变体对一个状态修改后,材质资源再对这个状态修改是不会同步到材质变体上的。 */
  15653. export class MaterialVariant extends Material {
  15654. /**
  15655. @param materialName materialName
  15656. @param owner owner
  15657. */
  15658. static createWithBuiltin (materialName: string, owner: cc.RenderComponent): MaterialVariant | null;
  15659. /**
  15660. @param material material
  15661. @param owner owner
  15662. */
  15663. static create (material: Material, owner: cc.RenderComponent): MaterialVariant | null;
  15664. }
  15665. /** !#en The trail module of 3d particle.
  15666. !#zh 3D 粒子拖尾模块 */
  15667. export class TrailModule {
  15668. /** !#en The enable of trailModule.
  15669. !#zh 是否启用 */
  15670. enable: boolean;
  15671. /** !#en Sets how particles generate trajectories.
  15672. !#zh 设定粒子生成轨迹的方式。 */
  15673. mode: trailModule.TrailMode;
  15674. /** !#en Life cycle of trajectory.
  15675. !#zh 轨迹存在的生命周期。 */
  15676. lifeTime: CurveRange;
  15677. /** !#en Minimum spacing between each track particle
  15678. !#zh 每个轨迹粒子之间的最小间距。 */
  15679. minParticleDistance: number;
  15680. /** !#en The coordinate system of trajectories.
  15681. !#zh 轨迹设定时的坐标系。 */
  15682. space: ParticleSystem3DAssembler.Space;
  15683. /** !#en Whether the particle itself exists.
  15684. !#zh 粒子本身是否存在。 */
  15685. existWithParticles: boolean;
  15686. /** !#en Set the texture fill method
  15687. !#zh 设定纹理填充方式。 */
  15688. textureMode: trailModule.TextureMode;
  15689. /** !#en Whether to use particle width
  15690. !#zh 是否使用粒子的宽度。 */
  15691. widthFromParticle: boolean;
  15692. /** !#en Curves that control track length
  15693. !#zh 控制轨迹长度的曲线。 */
  15694. widthRatio: CurveRange;
  15695. /** !#en Whether to use particle color
  15696. !#zh 是否使用粒子的颜色。 */
  15697. colorFromParticle: boolean;
  15698. /** !#en The color of trajectories.
  15699. !#zh 轨迹的颜色。 */
  15700. colorOverTrail: GradientRange;
  15701. /** !#en Trajectories color over time.
  15702. !#zh 轨迹随时间变化的颜色。 */
  15703. colorOvertime: GradientRange;
  15704. }
  15705. /** !#en The color over time module of 3d particle.
  15706. !#zh 3D 粒子颜色变化模块 */
  15707. export class ColorOvertimeModule {
  15708. /** !#en The enable of ColorOvertimeModule.
  15709. !#zh 是否启用 */
  15710. enable: boolean;
  15711. }
  15712. /** !#en The curve range of target value.
  15713. !#zh 目标值的曲线范围 */
  15714. export class CurveRange {
  15715. /** !#en Curve type.
  15716. !#zh 曲线类型。 */
  15717. mode: debug.DebugMode;
  15718. /** !#en The curve to use when mode is Curve.
  15719. !#zh 当 mode 为 Curve 时,使用的曲线。 */
  15720. curve: AnimationCurve;
  15721. /** !#en The lower limit of the curve to use when mode is TwoCurves
  15722. !#zh 当 mode 为 TwoCurves 时,使用的曲线下限。 */
  15723. curveMin: AnimationCurve;
  15724. /** !#en The upper limit of the curve to use when mode is TwoCurves
  15725. !#zh 当 mode 为 TwoCurves 时,使用的曲线上限。 */
  15726. curveMax: AnimationCurve;
  15727. /** !#en When mode is Constant, the value of the curve.
  15728. !#zh 当 mode 为 Constant 时,曲线的值。 */
  15729. constant: number;
  15730. /** !#en The lower limit of the curve to use when mode is TwoConstants
  15731. !#zh 当 mode 为 TwoConstants 时,曲线的下限。 */
  15732. constantMin: number;
  15733. /** !#en The upper limit of the curve to use when mode is TwoConstants
  15734. !#zh 当 mode 为 TwoConstants 时,曲线的上限。 */
  15735. constantMax: number;
  15736. /** !#en Coefficients applied to curve interpolation.
  15737. !#zh 应用于曲线插值的系数。 */
  15738. multiplier: number;
  15739. }
  15740. /** !#en The force over time module of 3d particle.
  15741. !#zh 3D 粒子的加速度模块 */
  15742. export class ForceOvertimeModule {
  15743. /** !#en The enable of ColorOvertimeModule.
  15744. !#zh 是否启用 */
  15745. enable: boolean;
  15746. /** !#en Coordinate system used in acceleration calculation.
  15747. !#zh 加速度计算时采用的坐标系。 */
  15748. space: ParticleSystem3DAssembler.Space;
  15749. /** !#en X-axis acceleration component.
  15750. !#zh X 轴方向上的加速度分量。 */
  15751. x: CurveRange;
  15752. /** !#en Y-axis acceleration component.
  15753. !#zh Y 轴方向上的加速度分量。 */
  15754. y: CurveRange;
  15755. /** !#en Z-axis acceleration component.
  15756. !#zh Z 轴方向上的加速度分量。 */
  15757. z: CurveRange;
  15758. }
  15759. /** !#en The gradient range of color.
  15760. !#zh 颜色值的渐变范围 */
  15761. export class GradientRange {
  15762. /** !#en Gradient type.
  15763. !#zh 渐变色类型。 */
  15764. mode: debug.DebugMode;
  15765. /** !#en The color when mode is Color.
  15766. !#zh 当 mode 为 Color 时的颜色。 */
  15767. color: Color;
  15768. /** !#en Lower color limit when mode is TwoColors.
  15769. !#zh 当 mode 为 TwoColors 时的颜色下限。 */
  15770. colorMin: Color;
  15771. /** !#en Upper color limit when mode is TwoColors.
  15772. !#zh 当 mode 为 TwoColors 时的颜色上限。 */
  15773. colorMax: Color;
  15774. /** !#en Color gradient when mode is Gradient
  15775. !#zh 当 mode 为 Gradient 时的颜色渐变。 */
  15776. gradient: Gradient;
  15777. /** !#en Lower color gradient limit when mode is TwoGradients.
  15778. !#zh 当 mode 为 TwoGradients 时的颜色渐变下限。 */
  15779. gradientMin: Gradient;
  15780. /** !#en Upper color gradient limit when mode is TwoGradients.
  15781. !#zh 当 mode 为 TwoGradients 时的颜色渐变上限。 */
  15782. gradientMax: Gradient;
  15783. }
  15784. /** !#en The color key of gradient.
  15785. !#zh color 关键帧 */
  15786. export class ColorKey {
  15787. /** !#en Color value.
  15788. !#zh 颜色值。 */
  15789. color: Color;
  15790. /** !#en Time value.
  15791. !#zh 时间值。 */
  15792. time: number;
  15793. }
  15794. /** !#en The alpha key of gradient.
  15795. !#zh alpha 关键帧 */
  15796. export class AlphaKey {
  15797. /** !#en Alpha value.
  15798. !#zh 透明度。 */
  15799. alpha: number;
  15800. /** !#en Time.
  15801. !#zh 时间帧。 */
  15802. time: number;
  15803. }
  15804. /** !#en The gradient data of color.
  15805. !#zh 颜色渐变数据 */
  15806. export class Gradient {
  15807. /** !#en Array of color key.
  15808. !#zh 颜色关键帧列表。 */
  15809. colorKeys: ColorKey[];
  15810. /** !#en Array of alpha key.
  15811. !#zh 透明度关键帧列表。 */
  15812. alphaKeys: AlphaKey[];
  15813. /** !#en Blend mode.
  15814. !#zh 混合模式。 */
  15815. mode: debug.DebugMode;
  15816. }
  15817. /** !#en The optimized curve.
  15818. !#zh 优化曲线 */
  15819. export class OptimizedCurve {
  15820. }
  15821. /** !#en The rotation module of 3d particle.
  15822. !#zh 3D 粒子的旋转模块 */
  15823. export class RotationOvertimeModule {
  15824. /** !#en The enable of RotationOvertimeModule.
  15825. !#zh 是否启用 */
  15826. enable: boolean;
  15827. /** !#en Whether to set the rotation of three axes separately (not currently supported)
  15828. !#zh 是否三个轴分开设定旋转(暂不支持)。 */
  15829. separateAxes: boolean;
  15830. /** !#en Set rotation around X axis.
  15831. !#zh 绕 X 轴设定旋转。 */
  15832. x: CurveRange;
  15833. /** !#en Set rotation around Y axis.
  15834. !#zh 绕 Y 轴设定旋转。 */
  15835. y: CurveRange;
  15836. /** !#en Set rotation around Z axis.
  15837. !#zh 绕 Z 轴设定旋转。 */
  15838. z: CurveRange;
  15839. }
  15840. /** !#en The size module of 3d particle.
  15841. !#zh 3D 粒子的大小模块 */
  15842. export class SizeOvertimeModule {
  15843. /** !#en The enable of SizeOvertimeModule.
  15844. !#zh 是否启用 */
  15845. enable: boolean;
  15846. /** !#en Decide whether to control particle size independently on each axis.
  15847. !#zh 决定是否在每个轴上独立控制粒子大小。 */
  15848. separateAxes: boolean;
  15849. /** !#en Define a curve to determine the size change of particles during their life cycle.
  15850. !#zh 定义一条曲线来决定粒子在其生命周期中的大小变化。 */
  15851. size: CurveRange;
  15852. /** !#en Defines a curve to determine the size change of particles in the X-axis direction during their life cycle.
  15853. !#zh 定义一条曲线来决定粒子在其生命周期中 X 轴方向上的大小变化。 */
  15854. x: CurveRange;
  15855. /** !#en Defines a curve to determine the size change of particles in the Y-axis direction during their life cycle.
  15856. !#zh 定义一条曲线来决定粒子在其生命周期中 Y 轴方向上的大小变化。 */
  15857. y: CurveRange;
  15858. /** !#en Defines a curve to determine the size change of particles in the Z-axis direction during their life cycle.
  15859. !#zh 定义一条曲线来决定粒子在其生命周期中 Z 轴方向上的大小变化。 */
  15860. z: CurveRange;
  15861. }
  15862. /** !#en The texture animation module of 3d particle.
  15863. !#zh 3D 粒子的贴图动画模块 */
  15864. export class TextureAnimationModule {
  15865. /** !#en The enable of TextureAnimationModule.
  15866. !#zh 是否启用 */
  15867. enable: boolean;
  15868. /** !#en Set the type of particle map animation (only supports Grid mode for the time being)
  15869. !#zh 设定粒子贴图动画的类型(暂只支持 Grid 模式。 */
  15870. mode: debug.DebugMode;
  15871. /** !#en Animation frames in X direction.
  15872. !#zh X 方向动画帧数。 */
  15873. numTilesX: number;
  15874. /** !#en Animation frames in Y direction.
  15875. !#zh Y 方向动画帧数。 */
  15876. numTilesY: number;
  15877. /** !#en The way of the animation plays.
  15878. !#zh 动画播放方式。 */
  15879. animation: Animation;
  15880. /** !#en Randomly select a line from the animated map to generate the animation. <br>
  15881. This option only takes effect when the animation playback mode is SingleRow.
  15882. !#zh 随机从动画贴图中选择一行以生成动画。<br>
  15883. 此选项仅在动画播放方式为 SingleRow 时生效。 */
  15884. randomRow: boolean;
  15885. /** !#en Select specific lines from the animation map to generate the animation. <br>
  15886. This option is only available when the animation playback mode is SingleRow and randomRow is disabled.
  15887. !#zh 从动画贴图中选择特定行以生成动画。<br>
  15888. 此选项仅在动画播放方式为 SingleRow 时且禁用 randomRow 时可用。 */
  15889. rowIndex: number;
  15890. /** !#en Frame and time curve of animation playback in one cycle.
  15891. !#zh 一个周期内动画播放的帧与时间变化曲线。 */
  15892. frameOverTime: CurveRange;
  15893. /** !#en Play from which frames, the time is the life cycle of the entire particle system.
  15894. !#zh 从第几帧开始播放,时间为整个粒子系统的生命周期。 */
  15895. startFrame: CurveRange;
  15896. /** !#en Number of playback loops in a life cycle.
  15897. !#zh 一个生命周期内播放循环的次数。 */
  15898. cycleCount: number;
  15899. }
  15900. /** !#en The velocity module of 3d particle.
  15901. !#zh 3D 粒子的速度模块 */
  15902. export class VelocityOvertimeModule {
  15903. /** !#en The enable of VelocityOvertimeModule.
  15904. !#zh 是否启用 */
  15905. enable: boolean;
  15906. /** !#en Coordinate system used in speed calculation.
  15907. !#zh 速度计算时采用的坐标系。 */
  15908. space: ParticleSystem3DAssembler.Space;
  15909. /** !#en Velocity component in X axis direction
  15910. !#zh X 轴方向上的速度分量。 */
  15911. x: CurveRange;
  15912. /** !#en Velocity component in Y axis direction
  15913. !#zh Y 轴方向上的速度分量。 */
  15914. y: CurveRange;
  15915. /** !#en Velocity component in Z axis direction
  15916. !#zh Z 轴方向上的速度分量。 */
  15917. z: CurveRange;
  15918. /** !#en Speed correction factor (only supports CPU particles).
  15919. !#zh 速度修正系数(只支持 CPU 粒子)。 */
  15920. speedModifier: CurveRange;
  15921. }
  15922. /** !#en The limit velocity module of 3d particle.
  15923. !#zh 3D 粒子的限速模块 */
  15924. export class LimitVelocityOvertimeModule {
  15925. /** !#en The enable of LimitVelocityOvertimeModule.
  15926. !#zh 是否启用 */
  15927. enable: boolean;
  15928. /** !#en The coordinate system used when calculating the lower speed limit.
  15929. !#zh 计算速度下限时采用的坐标系。 */
  15930. space: ParticleSystem3DAssembler.Space;
  15931. /** !#en Whether to limit the three axes separately.
  15932. !#zh 是否三个轴分开限制。 */
  15933. separateAxes: boolean;
  15934. /** !#en Lower speed limit
  15935. !#zh 速度下限。 */
  15936. limit: CurveRange;
  15937. /** !#en Lower speed limit in X direction.
  15938. !#zh X 轴方向上的速度下限。 */
  15939. limitX: CurveRange;
  15940. /** !#en Lower speed limit in Y direction.
  15941. !#zh Y 轴方向上的速度下限。 */
  15942. limitY: CurveRange;
  15943. /** !#en Lower speed limit in Z direction.
  15944. !#zh Z 轴方向上的速度下限。 */
  15945. limitZ: CurveRange;
  15946. /** !#en Interpolation of current speed and lower speed limit.
  15947. !#zh 当前速度与速度下限的插值。 */
  15948. dampen: number;
  15949. }
  15950. /** !#en The shape module of 3d particle.
  15951. !#zh 3D 粒子的发射形状模块 */
  15952. export class ShapeModule {
  15953. /** !#en The enable of shapeModule.
  15954. !#zh 是否启用 */
  15955. enable: boolean;
  15956. /** !#en Particle emitter type.
  15957. !#zh 粒子发射器类型。 */
  15958. shapeType: shapeModule.ShapeType;
  15959. /** !#en The emission site of the particle.
  15960. !#zh 粒子从发射器哪个部位发射。 */
  15961. emitFrom: shapeModule.EmitLocation;
  15962. /** !#en Particle emitter radius.
  15963. !#zh 粒子发射器半径。 */
  15964. radius: number;
  15965. /** !#en Particle emitter emission position (not valid for Box type emitters):<bg>
  15966. - 0 means emitted from the surface;
  15967. - 1 means launch from the center;
  15968. - 0 ~ 1 indicates emission from the center to the surface.
  15969. !#zh 粒子发射器发射位置(对 Box 类型的发射器无效):<bg>
  15970. - 0 表示从表面发射;
  15971. - 1 表示从中心发射;
  15972. - 0 ~ 1 之间表示在中心到表面之间发射。 */
  15973. radiusThickness: number;
  15974. /** !#en The angle between the axis of the cone and the generatrix<bg>
  15975. Determines the opening and closing of the cone launcher
  15976. !#zh 圆锥的轴与母线的夹角<bg>。
  15977. 决定圆锥发射器的开合程度。 */
  15978. angle: number;
  15979. /** !#en Particle emitters emit in a fan-shaped range.
  15980. !#zh 粒子发射器在一个扇形范围内发射。 */
  15981. arc: number;
  15982. /** !#en How particles are emitted in the sector range.
  15983. !#zh 粒子在扇形范围内的发射方式。 */
  15984. arcMode: shapeModule.ArcMode;
  15985. /** !#en Controls the discrete intervals around the arcs where particles might be generated.
  15986. !#zh 控制可能产生粒子的弧周围的离散间隔。 */
  15987. arcSpread: number;
  15988. /** !#en The speed at which particles are emitted around the circumference.
  15989. !#zh 粒子沿圆周发射的速度。 */
  15990. arcSpeed: CurveRange;
  15991. /** !#en Axis length from top of cone to bottom of cone <bg>.
  15992. Determines the height of the cone emitter.
  15993. !#zh 圆锥顶部截面距离底部的轴长<bg>。
  15994. 决定圆锥发射器的高度。 */
  15995. length: number;
  15996. /** !#en Particle emitter emission location (for box-type particle emitters).
  15997. !#zh 粒子发射器发射位置(针对 Box 类型的粒子发射器。 */
  15998. boxThickness: Vec3;
  15999. /** !#en Particle Emitter Position
  16000. !#zh 粒子发射器位置。 */
  16001. position: Vec3;
  16002. /** !#en Particle emitter rotation angle.
  16003. !#zh 粒子发射器旋转角度。 */
  16004. rotation: Vec3;
  16005. /** !#en Particle emitter scaling
  16006. !#zh 粒子发射器缩放比例。 */
  16007. scale: Vec3;
  16008. /** !#en The direction of particle movement is determined based on the initial direction of the particles.
  16009. !#zh 根据粒子的初始方向决定粒子的移动方向。 */
  16010. alignToDirection: boolean;
  16011. /** !#en Set particle generation direction randomly.
  16012. !#zh 粒子生成方向随机设定。 */
  16013. randomDirectionAmount: number;
  16014. /** !#en Interpolation between the current emission direction and the direction from the current position to the center of the node.
  16015. !#zh 表示当前发射方向与当前位置到结点中心连线方向的插值。 */
  16016. sphericalDirectionAmount: number;
  16017. }
  16018. /** !#en The rigid body type
  16019. !#zh 刚体类型 */
  16020. export enum ERigidBodyType {
  16021. DYNAMIC = 0,
  16022. STATIC = 0,
  16023. KINEMATIC = 0,
  16024. }
  16025. /** !#en
  16026. Physical systems manager.
  16027. !#zh
  16028. 物理系统管理器。 */
  16029. export class Physics3DManager {
  16030. /** !#en
  16031. Whether to enable the physics system, default is false.
  16032. !#zh
  16033. 是否启用物理系统,默认不启用。 */
  16034. enabled: boolean;
  16035. /** !#en
  16036. Whether to allow the physics system to automatically hibernate, default is true.
  16037. !#zh
  16038. 物理系统是否允许自动休眠,默认为 true。 */
  16039. allowSleep: boolean;
  16040. /** !#en
  16041. The maximum number of sub-steps a full step is permitted to be broken into, default is 2.
  16042. !#zh
  16043. 物理每帧模拟的最大子步数,默认为 2。 */
  16044. maxSubStep: number;
  16045. /** !#en
  16046. Time spent in each simulation of physics, default is 1/60s.
  16047. !#zh
  16048. 物理每步模拟消耗的固定时间,默认为 1/60 秒。 */
  16049. deltaTime: number;
  16050. /** !#en
  16051. Whether to use a fixed time step.
  16052. !#zh
  16053. 是否使用固定的时间步长。 */
  16054. useFixedTime: boolean;
  16055. /** !#en
  16056. Gravity value of the physics simulation, default is (0, -10, 0).
  16057. !#zh
  16058. 物理世界的重力数值,默认为 (0, -10, 0)。 */
  16059. gravity: Vec3;
  16060. /** !#en
  16061. Gets the global default physical material. Note that builtin is null.
  16062. !#zh
  16063. 获取全局的默认物理材质,注意:builtin 时为 null。 */
  16064. defaultMaterial: PhysicsMaterial|void;
  16065. /**
  16066. !#en
  16067. A physical system simulation is performed once and will now be performed automatically once per frame.
  16068. !#zh
  16069. 执行一次物理系统的模拟,目前将在每帧自动执行一次。
  16070. @param deltaTime The time difference from the last execution is currently elapsed per frame
  16071. */
  16072. update(deltaTime: number): void;
  16073. /**
  16074. !#en Detect all collision boxes and return all detected results, or null if none is detected. Note that the return value is taken from the object pool, so do not save the result reference or modify the result.
  16075. !#zh 检测所有的碰撞盒,并返回所有被检测到的结果,若没有检测到,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。
  16076. @param worldRay A ray in world space
  16077. @param groupIndexOrName Collision group index or group name
  16078. @param maxDistance Maximum detection distance
  16079. @param queryTrigger Detect trigger or not
  16080. */
  16081. raycast(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult[];
  16082. /**
  16083. !#en Detect all collision boxes and return the detection result with the shortest ray distance. If not, return null value. Note that the return value is taken from the object pool, so do not save the result reference or modify the result.
  16084. !#zh 检测所有的碰撞盒,并返回射线距离最短的检测结果,若没有,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。
  16085. @param worldRay A ray in world space
  16086. @param groupIndexOrName Collision group index or group name
  16087. @param maxDistance Maximum detection distance
  16088. @param queryTrigger Detect trigger or not
  16089. */
  16090. raycastClosest(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult;
  16091. }
  16092. /** !#en
  16093. Trigger event
  16094. !#zh
  16095. 触发事件。 */
  16096. export class ITriggerEvent {
  16097. /** !#en
  16098. The type of event fired
  16099. !#zh
  16100. 触发的事件类型 */
  16101. type: string;
  16102. /** !#en
  16103. Triggers its own collider in the event
  16104. !#zh
  16105. 触发事件中的自己的碰撞器 */
  16106. selfCollider: Collider3D;
  16107. /** !#en
  16108. Triggers another collider in the event
  16109. !#zh
  16110. 触发事件中的另一个碰撞器 */
  16111. otherCollider: Collider3D;
  16112. }
  16113. /** !#en
  16114. Collision information for collision events.
  16115. !#zh
  16116. 碰撞事件的碰撞信息。 */
  16117. export class IContactEquation {
  16118. /** !#en
  16119. The collision point A in the collision information.
  16120. !#zh
  16121. 碰撞信息中的碰撞点 A。 */
  16122. contactA: Vec3;
  16123. /** !#en
  16124. Collision point B in collision information.
  16125. !#zh
  16126. 碰撞信息中的碰撞点 B。 */
  16127. contactB: Vec3;
  16128. /** !#en
  16129. Normals in collision information.
  16130. !#zh
  16131. 碰撞信息中的法线。 */
  16132. normal: Vec3;
  16133. }
  16134. /** !#en
  16135. Collision events.
  16136. !#zh
  16137. 碰撞事件。 */
  16138. export class ICollisionEvent {
  16139. /** !#en
  16140. Event type of collision.
  16141. !#zh
  16142. 碰撞的事件类型。 */
  16143. type: string;
  16144. /** !#en
  16145. Collider of its own in collision.
  16146. !#zh
  16147. 碰撞中的自己的碰撞器。 */
  16148. selfCollider: Collider3D;
  16149. /** !#en
  16150. Another collider in the collision.
  16151. !#zh
  16152. 碰撞中的另一个碰撞器。 */
  16153. otherCollider: Collider3D;
  16154. /** !#en
  16155. Information about all the points of impact in the collision.
  16156. !#zh
  16157. 碰撞中的所有碰撞点的信息。 */
  16158. contacts: IContactEquation[];
  16159. }
  16160. /** !#en
  16161. Used to store physical ray detection results
  16162. !#zh
  16163. 用于保存物理射线检测结果 */
  16164. export class PhysicsRayResult {
  16165. /** !#en
  16166. Hit the point
  16167. !#zh
  16168. 击中点 */
  16169. hitPoint: Vec3;
  16170. /** !#en
  16171. Distance
  16172. !#zh
  16173. 距离 */
  16174. distance: number;
  16175. /** !#en
  16176. Hit the collision box
  16177. !#zh
  16178. 击中的碰撞盒 */
  16179. collider: Collider3D;
  16180. /**
  16181. !#en
  16182. Set up ray. This method is used internally by the engine. Do not call it from an external script
  16183. !#zh
  16184. 设置射线,此方法由引擎内部使用,请勿在外部脚本调用
  16185. @param hitPoint hitPoint
  16186. @param distance distance
  16187. @param collider collider
  16188. */
  16189. _assign(hitPoint: Vec3, distance: number, collider: Collider3D): void;
  16190. /**
  16191. !#en
  16192. Clone
  16193. !#zh
  16194. 克隆
  16195. */
  16196. clone(): void;
  16197. }
  16198. /** Rigid body interface */
  16199. export class IRigidBody {
  16200. rigidBody: RigidBody3D;
  16201. mass: number;
  16202. linearDamping: number;
  16203. angularDamping: number;
  16204. isKinematic: boolean;
  16205. useGravity: boolean;
  16206. fixedRotation: boolean;
  16207. linearFactor: IVec3Like;
  16208. angularFactor: IVec3Like;
  16209. allowSleep: boolean;
  16210. isAwake: boolean;
  16211. isSleepy: boolean;
  16212. isSleeping: boolean;
  16213. wakeUp(): void;
  16214. sleep(): void;
  16215. /**
  16216. @param out out
  16217. */
  16218. getLinearVelocity(out: IVec3Like): void;
  16219. /**
  16220. @param out out
  16221. */
  16222. setLinearVelocity(out: IVec3Like): void;
  16223. /**
  16224. @param out out
  16225. */
  16226. getAngularVelocity(out: IVec3Like): void;
  16227. /**
  16228. @param out out
  16229. */
  16230. setAngularVelocity(out: IVec3Like): void;
  16231. /**
  16232. @param force force
  16233. @param relativePoint relativePoint
  16234. */
  16235. applyForce(force: IVec3Like, relativePoint: IVec3Like): void;
  16236. /**
  16237. @param force force
  16238. @param relativePoint relativePoint
  16239. */
  16240. applyLocalForce(force: IVec3Like, relativePoint: IVec3Like): void;
  16241. /**
  16242. @param force force
  16243. @param relativePoint relativePoint
  16244. */
  16245. applyImpulse(force: IVec3Like, relativePoint: IVec3Like): void;
  16246. /**
  16247. @param force force
  16248. @param relativePoint relativePoint
  16249. */
  16250. applyLocalImpulse(force: IVec3Like, relativePoint: IVec3Like): void;
  16251. /**
  16252. @param torque torque
  16253. */
  16254. applyTorque(torque: IVec3Like): void;
  16255. /**
  16256. @param torque torque
  16257. */
  16258. applyLocalTorque(torque: IVec3Like): void;
  16259. }
  16260. /** Class has x y z properties */
  16261. export class IVec3Like {
  16262. x: number;
  16263. y: number;
  16264. z: number;
  16265. }
  16266. /** Class has x y z w properties */
  16267. export class IQuatLike {
  16268. x: number;
  16269. y: number;
  16270. z: number;
  16271. w: number;
  16272. }
  16273. /** !#en Base shape interface. */
  16274. export class IBaseShape {
  16275. collider: Collider3D;
  16276. attachedRigidBody: RigidBody3D|void;
  16277. material: any;
  16278. isTrigger: boolean;
  16279. center: IVec3Like;
  16280. }
  16281. /** !#en box shape interface */
  16282. export class IBoxShape {
  16283. size: IVec3Like;
  16284. }
  16285. /** !#en Sphere shape interface */
  16286. export class ISphereShape {
  16287. radius: number;
  16288. }
  16289. /** Ray cast options */
  16290. export class IRaycastOptions {
  16291. groupIndex: number;
  16292. queryTrigger: boolean;
  16293. maxDistance: number;
  16294. }
  16295. /** Collision detect */
  16296. export class ICollisionDetect {
  16297. /**
  16298. Ray cast, and return information of the closest hit.
  16299. @param worldRay worldRay
  16300. @param options options
  16301. @param out out
  16302. */
  16303. raycastClosest(worldRay: geomUtils.Ray, options: IRaycastOptions, out: PhysicsRayResult): boolean;
  16304. /**
  16305. Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument.
  16306. @param worldRay worldRay
  16307. @param options options
  16308. @param pool pool
  16309. @param resultes resultes
  16310. */
  16311. raycast(worldRay: geomUtils.Ray, options: IRaycastOptions, pool: RecyclePool, resultes: PhysicsRayResult[]): boolean;
  16312. }
  16313. /** Physics world interface */
  16314. export class IPhysicsWorld {
  16315. }
  16316. /** !#en Manage Dynamic Atlas Manager. Dynamic Atlas Manager is used for merging textures at runtime, see [Dynamic Atlas](https://docs.cocos.com/creator/2.4/manual/en/advanced-topics/dynamic-atlas.html) for details.
  16317. !#zh 管理动态图集。动态图集用于在运行时对贴图进行合并,详见 [动态合图](https://docs.cocos.com/creator/2.4/manual/zh/advanced-topics/dynamic-atlas.html)。 */
  16318. export class DynamicAtlasManager {
  16319. /** !#en Enable or disable the dynamic atlas, see [Dynamic Atlas](https://docs.cocos.com/creator/2.4/manual/en/advanced-topics/dynamic-atlas.html) for details.
  16320. !#zh 开启或者关闭动态图集,详见 [动态合图](https://docs.cocos.com/creator/2.4/manual/zh/advanced-topics/dynamic-atlas.html)。 */
  16321. enabled: boolean;
  16322. /** !#en The maximum number of atlas that can be created.
  16323. !#zh 可以创建的最大图集数量。 */
  16324. maxAtlasCount: number;
  16325. /** !#en Get the current created atlas count.
  16326. !#zh 获取当前已经创建的图集数量。 */
  16327. atlasCount: number;
  16328. /** !#en Is enable textureBleeding.
  16329. !#zh 是否开启 textureBleeding */
  16330. textureBleeding: boolean;
  16331. /** !#en The size of the atlas that was created
  16332. !#zh 创建的图集的宽高 */
  16333. textureSize: number;
  16334. /** !#en The maximum size of the picture that can be added to the atlas.
  16335. !#zh 可以添加进图集的图片的最大尺寸。 */
  16336. maxFrameSize: number;
  16337. /** !#en The minimum size of the picture that can be added to the atlas.
  16338. !#zh 可以添加进图集的图片的最小尺寸。 */
  16339. minFrameSize: number;
  16340. /**
  16341. !#en Append a sprite frame into the dynamic atlas.
  16342. !#zh 添加碎图进入动态图集。
  16343. @param spriteFrame spriteFrame
  16344. */
  16345. insertSpriteFrame(spriteFrame: SpriteFrame): any;
  16346. /**
  16347. !#en Resets all dynamic atlas, and the existing ones will be destroyed.
  16348. !#zh 重置所有动态图集,已有的动态图集会被销毁。
  16349. */
  16350. reset(): void;
  16351. /**
  16352. !#en Displays all the dynamic atlas in the current scene, which you can use to view the current atlas state.
  16353. !#zh 在当前场景中显示所有动态图集,可以用来查看当前的合图状态。
  16354. @param show show
  16355. */
  16356. showDebug(show: boolean): Node;
  16357. }
  16358. /** !#en
  16359. Physics material.
  16360. !#zh
  16361. 物理材质。 */
  16362. export class PhysicsMaterial extends Asset {
  16363. /** !#en
  16364. Friction for this material.
  16365. !#zh
  16366. 物理材质的摩擦力。 */
  16367. friction: number;
  16368. /** !#en
  16369. Restitution for this material.
  16370. !#zh
  16371. 物理材质的弹力。 */
  16372. restitution: number;
  16373. }
  16374. /** !#en
  16375. Each frame applies a constant force to a rigid body, depending on the RigidBody3D
  16376. !#zh
  16377. 在每帧对一个刚体施加持续的力,依赖 RigidBody3D 组件 */
  16378. export class ConstantForce extends Component {
  16379. /** !#en
  16380. Set the force used in the world coordinate system, use `this.force = otherVec3`.
  16381. !#zh
  16382. 设置世界坐标系中使用的力,设置时请用 `this.force = otherVec3` 的方式。 */
  16383. force: Vec3;
  16384. /** !#en
  16385. Set the force used in the local coordinate system, using `this.localforce = otherVec3`.
  16386. !#zh
  16387. 获取和设置本地坐标系中使用的力,设置时请用 `this.localForce = otherVec3` 的方式。 */
  16388. localForce: Vec3;
  16389. /** !#en
  16390. Torque applied to the world orientation
  16391. !#zh
  16392. 对世界朝向施加的扭矩 */
  16393. torque: Vec3;
  16394. /** !#en
  16395. Torque applied to local orientation, using `this.localtorque = otherVec3`.
  16396. !#zh
  16397. 对本地朝向施加的扭矩,设置时请用 `this.localTorque = otherVec3` 的方式。 */
  16398. localTorque: Vec3;
  16399. }
  16400. /** !#en
  16401. RigidBody is the basic object that make up the physical world, and it can make a node physically affected and react.
  16402. !#zh
  16403. 刚体是组成物理世界的基本对象,可以让一个节点受到物理影响并产生反应。该组件在使用 Builtin 物理引擎时无效。 */
  16404. export class RigidBody3D extends Component {
  16405. /** !#en
  16406. Whether sleep is allowed.
  16407. !#zh
  16408. 是否允许休眠。 */
  16409. allowSleep: boolean;
  16410. /** !#en
  16411. The mass of the rigidbody.
  16412. !#zh
  16413. 刚体的质量。 */
  16414. mass: number;
  16415. /** !#en
  16416. Used to reduce the linear rate of rigidbody. The larger the value, the slower the rigidbody moves.
  16417. !#zh
  16418. 线性阻尼,用于减小刚体的线性速率,值越大物体移动越慢。 */
  16419. linearDamping: number;
  16420. /** !#en
  16421. Used to reduce the rotation rate of rigidbody. The larger the value, the slower the rigidbody rotates.
  16422. !#zh
  16423. 角阻尼,用于减小刚体的旋转速率,值越大刚体旋转越慢。 */
  16424. angularDamping: number;
  16425. /** !#en
  16426. If enabled, the developer controls the displacement and rotation of the rigidbody, not the physics engine.
  16427. !#zh
  16428. 是否由开发者来控制刚体的位移和旋转,而不是受物理引擎的影响。 */
  16429. isKinematic: boolean;
  16430. /** !#en
  16431. If enabled, the rigidbody is affected by gravity.
  16432. !#zh
  16433. 如果开启,刚体会受到重力影响。 */
  16434. useGravity: boolean;
  16435. /** !#en
  16436. If enabled, the rigidbody will be fixed without rotation during a collision.
  16437. !#zh
  16438. 如果开启,发生碰撞时会固定刚体不产生旋转。 */
  16439. fixedRotation: boolean;
  16440. /** !#en
  16441. It can affect the linear velocity change of the rigidbody in each axis. The larger the value, the faster the rigidbody moves.
  16442. !#zh
  16443. 线性因子,可影响刚体在每个轴向的线性速度变化,值越大刚体移动越快。 */
  16444. linearFactor: Vec3;
  16445. /** !#en
  16446. It can affect the rotation speed change of the rigidbody in each axis. The larger the value, the faster the rigidbody rotates.
  16447. !#zh
  16448. 旋转因子,可影响刚体在每个轴向的旋转速度变化,值越大刚体旋转越快。 */
  16449. angularFactor: Vec3;
  16450. /** !#en
  16451. The rigidbody is awake.
  16452. !#zh
  16453. 刚体是否为唤醒的状态。 */
  16454. isAwake: boolean;
  16455. /** !#en
  16456. The rigidbody can enter hibernation.
  16457. !#zh
  16458. 刚体是否为可进入休眠的状态。 */
  16459. isSleepy: boolean;
  16460. /** !#en
  16461. The rigidbody is sleeping.
  16462. !#zh
  16463. 刚体是否为正在休眠的状态。 */
  16464. isSleeping: boolean;
  16465. /** !#en
  16466. Get the rigidbody object inside the physics engine.
  16467. !#zh
  16468. 获得物理引擎内部刚体对象。 */
  16469. rigidBody: IRigidBody;
  16470. /**
  16471. !#en
  16472. A force is applied to a rigid body at a point in world space.
  16473. !#zh
  16474. 在世界空间中的某点上对刚体施加一个作用力。
  16475. @param force force
  16476. @param relativePoint The point of action, relative to the center of the rigid body.
  16477. */
  16478. applyForce(force: Vec3, relativePoint: Vec3): void;
  16479. /**
  16480. !#en
  16481. Apply a force on the rigid body at a point in local space.
  16482. !#zh
  16483. 在本地空间中的某点上对刚体施加一个作用力。
  16484. @param force force
  16485. @param localPoint Point of application
  16486. */
  16487. applyLocalForce(force: Vec3, localPoint: Vec3): void;
  16488. /**
  16489. !#en
  16490. Apply an impulse to a rigid body at a point in world space.
  16491. !#zh
  16492. 在世界空间的某点上对刚体施加一个冲量。
  16493. @param impulse impulse
  16494. @param relativePoint The point of action, relative to the center of the rigid body.
  16495. */
  16496. applyImpulse(impulse: Vec3, relativePoint: Vec3): void;
  16497. /**
  16498. !#en
  16499. Apply an impulse to the rigid body at a point in local space.
  16500. !#zh
  16501. 在本地空间的某点上对刚体施加一个冲量。
  16502. @param impulse impulse
  16503. @param localPoint Point of application
  16504. */
  16505. applyLocalImpulse(impulse: Vec3, localPoint: Vec3): void;
  16506. /**
  16507. !#en
  16508. Apply a torque to the rigid body.
  16509. !#zh
  16510. 对刚体施加扭转力。
  16511. @param torque torque
  16512. */
  16513. applyTorque(torque: Vec3): void;
  16514. /**
  16515. !#en
  16516. Apply a local torque to the rigid body.
  16517. !#zh
  16518. 对刚体施加本地扭转力。
  16519. @param torque torque
  16520. */
  16521. applyLocalTorque(torque: Vec3): void;
  16522. /**
  16523. !#en
  16524. Awaken the rigid body.
  16525. !#zh
  16526. 唤醒刚体。
  16527. */
  16528. wakeUp(): void;
  16529. /**
  16530. !#en
  16531. Dormant rigid body.
  16532. !#zh
  16533. 休眠刚体。
  16534. */
  16535. sleep(): void;
  16536. /**
  16537. !#en
  16538. Get linear velocity.
  16539. !#zh
  16540. 获取线性速度。
  16541. @param out out
  16542. */
  16543. getLinearVelocity(out: Vec3): void;
  16544. /**
  16545. !#en
  16546. Set linear speed.
  16547. !#zh
  16548. 设置线性速度。
  16549. @param value value
  16550. */
  16551. setLinearVelocity(value: Vec3): void;
  16552. /**
  16553. !#en
  16554. Gets the rotation speed.
  16555. !#zh
  16556. 获取旋转速度。
  16557. @param out out
  16558. */
  16559. getAngularVelocity(out: Vec3): void;
  16560. /**
  16561. !#en
  16562. Set rotation speed.
  16563. !#zh
  16564. 设置旋转速度。
  16565. @param value value
  16566. */
  16567. setAngularVelocity(value: Vec3): void;
  16568. }
  16569. /** !#en
  16570. Physics box collider
  16571. !#zh
  16572. 物理盒子碰撞器 */
  16573. export class BoxCollider3D extends Collider3D {
  16574. /** !#en
  16575. Get or set the size of the box, in local space.
  16576. !#zh
  16577. 获取或设置盒的大小。 */
  16578. size: Vec3;
  16579. boxShape: IBoxShape;
  16580. }
  16581. /** !#en
  16582. The base class of the collider.
  16583. !#zh
  16584. 碰撞器的基类。 */
  16585. export class Collider3D extends Component implements EventTarget {
  16586. sharedMaterial: PhysicsMaterial;
  16587. /** !#en
  16588. get or set the collider is trigger, this will be always trigger if using builtin.
  16589. !#zh
  16590. 获取或设置碰撞器是否为触发器。 */
  16591. isTrigger: boolean;
  16592. /** !#en
  16593. get or set the center of the collider, in local space.
  16594. !#zh
  16595. 获取或设置碰撞器的中心点。 */
  16596. center: Vec3;
  16597. /** !#en
  16598. get the collider attached rigidbody, this may be null.
  16599. !#zh
  16600. 获取碰撞器所绑定的刚体组件,可能为 null。 */
  16601. attachedRigidbody: RigidBody3D|void;
  16602. /** !#en
  16603. get collider shape.
  16604. !#zh
  16605. 获取碰撞器形状。 */
  16606. shape: IBaseShape;
  16607. /**
  16608. !#en
  16609. Register an callback of a specific event type on the EventTarget.
  16610. This type of event should be triggered via `emit`.
  16611. !#zh
  16612. 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。
  16613. @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`.
  16614. @param callback The callback that will be invoked when the event is dispatched.
  16615. The callback is ignored if it is a duplicate (the callbacks are unique).
  16616. @param target The target (this object) to invoke the callback, can be null.
  16617. @example
  16618. ```js
  16619. eventTarget.on('fire', function (event) {
  16620. // event is ITriggerEvent or ICollisionEvent
  16621. }, node);
  16622. ```
  16623. */
  16624. on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
  16625. /**
  16626. !#en
  16627. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  16628. if only type is passed as parameter, all listeners registered with that type will be removed.
  16629. !#zh
  16630. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  16631. @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`.
  16632. @param callback The callback to remove.
  16633. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed.
  16634. @example
  16635. ```js
  16636. // register fire eventListener
  16637. var callback = eventTarget.on('fire', function () {
  16638. cc.log("fire in the hole");
  16639. }, target);
  16640. // remove fire event listener
  16641. eventTarget.off('fire', callback, target);
  16642. // remove all fire event listeners
  16643. eventTarget.off('fire');
  16644. ```
  16645. */
  16646. off(type: string, callback?: Function, target?: any): void;
  16647. /**
  16648. !#en
  16649. Register an callback of a specific event type on the EventTarget,
  16650. the callback will remove itself after the first time it is triggered.
  16651. !#zh
  16652. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  16653. @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`.
  16654. @param callback The callback that will be invoked when the event is dispatched.
  16655. The callback is ignored if it is a duplicate (the callbacks are unique).
  16656. @param target The target (this object) to invoke the callback, can be null.
  16657. @example
  16658. ```js
  16659. eventTarget.once('fire', function (event) {
  16660. // event is ITriggerEvent or ICollisionEvent
  16661. }, node);
  16662. ```
  16663. */
  16664. once(type: string, callback: (event: ITriggerEvent|ICollisionEvent) => void, target?: any): void;
  16665. /**
  16666. !#en Checks whether the EventTarget object has any callback registered for a specific type of event.
  16667. !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。
  16668. @param type The type of event.
  16669. */
  16670. hasEventListener(type: string): boolean;
  16671. /**
  16672. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  16673. This is not for removing all listeners in the current event target,
  16674. and this is not for removing all listeners the target parameter have registered.
  16675. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  16676. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  16677. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  16678. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  16679. @param target The target to be searched for all related listeners
  16680. */
  16681. targetOff(target: any): void;
  16682. /**
  16683. !#en
  16684. Send an event with the event object.
  16685. !#zh
  16686. 通过事件对象派发事件
  16687. @param event event
  16688. */
  16689. dispatchEvent(event: Event): void;
  16690. /**
  16691. !#en
  16692. Destroy all callbackInfos.
  16693. !#zh
  16694. 销毁记录的事件
  16695. */
  16696. clear(): void;
  16697. }
  16698. /** !#en
  16699. Physics sphere collider
  16700. !#zh
  16701. 物理球碰撞器 */
  16702. export class SphereCollider3D extends Collider3D {
  16703. /** !#en
  16704. Get or set the radius of the sphere.
  16705. !#zh
  16706. 获取或设置球的半径。 */
  16707. radius: number;
  16708. sphereShape: ISphereShape;
  16709. }
  16710. /****************************************************
  16711. * audioEngine
  16712. *****************************************************/
  16713. export namespace audioEngine {
  16714. /** !#en Audio state.
  16715. !#zh 声音播放状态 */
  16716. export enum AudioState {
  16717. ERROR = 0,
  16718. INITIALZING = 0,
  16719. PLAYING = 0,
  16720. PAUSED = 0,
  16721. STOPPED = 0,
  16722. }
  16723. }
  16724. /****************************************************
  16725. * debug
  16726. *****************************************************/
  16727. export namespace debug {
  16728. /** !#en Enum for debug modes.
  16729. !#zh 调试模式 */
  16730. export enum DebugMode {
  16731. NONE = 0,
  16732. INFO = 0,
  16733. WARN = 0,
  16734. ERROR = 0,
  16735. INFO_FOR_WEB_PAGE = 0,
  16736. WARN_FOR_WEB_PAGE = 0,
  16737. ERROR_FOR_WEB_PAGE = 0,
  16738. }
  16739. }
  16740. /****************************************************
  16741. * Node
  16742. *****************************************************/
  16743. export namespace Node {
  16744. /** !#en Node's local dirty properties flag
  16745. !#zh Node 的本地属性 dirty 状态位 */
  16746. export enum _LocalDirtyFlag {
  16747. POSITION = 0,
  16748. SCALE = 0,
  16749. ROTATION = 0,
  16750. SKEW = 0,
  16751. TRS = 0,
  16752. RS = 0,
  16753. TRS = 0,
  16754. PHYSICS_POSITION = 0,
  16755. PHYSICS_SCALE = 0,
  16756. PHYSICS_ROTATION = 0,
  16757. PHYSICS_TRS = 0,
  16758. PHYSICS_RS = 0,
  16759. ALL_POSITION = 0,
  16760. ALL_SCALE = 0,
  16761. ALL_ROTATION = 0,
  16762. ALL_TRS = 0,
  16763. ALL = 0,
  16764. }
  16765. }
  16766. /****************************************************
  16767. * Node
  16768. *****************************************************/
  16769. export namespace Node {
  16770. /** !#en The event type supported by Node
  16771. !#zh Node 支持的事件类型 */
  16772. export class EventType {
  16773. /** !#en The event type for touch start event, you can use its value directly: 'touchstart'
  16774. !#zh 当手指触摸到屏幕时。 */
  16775. static TOUCH_START: string;
  16776. /** !#en The event type for touch move event, you can use its value directly: 'touchmove'
  16777. !#zh 当手指在屏幕上移动时。 */
  16778. static TOUCH_MOVE: string;
  16779. /** !#en The event type for touch end event, you can use its value directly: 'touchend'
  16780. !#zh 当手指在目标节点区域内离开屏幕时。 */
  16781. static TOUCH_END: string;
  16782. /** !#en The event type for touch end event, you can use its value directly: 'touchcancel'
  16783. !#zh 当手指在目标节点区域外离开屏幕时。 */
  16784. static TOUCH_CANCEL: string;
  16785. /** !#en The event type for mouse down events, you can use its value directly: 'mousedown'
  16786. !#zh 当鼠标按下时触发一次。 */
  16787. static MOUSE_DOWN: string;
  16788. /** !#en The event type for mouse move events, you can use its value directly: 'mousemove'
  16789. !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。 */
  16790. static MOUSE_MOVE: string;
  16791. /** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter'
  16792. !#zh 当鼠标移入目标节点区域时,不论是否按下。 */
  16793. static MOUSE_ENTER: string;
  16794. /** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave'
  16795. !#zh 当鼠标移出目标节点区域时,不论是否按下。 */
  16796. static MOUSE_LEAVE: string;
  16797. /** !#en The event type for mouse up events, you can use its value directly: 'mouseup'
  16798. !#zh 当鼠标从按下状态松开时触发一次。 */
  16799. static MOUSE_UP: string;
  16800. /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel'
  16801. !#zh 当鼠标滚轮滚动时。 */
  16802. static MOUSE_WHEEL: string;
  16803. /** !#en The event type for position change events.
  16804. Performance note, this event will be triggered every time corresponding properties being changed,
  16805. if the event callback have heavy logic it may have great performance impact, try to avoid such scenario.
  16806. !#zh 当节点位置改变时触发的事件。
  16807. 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */
  16808. static POSITION_CHANGED: string;
  16809. /** !#en The event type for rotation change events.
  16810. Performance note, this event will be triggered every time corresponding properties being changed,
  16811. if the event callback have heavy logic it may have great performance impact, try to avoid such scenario.
  16812. !#zh 当节点旋转改变时触发的事件。
  16813. 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */
  16814. static ROTATION_CHANGED: string;
  16815. /** !#en The event type for scale change events.
  16816. Performance note, this event will be triggered every time corresponding properties being changed,
  16817. if the event callback have heavy logic it may have great performance impact, try to avoid such scenario.
  16818. !#zh 当节点缩放改变时触发的事件。
  16819. 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */
  16820. static SCALE_CHANGED: string;
  16821. /** !#en The event type for size change events.
  16822. Performance note, this event will be triggered every time corresponding properties being changed,
  16823. if the event callback have heavy logic it may have great performance impact, try to avoid such scenario.
  16824. !#zh 当节点尺寸改变时触发的事件。
  16825. 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */
  16826. static SIZE_CHANGED: string;
  16827. /** !#en The event type for anchor point change events.
  16828. Performance note, this event will be triggered every time corresponding properties being changed,
  16829. if the event callback have heavy logic it may have great performance impact, try to avoid such scenario.
  16830. !#zh 当节点锚点改变时触发的事件。
  16831. 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */
  16832. static ANCHOR_CHANGED: string;
  16833. /** !#en The event type for color change events.
  16834. Performance note, this event will be triggered every time corresponding properties being changed,
  16835. if the event callback have heavy logic it may have great performance impact, try to avoid such scenario.
  16836. !#zh 当节点颜色改变时触发的事件。
  16837. 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */
  16838. static COLOR_CHANGED: string;
  16839. /** !#en The event type for new child added events.
  16840. !#zh 当新的子节点被添加时触发的事件。 */
  16841. static CHILD_ADDED: string;
  16842. /** !#en The event type for child removed events.
  16843. !#zh 当子节点被移除时触发的事件。 */
  16844. static CHILD_REMOVED: string;
  16845. /** !#en The event type for children reorder events.
  16846. !#zh 当子节点顺序改变时触发的事件。 */
  16847. static CHILD_REORDER: string;
  16848. /** !#en The event type for node group changed events.
  16849. !#zh 当节点归属群组发生变化时触发的事件。 */
  16850. static GROUP_CHANGED: string;
  16851. /** !#en The event type for node's sibling order changed.
  16852. !#zh 当节点在兄弟节点中的顺序发生变化时触发的事件。 */
  16853. static SIBLING_ORDER_CHANGED: string;
  16854. }
  16855. }
  16856. /****************************************************
  16857. * TiledMap
  16858. *****************************************************/
  16859. export namespace TiledMap {
  16860. /** !#en The orientation of tiled map.
  16861. !#zh Tiled Map 地图方向。 */
  16862. export enum Orientation {
  16863. ORTHO = 0,
  16864. HEX = 0,
  16865. ISO = 0,
  16866. }
  16867. }
  16868. /****************************************************
  16869. * TiledMap
  16870. *****************************************************/
  16871. export namespace TiledMap {
  16872. /** The property type of tiled map. */
  16873. export enum Property {
  16874. NONE = 0,
  16875. MAP = 0,
  16876. LAYER = 0,
  16877. OBJECTGROUP = 0,
  16878. OBJECT = 0,
  16879. TILE = 0,
  16880. }
  16881. }
  16882. /****************************************************
  16883. * TiledMap
  16884. *****************************************************/
  16885. export namespace TiledMap {
  16886. /** The tile flags of tiled map. */
  16887. export enum TileFlag {
  16888. HORIZONTAL = 0,
  16889. VERTICAL = 0,
  16890. DIAGONAL = 0,
  16891. FLIPPED_ALL = 0,
  16892. FLIPPED_MASK = 0,
  16893. }
  16894. }
  16895. /****************************************************
  16896. * TiledMap
  16897. *****************************************************/
  16898. export namespace TiledMap {
  16899. /** !#en The stagger axis of Hex tiled map.
  16900. !#zh 六边形地图的 stagger axis 值 */
  16901. export enum StaggerAxis {
  16902. STAGGERAXIS_X = 0,
  16903. STAGGERAXIS_Y = 0,
  16904. }
  16905. }
  16906. /****************************************************
  16907. * TiledMap
  16908. *****************************************************/
  16909. export namespace TiledMap {
  16910. /** !#en The render order of tiled map.
  16911. !#zh 地图的渲染顺序 */
  16912. export enum RenderOrder {
  16913. STAGGERINDEX_ODD = 0,
  16914. STAGGERINDEX_EVEN = 0,
  16915. RightDown = 0,
  16916. RightUp = 0,
  16917. LeftDown = 0,
  16918. LeftUp = 0,
  16919. }
  16920. }
  16921. /****************************************************
  16922. * TiledMap
  16923. *****************************************************/
  16924. export namespace TiledMap {
  16925. /** !#en TiledMap Object Type
  16926. !#zh 地图物体类型 */
  16927. export enum TMXObjectType {
  16928. RECT = 0,
  16929. ELLIPSE = 0,
  16930. POLYGON = 0,
  16931. POLYLINE = 0,
  16932. IMAGE = 0,
  16933. TEXT = 0,
  16934. }
  16935. }
  16936. /****************************************************
  16937. * ParticleSystem
  16938. *****************************************************/
  16939. export namespace ParticleSystem {
  16940. /** !#en Enum for emitter modes
  16941. !#zh 发射模式 */
  16942. export enum EmitterMode {
  16943. GRAVITY = 0,
  16944. RADIUS = 0,
  16945. }
  16946. }
  16947. /****************************************************
  16948. * ParticleSystem
  16949. *****************************************************/
  16950. export namespace ParticleSystem {
  16951. /** !#en Enum for particles movement type.
  16952. !#zh 粒子位置类型 */
  16953. export enum PositionType {
  16954. FREE = 0,
  16955. RELATIVE = 0,
  16956. GROUPED = 0,
  16957. }
  16958. }
  16959. /****************************************************
  16960. * WebView
  16961. *****************************************************/
  16962. export namespace WebView {
  16963. /** !#en WebView event type
  16964. !#zh 网页视图事件类型 */
  16965. export enum EventType {
  16966. LOADED = 0,
  16967. LOADING = 0,
  16968. ERROR = 0,
  16969. }
  16970. }
  16971. /****************************************************
  16972. * VideoPlayer
  16973. *****************************************************/
  16974. export namespace VideoPlayer {
  16975. /** !#en Video event type
  16976. !#zh 视频事件类型 */
  16977. export enum EventType {
  16978. PLAYING = 0,
  16979. PAUSED = 0,
  16980. STOPPED = 0,
  16981. COMPLETED = 0,
  16982. META_LOADED = 0,
  16983. CLICKED = 0,
  16984. READY_TO_PLAY = 0,
  16985. }
  16986. }
  16987. /****************************************************
  16988. * VideoPlayer
  16989. *****************************************************/
  16990. export namespace VideoPlayer {
  16991. /** !#en Enum for video resouce type type.
  16992. !#zh 视频来源 */
  16993. export enum ResourceType {
  16994. REMOTE = 0,
  16995. LOCAL = 0,
  16996. }
  16997. }
  16998. /****************************************************
  16999. * Light
  17000. *****************************************************/
  17001. export namespace Light {
  17002. /** !#en The light source type
  17003. !#zh 光源类型 */
  17004. export enum Type {
  17005. DIRECTIONAL = 0,
  17006. POINT = 0,
  17007. SPOT = 0,
  17008. AMBIENT = 0,
  17009. }
  17010. }
  17011. /****************************************************
  17012. * Light
  17013. *****************************************************/
  17014. export namespace Light {
  17015. /** !#en The shadow type
  17016. !#zh 阴影类型 */
  17017. export enum ShadowType {
  17018. NONE = 0,
  17019. HARD = 0,
  17020. SOFT_PCF3X3 = 0,
  17021. SOFT_PCF5X5 = 0,
  17022. }
  17023. }
  17024. /****************************************************
  17025. * Camera
  17026. *****************************************************/
  17027. export namespace Camera {
  17028. /** !#en Values for Camera.clearFlags, determining what to clear when rendering a Camera.
  17029. !#zh 摄像机清除标记位,决定摄像机渲染时会清除哪些状态 */
  17030. export enum ClearFlags {
  17031. COLOR = 0,
  17032. DEPTH = 0,
  17033. STENCIL = 0,
  17034. }
  17035. }
  17036. /****************************************************
  17037. * Collider
  17038. *****************************************************/
  17039. export namespace Collider {
  17040. /** !#en Defines a Box Collider .
  17041. !#zh 用来定义包围盒碰撞体 */
  17042. export class Box {
  17043. /** !#en Position offset
  17044. !#zh 位置偏移量 */
  17045. offset: Vec2;
  17046. /** !#en Box size
  17047. !#zh 包围盒大小 */
  17048. size: Size;
  17049. }
  17050. }
  17051. /****************************************************
  17052. * Collider
  17053. *****************************************************/
  17054. export namespace Collider {
  17055. /** !#en Defines a Circle Collider .
  17056. !#zh 用来定义圆形碰撞体 */
  17057. export class Circle {
  17058. /** !#en Position offset
  17059. !#zh 位置偏移量 */
  17060. offset: Vec2;
  17061. /** !#en Circle radius
  17062. !#zh 圆形半径 */
  17063. radius: number;
  17064. }
  17065. }
  17066. /****************************************************
  17067. * Collider
  17068. *****************************************************/
  17069. export namespace Collider {
  17070. /** !#en Defines a Polygon Collider .
  17071. !#zh 用来定义多边形碰撞体 */
  17072. export class Polygon {
  17073. /** !#en Position offset
  17074. !#zh 位置偏移量 */
  17075. offset: Vec2;
  17076. /** !#en Polygon points
  17077. !#zh 多边形顶点数组 */
  17078. points: Vec2[];
  17079. }
  17080. }
  17081. /****************************************************
  17082. * Animation
  17083. *****************************************************/
  17084. export namespace Animation {
  17085. /** !#en The event type supported by Animation
  17086. !#zh Animation 支持的事件类型 */
  17087. export class EventType {
  17088. /** !#en Emit when begin playing animation
  17089. !#zh 开始播放时触发 */
  17090. static PLAY: string;
  17091. /** !#en Emit when stop playing animation
  17092. !#zh 停止播放时触发 */
  17093. static STOP: string;
  17094. /** !#en Emit when pause animation
  17095. !#zh 暂停播放时触发 */
  17096. static PAUSE: string;
  17097. /** !#en Emit when resume animation
  17098. !#zh 恢复播放时触发 */
  17099. static RESUME: string;
  17100. /** !#en If animation repeat count is larger than 1, emit when animation play to the last frame
  17101. !#zh 假如动画循环次数大于 1,当动画播放到最后一帧时触发 */
  17102. static LASTFRAME: string;
  17103. /** !#en Emit when finish playing animation
  17104. !#zh 动画播放完成时触发 */
  17105. static FINISHED: string;
  17106. }
  17107. }
  17108. /****************************************************
  17109. * Button
  17110. *****************************************************/
  17111. export namespace Button {
  17112. /** !#en Enum for transition type.
  17113. !#zh 过渡类型 */
  17114. export enum Transition {
  17115. NONE = 0,
  17116. COLOR = 0,
  17117. SPRITE = 0,
  17118. SCALE = 0,
  17119. }
  17120. }
  17121. /****************************************************
  17122. * Component
  17123. *****************************************************/
  17124. export namespace Component {
  17125. /** !#en
  17126. Component will register a event to target component's handler.
  17127. And it will trigger the handler when a certain event occurs.
  17128. !@zh
  17129. “EventHandler” 类用来设置场景中的事件回调,
  17130. 该类允许用户设置回调目标节点,目标组件名,组件方法名,
  17131. 并可通过 emit 方法调用目标函数。 */
  17132. export class EventHandler {
  17133. /** !#en the node that contains target callback, such as the node example script belongs to
  17134. !#zh 事件响应函数所在节点 ,比如例子中脚本归属的节点本身 */
  17135. target: Node;
  17136. /** !#en name of the component(script) that contains target callback, such as the name 'MainMenu' of script in example
  17137. !#zh 事件响应函数所在组件名(脚本名), 比如例子中的脚本名 'MainMenu' */
  17138. component: string;
  17139. /** !#en Event handler, such as function's name 'onClick' in example
  17140. !#zh 响应事件函数名,比如例子中的 'onClick' */
  17141. handler: string;
  17142. /** !#en Custom Event Data, such as 'eventType' in example
  17143. !#zh 自定义事件数据,比如例子中的 eventType */
  17144. customEventData: string;
  17145. /**
  17146. @param events events
  17147. @param params params
  17148. */
  17149. static emitEvents(events: EventHandler[], ...params: any[]): void;
  17150. /**
  17151. !#en Emit event with params
  17152. !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。
  17153. @param params params
  17154. @example
  17155. ```js
  17156. // Call Function
  17157. var eventHandler = new cc.Component.EventHandler();
  17158. eventHandler.target = newTarget;
  17159. eventHandler.component = "MainMenu";
  17160. eventHandler.handler = "OnClick"
  17161. eventHandler.emit(["param1", "param2", ....]);
  17162. ```
  17163. */
  17164. emit(params: any[]): void;
  17165. }
  17166. }
  17167. /****************************************************
  17168. * Label
  17169. *****************************************************/
  17170. export namespace Label {
  17171. /** !#en Enum for text alignment.
  17172. !#zh 文本横向对齐类型 */
  17173. export enum HorizontalAlign {
  17174. LEFT = 0,
  17175. CENTER = 0,
  17176. RIGHT = 0,
  17177. }
  17178. }
  17179. /****************************************************
  17180. * Label
  17181. *****************************************************/
  17182. export namespace Label {
  17183. /** !#en Enum for vertical text alignment.
  17184. !#zh 文本垂直对齐类型 */
  17185. export enum VerticalAlign {
  17186. TOP = 0,
  17187. CENTER = 0,
  17188. BOTTOM = 0,
  17189. }
  17190. }
  17191. /****************************************************
  17192. * Label
  17193. *****************************************************/
  17194. export namespace Label {
  17195. /** !#en Enum for Overflow.
  17196. !#zh Overflow 类型 */
  17197. export enum Overflow {
  17198. NONE = 0,
  17199. CLAMP = 0,
  17200. SHRINK = 0,
  17201. RESIZE_HEIGHT = 0,
  17202. }
  17203. }
  17204. /****************************************************
  17205. * Label
  17206. *****************************************************/
  17207. export namespace Label {
  17208. /** !#en Enum for font type.
  17209. !#zh Type 类型 */
  17210. export enum Type {
  17211. TTF = 0,
  17212. BMFont = 0,
  17213. SystemFont = 0,
  17214. }
  17215. }
  17216. /****************************************************
  17217. * Label
  17218. *****************************************************/
  17219. export namespace Label {
  17220. /** !#en Enum for cache mode.
  17221. !#zh CacheMode 类型 */
  17222. export enum CacheMode {
  17223. NONE = 0,
  17224. BITMAP = 0,
  17225. CHAR = 0,
  17226. }
  17227. }
  17228. /****************************************************
  17229. * Layout
  17230. *****************************************************/
  17231. export namespace Layout {
  17232. /** !#en Enum for Layout type
  17233. !#zh 布局类型 */
  17234. export enum Type {
  17235. NONE = 0,
  17236. HORIZONTAL = 0,
  17237. VERTICAL = 0,
  17238. GRID = 0,
  17239. }
  17240. }
  17241. /****************************************************
  17242. * Layout
  17243. *****************************************************/
  17244. export namespace Layout {
  17245. /** !#en Enum for Layout Resize Mode
  17246. !#zh 缩放模式 */
  17247. export enum ResizeMode {
  17248. NONE = 0,
  17249. CONTAINER = 0,
  17250. CHILDREN = 0,
  17251. }
  17252. }
  17253. /****************************************************
  17254. * Layout
  17255. *****************************************************/
  17256. export namespace Layout {
  17257. /** !#en Enum for Grid Layout start axis direction.
  17258. The items in grid layout will be arranged in each axis at first.;
  17259. !#zh 布局轴向,只用于 GRID 布局。 */
  17260. export enum AxisDirection {
  17261. HORIZONTAL = 0,
  17262. VERTICAL = 0,
  17263. }
  17264. }
  17265. /****************************************************
  17266. * Layout
  17267. *****************************************************/
  17268. export namespace Layout {
  17269. /** !#en Enum for vertical layout direction.
  17270. Used in Grid Layout together with AxisDirection is VERTICAL
  17271. !#zh 垂直方向布局方式 */
  17272. export enum VerticalDirection {
  17273. BOTTOM_TO_TOP = 0,
  17274. TOP_TO_BOTTOM = 0,
  17275. }
  17276. }
  17277. /****************************************************
  17278. * Layout
  17279. *****************************************************/
  17280. export namespace Layout {
  17281. /** !#en Enum for horizontal layout direction.
  17282. Used in Grid Layout together with AxisDirection is HORIZONTAL
  17283. !#zh 水平方向布局方式 */
  17284. export enum HorizontalDirection {
  17285. LEFT_TO_RIGHT = 0,
  17286. RIGHT_TO_LEFT = 0,
  17287. }
  17288. }
  17289. /****************************************************
  17290. * Mask
  17291. *****************************************************/
  17292. export namespace Mask {
  17293. /** !#en the type for mask.
  17294. !#zh 遮罩组件类型 */
  17295. export enum Type {
  17296. RECT = 0,
  17297. ELLIPSE = 0,
  17298. IMAGE_STENCIL = 0,
  17299. }
  17300. }
  17301. /****************************************************
  17302. * PageView
  17303. *****************************************************/
  17304. export namespace PageView {
  17305. /** !#en The Page View Size Mode
  17306. !#zh 页面视图每个页面统一的大小类型 */
  17307. export enum SizeMode {
  17308. Unified = 0,
  17309. Free = 0,
  17310. }
  17311. }
  17312. /****************************************************
  17313. * PageView
  17314. *****************************************************/
  17315. export namespace PageView {
  17316. /** !#en The Page View Direction
  17317. !#zh 页面视图滚动类型 */
  17318. export enum Direction {
  17319. Horizontal = 0,
  17320. Vertical = 0,
  17321. }
  17322. }
  17323. /****************************************************
  17324. * PageView
  17325. *****************************************************/
  17326. export namespace PageView {
  17327. /** !#en Enum for ScrollView event type.
  17328. !#zh 滚动视图事件类型 */
  17329. export enum EventType {
  17330. PAGE_TURNING = 0,
  17331. }
  17332. }
  17333. /****************************************************
  17334. * PageViewIndicator
  17335. *****************************************************/
  17336. export namespace PageViewIndicator {
  17337. /** !#en Enum for PageView Indicator direction
  17338. !#zh 页面视图指示器的摆放方向 */
  17339. export enum Direction {
  17340. HORIZONTAL = 0,
  17341. VERTICAL = 0,
  17342. }
  17343. }
  17344. /****************************************************
  17345. * ProgressBar
  17346. *****************************************************/
  17347. export namespace ProgressBar {
  17348. /** !#en Enum for ProgressBar mode
  17349. !#zh 进度条模式 */
  17350. export enum Mode {
  17351. HORIZONTAL = 0,
  17352. VERTICAL = 0,
  17353. FILLED = 0,
  17354. }
  17355. }
  17356. /****************************************************
  17357. * Scrollbar
  17358. *****************************************************/
  17359. export namespace Scrollbar {
  17360. /** Enum for Scrollbar direction */
  17361. export enum Direction {
  17362. HORIZONTAL = 0,
  17363. VERTICAL = 0,
  17364. }
  17365. }
  17366. /****************************************************
  17367. * ScrollView
  17368. *****************************************************/
  17369. export namespace ScrollView {
  17370. /** !#en Enum for ScrollView event type.
  17371. !#zh 滚动视图事件类型 */
  17372. export enum EventType {
  17373. SCROLL_TO_TOP = 0,
  17374. SCROLL_TO_BOTTOM = 0,
  17375. SCROLL_TO_LEFT = 0,
  17376. SCROLL_TO_RIGHT = 0,
  17377. SCROLLING = 0,
  17378. BOUNCE_TOP = 0,
  17379. BOUNCE_BOTTOM = 0,
  17380. BOUNCE_LEFT = 0,
  17381. BOUNCE_RIGHT = 0,
  17382. SCROLL_ENDED = 0,
  17383. TOUCH_UP = 0,
  17384. AUTOSCROLL_ENDED_WITH_THRESHOLD = 0,
  17385. SCROLL_BEGAN = 0,
  17386. }
  17387. }
  17388. /****************************************************
  17389. * Slider
  17390. *****************************************************/
  17391. export namespace Slider {
  17392. /** !#en The Slider Direction
  17393. !#zh 滑动器方向 */
  17394. export enum Direction {
  17395. Horizontal = 0,
  17396. Vertical = 0,
  17397. }
  17398. }
  17399. /****************************************************
  17400. * Sprite
  17401. *****************************************************/
  17402. export namespace Sprite {
  17403. /** !#en Enum for sprite type.
  17404. !#zh Sprite 类型 */
  17405. export enum Type {
  17406. SIMPLE = 0,
  17407. SLICED = 0,
  17408. TILED = 0,
  17409. FILLED = 0,
  17410. MESH = 0,
  17411. }
  17412. }
  17413. /****************************************************
  17414. * Sprite
  17415. *****************************************************/
  17416. export namespace Sprite {
  17417. /** !#en Enum for fill type.
  17418. !#zh 填充类型 */
  17419. export enum FillType {
  17420. HORIZONTAL = 0,
  17421. VERTICAL = 0,
  17422. RADIAL = 0,
  17423. }
  17424. }
  17425. /****************************************************
  17426. * Sprite
  17427. *****************************************************/
  17428. export namespace Sprite {
  17429. /** !#en Sprite Size can track trimmed size, raw size or none.
  17430. !#zh 精灵尺寸调整模式 */
  17431. export enum SizeMode {
  17432. CUSTOM = 0,
  17433. TRIMMED = 0,
  17434. RAW = 0,
  17435. }
  17436. }
  17437. /****************************************************
  17438. * Sprite
  17439. *****************************************************/
  17440. export namespace Sprite {
  17441. /** !#en Sprite state can choice the normal or grayscale.
  17442. !#zh 精灵颜色通道模式。 */
  17443. export enum State {
  17444. NORMAL = 0,
  17445. GRAY = 0,
  17446. }
  17447. }
  17448. /****************************************************
  17449. * Widget
  17450. *****************************************************/
  17451. export namespace Widget {
  17452. /** !#en Enum for Widget's alignment mode, indicating when the widget should refresh.
  17453. !#zh Widget 的对齐模式,表示 Widget 应该何时刷新。 */
  17454. export enum AlignMode {
  17455. ONCE = 0,
  17456. ON_WINDOW_RESIZE = 0,
  17457. ALWAYS = 0,
  17458. }
  17459. }
  17460. /****************************************************
  17461. * Event
  17462. *****************************************************/
  17463. export namespace Event {
  17464. /** !#en The mouse event
  17465. !#zh 鼠标事件类型 */
  17466. export class EventMouse extends Event {
  17467. /**
  17468. !#en Sets scroll data.
  17469. !#zh 设置鼠标的滚动数据。
  17470. @param scrollX scrollX
  17471. @param scrollY scrollY
  17472. */
  17473. setScrollData(scrollX: number, scrollY: number): void;
  17474. /**
  17475. !#en Returns the x axis scroll value.
  17476. !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。
  17477. */
  17478. getScrollX(): number;
  17479. /**
  17480. !#en Returns the y axis scroll value.
  17481. !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。
  17482. */
  17483. getScrollY(): number;
  17484. /**
  17485. !#en Sets cursor location.
  17486. !#zh 设置当前鼠标位置。
  17487. @param x x
  17488. @param y y
  17489. */
  17490. setLocation(x: number, y: number): void;
  17491. /**
  17492. !#en Returns cursor location.
  17493. !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。
  17494. */
  17495. getLocation(): Vec2;
  17496. /**
  17497. !#en Returns the current cursor location in screen coordinates.
  17498. !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
  17499. */
  17500. getLocationInView(): Vec2;
  17501. /**
  17502. !#en Returns the previous touch location.
  17503. !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。
  17504. */
  17505. getPreviousLocation(): Vec2;
  17506. /**
  17507. !#en Returns the delta distance from the previous location to current location.
  17508. !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  17509. */
  17510. getDelta(): Vec2;
  17511. /**
  17512. !#en Returns the X axis delta distance from the previous location to current location.
  17513. !#zh 获取鼠标距离上一次事件移动的 X 轴距离。
  17514. */
  17515. getDeltaX(): number;
  17516. /**
  17517. !#en Returns the Y axis delta distance from the previous location to current location.
  17518. !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。
  17519. */
  17520. getDeltaY(): number;
  17521. /**
  17522. !#en Sets mouse button.
  17523. !#zh 设置鼠标按键。
  17524. @param button button
  17525. */
  17526. setButton(button: number): void;
  17527. /**
  17528. !#en Returns mouse button.
  17529. !#zh 获取鼠标按键。
  17530. */
  17531. getButton(): number;
  17532. /**
  17533. !#en Returns location X axis data.
  17534. !#zh 获取鼠标当前位置 X 轴。
  17535. */
  17536. getLocationX(): number;
  17537. /**
  17538. !#en Returns location Y axis data.
  17539. !#zh 获取鼠标当前位置 Y 轴。
  17540. */
  17541. getLocationY(): number;
  17542. /** !#en The none event code of mouse event.
  17543. !#zh 无。 */
  17544. static NONE: number;
  17545. /** !#en The event type code of mouse down event.
  17546. !#zh 鼠标按下事件。 */
  17547. static DOWN: number;
  17548. /** !#en The event type code of mouse up event.
  17549. !#zh 鼠标按下后释放事件。 */
  17550. static UP: number;
  17551. /** !#en The event type code of mouse move event.
  17552. !#zh 鼠标移动事件。 */
  17553. static MOVE: number;
  17554. /** !#en The event type code of mouse scroll event.
  17555. !#zh 鼠标滚轮事件。 */
  17556. static SCROLL: number;
  17557. /** !#en The tag of Mouse left button.
  17558. !#zh 鼠标左键的标签。 */
  17559. static BUTTON_LEFT: number;
  17560. /** !#en The tag of Mouse right button (The right button number is 2 on browser).
  17561. !#zh 鼠标右键的标签。 */
  17562. static BUTTON_RIGHT: number;
  17563. /** !#en The tag of Mouse middle button (The right button number is 1 on browser).
  17564. !#zh 鼠标中键的标签。 */
  17565. static BUTTON_MIDDLE: number;
  17566. /** !#en The tag of Mouse button 4.
  17567. !#zh 鼠标按键 4 的标签。 */
  17568. static BUTTON_4: number;
  17569. /** !#en The tag of Mouse button 5.
  17570. !#zh 鼠标按键 5 的标签。 */
  17571. static BUTTON_5: number;
  17572. /** !#en The tag of Mouse button 6.
  17573. !#zh 鼠标按键 6 的标签。 */
  17574. static BUTTON_6: number;
  17575. /** !#en The tag of Mouse button 7.
  17576. !#zh 鼠标按键 7 的标签。 */
  17577. static BUTTON_7: number;
  17578. /** !#en The tag of Mouse button 8.
  17579. !#zh 鼠标按键 8 的标签。 */
  17580. static BUTTON_8: number;
  17581. }
  17582. }
  17583. /****************************************************
  17584. * Event
  17585. *****************************************************/
  17586. export namespace Event {
  17587. /** !#en The touch event
  17588. !#zh 触摸事件 */
  17589. export class EventTouch extends Event {
  17590. /**
  17591. @param touchArr The array of the touches
  17592. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  17593. */
  17594. constructor(touchArr: any[], bubbles: boolean);
  17595. /** !#en The current touch object
  17596. !#zh 当前触点对象 */
  17597. touch: Touch;
  17598. /**
  17599. !#en Returns event code.
  17600. !#zh 获取事件类型。
  17601. */
  17602. getEventCode(): number;
  17603. /**
  17604. !#en Returns touches of event.
  17605. !#zh 获取触摸点的列表。
  17606. */
  17607. getTouches(): any[];
  17608. /**
  17609. !#en Sets touch location.
  17610. !#zh 设置当前触点位置
  17611. @param x x
  17612. @param y y
  17613. */
  17614. setLocation(x: number, y: number): void;
  17615. /**
  17616. !#en Returns touch location.
  17617. !#zh 获取触点位置。
  17618. */
  17619. getLocation(): Vec2;
  17620. /**
  17621. !#en Returns the current touch location in screen coordinates.
  17622. !#zh 获取当前触点在游戏窗口中的位置。
  17623. */
  17624. getLocationInView(): Vec2;
  17625. /**
  17626. !#en Returns the previous touch location.
  17627. !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
  17628. */
  17629. getPreviousLocation(): Vec2;
  17630. /**
  17631. !#en Returns the start touch location.
  17632. !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。
  17633. */
  17634. getStartLocation(): Vec2;
  17635. /**
  17636. !#en Returns the id of cc.Touch.
  17637. !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
  17638. */
  17639. getID(): number;
  17640. /**
  17641. !#en Returns the delta distance from the previous location to current location.
  17642. !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  17643. */
  17644. getDelta(): Vec2;
  17645. /**
  17646. !#en Returns the X axis delta distance from the previous location to current location.
  17647. !#zh 获取触点距离上一次事件移动的 x 轴距离。
  17648. */
  17649. getDeltaX(): number;
  17650. /**
  17651. !#en Returns the Y axis delta distance from the previous location to current location.
  17652. !#zh 获取触点距离上一次事件移动的 y 轴距离。
  17653. */
  17654. getDeltaY(): number;
  17655. /**
  17656. !#en Returns location X axis data.
  17657. !#zh 获取当前触点 X 轴位置。
  17658. */
  17659. getLocationX(): number;
  17660. /**
  17661. !#en Returns location Y axis data.
  17662. !#zh 获取当前触点 Y 轴位置。
  17663. */
  17664. getLocationY(): number;
  17665. }
  17666. }
  17667. /****************************************************
  17668. * Event
  17669. *****************************************************/
  17670. export namespace Event {
  17671. /** !#en The acceleration event
  17672. !#zh 加速度事件 */
  17673. export class EventAcceleration extends Event {
  17674. }
  17675. }
  17676. /****************************************************
  17677. * Event
  17678. *****************************************************/
  17679. export namespace Event {
  17680. /** !#en The keyboard event
  17681. !#zh 键盘事件 */
  17682. export class EventKeyboard extends Event {
  17683. /** !#en
  17684. The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key.
  17685. This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key.
  17686. If the key can't be identified, this value is 0.
  17687. !#zh
  17688. keyCode 是只读属性它表示一个系统和依赖于实现的数字代码,可以识别按键的未修改值。
  17689. 这通常是十进制 ASCII (RFC20) 或者 Windows 1252 代码,所对应的密钥。
  17690. 如果无法识别该键,则该值为 0。 */
  17691. keyCode: number;
  17692. }
  17693. }
  17694. /****************************************************
  17695. * Event
  17696. *****************************************************/
  17697. export namespace Event {
  17698. /** !#en The Custom event
  17699. !#zh 自定义事件 */
  17700. export class EventCustom extends Event {
  17701. /**
  17702. @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
  17703. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  17704. */
  17705. constructor(type: string, bubbles: boolean);
  17706. /** !#en A reference to the detailed data of the event
  17707. !#zh 事件的详细数据 */
  17708. detail: any;
  17709. /**
  17710. !#en Sets user data
  17711. !#zh 设置用户数据
  17712. @param data data
  17713. */
  17714. setUserData(data: any): void;
  17715. /**
  17716. !#en Gets user data
  17717. !#zh 获取用户数据
  17718. */
  17719. getUserData(): any;
  17720. /**
  17721. !#en Gets event name
  17722. !#zh 获取事件名称
  17723. */
  17724. getEventName(): string;
  17725. }
  17726. }
  17727. /****************************************************
  17728. * SystemEvent
  17729. *****************************************************/
  17730. export namespace SystemEvent {
  17731. /** !#en The event type supported by SystemEvent
  17732. !#zh SystemEvent 支持的事件类型 */
  17733. export class EventType {
  17734. /** !#en The event type for press the key down event, you can use its value directly: 'keydown'
  17735. !#zh 当按下按键时触发的事件 */
  17736. static KEY_DOWN: string;
  17737. /** !#en The event type for press the key up event, you can use its value directly: 'keyup'
  17738. !#zh 当松开按键时触发的事件 */
  17739. static KEY_UP: string;
  17740. /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion'
  17741. !#zh 重力感应 */
  17742. static DEVICEMOTION: string;
  17743. }
  17744. }
  17745. /****************************************************
  17746. * Graphics
  17747. *****************************************************/
  17748. export namespace Graphics {
  17749. /** !#en Enum for LineCap.
  17750. !#zh 线段末端属性 */
  17751. export enum LineCap {
  17752. BUTT = 0,
  17753. ROUND = 0,
  17754. SQUARE = 0,
  17755. }
  17756. }
  17757. /****************************************************
  17758. * Graphics
  17759. *****************************************************/
  17760. export namespace Graphics {
  17761. /** !#en Enum for LineJoin.
  17762. !#zh 线段拐角属性 */
  17763. export enum LineJoin {
  17764. BEVEL = 0,
  17765. ROUND = 0,
  17766. MITER = 0,
  17767. }
  17768. }
  17769. /****************************************************
  17770. * MeshRenderer
  17771. *****************************************************/
  17772. export namespace MeshRenderer {
  17773. /** !#en Shadow projection mode
  17774. !#ch 阴影投射方式 */
  17775. export enum ShadowCastingMode {
  17776. OFF = 0,
  17777. ON = 0,
  17778. }
  17779. }
  17780. /****************************************************
  17781. * macro
  17782. *****************************************************/
  17783. export namespace macro {
  17784. /** !#en Key map for keyboard event
  17785. !#zh 键盘事件的按键值 */
  17786. export enum KEY {
  17787. none = 0,
  17788. back = 0,
  17789. menu = 0,
  17790. backspace = 0,
  17791. tab = 0,
  17792. enter = 0,
  17793. shift = 0,
  17794. ctrl = 0,
  17795. alt = 0,
  17796. pause = 0,
  17797. capslock = 0,
  17798. escape = 0,
  17799. space = 0,
  17800. pageup = 0,
  17801. pagedown = 0,
  17802. end = 0,
  17803. home = 0,
  17804. left = 0,
  17805. up = 0,
  17806. right = 0,
  17807. down = 0,
  17808. select = 0,
  17809. insert = 0,
  17810. Delete = 0,
  17811. a = 0,
  17812. b = 0,
  17813. c = 0,
  17814. d = 0,
  17815. e = 0,
  17816. f = 0,
  17817. g = 0,
  17818. h = 0,
  17819. i = 0,
  17820. j = 0,
  17821. k = 0,
  17822. l = 0,
  17823. m = 0,
  17824. n = 0,
  17825. o = 0,
  17826. p = 0,
  17827. q = 0,
  17828. r = 0,
  17829. s = 0,
  17830. t = 0,
  17831. u = 0,
  17832. v = 0,
  17833. w = 0,
  17834. x = 0,
  17835. y = 0,
  17836. z = 0,
  17837. num0 = 0,
  17838. num1 = 0,
  17839. num2 = 0,
  17840. num3 = 0,
  17841. num4 = 0,
  17842. num5 = 0,
  17843. num6 = 0,
  17844. num7 = 0,
  17845. num8 = 0,
  17846. num9 = 0,
  17847. '*' = 0,
  17848. '+' = 0,
  17849. '-' = 0,
  17850. numdel = 0,
  17851. '/' = 0,
  17852. f1 = 0,
  17853. f2 = 0,
  17854. f3 = 0,
  17855. f4 = 0,
  17856. f5 = 0,
  17857. f6 = 0,
  17858. f7 = 0,
  17859. f8 = 0,
  17860. f9 = 0,
  17861. f10 = 0,
  17862. f11 = 0,
  17863. f12 = 0,
  17864. numlock = 0,
  17865. scrolllock = 0,
  17866. ';' = 0,
  17867. semicolon = 0,
  17868. equal = 0,
  17869. '=' = 0,
  17870. ',' = 0,
  17871. comma = 0,
  17872. dash = 0,
  17873. '.' = 0,
  17874. period = 0,
  17875. forwardslash = 0,
  17876. grave = 0,
  17877. '[' = 0,
  17878. openbracket = 0,
  17879. backslash = 0,
  17880. ']' = 0,
  17881. closebracket = 0,
  17882. quote = 0,
  17883. dpadLeft = 0,
  17884. dpadRight = 0,
  17885. dpadUp = 0,
  17886. dpadDown = 0,
  17887. dpadCenter = 0,
  17888. }
  17889. }
  17890. /****************************************************
  17891. * macro
  17892. *****************************************************/
  17893. export namespace macro {
  17894. /** Image formats */
  17895. export enum ImageFormat {
  17896. JPG = 0,
  17897. PNG = 0,
  17898. TIFF = 0,
  17899. WEBP = 0,
  17900. PVR = 0,
  17901. ETC = 0,
  17902. S3TC = 0,
  17903. ATITC = 0,
  17904. TGA = 0,
  17905. RAWDATA = 0,
  17906. UNKNOWN = 0,
  17907. }
  17908. }
  17909. /****************************************************
  17910. * macro
  17911. *****************************************************/
  17912. export namespace macro {
  17913. /** !#en
  17914. Enum for blend factor
  17915. Refer to: http://www.andersriggelsen.dk/glblendfunc.php
  17916. !#zh
  17917. 混合因子
  17918. 可参考: http://www.andersriggelsen.dk/glblendfunc.php */
  17919. export enum BlendFactor {
  17920. ONE = 0,
  17921. ZERO = 0,
  17922. SRC_ALPHA = 0,
  17923. SRC_COLOR = 0,
  17924. DST_ALPHA = 0,
  17925. DST_COLOR = 0,
  17926. ONE_MINUS_SRC_ALPHA = 0,
  17927. ONE_MINUS_SRC_COLOR = 0,
  17928. ONE_MINUS_DST_ALPHA = 0,
  17929. ONE_MINUS_DST_COLOR = 0,
  17930. }
  17931. }
  17932. /****************************************************
  17933. * macro
  17934. *****************************************************/
  17935. export namespace macro {
  17936. /** undefined */
  17937. export enum TextAlignment {
  17938. LEFT = 0,
  17939. CENTER = 0,
  17940. RIGHT = 0,
  17941. }
  17942. }
  17943. /****************************************************
  17944. * sys
  17945. *****************************************************/
  17946. export namespace sys {
  17947. /** !#en
  17948. Network type enumeration
  17949. !#zh
  17950. 网络类型枚举 */
  17951. export enum NetworkType {
  17952. NONE = 0,
  17953. LAN = 0,
  17954. WWAN = 0,
  17955. }
  17956. }
  17957. /****************************************************
  17958. * geomUtils
  17959. *****************************************************/
  17960. export namespace geomUtils {
  17961. /** Aabb */
  17962. export class Aabb {
  17963. /**
  17964. create a new aabb
  17965. @param px X coordinates for aabb's original point
  17966. @param py Y coordinates for aabb's original point
  17967. @param pz Z coordinates for aabb's original point
  17968. @param w the half of aabb width
  17969. @param h the half of aabb height
  17970. @param l the half of aabb length
  17971. */
  17972. create(px: number, py: number, pz: number, w: number, h: number, l: number): Aabb;
  17973. /**
  17974. clone a new aabb
  17975. @param a the source aabb
  17976. */
  17977. clone(a: Aabb): Aabb;
  17978. /**
  17979. copy the values from one aabb to another
  17980. @param out the receiving aabb
  17981. @param a the source aabb
  17982. */
  17983. copy(out: Aabb, a: Aabb): Aabb;
  17984. /**
  17985. create a new aabb from two corner points
  17986. @param out the receiving aabb
  17987. @param minPos lower corner position of the aabb
  17988. @param maxPos upper corner position of the aabb
  17989. */
  17990. fromPoints(out: Aabb, minPos: Vec3, maxPos: Vec3): Aabb;
  17991. /**
  17992. Set the components of a aabb to the given values
  17993. @param out the receiving aabb
  17994. @param px X coordinates for aabb's original point
  17995. @param py Y coordinates for aabb's original point
  17996. @param pz Z coordinates for aabb's original point
  17997. @param w the half of aabb width
  17998. @param h the half of aabb height
  17999. @param l the half of aabb length
  18000. */
  18001. set(out: Aabb, px: number, py: number, pz: number, w: number, h: number, l: number): Aabb;
  18002. center: Vec3;
  18003. halfExtents: Vec3;
  18004. _type: number;
  18005. /**
  18006. Get the bounding points of this shape
  18007. @param minPos minPos
  18008. @param maxPos maxPos
  18009. */
  18010. getBoundary(minPos: Vec3, maxPos: Vec3): void;
  18011. /**
  18012. Transform this shape
  18013. @param m the transform matrix
  18014. @param pos the position part of the transform
  18015. @param rot the rotation part of the transform
  18016. @param scale the scale part of the transform
  18017. @param out the target shape
  18018. */
  18019. transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out?: Aabb): void;
  18020. }
  18021. }
  18022. /****************************************************
  18023. * geomUtils
  18024. *****************************************************/
  18025. export namespace geomUtils {
  18026. /** !#en Shape type. */
  18027. export enum enums {
  18028. SHAPE_RAY = 0,
  18029. SHAPE_LINE = 0,
  18030. SHAPE_SPHERE = 0,
  18031. SHAPE_AABB = 0,
  18032. SHAPE_OBB = 0,
  18033. SHAPE_PLANE = 0,
  18034. SHAPE_TRIANGLE = 0,
  18035. SHAPE_FRUSTUM = 0,
  18036. SHAPE_FRUSTUM_ACCURATE = 0,
  18037. }
  18038. }
  18039. /****************************************************
  18040. * geomUtils
  18041. *****************************************************/
  18042. export namespace geomUtils {
  18043. /** !#en frustum
  18044. !#zh 平截头体 */
  18045. export class Frustum {
  18046. /** Set whether to use accurate intersection testing function on this frustum */
  18047. accurate: boolean;
  18048. /**
  18049. create a new frustum
  18050. */
  18051. static create(): Frustum;
  18052. /**
  18053. Clone a frustum
  18054. @param f f
  18055. */
  18056. static clone(f: Frustum): Frustum;
  18057. /**
  18058. Copy the values from one frustum to another
  18059. @param out out
  18060. @param f f
  18061. */
  18062. copy(out: Frustum, f: Frustum): Frustum;
  18063. planes: geomUtils.Plane[];
  18064. planes: Vec3[];
  18065. /**
  18066. !#en Update the frustum information according to the given transform matrix.
  18067. Note that the resulting planes are not normalized under normal mode.
  18068. @param m the view-projection matrix
  18069. @param inv the inverse view-projection matrix
  18070. */
  18071. update(m: Mat4, inv: Mat4): void;
  18072. /**
  18073. !#en transform by matrix
  18074. @param mat mat
  18075. */
  18076. transform(mat: Mat4): void;
  18077. }
  18078. }
  18079. /****************************************************
  18080. * geomUtils
  18081. *****************************************************/
  18082. export namespace geomUtils {
  18083. /** !#en
  18084. line
  18085. !#zh
  18086. 直线 */
  18087. export class Line {
  18088. /**
  18089. !#en
  18090. create a new line
  18091. !#zh
  18092. 创建一个新的 line。
  18093. @param sx The x part of the starting point.
  18094. @param sy The y part of the starting point.
  18095. @param sz The z part of the starting point.
  18096. @param ex The x part of the end point.
  18097. @param ey The y part of the end point.
  18098. @param ez The z part of the end point.
  18099. */
  18100. create(sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line;
  18101. /**
  18102. !#en
  18103. Creates a new line initialized with values from an existing line
  18104. !#zh
  18105. 克隆一个新的 line。
  18106. @param a The source of cloning.
  18107. */
  18108. clone(a: Line): Line;
  18109. /**
  18110. !#en
  18111. Copy the values from one line to another
  18112. !#zh
  18113. 复制一个线的值到另一个。
  18114. @param out The object that accepts the action.
  18115. @param a The source of the copy.
  18116. */
  18117. copy(out: Line, a: Line): Line;
  18118. /**
  18119. !#en
  18120. create a line from two points
  18121. !#zh
  18122. 用两个点创建一个线。
  18123. @param out The object that accepts the action.
  18124. @param start The starting point.
  18125. @param end At the end.
  18126. */
  18127. fromPoints(out: Line, start: Vec3, end: Vec3): Line;
  18128. /**
  18129. !#en
  18130. Set the components of a Vec3 to the given values
  18131. !#zh
  18132. 将给定线的属性设置为给定值。
  18133. @param out The object that accepts the action.
  18134. @param sx The x part of the starting point.
  18135. @param sy The y part of the starting point.
  18136. @param sz The z part of the starting point.
  18137. @param ex The x part of the end point.
  18138. @param ey The y part of the end point.
  18139. @param ez The z part of the end point.
  18140. */
  18141. set(out: Line, sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line;
  18142. /**
  18143. !#en
  18144. Calculate the length of the line.
  18145. !#zh
  18146. 计算线的长度。
  18147. @param a The line to calculate.
  18148. */
  18149. len(a: Line): number;
  18150. /** !#en
  18151. Start points.
  18152. !#zh
  18153. 起点。 */
  18154. s: Vec3;
  18155. /** !#en
  18156. End points.
  18157. !#zh
  18158. 终点。 */
  18159. e: Vec3;
  18160. /**
  18161. !#en
  18162. Calculate the length of the line.
  18163. !#zh
  18164. 计算线的长度。
  18165. */
  18166. length(): number;
  18167. }
  18168. }
  18169. /****************************************************
  18170. * geomUtils
  18171. *****************************************************/
  18172. export namespace geomUtils {
  18173. /** !#en obb
  18174. !#zh
  18175. 基础几何 方向包围盒。 */
  18176. export class Obb {
  18177. /** !#zh
  18178. 获取形状的类型。 */
  18179. type: number;
  18180. /**
  18181. !#en
  18182. create a new obb
  18183. !#zh
  18184. 创建一个新的 obb 实例。
  18185. @param cx X coordinates of the shape relative to the origin.
  18186. @param cy Y coordinates of the shape relative to the origin.
  18187. @param cz Z coordinates of the shape relative to the origin.
  18188. @param hw Obb is half the width.
  18189. @param hh Obb is half the height.
  18190. @param hl Obb is half the Length.
  18191. @param ox_1 Direction matrix parameter.
  18192. @param ox_2 Direction matrix parameter.
  18193. @param ox_3 Direction matrix parameter.
  18194. @param oy_1 Direction matrix parameter.
  18195. @param oy_2 Direction matrix parameter.
  18196. @param oy_3 Direction matrix parameter.
  18197. @param oz_1 Direction matrix parameter.
  18198. @param oz_2 Direction matrix parameter.
  18199. @param oz_3 Direction matrix parameter.
  18200. */
  18201. create(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb;
  18202. /**
  18203. !#en
  18204. clone a new obb
  18205. !#zh
  18206. 克隆一个 obb。
  18207. @param a The target of cloning.
  18208. */
  18209. clone(a: Obb): Obb;
  18210. /**
  18211. !#en
  18212. copy the values from one obb to another
  18213. !#zh
  18214. 将从一个 obb 的值复制到另一个 obb。
  18215. @param out Obb that accepts the operation.
  18216. @param a Obb being copied.
  18217. */
  18218. copy(out: Obb, a: Obb): Obb;
  18219. /**
  18220. !#en
  18221. create a new obb from two corner points
  18222. !#zh
  18223. 用两个点创建一个新的 obb。
  18224. @param out Obb that accepts the operation.
  18225. @param minPos The smallest point of obb.
  18226. @param maxPos Obb's maximum point.
  18227. */
  18228. fromPoints(out: Obb, minPos: Vec3, maxPos: Vec3): Obb;
  18229. /**
  18230. !#en
  18231. Set the components of a obb to the given values
  18232. !#zh
  18233. 将给定 obb 的属性设置为给定的值。
  18234. @param cx X coordinates of the shape relative to the origin.
  18235. @param cy Y coordinates of the shape relative to the origin.
  18236. @param cz Z coordinates of the shape relative to the origin.
  18237. @param hw Obb is half the width.
  18238. @param hh Obb is half the height.
  18239. @param hl Obb is half the Length.
  18240. @param ox_1 Direction matrix parameter.
  18241. @param ox_2 Direction matrix parameter.
  18242. @param ox_3 Direction matrix parameter.
  18243. @param oy_1 Direction matrix parameter.
  18244. @param oy_2 Direction matrix parameter.
  18245. @param oy_3 Direction matrix parameter.
  18246. @param oz_1 Direction matrix parameter.
  18247. @param oz_2 Direction matrix parameter.
  18248. @param oz_3 Direction matrix parameter.
  18249. */
  18250. set(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb;
  18251. /** !#en
  18252. The center of the local coordinate.
  18253. !#zh
  18254. 本地坐标的中心点。 */
  18255. center: Vec3;
  18256. /** !#en
  18257. Half the length, width, and height.
  18258. !#zh
  18259. 长宽高的一半。 */
  18260. halfExtents: Vec3;
  18261. /** !#en
  18262. Direction matrix.
  18263. !#zh
  18264. 方向矩阵。 */
  18265. orientation: Mat3;
  18266. /**
  18267. !#en
  18268. Get the bounding points of this shape
  18269. !#zh
  18270. 获取 obb 的最小点和最大点。
  18271. @param minPos minPos
  18272. @param maxPos maxPos
  18273. */
  18274. getBoundary(minPos: Vec3, maxPos: Vec3): void;
  18275. /**
  18276. !#en Transform this shape
  18277. !#zh
  18278. 将 out 根据这个 obb 的数据进行变换。
  18279. @param m The transformation matrix.
  18280. @param pos The position part of the transformation.
  18281. @param rot The rotating part of the transformation.
  18282. @param scale The scaling part of the transformation.
  18283. @param out Target of transformation.
  18284. */
  18285. transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out: Obb): void;
  18286. /**
  18287. !#en
  18288. Transform out based on this obb data.
  18289. !#zh
  18290. 将 out 根据这个 obb 的数据进行变换。
  18291. @param m The transformation matrix.
  18292. @param rot The rotating part of the transformation.
  18293. @param out Target of transformation.
  18294. */
  18295. translateAndRotate(m: Mat4, rot: Quat, out: Obb): void;
  18296. /**
  18297. !#en
  18298. Scale out based on this obb data.
  18299. !#zh
  18300. 将 out 根据这个 obb 的数据进行缩放。
  18301. @param scale Scale value.
  18302. @param out Scaled target.
  18303. */
  18304. setScale(scale: Vec3, out: Obb): void;
  18305. }
  18306. }
  18307. /****************************************************
  18308. * geomUtils
  18309. *****************************************************/
  18310. export namespace geomUtils {
  18311. /** undefined */
  18312. export class intersect {
  18313. /**
  18314. !#en
  18315. Check whether ray intersect with nodes
  18316. !#zh
  18317. 检测射线是否与物体有交集
  18318. @param root If root is null, then traversal nodes from scene node
  18319. @param worldRay worldRay
  18320. @param handler handler
  18321. @param filter filter
  18322. */
  18323. static ray_cast(root: Node, worldRay: geomUtils.Ray, handler: Function, filter: Function): any[];
  18324. /**
  18325. !#en ray-plane intersect<br/>
  18326. !#zh 射线与平面的相交性检测。
  18327. @param ray ray
  18328. @param plane plane
  18329. */
  18330. static ray_plane(ray: geomUtils.Ray, plane: geomUtils.Plane): number;
  18331. /**
  18332. !#en line-plane intersect<br/>
  18333. !#zh 线段与平面的相交性检测。
  18334. @param line line
  18335. @param plane plane
  18336. */
  18337. static line_plane(line: Line, plane: geomUtils.Plane): number;
  18338. /**
  18339. !#en ray-triangle intersect<br/>
  18340. !#zh 射线与三角形的相交性检测。
  18341. @param ray ray
  18342. @param triangle triangle
  18343. @param doubleSided doubleSided
  18344. */
  18345. static ray_triangle(ray: geomUtils.Ray, triangle: geomUtils.Triangle, doubleSided: boolean): number;
  18346. /**
  18347. !#en line-triangle intersect<br/>
  18348. !#zh 线段与三角形的相交性检测。
  18349. @param line line
  18350. @param triangle triangle
  18351. @param outPt optional, The intersection point
  18352. */
  18353. static line_triangle(line: Line, triangle: geomUtils.Triangle, outPt: Vec3): number;
  18354. /**
  18355. !#en line-quad intersect<br/>
  18356. !#zh 线段与四边形的相交性检测。
  18357. @param p A point on a line segment
  18358. @param q Another point on the line segment
  18359. @param a Quadrilateral point a
  18360. @param b Quadrilateral point b
  18361. @param c Quadrilateral point c
  18362. @param d Quadrilateral point d
  18363. @param outPt optional, The intersection point
  18364. */
  18365. static line_quad(p: Vec3, q: Vec3, a: Vec3, b: Vec3, c: Vec3, d: Vec3, outPt: Vec3): number;
  18366. /**
  18367. !#en ray-sphere intersect<br/>
  18368. !#zh 射线和球的相交性检测。
  18369. @param ray ray
  18370. @param sphere sphere
  18371. */
  18372. static ray_sphere(ray: geomUtils.Ray, sphere: geomUtils.Sphere): number;
  18373. /**
  18374. !#en ray-aabb intersect<br/>
  18375. !#zh 射线和轴对齐包围盒的相交性检测。
  18376. @param ray ray
  18377. @param aabb Align the axis around the box
  18378. */
  18379. static ray_aabb(ray: geomUtils.Ray, aabb: Aabb): number;
  18380. /**
  18381. !#en ray-obb intersect<br/>
  18382. !#zh 射线和方向包围盒的相交性检测。
  18383. @param ray ray
  18384. @param obb Direction box
  18385. */
  18386. static ray_obb(ray: geomUtils.Ray, obb: Obb): number;
  18387. /**
  18388. !#en aabb-aabb intersect<br/>
  18389. !#zh 轴对齐包围盒和轴对齐包围盒的相交性检测。
  18390. @param aabb1 Axis alignment surrounds box 1
  18391. @param aabb2 Axis alignment surrounds box 2
  18392. */
  18393. static aabb_aabb(aabb1: Aabb, aabb2: Aabb): number;
  18394. /**
  18395. !#en aabb-obb intersect<br/>
  18396. !#zh 轴对齐包围盒和方向包围盒的相交性检测。
  18397. @param aabb Align the axis around the box
  18398. @param obb Direction box
  18399. */
  18400. static aabb_obb(aabb: Aabb, obb: Obb): number;
  18401. /**
  18402. !#en aabb-plane intersect<br/>
  18403. !#zh 轴对齐包围盒和平面的相交性检测。
  18404. @param aabb Align the axis around the box
  18405. @param plane plane
  18406. */
  18407. static aabb_plane(aabb: Aabb, plane: geomUtils.Plane): number;
  18408. /**
  18409. !#en aabb-frustum intersect, faster but has false positive corner cases<br/>
  18410. !#zh 轴对齐包围盒和锥台相交性检测,速度快,但有错误情况。
  18411. @param aabb Align the axis around the box
  18412. @param frustum frustum
  18413. */
  18414. static aabb_frustum(aabb: Aabb, frustum: Frustum): number;
  18415. /**
  18416. !#en aabb-frustum intersect, handles most of the false positives correctly<br/>
  18417. !#zh 轴对齐包围盒和锥台相交性检测,正确处理大多数错误情况。
  18418. @param aabb Align the axis around the box
  18419. @param frustum frustum
  18420. */
  18421. static aabb_frustum_accurate(aabb: Aabb, frustum: Frustum): number;
  18422. /**
  18423. !#en obb-point intersect<br/>
  18424. !#zh 方向包围盒和点的相交性检测。
  18425. @param obb Direction box
  18426. @param point point
  18427. */
  18428. static obb_point(obb: Obb, point: geomUtils.Vec3): boolean;
  18429. /**
  18430. !#en obb-plane intersect<br/>
  18431. !#zh 方向包围盒和平面的相交性检测。
  18432. @param obb Direction box
  18433. @param plane plane
  18434. */
  18435. static obb_plane(obb: Obb, plane: geomUtils.Plane): number;
  18436. /**
  18437. !#en obb-frustum intersect, faster but has false positive corner cases<br/>
  18438. !#zh 方向包围盒和锥台相交性检测,速度快,但有错误情况。
  18439. @param obb Direction box
  18440. @param frustum frustum
  18441. */
  18442. static obb_frustum(obb: Obb, frustum: Frustum): number;
  18443. /**
  18444. !#en obb-frustum intersect, handles most of the false positives correctly<br/>
  18445. !#zh 方向包围盒和锥台相交性检测,正确处理大多数错误情况。
  18446. @param obb Direction box
  18447. @param frustum frustum
  18448. */
  18449. static obb_frustum_accurate(obb: Obb, frustum: Frustum): number;
  18450. /**
  18451. !#en obb-obb intersect<br/>
  18452. !#zh 方向包围盒和方向包围盒的相交性检测。
  18453. @param obb1 Direction box1
  18454. @param obb2 Direction box2
  18455. */
  18456. static obb_obb(obb1: Obb, obb2: Obb): number;
  18457. /**
  18458. !#en phere-plane intersect, not necessarily faster than obb-plane<br/>
  18459. due to the length calculation of the plane normal to factor out<br/>
  18460. the unnomalized plane distance<br/>
  18461. !#zh 球与平面的相交性检测。
  18462. @param sphere sphere
  18463. @param plane plane
  18464. */
  18465. static sphere_plane(sphere: geomUtils.Sphere, plane: geomUtils.Plane): number;
  18466. /**
  18467. !#en sphere-frustum intersect, faster but has false positive corner cases<br/>
  18468. !#zh 球和锥台的相交性检测,速度快,但有错误情况。
  18469. @param sphere sphere
  18470. @param frustum frustum
  18471. */
  18472. static sphere_frustum(sphere: geomUtils.Sphere, frustum: Frustum): number;
  18473. /**
  18474. !#en sphere-frustum intersect, handles the false positives correctly<br/>
  18475. !#zh 球和锥台的相交性检测,正确处理大多数错误情况。
  18476. @param sphere sphere
  18477. @param frustum frustum
  18478. */
  18479. static sphere_frustum_accurate(sphere: geomUtils.Sphere, frustum: Frustum): number;
  18480. /**
  18481. !#en sphere-sphere intersect<br/>
  18482. !#zh 球和球的相交性检测。
  18483. @param sphere0 sphere0
  18484. @param sphere1 sphere1
  18485. */
  18486. static sphere_sphere(sphere0: geomUtils.Sphere, sphere1: geomUtils.Sphere): boolean;
  18487. /**
  18488. !#en sphere-aabb intersect<br/>
  18489. !#zh 球和轴对齐包围盒的相交性检测。
  18490. @param sphere sphere
  18491. @param aabb aabb
  18492. */
  18493. static sphere_aabb(sphere: geomUtils.Sphere, aabb: Aabb): boolean;
  18494. /**
  18495. !#en sphere-obb intersect<br/>
  18496. !#zh 球和方向包围盒的相交性检测。
  18497. @param sphere sphere
  18498. @param obb obb
  18499. */
  18500. static sphere_obb(sphere: geomUtils.Sphere, obb: Obb): boolean;
  18501. /**
  18502. !#en
  18503. The intersection detection of g1 and g2 can fill in the shape in the basic geometry.
  18504. !#zh
  18505. g1 和 g2 的相交性检测,可填入基础几何中的形状。
  18506. @param g1 Geometry 1
  18507. @param g2 Geometry 2
  18508. @param outPt optional, Intersection point. (note: only partial shape detection with this return value)
  18509. */
  18510. static resolve(g1: any, g2: any, outPt: any): void;
  18511. }
  18512. }
  18513. /****************************************************
  18514. * geomUtils
  18515. *****************************************************/
  18516. export namespace geomUtils {
  18517. /** !#en
  18518. plane。
  18519. !#zh
  18520. 平面。 */
  18521. export class Plane {
  18522. /**
  18523. !#en
  18524. create a new plane
  18525. !#zh
  18526. 创建一个新的 plane。
  18527. @param nx The x part of the normal component.
  18528. @param ny The y part of the normal component.
  18529. @param nz The z part of the normal component.
  18530. @param d Distance from the origin.
  18531. */
  18532. create(nx: number, ny: number, nz: number, d: number): Plane;
  18533. /**
  18534. !#en
  18535. clone a new plane
  18536. !#zh
  18537. 克隆一个新的 plane。
  18538. @param p The source of cloning.
  18539. */
  18540. clone(p: Plane): Plane;
  18541. /**
  18542. !#en
  18543. copy the values from one plane to another
  18544. !#zh
  18545. 复制一个平面的值到另一个。
  18546. @param out The object that accepts the action.
  18547. @param p The source of the copy.
  18548. */
  18549. copy(out: Plane, p: Plane): Plane;
  18550. /**
  18551. !#en
  18552. create a plane from three points
  18553. !#zh
  18554. 用三个点创建一个平面。
  18555. @param out The object that accepts the action.
  18556. @param a Point a。
  18557. @param b Point b。
  18558. @param c Point c。
  18559. */
  18560. fromPoints(out: Plane, a: Vec3, b: Vec3, c: Vec3): Plane;
  18561. /**
  18562. !#en
  18563. Set the components of a plane to the given values
  18564. !#zh
  18565. 将给定平面的属性设置为给定值。
  18566. @param out The object that accepts the action.
  18567. @param nx The x part of the normal component.
  18568. @param ny The y part of the normal component.
  18569. @param nz The z part of the normal component.
  18570. @param d Distance from the origin.
  18571. */
  18572. set(out: Plane, nx: number, ny: number, nz: number, d: number): Plane;
  18573. /**
  18574. !#en
  18575. create plane from normal and point
  18576. !#zh
  18577. 用一条法线和一个点创建平面。
  18578. @param out The object that accepts the action.
  18579. @param normal The normal of a plane.
  18580. @param point A point on the plane.
  18581. */
  18582. fromNormalAndPoint(out: Plane, normal: Vec3, point: Vec3): Plane;
  18583. /**
  18584. !#en
  18585. normalize a plane
  18586. !#zh
  18587. 归一化一个平面。
  18588. @param out The object that accepts the action.
  18589. @param a Source data for operations.
  18590. */
  18591. normalize(out: Plane, a: Plane): Plane;
  18592. /** !#en
  18593. A normal vector.
  18594. !#zh
  18595. 法线向量。 */
  18596. n: Vec3;
  18597. /** !#en
  18598. The distance from the origin to the plane.
  18599. !#zh
  18600. 原点到平面的距离。 */
  18601. d: number;
  18602. /**
  18603. !#en
  18604. Transform a plane.
  18605. !#zh
  18606. 变换一个平面。
  18607. @param mat mat
  18608. */
  18609. transform(mat: Mat4): void;
  18610. }
  18611. }
  18612. /****************************************************
  18613. * geomUtils
  18614. *****************************************************/
  18615. export namespace geomUtils {
  18616. /** !#en
  18617. ray
  18618. !#zh
  18619. 射线。 */
  18620. export class Ray {
  18621. /**
  18622. !#en
  18623. create a new ray
  18624. !#zh
  18625. 创建一条射线。
  18626. @param ox The x part of the starting point.
  18627. @param oy The y part of the starting point.
  18628. @param oz The z part of the starting point.
  18629. @param dx X in the direction.
  18630. @param dy Y in the direction.
  18631. @param dz Z in the direction.
  18632. */
  18633. create(ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray;
  18634. /**
  18635. !#en
  18636. Creates a new ray initialized with values from an existing ray
  18637. !#zh
  18638. 从一条射线克隆出一条新的射线。
  18639. @param a Clone target
  18640. */
  18641. clone(a: Ray): Ray;
  18642. /**
  18643. !#en
  18644. Copy the values from one ray to another
  18645. !#zh
  18646. 将从一个 ray 的值复制到另一个 ray。
  18647. @param out Accept the ray of the operation.
  18648. @param a Copied ray.
  18649. */
  18650. copy(out: Ray, a: Ray): Ray;
  18651. /**
  18652. !#en
  18653. create a ray from two points
  18654. !#zh
  18655. 用两个点创建一条射线。
  18656. @param out Receive the operating ray.
  18657. @param origin Origin of ray
  18658. @param target A point on a ray.
  18659. */
  18660. fromPoints(out: Ray, origin: Vec3, target: Vec3): Ray;
  18661. /**
  18662. !#en
  18663. Set the components of a ray to the given values
  18664. !#zh
  18665. 将给定射线的属性设置为给定的值。
  18666. @param out Receive the operating ray.
  18667. @param ox The x part of the starting point.
  18668. @param oy The y part of the starting point.
  18669. @param oz The z part of the starting point.
  18670. @param dx X in the direction.
  18671. @param dy Y in the direction.
  18672. @param dz Z in the direction.
  18673. */
  18674. set(out: Ray, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray;
  18675. /** !#en
  18676. Start point.
  18677. !#zh
  18678. 起点。 */
  18679. o: Vec3;
  18680. /** !#e
  18681. Direction
  18682. !#zh
  18683. 方向。 */
  18684. d: Vec3;
  18685. /**
  18686. !#en Compute hit.
  18687. @param out out
  18688. @param distance distance
  18689. */
  18690. computeHit(out: IVec3Like, distance: number): void;
  18691. }
  18692. }
  18693. /****************************************************
  18694. * geomUtils
  18695. *****************************************************/
  18696. export namespace geomUtils {
  18697. /** !#en
  18698. Sphere.
  18699. !#zh
  18700. 轴对齐球。 */
  18701. export class Sphere {
  18702. /**
  18703. !#en
  18704. create a new sphere
  18705. !#zh
  18706. 创建一个新的 sphere 实例。
  18707. @param cx X coordinates of the shape relative to the origin.
  18708. @param cy Y coordinates of the shape relative to the origin.
  18709. @param cz Z coordinates of the shape relative to the origin.
  18710. @param r Radius of sphere
  18711. */
  18712. create(cx: any, cy: any, cz: any, r: any): Sphere;
  18713. /**
  18714. !#en
  18715. clone a new sphere
  18716. !#zh
  18717. 克隆一个新的 sphere 实例。
  18718. @param p The target of cloning.
  18719. */
  18720. clone(p: Sphere): Sphere;
  18721. /**
  18722. !#en
  18723. copy the values from one sphere to another
  18724. !#zh
  18725. 将从一个 sphere 的值复制到另一个 sphere。
  18726. @param out Accept the sphere of operations.
  18727. @param a Sphere being copied.
  18728. */
  18729. copy(out: Sphere, a: Sphere): Sphere;
  18730. /**
  18731. !#en
  18732. create a new bounding sphere from two corner points
  18733. !#zh
  18734. 从两个点创建一个新的 sphere。
  18735. @param out Accept the sphere of operations.
  18736. @param minPos The smallest point of sphere.
  18737. @param maxPos The maximum point of sphere.
  18738. */
  18739. fromPoints(out: any, minPos: any, maxPos: any): Sphere;
  18740. /**
  18741. !#en Set the components of a sphere to the given values
  18742. !#zh 将球体的属性设置为给定的值。
  18743. @param out Accept the sphere of operations.
  18744. @param cx X coordinates of the shape relative to the origin.
  18745. @param cy Y coordinates of the shape relative to the origin.
  18746. @param cz Z coordinates of the shape relative to the origin.
  18747. @param r Radius.
  18748. */
  18749. set(out: Sphere, cx: any, cy: any, cz: any, r: number): Sphere;
  18750. /** !#en
  18751. The center of the local coordinate.
  18752. !#zh
  18753. 本地坐标的中心点。 */
  18754. center: Vec3;
  18755. /** !#zh
  18756. 半径。 */
  18757. radius: number;
  18758. /**
  18759. !#en
  18760. Clone.
  18761. !#zh
  18762. 获得克隆。
  18763. */
  18764. clone(): void;
  18765. /**
  18766. !#en
  18767. Copy sphere
  18768. !#zh
  18769. 拷贝对象。
  18770. @param a Copy target.
  18771. */
  18772. copy(a: any): void;
  18773. /**
  18774. !#en
  18775. Get the bounding points of this shape
  18776. !#zh
  18777. 获取此形状的边界点。
  18778. @param minPos minPos
  18779. @param maxPos maxPos
  18780. */
  18781. getBoundary(minPos: Vec3, maxPos: Vec3): void;
  18782. /**
  18783. !#en
  18784. Transform this shape
  18785. !#zh
  18786. 将 out 根据这个 sphere 的数据进行变换。
  18787. @param m The transformation matrix.
  18788. @param pos The position part of the transformation.
  18789. @param rot The rotating part of the transformation.
  18790. @param scale The scaling part of the transformation.
  18791. @param out The target of the transformation.
  18792. */
  18793. transform(m: any, pos: any, rot: any, scale: any, out: any): void;
  18794. /**
  18795. !#en
  18796. Scale out based on the sphere data.
  18797. !#zh
  18798. 将 out 根据这个 sphere 的数据进行缩放。
  18799. @param scale Scale value
  18800. @param out Scale target
  18801. */
  18802. setScale(scale: any, out: any): void;
  18803. }
  18804. }
  18805. /****************************************************
  18806. * geomUtils
  18807. *****************************************************/
  18808. export namespace geomUtils {
  18809. /** Triangle */
  18810. export class Triangle {
  18811. /**
  18812. create a new triangle
  18813. @param ax ax
  18814. @param ay ay
  18815. @param az az
  18816. @param bx bx
  18817. @param by by
  18818. @param bz bz
  18819. @param cx cx
  18820. @param cy cy
  18821. @param cz cz
  18822. */
  18823. create(ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Triangle;
  18824. /**
  18825. clone a new triangle
  18826. @param t the source plane
  18827. */
  18828. clone(t: Triangle): Triangle;
  18829. /**
  18830. copy the values from one triangle to another
  18831. @param out the receiving triangle
  18832. @param t the source triangle
  18833. */
  18834. copy(out: Triangle, t: Triangle): Triangle;
  18835. /**
  18836. Create a triangle from three points
  18837. @param out the receiving triangle
  18838. @param a a
  18839. @param b b
  18840. @param c c
  18841. */
  18842. fromPoints(out: Triangle, a: Vec3, b: Vec3, c: Vec3): Triangle;
  18843. /**
  18844. Set the components of a triangle to the given values
  18845. @param out the receiving plane
  18846. @param ax X component of a
  18847. @param ay Y component of a
  18848. @param az Z component of a
  18849. @param bx X component of b
  18850. @param by Y component of b
  18851. @param bz Z component of b
  18852. @param cx X component of c
  18853. @param cy Y component of c
  18854. @param cz Z component of c
  18855. */
  18856. set(out: Triangle, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Plane;
  18857. a: Vec3;
  18858. b: Vec3;
  18859. c: Vec3;
  18860. }
  18861. }
  18862. /****************************************************
  18863. * PhysicsManager
  18864. *****************************************************/
  18865. export namespace PhysicsManager {
  18866. /** !#en
  18867. The draw bits for drawing physics debug information.<br>
  18868. example:<br>
  18869. ```js
  18870. cc.director.getPhysicsManager().debugDrawFlags =
  18871. // cc.PhysicsManager.DrawBits.e_aabbBit |
  18872. // cc.PhysicsManager.DrawBits.e_pairBit |
  18873. // cc.PhysicsManager.DrawBits.e_centerOfMassBit |
  18874. cc.PhysicsManager.DrawBits.e_jointBit |
  18875. cc.PhysicsManager.DrawBits.e_shapeBit;
  18876. ```
  18877. !#zh
  18878. 指定物理系统需要绘制哪些调试信息。<br>
  18879. example:<br>
  18880. ```js
  18881. cc.director.getPhysicsManager().debugDrawFlags =
  18882. // cc.PhysicsManager.DrawBits.e_aabbBit |
  18883. // cc.PhysicsManager.DrawBits.e_pairBit |
  18884. // cc.PhysicsManager.DrawBits.e_centerOfMassBit |
  18885. cc.PhysicsManager.DrawBits.e_jointBit |
  18886. cc.PhysicsManager.DrawBits.e_shapeBit;
  18887. ``` */
  18888. export enum DrawBits {
  18889. e_aabbBit = 0,
  18890. e_jointBit = 0,
  18891. e_shapeBit = 0,
  18892. }
  18893. }
  18894. /****************************************************
  18895. * RenderTexture
  18896. *****************************************************/
  18897. export namespace RenderTexture {
  18898. /** !#en The depth buffer and stencil buffer format for RenderTexture.
  18899. !#zh RenderTexture 的深度缓冲以及模板缓冲格式。 */
  18900. export enum DepthStencilFormat {
  18901. RB_FMT_D24S8 = 0,
  18902. RB_FMT_S8 = 0,
  18903. RB_FMT_D16 = 0,
  18904. }
  18905. }
  18906. /****************************************************
  18907. * Prefab
  18908. *****************************************************/
  18909. export namespace Prefab {
  18910. /** !#zh
  18911. Prefab 创建实例所用的优化策略,配合 {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} 使用。
  18912. !#en
  18913. An enumeration used with the {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}}
  18914. to specify how to optimize the instantiate operation. */
  18915. export enum OptimizationPolicy {
  18916. AUTO = 0,
  18917. SINGLE_INSTANCE = 0,
  18918. MULTI_INSTANCE = 0,
  18919. }
  18920. }
  18921. /****************************************************
  18922. * Texture2D
  18923. *****************************************************/
  18924. export namespace Texture2D {
  18925. /** The texture pixel format, default value is RGBA8888,
  18926. you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format,
  18927. other formats are supported by compressed file types or raw data. */
  18928. export enum PixelFormat {
  18929. RGB565 = 0,
  18930. RGB5A1 = 0,
  18931. RGBA4444 = 0,
  18932. RGB888 = 0,
  18933. RGBA8888 = 0,
  18934. RGBA32F = 0,
  18935. A8 = 0,
  18936. I8 = 0,
  18937. AI88 = 0,
  18938. RGB_PVRTC_2BPPV1 = 0,
  18939. RGBA_PVRTC_2BPPV1 = 0,
  18940. RGB_A_PVRTC_2BPPV1 = 0,
  18941. RGB_PVRTC_4BPPV1 = 0,
  18942. RGBA_PVRTC_4BPPV1 = 0,
  18943. RGB_A_PVRTC_4BPPV1 = 0,
  18944. RGB_ETC1 = 0,
  18945. RGBA_ETC1 = 0,
  18946. RGB_ETC2 = 0,
  18947. RGBA_ETC2 = 0,
  18948. }
  18949. }
  18950. /****************************************************
  18951. * Texture2D
  18952. *****************************************************/
  18953. export namespace Texture2D {
  18954. /** The texture wrap mode */
  18955. export enum WrapMode {
  18956. REPEAT = 0,
  18957. CLAMP_TO_EDGE = 0,
  18958. MIRRORED_REPEAT = 0,
  18959. }
  18960. }
  18961. /****************************************************
  18962. * Texture2D
  18963. *****************************************************/
  18964. export namespace Texture2D {
  18965. /** The texture filter mode */
  18966. export enum Filter {
  18967. LINEAR = 0,
  18968. NEAREST = 0,
  18969. }
  18970. }
  18971. /****************************************************
  18972. * AnimationCurve
  18973. *****************************************************/
  18974. export namespace AnimationCurve {
  18975. /** !#en The wrap mode
  18976. !#zh 循环模式 */
  18977. export enum WrapMode {
  18978. Default = 0,
  18979. Once = 0,
  18980. Loop = 0,
  18981. PingPong = 0,
  18982. ClampForever = 0,
  18983. time = 0,
  18984. value = 0,
  18985. inTangent = 0,
  18986. outTangent = 0,
  18987. }
  18988. }
  18989. /****************************************************
  18990. * ParticleSystem3DAssembler
  18991. *****************************************************/
  18992. export namespace ParticleSystem3DAssembler {
  18993. /** undefined */
  18994. export enum Space {
  18995. }
  18996. }
  18997. /****************************************************
  18998. * ParticleSystem3DAssembler
  18999. *****************************************************/
  19000. export namespace ParticleSystem3DAssembler {
  19001. /** 粒子的生成模式 */
  19002. export enum RenderMode {
  19003. }
  19004. }
  19005. /****************************************************
  19006. * shapeModule
  19007. *****************************************************/
  19008. export namespace shapeModule {
  19009. /** 粒子发射器类型 */
  19010. export enum ShapeType {
  19011. Box = 0,
  19012. Circle = 0,
  19013. Cone = 0,
  19014. Sphere = 0,
  19015. Hemisphere = 0,
  19016. }
  19017. }
  19018. /****************************************************
  19019. * shapeModule
  19020. *****************************************************/
  19021. export namespace shapeModule {
  19022. /** 粒子从发射器的哪个部位发射 */
  19023. export enum EmitLocation {
  19024. Base = 0,
  19025. Edge = 0,
  19026. Shell = 0,
  19027. Volume = 0,
  19028. }
  19029. }
  19030. /****************************************************
  19031. * shapeModule
  19032. *****************************************************/
  19033. export namespace shapeModule {
  19034. /** 粒子在扇形区域的发射方式 */
  19035. export enum ArcMode {
  19036. Random = 0,
  19037. Loop = 0,
  19038. PingPong = 0,
  19039. }
  19040. }
  19041. /****************************************************
  19042. * trailModule
  19043. *****************************************************/
  19044. export namespace trailModule {
  19045. /** 选择如何为粒子系统生成轨迹 */
  19046. export enum TrailMode {
  19047. }
  19048. }
  19049. /****************************************************
  19050. * trailModule
  19051. *****************************************************/
  19052. export namespace trailModule {
  19053. /** 纹理填充模式 */
  19054. export enum TextureMode {
  19055. }
  19056. }
  19057. /****************************************************
  19058. * primitive
  19059. *****************************************************/
  19060. export namespace primitive {
  19061. /** undefined */
  19062. export enum PolyhedronType {
  19063. Tetrahedron = 0,
  19064. Octahedron = 0,
  19065. Dodecahedron = 0,
  19066. Icosahedron = 0,
  19067. Rhombicuboctahedron = 0,
  19068. TriangularPrism = 0,
  19069. PentagonalPrism = 0,
  19070. HexagonalPrism = 0,
  19071. SquarePyramid = 0,
  19072. PentagonalPyramid = 0,
  19073. TriangularDipyramid = 0,
  19074. PentagonalDipyramid = 0,
  19075. ElongatedSquareDipyramid = 0,
  19076. ElongatedPentagonalDipyramid = 0,
  19077. ElongatedPentagonalCupola = 0,
  19078. }
  19079. }
  19080. /****************************************************
  19081. * primitive
  19082. *****************************************************/
  19083. export namespace primitive {
  19084. /** undefined */
  19085. export class VertexData {
  19086. positions: number[];
  19087. normals: number[];
  19088. uvs: number[];
  19089. indices: number[];
  19090. minPos: Vec3;
  19091. maxPos: Vec3;
  19092. boundingRadius: number;
  19093. }
  19094. }
  19095. /****************************************************
  19096. * EditBox
  19097. *****************************************************/
  19098. export namespace EditBox {
  19099. /** !#en Enum for keyboard return types
  19100. !#zh 键盘的返回键类型 */
  19101. export enum KeyboardReturnType {
  19102. DEFAULT = 0,
  19103. DONE = 0,
  19104. SEND = 0,
  19105. SEARCH = 0,
  19106. GO = 0,
  19107. NEXT = 0,
  19108. }
  19109. }
  19110. /****************************************************
  19111. * EditBox
  19112. *****************************************************/
  19113. export namespace EditBox {
  19114. /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter.
  19115. !#zh 输入模式 */
  19116. export enum InputMode {
  19117. ANY = 0,
  19118. EMAIL_ADDR = 0,
  19119. NUMERIC = 0,
  19120. PHONE_NUMBER = 0,
  19121. URL = 0,
  19122. DECIMAL = 0,
  19123. SINGLE_LINE = 0,
  19124. }
  19125. }
  19126. /****************************************************
  19127. * EditBox
  19128. *****************************************************/
  19129. export namespace EditBox {
  19130. /** !#en Enum for the EditBox's input flags
  19131. !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */
  19132. export enum InputFlag {
  19133. PASSWORD = 0,
  19134. SENSITIVE = 0,
  19135. INITIAL_CAPS_WORD = 0,
  19136. INITIAL_CAPS_SENTENCE = 0,
  19137. INITIAL_CAPS_ALL_CHARACTERS = 0,
  19138. DEFAULT = 0,
  19139. }
  19140. }
  19141. /****************************************************
  19142. * Material
  19143. *****************************************************/
  19144. export namespace Material {
  19145. /** !#en Material builtin name
  19146. !#zh 内置材质名字 */
  19147. export enum BUILTIN_NAME {
  19148. SPRITE = 0,
  19149. GRAY_SPRITE = 0,
  19150. UNLIT = 0,
  19151. }
  19152. }
  19153. /****************************************************
  19154. * textureAnimationModule
  19155. *****************************************************/
  19156. export namespace textureAnimationModule {
  19157. /** 粒子贴图动画类型 */
  19158. export enum Mode {
  19159. }
  19160. }
  19161. /****************************************************
  19162. * textureAnimationModule
  19163. *****************************************************/
  19164. export namespace textureAnimationModule {
  19165. /** 贴图动画的播放方式 */
  19166. export enum Animation {
  19167. }
  19168. }
  19169. }
  19170. /** !#en
  19171. The global main namespace of Spine, all classes, functions,
  19172. properties and constants of Spine are defined in this namespace
  19173. !#zh
  19174. Spine 的全局的命名空间,
  19175. 与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */
  19176. declare namespace sp {
  19177. /** !#en
  19178. The skeleton of Spine <br/>
  19179. <br/>
  19180. (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance,
  19181. which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
  19182. Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.) <br/>
  19183. !#zh
  19184. Spine 骨骼动画 <br/>
  19185. <br/>
  19186. (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态,
  19187. 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。<br/>
  19188. 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */
  19189. export class Skeleton extends cc.RenderComponent {
  19190. /** !#en The skeletal animation is paused?
  19191. !#zh 该骨骼动画是否暂停。 */
  19192. paused: boolean;
  19193. /** !#en
  19194. The skeleton data contains the skeleton information (bind pose bones, slots, draw order,
  19195. attachments, skins, etc) and animations but does not hold any state.<br/>
  19196. Multiple skeletons can share the same skeleton data.
  19197. !#zh
  19198. 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
  19199. attachments,皮肤等等)和动画但不持有任何状态。<br/>
  19200. 多个 Skeleton 可以共用相同的骨骼数据。 */
  19201. skeletonData: SkeletonData;
  19202. /** !#en The name of default skin.
  19203. !#zh 默认的皮肤名称。 */
  19204. defaultSkin: string;
  19205. /** !#en The name of default animation.
  19206. !#zh 默认的动画名称。 */
  19207. defaultAnimation: string;
  19208. /** !#en The name of current playing animation.
  19209. !#zh 当前播放的动画名称。 */
  19210. animation: string;
  19211. _defaultSkinIndex: number;
  19212. /** !#en TODO
  19213. !#zh 是否循环播放当前骨骼动画。 */
  19214. loop: boolean;
  19215. /** !#en Indicates whether to enable premultiplied alpha.
  19216. You should disable this option when image's transparent area appears to have opaque pixels,
  19217. or enable this option when image's half transparent area appears to be darken.
  19218. !#zh 是否启用贴图预乘。
  19219. 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */
  19220. premultipliedAlpha: boolean;
  19221. /** !#en The time scale of this skeleton.
  19222. !#zh 当前骨骼中所有动画的时间缩放率。 */
  19223. timeScale: number;
  19224. /** !#en Indicates whether open debug slots.
  19225. !#zh 是否显示 slot 的 debug 信息。 */
  19226. debugSlots: boolean;
  19227. /** !#en Indicates whether open debug bones.
  19228. !#zh 是否显示 bone 的 debug 信息。 */
  19229. debugBones: boolean;
  19230. /** !#en Indicates whether open debug mesh.
  19231. !#zh 是否显示 mesh 的 debug 信息。 */
  19232. debugMesh: boolean;
  19233. /** !#en Enabled two color tint.
  19234. !#zh 是否启用染色效果。 */
  19235. useTint: boolean;
  19236. /** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance.
  19237. !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。 */
  19238. enableBatch: boolean;
  19239. /**
  19240. !#en
  19241. Sets runtime skeleton data to sp.Skeleton.<br>
  19242. 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.
  19243. !#zh
  19244. 设置底层运行时用到的 SkeletonData。<br>
  19245. 这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。
  19246. @param skeletonData skeletonData
  19247. */
  19248. setSkeletonData(skeletonData: sp.spine.SkeletonData): void;
  19249. /**
  19250. !#en Sets slots visible range.
  19251. !#zh 设置骨骼插槽可视范围。
  19252. @param startSlotIndex startSlotIndex
  19253. @param endSlotIndex endSlotIndex
  19254. */
  19255. setSlotsRange(startSlotIndex: number, endSlotIndex: number): void;
  19256. /**
  19257. !#en Sets animation state data.<br>
  19258. The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData.
  19259. !#zh 设置动画状态数据。<br>
  19260. 参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。
  19261. @param stateData stateData
  19262. */
  19263. setAnimationStateData(stateData: sp.spine.AnimationStateData): void;
  19264. /**
  19265. !#en
  19266. It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time.
  19267. If set the mode in editor, then no need to worry about order problem.
  19268. !#zh
  19269. 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。
  19270. 若在编辑中设置渲染模式,则无需担心设置次序的问题。
  19271. @param cacheMode cacheMode
  19272. @example
  19273. ```js
  19274. skeleton.setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.SHARED_CACHE);
  19275. ```
  19276. */
  19277. setAnimationCacheMode(cacheMode: Skeleton.AnimationCacheMode): void;
  19278. /**
  19279. !#en Whether in cached mode.
  19280. !#zh 当前是否处于缓存模式。
  19281. */
  19282. isAnimationCached(): boolean;
  19283. /**
  19284. !#en Sets vertex effect delegate.
  19285. !#zh 设置顶点动画代理
  19286. @param effectDelegate effectDelegate
  19287. */
  19288. setVertexEffectDelegate(effectDelegate: VertexEffectDelegate): void;
  19289. /**
  19290. !#en Computes the world SRT from the local SRT for each bone.
  19291. !#zh 重新更新所有骨骼的世界 Transform,
  19292. 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。
  19293. @example
  19294. ```js
  19295. var bone = spine.findBone('head');
  19296. cc.log(bone.worldX); // return 0;
  19297. spine.updateWorldTransform();
  19298. bone = spine.findBone('head');
  19299. cc.log(bone.worldX); // return -23.12;
  19300. ```
  19301. */
  19302. updateWorldTransform(): void;
  19303. /**
  19304. !#en Sets the bones and slots to the setup pose.
  19305. !#zh 还原到起始动作
  19306. */
  19307. setToSetupPose(): void;
  19308. /**
  19309. !#en
  19310. Sets the bones to the setup pose,
  19311. using the values from the `BoneData` list in the `SkeletonData`.
  19312. !#zh
  19313. 设置 bone 到起始动作
  19314. 使用 SkeletonData 中的 BoneData 列表中的值。
  19315. */
  19316. setBonesToSetupPose(): void;
  19317. /**
  19318. !#en
  19319. Sets the slots to the setup pose,
  19320. using the values from the `SlotData` list in the `SkeletonData`.
  19321. !#zh
  19322. 设置 slot 到起始动作。
  19323. 使用 SkeletonData 中的 SlotData 列表中的值。
  19324. */
  19325. setSlotsToSetupPose(): void;
  19326. /**
  19327. !#en
  19328. Updating an animation cache to calculate all frame data in the animation is a cost in
  19329. performance due to calculating all data in a single frame.
  19330. To update the cache, use the invalidAnimationCache method with high performance.
  19331. !#zh
  19332. 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。
  19333. 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。
  19334. @param animName animName
  19335. */
  19336. updateAnimationCache(animName: string): void;
  19337. /**
  19338. !#en
  19339. Invalidates the animation cache, which is then recomputed on each frame..
  19340. !#zh
  19341. 使动画缓存失效,之后会在每帧重新计算。
  19342. */
  19343. invalidAnimationCache(): void;
  19344. /**
  19345. !#en
  19346. Finds a bone by name.
  19347. This does a string comparison for every bone.<br>
  19348. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object.
  19349. !#zh
  19350. 通过名称查找 bone。
  19351. 这里对每个 bone 的名称进行了对比。<br>
  19352. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。
  19353. @param boneName boneName
  19354. */
  19355. findBone(boneName: string): sp.spine.Bone;
  19356. /**
  19357. !#en
  19358. Finds a slot by name. This does a string comparison for every slot.<br>
  19359. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object.
  19360. !#zh
  19361. 通过名称查找 slot。这里对每个 slot 的名称进行了比较。<br>
  19362. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。
  19363. @param slotName slotName
  19364. */
  19365. findSlot(slotName: string): sp.spine.Slot;
  19366. /**
  19367. !#en
  19368. Finds a skin by name and makes it the active skin.
  19369. This does a string comparison for every skin.<br>
  19370. Note that setting the skin does not change which attachments are visible.<br>
  19371. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object.
  19372. !#zh
  19373. 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。<br>
  19374. 注意:设置皮肤不会改变 attachment 的可见性。<br>
  19375. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。
  19376. @param skinName skinName
  19377. */
  19378. setSkin(skinName: string): void;
  19379. /**
  19380. !#en
  19381. Returns the attachment for the slot and attachment name.
  19382. The skeleton looks first in its skin, then in the skeleton data’s default skin.<br>
  19383. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object.
  19384. !#zh
  19385. 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。<br>
  19386. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。
  19387. @param slotName slotName
  19388. @param attachmentName attachmentName
  19389. */
  19390. getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment;
  19391. /**
  19392. !#en
  19393. Sets the attachment for the slot and attachment name.
  19394. The skeleton looks first in its skin, then in the skeleton data’s default skin.
  19395. !#zh
  19396. 通过 slot 和 attachment 的名字来设置 attachment。
  19397. Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
  19398. @param slotName slotName
  19399. @param attachmentName attachmentName
  19400. */
  19401. setAttachment(slotName: string, attachmentName: string): void;
  19402. /**
  19403. Return the renderer of attachment.
  19404. @param regionAttachment regionAttachment
  19405. */
  19406. getTextureAtlas(regionAttachment: sp.spine.RegionAttachment|spine.BoundingBoxAttachment): sp.spine.TextureAtlasRegion;
  19407. /**
  19408. !#en
  19409. Mix applies all keyframe values,
  19410. interpolated for the specified time and mixed with the current values.
  19411. !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。
  19412. @param fromAnimation fromAnimation
  19413. @param toAnimation toAnimation
  19414. @param duration duration
  19415. */
  19416. setMix(fromAnimation: string, toAnimation: string, duration: number): void;
  19417. /**
  19418. !#en Set the current animation. Any queued animations are cleared.<br>
  19419. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  19420. !#zh 设置当前动画。队列中的任何的动画将被清除。<br>
  19421. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  19422. @param trackIndex trackIndex
  19423. @param name name
  19424. @param loop loop
  19425. */
  19426. setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry;
  19427. /**
  19428. !#en Adds an animation to be played delay seconds after the current or last queued animation.<br>
  19429. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  19430. !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。<br>
  19431. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  19432. @param trackIndex trackIndex
  19433. @param name name
  19434. @param loop loop
  19435. @param delay delay
  19436. */
  19437. addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry;
  19438. /**
  19439. !#en Find animation with specified name.
  19440. !#zh 查找指定名称的动画
  19441. @param name name
  19442. */
  19443. findAnimation(name: string): sp.spine.Animation;
  19444. /**
  19445. !#en Returns track entry by trackIndex.<br>
  19446. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  19447. !#zh 通过 track 索引获取 TrackEntry。<br>
  19448. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  19449. @param trackIndex trackIndex
  19450. */
  19451. getCurrent(trackIndex: any): sp.spine.TrackEntry;
  19452. /**
  19453. !#en Clears all tracks of animation state.
  19454. !#zh 清除所有 track 的动画状态。
  19455. */
  19456. clearTracks(): void;
  19457. /**
  19458. !#en Clears track of animation state by trackIndex.
  19459. !#zh 清除出指定 track 的动画状态。
  19460. @param trackIndex trackIndex
  19461. */
  19462. clearTrack(trackIndex: number): void;
  19463. /**
  19464. !#en Set the start event listener.
  19465. !#zh 用来设置开始播放动画的事件监听。
  19466. @param listener listener
  19467. */
  19468. setStartListener(listener: Function): void;
  19469. /**
  19470. !#en Set the interrupt event listener.
  19471. !#zh 用来设置动画被打断的事件监听。
  19472. @param listener listener
  19473. */
  19474. setInterruptListener(listener: Function): void;
  19475. /**
  19476. !#en Set the end event listener.
  19477. !#zh 用来设置动画播放完后的事件监听。
  19478. @param listener listener
  19479. */
  19480. setEndListener(listener: Function): void;
  19481. /**
  19482. !#en Set the dispose event listener.
  19483. !#zh 用来设置动画将被销毁的事件监听。
  19484. @param listener listener
  19485. */
  19486. setDisposeListener(listener: Function): void;
  19487. /**
  19488. !#en Set the complete event listener.
  19489. !#zh 用来设置动画播放一次循环结束后的事件监听。
  19490. @param listener listener
  19491. */
  19492. setCompleteListener(listener: Function): void;
  19493. /**
  19494. !#en Set the animation event listener.
  19495. !#zh 用来设置动画播放过程中帧事件的监听。
  19496. @param listener listener
  19497. */
  19498. setEventListener(listener: Function): void;
  19499. /**
  19500. !#en Set the start event listener for specified TrackEntry.
  19501. !#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。
  19502. @param entry entry
  19503. @param listener listener
  19504. */
  19505. setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void;
  19506. /**
  19507. !#en Set the interrupt event listener for specified TrackEntry.
  19508. !#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。
  19509. @param entry entry
  19510. @param listener listener
  19511. */
  19512. setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void;
  19513. /**
  19514. !#en Set the end event listener for specified TrackEntry.
  19515. !#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。
  19516. @param entry entry
  19517. @param listener listener
  19518. */
  19519. setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void;
  19520. /**
  19521. !#en Set the dispose event listener for specified TrackEntry.
  19522. !#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。
  19523. @param entry entry
  19524. @param listener listener
  19525. */
  19526. setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void;
  19527. /**
  19528. !#en Set the complete event listener for specified TrackEntry.
  19529. !#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。
  19530. @param entry entry
  19531. @param listener listener
  19532. */
  19533. setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: (entry: sp.spine.TrackEntry, loopCount: number) => void): void;
  19534. /**
  19535. !#en Set the event listener for specified TrackEntry.
  19536. !#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。
  19537. @param entry entry
  19538. @param listener listener
  19539. */
  19540. setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void;
  19541. /**
  19542. !#en Get the animation state object
  19543. !#zh 获取动画状态
  19544. */
  19545. getState(): sp.spine.AnimationState;
  19546. }
  19547. /** !#en The event type of spine skeleton animation.
  19548. !#zh 骨骼动画事件类型。 */
  19549. export enum AnimationEventType {
  19550. START = 0,
  19551. END = 0,
  19552. COMPLETE = 0,
  19553. EVENT = 0,
  19554. }
  19555. /** !#en The skeleton data of spine.
  19556. !#zh Spine 的 骨骼数据。 */
  19557. export class SkeletonData extends cc.Asset {
  19558. /** !#en See http://en.esotericsoftware.com/spine-json-format
  19559. !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */
  19560. skeletonJson: any;
  19561. atlasText: string;
  19562. textures: cc.Texture2D[];
  19563. /** !#en
  19564. A scale can be specified on the JSON or binary loader which will scale the bone positions,
  19565. image sizes, and animation translations.
  19566. This can be useful when using different sized images than were used when designing the skeleton
  19567. in Spine. For example, if using images that are half the size than were used in Spine,
  19568. a scale of 0.5 can be used. This is commonly used for games that can run with either low or high
  19569. resolution texture atlases.
  19570. see http://en.esotericsoftware.com/spine-using-runtimes#Scaling
  19571. !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */
  19572. scale: number;
  19573. /**
  19574. !#en Get the included SkeletonData used in spine runtime.<br>
  19575. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object.
  19576. !#zh 获取 Spine Runtime 使用的 SkeletonData。<br>
  19577. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData 对象。
  19578. @param quiet quiet
  19579. */
  19580. getRuntimeData(quiet?: boolean): sp.spine.SkeletonData;
  19581. }
  19582. /** !#en
  19583. The delegate of spine vertex effect
  19584. !#zh
  19585. Spine 顶点动画代理 */
  19586. export class VertexEffectDelegate {
  19587. /**
  19588. !#en Clears vertex effect.
  19589. !#zh 清空顶点效果
  19590. */
  19591. clear(): void;
  19592. /**
  19593. !#en Inits delegate with jitter effect
  19594. !#zh 设置顶点抖动效果
  19595. @param jitterX jitterX
  19596. @param jitterY jitterY
  19597. */
  19598. initJitter(jitterX: number, jitterY: number): void;
  19599. /**
  19600. !#en Inits delegate with swirl effect
  19601. !#zh 设置顶点漩涡效果
  19602. @param radius radius
  19603. @param power power
  19604. */
  19605. initSwirlWithPow(radius: number, power: number): sp.spine.JitterEffect;
  19606. /**
  19607. !#en Inits delegate with swirl effect
  19608. !#zh 设置顶点漩涡效果
  19609. @param radius radius
  19610. @param power power
  19611. */
  19612. initSwirlWithPowOut(radius: number, power: number): sp.spine.SwirlEffect;
  19613. /**
  19614. !#en Gets jitter vertex effect
  19615. !#zh 获取顶点抖动效果
  19616. */
  19617. getJitterVertexEffect(): sp.spine.JitterEffect;
  19618. /**
  19619. !#en Gets swirl vertex effect
  19620. !#zh 获取顶点漩涡效果
  19621. */
  19622. getSwirlVertexEffect(): sp.spine.SwirlEffect;
  19623. /**
  19624. !#en Gets vertex effect
  19625. !#zh 获取顶点效果
  19626. */
  19627. getVertexEffect(): sp.spine.JitterEffect;
  19628. /**
  19629. !#en Gets effect type
  19630. !#zh 获取效果类型
  19631. */
  19632. getEffectType(): string;
  19633. }
  19634. /****************************************************
  19635. * sp
  19636. *****************************************************/
  19637. export namespace sp {
  19638. /** !#en Attach node tool
  19639. !#zh 挂点工具类 */
  19640. export class AttachUtil {
  19641. /**
  19642. !#en Gets attached root node.
  19643. !#zh 获取挂接节点树的根节点
  19644. */
  19645. getAttachedRootNode(): cc.Node;
  19646. /**
  19647. !#en Gets attached node which you want.
  19648. !#zh 获得对应的挂点
  19649. @param boneName boneName
  19650. */
  19651. getAttachedNodes(boneName: string): cc.Node[];
  19652. /**
  19653. !#en Destroy attached node which you want.
  19654. !#zh 销毁对应的挂点
  19655. @param boneName boneName
  19656. */
  19657. destroyAttachedNodes(boneName: string): void;
  19658. /**
  19659. !#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface.
  19660. !#zh 遍历所有插槽,生成包含所有给定插槽名称的最小节点树,注意,调用该接口前请确保骨骼动画已经初始化好。
  19661. @param boneName boneName
  19662. */
  19663. generateAttachedNodes(boneName: string): cc.Node[];
  19664. /**
  19665. !#en Destroy all attached node.
  19666. !#zh 销毁所有挂点
  19667. */
  19668. destroyAllAttachedNodes(): void;
  19669. /**
  19670. !#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface.
  19671. !#zh 遍历所有插槽,生成包含所有插槽的节点树,注意,调用该接口前请确保骨骼动画已经初始化好。
  19672. */
  19673. generateAllAttachedNodes(): cc.Node;
  19674. }
  19675. }
  19676. /****************************************************
  19677. * Skeleton
  19678. *****************************************************/
  19679. export namespace Skeleton {
  19680. /** !#en Enum for animation cache mode type.
  19681. !#zh Spine动画缓存类型 */
  19682. export enum AnimationCacheMode {
  19683. REALTIME = 0,
  19684. SHARED_CACHE = 0,
  19685. PRIVATE_CACHE = 0,
  19686. }
  19687. }
  19688. }
  19689. /** !#en
  19690. `sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.<br>
  19691. Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes)
  19692. !#zh
  19693. sp.spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */
  19694. declare namespace sp.spine {
  19695. }
  19696. /** !#en
  19697. The global main namespace of DragonBones, all classes, functions,
  19698. properties and constants of DragonBones are defined in this namespace
  19699. !#zh
  19700. DragonBones 的全局的命名空间,
  19701. 与 DragonBones 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */
  19702. declare namespace dragonBones {
  19703. /** !#en
  19704. The Armature Display of DragonBones <br/>
  19705. <br/>
  19706. Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance,
  19707. which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
  19708. Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments. <br/>
  19709. !#zh
  19710. DragonBones 骨骼动画 <br/>
  19711. <br/>
  19712. Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态,
  19713. 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。<br/>
  19714. 多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。<br/> */
  19715. export class ArmatureDisplay extends cc.RenderComponent {
  19716. /** !#en
  19717. The DragonBones data contains the armatures information (bind pose bones, slots, draw order,
  19718. attachments, skins, etc) and animations but does not hold any state.<br/>
  19719. Multiple ArmatureDisplay can share the same DragonBones data.
  19720. !#zh
  19721. 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
  19722. attachments,皮肤等等)和动画但不持有任何状态。<br/>
  19723. 多个 ArmatureDisplay 可以共用相同的骨骼数据。 */
  19724. dragonAsset: DragonBonesAsset;
  19725. /** !#en
  19726. The atlas asset for the DragonBones.
  19727. !#zh
  19728. 骨骼数据所需的 Atlas Texture 数据。 */
  19729. dragonAtlasAsset: DragonBonesAtlasAsset;
  19730. /** !#en The name of current armature.
  19731. !#zh 当前的 Armature 名称。 */
  19732. armatureName: string;
  19733. /** !#en The name of current playing animation.
  19734. !#zh 当前播放的动画名称。 */
  19735. animationName: string;
  19736. _defaultArmatureIndex: number;
  19737. /** !#en The time scale of this armature.
  19738. !#zh 当前骨骼中所有动画的时间缩放率。 */
  19739. timeScale: number;
  19740. /** !#en The play times of the default animation.
  19741. -1 means using the value of config file;
  19742. 0 means repeat for ever
  19743. >0 means repeat times
  19744. !#zh 播放默认动画的循环次数
  19745. -1 表示使用配置文件中的默认值;
  19746. 0 表示无限循环
  19747. >0 表示循环次数 */
  19748. playTimes: number;
  19749. /** !#en Indicates whether to enable premultiplied alpha.
  19750. You should disable this option when image's transparent area appears to have opaque pixels,
  19751. or enable this option when image's half transparent area appears to be darken.
  19752. !#zh 是否启用贴图预乘。
  19753. 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */
  19754. premultipliedAlpha: boolean;
  19755. /** !#en Indicates whether open debug bones.
  19756. !#zh 是否显示 bone 的 debug 信息。 */
  19757. debugBones: boolean;
  19758. /** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance.
  19759. !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。 */
  19760. enableBatch: boolean;
  19761. /**
  19762. !#en
  19763. The key of dragonbones cache data, which is regard as 'dragonbonesName', when you want to change dragonbones cloth.
  19764. !#zh
  19765. 缓存龙骨数据的key值,换装的时会使用到该值,作为dragonbonesName使用
  19766. @example
  19767. ```js
  19768. let factory = dragonBones.CCFactory.getInstance();
  19769. let needChangeSlot = needChangeArmature.armature().getSlot("changeSlotName");
  19770. factory.replaceSlotDisplay(toChangeArmature.getArmatureKey(), "armatureName", "slotName", "displayName", needChangeSlot);
  19771. ```
  19772. */
  19773. getArmatureKey(): string;
  19774. /**
  19775. !#en
  19776. It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time.
  19777. If set the mode in editor, then no need to worry about order problem.
  19778. !#zh
  19779. 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。
  19780. 若在编辑中设置渲染模式,则无需担心设置次序的问题。
  19781. @param cacheMode cacheMode
  19782. @example
  19783. ```js
  19784. armatureDisplay.setAnimationCacheMode(dragonBones.ArmatureDisplay.AnimationCacheMode.SHARED_CACHE);
  19785. ```
  19786. */
  19787. setAnimationCacheMode(cacheMode: ArmatureDisplay.AnimationCacheMode): void;
  19788. /**
  19789. !#en Whether in cached mode.
  19790. !#zh 当前是否处于缓存模式。
  19791. */
  19792. isAnimationCached(): boolean;
  19793. /**
  19794. !#en
  19795. Play the specified animation.
  19796. Parameter animName specify the animation name.
  19797. Parameter playTimes specify the repeat times of the animation.
  19798. -1 means use the value of the config file.
  19799. 0 means play the animation for ever.
  19800. >0 means repeat times.
  19801. !#zh
  19802. 播放指定的动画.
  19803. animName 指定播放动画的名称。
  19804. playTimes 指定播放动画的次数。
  19805. -1 为使用配置文件中的次数。
  19806. 0 为无限循环播放。
  19807. >0 为动画的重复次数。
  19808. @param animName animName
  19809. @param playTimes playTimes
  19810. */
  19811. playAnimation(animName: string, playTimes: number): dragonBones.AnimationState;
  19812. /**
  19813. !#en
  19814. Updating an animation cache to calculate all frame data in the animation is a cost in
  19815. performance due to calculating all data in a single frame.
  19816. To update the cache, use the invalidAnimationCache method with high performance.
  19817. !#zh
  19818. 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。
  19819. 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。
  19820. @param animName animName
  19821. */
  19822. updateAnimationCache(animName: string): void;
  19823. /**
  19824. !#en
  19825. Invalidates the animation cache, which is then recomputed on each frame..
  19826. !#zh
  19827. 使动画缓存失效,之后会在每帧重新计算。
  19828. */
  19829. invalidAnimationCache(): void;
  19830. /**
  19831. !#en
  19832. Get the all armature names in the DragonBones Data.
  19833. !#zh
  19834. 获取 DragonBones 数据中所有的 armature 名称
  19835. */
  19836. getArmatureNames(): any[];
  19837. /**
  19838. !#en
  19839. Get the all animation names of specified armature.
  19840. !#zh
  19841. 获取指定的 armature 的所有动画名称。
  19842. @param armatureName armatureName
  19843. */
  19844. getAnimationNames(armatureName: string): any[];
  19845. /**
  19846. !#en
  19847. Add event listener for the DragonBones Event, the same to addEventListener.
  19848. !#zh
  19849. 添加 DragonBones 事件监听器,与 addEventListener 作用相同。
  19850. @param type A string representing the event type to listen for.
  19851. @param listener The callback that will be invoked when the event is dispatched.
  19852. @param target The target (this object) to invoke the callback, can be null
  19853. */
  19854. on(type: string, listener: (event: cc.Event) => void, target?: any): void;
  19855. /**
  19856. !#en
  19857. Remove the event listener for the DragonBones Event, the same to removeEventListener.
  19858. !#zh
  19859. 移除 DragonBones 事件监听器,与 removeEventListener 作用相同。
  19860. @param type A string representing the event type to listen for.
  19861. @param listener listener
  19862. @param target target
  19863. */
  19864. off(type: string, listener?: Function, target?: any): void;
  19865. /**
  19866. !#en
  19867. Add DragonBones one-time event listener, the callback will remove itself after the first time it is triggered.
  19868. !#zh
  19869. 添加 DragonBones 一次性事件监听器,回调会在第一时间被触发后删除自身。
  19870. @param type A string representing the event type to listen for.
  19871. @param listener The callback that will be invoked when the event is dispatched.
  19872. @param target The target (this object) to invoke the callback, can be null
  19873. */
  19874. once(type: string, listener: (event: cc.Event) => void, target?: any): void;
  19875. /**
  19876. !#en
  19877. Add event listener for the DragonBones Event.
  19878. !#zh
  19879. 添加 DragonBones 事件监听器。
  19880. @param type A string representing the event type to listen for.
  19881. @param listener The callback that will be invoked when the event is dispatched.
  19882. @param target The target (this object) to invoke the callback, can be null
  19883. */
  19884. addEventListener(type: string, listener: (event: cc.Event) => void, target?: any): void;
  19885. /**
  19886. !#en
  19887. Remove the event listener for the DragonBones Event.
  19888. !#zh
  19889. 移除 DragonBones 事件监听器。
  19890. @param type A string representing the event type to listen for.
  19891. @param listener listener
  19892. @param target target
  19893. */
  19894. removeEventListener(type: string, listener?: Function, target?: any): void;
  19895. /**
  19896. !#en
  19897. Build the armature for specified name.
  19898. !#zh
  19899. 构建指定名称的 armature 对象
  19900. @param armatureName armatureName
  19901. @param node node
  19902. */
  19903. buildArmature(armatureName: string, node: cc.Node): ArmatureDisplay;
  19904. /**
  19905. !#en
  19906. Get the current armature object of the ArmatureDisplay.
  19907. !#zh
  19908. 获取 ArmatureDisplay 当前使用的 Armature 对象
  19909. */
  19910. armature(): any;
  19911. }
  19912. /** DragonBones factory */
  19913. export class CCFactory extends BaseFactory {
  19914. /**
  19915. @example
  19916. ```js
  19917. let factory = dragonBones.CCFactory.getInstance();
  19918. ```
  19919. */
  19920. static getInstance(): CCFactory;
  19921. }
  19922. /** !#en The skeleton data of dragonBones.
  19923. !#zh dragonBones 的 骨骼数据。 */
  19924. export class DragonBonesAsset extends cc.Asset {
  19925. /** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html
  19926. !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */
  19927. dragonBonesJson: string;
  19928. }
  19929. /** !#en The skeleton atlas data of dragonBones.
  19930. !#zh dragonBones 的骨骼纹理数据。 */
  19931. export class DragonBonesAtlasAsset extends cc.Asset {
  19932. atlasJson: string;
  19933. texture: cc.Texture2D;
  19934. }
  19935. /****************************************************
  19936. * dragonBones
  19937. *****************************************************/
  19938. export namespace dragonBones {
  19939. /** !#en Attach node tool
  19940. !#zh 挂点工具类 */
  19941. export class AttachUtil {
  19942. /**
  19943. !#en Gets attached root node.
  19944. !#zh 获取挂接节点树的根节点
  19945. */
  19946. getAttachedRootNode(): cc.Node;
  19947. /**
  19948. !#en Gets attached node which you want.
  19949. !#zh 获得对应的挂点
  19950. @param boneName boneName
  19951. */
  19952. getAttachedNodes(boneName: string): cc.Node[];
  19953. /**
  19954. !#en Destroy attached node which you want.
  19955. !#zh 销毁对应的挂点
  19956. @param boneName boneName
  19957. */
  19958. destroyAttachedNodes(boneName: string): void;
  19959. /**
  19960. !#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface.
  19961. !#zh 遍历所有插槽,生成包含所有给定插槽名称的最小节点树,注意,调用该接口前请确保骨骼动画已经初始化好。
  19962. @param boneName boneName
  19963. */
  19964. generateAttachedNodes(boneName: string): cc.Node[];
  19965. /**
  19966. !#en Destroy all attached node.
  19967. !#zh 销毁所有挂点
  19968. */
  19969. destroyAllAttachedNodes(): void;
  19970. /**
  19971. !#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface.
  19972. !#zh 遍历所有插槽,生成包含所有插槽的节点树,注意,调用该接口前请确保骨骼动画已经初始化好。
  19973. */
  19974. generateAllAttachedNodes(): cc.Node;
  19975. }
  19976. }
  19977. /****************************************************
  19978. * ArmatureDisplay
  19979. *****************************************************/
  19980. export namespace ArmatureDisplay {
  19981. /** !#en Enum for cache mode type.
  19982. !#zh Dragonbones渲染类型 */
  19983. export enum AnimationCacheMode {
  19984. REALTIME = 0,
  19985. SHARED_CACHE = 0,
  19986. PRIVATE_CACHE = 0,
  19987. }
  19988. }
  19989. }
  19990. /** !#en
  19991. This module controls asset's behaviors and information, include loading, releasing etc.
  19992. All member can be accessed with `cc.assetManager`. All class or enum can be accessed with `cc.AssetManager`
  19993. !#zh
  19994. 此模块管理资源的行为和信息,包括加载,释放等,所有成员能够通过 `cc.assetManager` 调用. 所有类型或枚举能通过 `cc.AssetManager` 访问 */
  19995. declare namespace cc.AssetManager {
  19996. /** !#en
  19997. This module contains the builtin asset, it's a singleton, all member can be accessed with `cc.assetManager.builtins`
  19998. !#zh
  19999. 此模块包含内建资源,这是一个单例,所有成员能通过 `cc.assetManager.builtins` 访问 */
  20000. export class Builtins {
  20001. /**
  20002. !#en
  20003. Initialize
  20004. !#zh
  20005. 初始化
  20006. @param cb Callback when finish loading built-in assets
  20007. */
  20008. init (cb: () => void): void;
  20009. /**
  20010. !#en
  20011. Get the built-in asset using specific type and name.
  20012. !#zh
  20013. 通过特定的类型和名称获取内建资源
  20014. @param type The type of asset, such as `effect`
  20015. @param name The name of asset, such as `phong`
  20016. @example
  20017. ```js
  20018. cc.assetManaer.builtins.getBuiltin('effect', 'phone');
  20019. ```
  20020. */
  20021. getBuiltin(type?: string, name?: string): cc.Asset | Cache<cc.Asset>;
  20022. /**
  20023. !#en
  20024. Clear all builtin assets
  20025. !#zh
  20026. 清空所有内置资源
  20027. */
  20028. clear(): void;
  20029. }
  20030. /** !#en
  20031. A bundle contains an amount of assets(includes scene), you can load, preload, release asset which is in this bundle
  20032. !#zh
  20033. 一个包含一定数量资源(包括场景)的包,你可以加载,预加载,释放此包内的资源 */
  20034. export class Bundle {
  20035. /**
  20036. !#en
  20037. Create a bundle
  20038. !#zh
  20039. 创建一个 bundle
  20040. */
  20041. constructor();
  20042. /** !#en
  20043. The name of this bundle
  20044. !#zh
  20045. 此 bundle 的名称 */
  20046. name: string;
  20047. /** !#en
  20048. The dependency of this bundle
  20049. !#zh
  20050. 此 bundle 的依赖 */
  20051. deps: string[];
  20052. /** !#en
  20053. The root path of this bundle, such like 'http://example.com/bundle1'
  20054. !#zh
  20055. 此 bundle 的根路径, 例如 'http://example.com/bundle1' */
  20056. base: string;
  20057. /**
  20058. !#en
  20059. Get asset's info using path, only valid when asset is in bundle folder.
  20060. !#zh
  20061. 使用 path 获取资源的配置信息
  20062. @param path The relative path of asset, such as 'images/a'
  20063. @param type The constructor of asset, such as `cc.Texture2D`
  20064. @example
  20065. ```js
  20066. var info = bundle.getInfoWithPath('image/a', cc.Texture2D);
  20067. ```
  20068. */
  20069. getInfoWithPath (path: string, type?: typeof cc.Asset): Record<string, any>;
  20070. /**
  20071. !#en
  20072. Get all asset's info within specific folder
  20073. !#zh
  20074. 获取在某个指定文件夹下的所有资源信息
  20075. @param path The relative path of folder, such as 'images'
  20076. @param type The constructor should be used to filter paths
  20077. @param out The output array
  20078. @example
  20079. ```js
  20080. var infos = [];
  20081. bundle.getDirWithPath('images', cc.Texture2D, infos);
  20082. ```
  20083. */
  20084. getDirWithPath (path: string, type: typeof cc.Asset, out: Array<Record<string, any>>): Array<Record<string, any>>;
  20085. getDirWithPath (path: string, type: typeof cc.Asset): Array<Record<string, any>>;
  20086. getDirWithPath (path: string): Array<Record<string, any>>;
  20087. /**
  20088. !#en
  20089. Get asset's info with uuid
  20090. !#zh
  20091. 通过 uuid 获取资源信息
  20092. @param uuid The asset's uuid
  20093. @example
  20094. ```js
  20095. var info = bundle.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z');
  20096. ```
  20097. */
  20098. getAssetInfo (uuid: string): Record<string, any>;
  20099. /**
  20100. !#en
  20101. Get scene'info with name
  20102. !#zh
  20103. 通过场景名获取场景信息
  20104. @param name The name of scene
  20105. @example
  20106. ```js
  20107. var info = bundle.getSceneInfo('first.fire');
  20108. ```
  20109. */
  20110. getSceneInfo(name: string): Record<string, any>;
  20111. /**
  20112. !#en
  20113. Initialize this bundle with options
  20114. !#zh
  20115. 初始化此 bundle
  20116. @param options options
  20117. */
  20118. init(options: Record<string, any>): void;
  20119. /**
  20120. !#en
  20121. Load the asset within this bundle by the path which is relative to bundle's path
  20122. !#zh
  20123. 通过相对路径加载分包中的资源。路径是相对分包文件夹路径的相对路径
  20124. @param paths Paths of the target assets.The path is relative to the bundle's folder, extensions must be omitted.
  20125. @param type Only asset of type will be loaded if this argument is supplied.
  20126. @param onProgress Callback invoked when progression change.
  20127. @param onComplete Callback invoked when all assets loaded.
  20128. @example
  20129. ```js
  20130. // load the texture (${project}/assets/resources/textures/background.jpg) from resources
  20131. cc.resources.load('textures/background', cc.Texture2D, (err, texture) => console.log(err));
  20132. // load the audio (${project}/assets/resources/music/hit.mp3) from resources
  20133. cc.resources.load('music/hit', cc.AudioClip, (err, audio) => console.log(err));
  20134. // load the prefab (${project}/assets/bundle1/misc/character/cocos) from bundle1 folder
  20135. bundle1.load('misc/character/cocos', cc.Prefab, (err, prefab) => console.log(err));
  20136. // load the sprite frame (${project}/assets/some/xxx/bundle2/imgs/cocos.png) from bundle2 folder
  20137. bundle2.load('imgs/cocos', cc.SpriteFrame, null, (err, spriteFrame) => console.log(err));
  20138. ```
  20139. */
  20140. load<T extends cc.Asset>(paths: string, type: { prototype: T } onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T) => void): void;
  20141. load<T extends cc.Asset>(paths: string[], type: { prototype: T }, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array<T>) => void): void;
  20142. load<T extends cc.Asset>(paths: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T) => void): void;
  20143. load<T extends cc.Asset>(paths: string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array<T>) => void): void;
  20144. load<T extends cc.Asset>(paths: string, type: { prototype: T }, onComplete?: (error: Error, assets: T) => void): void;
  20145. load<T extends cc.Asset>(paths: string[], type: { prototype: T }, onComplete?: (error: Error, assets: Array<T>) => void): void;
  20146. load<T extends cc.Asset>(paths: string, onComplete?: (error: Error, assets: T) => void): void;
  20147. load<T extends cc.Asset>(paths: string[], onComplete?: (error: Error, assets: Array<T>) => void): void;
  20148. /**
  20149. !#en
  20150. Preload the asset within this bundle by the path which is relative to bundle's path.
  20151. After calling this method, you still need to finish loading by calling `Bundle.load`.
  20152. It will be totally fine to call `Bundle.load` at any time even if the preloading is not
  20153. yet finished
  20154. !#zh
  20155. 通过相对路径预加载分包中的资源。路径是相对分包文件夹路径的相对路径。调用完后,你仍然需要通过 `Bundle.load` 来完成加载。
  20156. 就算预加载还没完成,你也可以直接调用 `Bundle.load`。
  20157. @param paths Paths of the target asset.The path is relative to bundle folder, extensions must be omitted.
  20158. @param type Only asset of type will be loaded if this argument is supplied.
  20159. @param onProgress Callback invoked when progression change.
  20160. @param onComplete Callback invoked when the resource loaded.
  20161. @example
  20162. ```js
  20163. // preload the texture (${project}/assets/resources/textures/background.jpg) from resources
  20164. cc.resources.preload('textures/background', cc.Texture2D);
  20165. // preload the audio (${project}/assets/resources/music/hit.mp3) from resources
  20166. cc.resources.preload('music/hit', cc.AudioClip);
  20167. // wait for while
  20168. cc.resources.load('music/hit', cc.AudioClip, (err, audioClip) => {});
  20169. * // preload the prefab (${project}/assets/bundle1/misc/character/cocos) from bundle1 folder
  20170. bundle1.preload('misc/character/cocos', cc.Prefab);
  20171. // load the sprite frame of (${project}/assets/bundle2/imgs/cocos.png) from bundle2 folder
  20172. bundle2.preload('imgs/cocos', cc.SpriteFrame);
  20173. // wait for while
  20174. bundle2.load('imgs/cocos', cc.SpriteFrame, (err, spriteFrame) => {});
  20175. ```
  20176. */
  20177. preload(paths: string|string[], type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void;
  20178. preload(paths: string|string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void;
  20179. preload(paths: string|string[], type: typeof cc.Asset, onComplete: (error: Error, items: RequestItem[]) => void): void;
  20180. preload(paths: string|string[], type: typeof cc.Asset): void;
  20181. preload(paths: string|string[], onComplete: (error: Error, items: RequestItem[]) => void): void;
  20182. preload(paths: string|string[]): void;
  20183. /**
  20184. !#en
  20185. Load all assets under a folder inside the bundle folder.<br>
  20186. <br>
  20187. Note: All asset paths in Creator use forward slashes, paths using backslashes will not work.
  20188. !#zh
  20189. 加载目标文件夹中的所有资源, 注意:路径中只能使用斜杠,反斜杠将停止工作
  20190. @param dir path of the target folder.The path is relative to the bundle folder, extensions must be omitted.
  20191. @param type Only asset of type will be loaded if this argument is supplied.
  20192. @param onProgress Callback invoked when progression change.
  20193. @param onComplete A callback which is called when all assets have been loaded, or an error occurs.
  20194. @example
  20195. ```js
  20196. // load all audios (resources/audios/)
  20197. cc.resources.loadDir('audios', cc.AudioClip, (err, audios) => {});
  20198. // load all textures in "resources/imgs/"
  20199. cc.resources.loadDir('imgs', cc.Texture2D, null, function (err, textures) {
  20200. var texture1 = textures[0];
  20201. var texture2 = textures[1];
  20202. });
  20203. // load all prefabs (${project}/assets/bundle1/misc/characters/) from bundle1 folder
  20204. bundle1.loadDir('misc/characters', cc.Prefab, (err, prefabs) => console.log(err));
  20205. // load all sprite frame (${project}/assets/some/xxx/bundle2/skills/) from bundle2 folder
  20206. bundle2.loadDir('skills', cc.SpriteFrame, null, (err, spriteFrames) => console.log(err));
  20207. ```
  20208. */
  20209. loadDir<T extends cc.Asset>(dir: string, type: { prototype: T }, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array<T>) => void): void;
  20210. loadDir<T extends cc.Asset>(dir: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array<T>) => void): void;
  20211. loadDir<T extends cc.Asset>(dir: string, type: { prototype: T }, onComplete: (error: Error, assets: Array<T>) => void): void;
  20212. loadDir<T extends cc.Asset>(dir: string, type: { prototype: T }): void;
  20213. loadDir<T extends cc.Asset>(dir: string, onComplete: (error: Error, assets: Array<T>) => void): void;
  20214. loadDir<T extends cc.Asset>(dir: string): void;
  20215. /**
  20216. !#en
  20217. Preload all assets under a folder inside the bundle folder.<br> After calling this method, you still need to finish loading by calling `Bundle.loadDir`.
  20218. It will be totally fine to call `Bundle.loadDir` at any time even if the preloading is not yet finished
  20219. !#zh
  20220. 预加载目标文件夹中的所有资源。调用完后,你仍然需要通过 `Bundle.loadDir` 来完成加载。
  20221. 就算预加载还没完成,你也可以直接调用 `Bundle.loadDir`。
  20222. @param dir path of the target folder.The path is relative to the bundle folder, extensions must be omitted.
  20223. @param type Only asset of type will be preloaded if this argument is supplied.
  20224. @param onProgress Callback invoked when progression change.
  20225. @param onComplete A callback which is called when all assets have been loaded, or an error occurs.
  20226. @example
  20227. ```js
  20228. // preload all audios (resources/audios/)
  20229. cc.resources.preloadDir('audios', cc.AudioClip);
  20230. // preload all textures in "resources/imgs/"
  20231. cc.resources.preloadDir('imgs', cc.Texture2D);
  20232. // wait for while
  20233. cc.resources.loadDir('imgs', cc.Texture2D, (err, textures) => {});
  20234. // preload all prefabs (${project}/assets/bundle1/misc/characters/) from bundle1 folder
  20235. bundle1.preloadDir('misc/characters', cc.Prefab);
  20236. // preload all sprite frame (${project}/assets/some/xxx/bundle2/skills/) from bundle2 folder
  20237. bundle2.preloadDir('skills', cc.SpriteFrame);
  20238. // wait for while
  20239. bundle2.loadDir('skills', cc.SpriteFrame, (err, spriteFrames) => {});
  20240. ```
  20241. */
  20242. preloadDir(dir: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void;
  20243. preloadDir(dir: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void;
  20244. preloadDir(dir: string, type: typeof cc.Asset, onComplete: (error: Error, items: RequestItem[]) => void): void;
  20245. preloadDir(dir: string, type: typeof cc.Asset): void;
  20246. preloadDir(dir: string, onComplete: (error: Error, items: RequestItem[]) => void): void;
  20247. preloadDir(dir: string): void;
  20248. /**
  20249. !#en
  20250. Loads the scene within this bundle by its name.
  20251. !#zh
  20252. 通过场景名称加载分包中的场景。
  20253. @param sceneName The name of the scene to load.
  20254. @param options Some optional parameters
  20255. @param onProgress Callback invoked when progression change.
  20256. @param onComplete callback, will be called after scene launched.
  20257. @example
  20258. ```js
  20259. bundle1.loadScene('first', (err, sceneAsset) => cc.director.runScene(sceneAsset));
  20260. ```
  20261. */
  20262. loadScene(sceneName: string, options: Record<string, any>, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void;
  20263. loadScene(sceneName: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void;
  20264. loadScene(sceneName: string, options: Record<string, any>, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void;
  20265. loadScene(sceneName: string, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void;
  20266. loadScene(sceneName: string, options: Record<string, any>): void;
  20267. loadScene(sceneName: string): void;
  20268. /**
  20269. !#en
  20270. Preloads the scene within this bundle by its name. After calling this method, you still need to finish loading by calling `Bundle.loadScene` or `cc.director.loadScene`.
  20271. It will be totally fine to call `Bundle.loadDir` at any time even if the preloading is not yet finished
  20272. !#zh
  20273. 通过场景名称预加载分包中的场景.调用完后,你仍然需要通过 `Bundle.loadScene` 或 `cc.director.loadScene` 来完成加载。
  20274. 就算预加载还没完成,你也可以直接调用 `Bundle.loadScene` 或 `cc.director.loadScene`。
  20275. @param sceneName The name of the scene to preload.
  20276. @param options Some optional parameters
  20277. @param onProgress callback, will be called when the load progression change.
  20278. @param onComplete callback, will be called after scene loaded.
  20279. @example
  20280. ```js
  20281. bundle1.preloadScene('first');
  20282. // wait for a while
  20283. bundle1.loadScene('first', (err, scene) => cc.director.runScene(scene));
  20284. ```
  20285. */
  20286. preloadScene(sceneName: string, options: Record<string, any>, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error) => void): void;
  20287. preloadScene(sceneName: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error) => void): void;
  20288. preloadScene(sceneName: string, options: Record<string, any>, onComplete: (error: Error) => void): void;
  20289. preloadScene(sceneName: string, onComplete: (error: Error) => void): void;
  20290. preloadScene(sceneName: string, options: Record<string, any>): void;
  20291. preloadScene(sceneName: string): void;
  20292. /**
  20293. !#en
  20294. Get asset within this bundle by path and type. <br>
  20295. After you load asset with {{#crossLink "Bundle/load:method"}}{{/crossLink}} or {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}},
  20296. you can acquire them by passing the path to this API.
  20297. !#zh
  20298. 通过路径与类型获取资源。在你使用 {{#crossLink "Bundle/load:method"}}{{/crossLink}} 或者 {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} 之后,
  20299. 你能通过传路径通过这个 API 获取到这些资源。
  20300. @param path The path of asset
  20301. @param type Only asset of type will be returned if this argument is supplied.
  20302. @example
  20303. ```js
  20304. bundle1.get('music/hit', cc.AudioClip);
  20305. ```
  20306. */
  20307. get<T extends cc.Asset> (path: string, type?: { prototype: T }): T;
  20308. /**
  20309. !#en
  20310. Release the asset loaded by {{#crossLink "Bundle/load:method"}}{{/crossLink}} or {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} and it's dependencies.
  20311. Refer to {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} for detailed informations.
  20312. !#zh
  20313. 释放通过 {{#crossLink "Bundle/load:method"}}{{/crossLink}} 或者 {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}}
  20314. @param path The path of asset
  20315. @param type Only asset of type will be released if this argument is supplied.
  20316. @example
  20317. ```js
  20318. // release a texture which is no longer need
  20319. bundle1.release('misc/character/cocos');
  20320. ```
  20321. */
  20322. release(path: string, type: typeof cc.Asset): void;
  20323. release(path: string): void;
  20324. /**
  20325. !#en
  20326. Release all assets within this bundle. Refer to {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} for detailed informations.
  20327. !#zh
  20328. 释放此包中的所有资源。详细信息请参考 {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}}
  20329. @example
  20330. ```js
  20331. // release all asset within bundle1
  20332. bundle1.releaseAll();
  20333. ```
  20334. */
  20335. releaseAll(): void;
  20336. }
  20337. /** !#en
  20338. Cache manager is a module which controls all caches downloaded from server in non-web platform, it is a singleton
  20339. All member can be accessed with `cc.assetManager.cacheManager`.
  20340. !#zh
  20341. 缓存管理器是一个模块,在非 WEB 平台上,用于管理所有从服务器上下载下来的缓存,这是一个单例,所有成员能通过 `cc.assetManager.cacheManager` 访问。 */
  20342. export class CacheManager {
  20343. /** !#en
  20344. The name of cacheDir
  20345. !#zh
  20346. 缓存目录的名称 */
  20347. cacheDir: string;
  20348. /** !#en
  20349. Whether or not cache asset into user's storage space, this property only works on mini-game platforms
  20350. !#zh
  20351. 是否缓存资源到用户存储空间,此属性只在小游戏平台有效 */
  20352. cacheEnabled: boolean;
  20353. /** !#en
  20354. Whether or not auto clear cache when storage ran out, this property only works on mini-game platforms
  20355. !#zh
  20356. 是否在存储空间满了后自动清理缓存,此属性只在小游戏平台有效 */
  20357. autoClear: boolean;
  20358. /** !#en
  20359. The interval between caching resources, this property only works on mini-game platforms, unit: ms
  20360. !#zh
  20361. 缓存资源的间隔时间,此属性只在小游戏平台有效,单位:ms */
  20362. cacheInterval: number;
  20363. /** !#en
  20364. The interval between deleting resources, when you use `cleanLRU`, the resources will be deleted as this interval, unit: ms
  20365. !#zh
  20366. 清理资源的间隔时间,当你使用 `cleanLRU` 时,资源将以此间隔被删除,单位:ms */
  20367. deleteInterval: number;
  20368. /** !#en
  20369. List of all cached files
  20370. !#zh
  20371. 所有缓存文件列表 */
  20372. cachedFiles: Cache<{ bundle: string, url: string, lastTime: number }>;
  20373. /**
  20374. !#en
  20375. Get cached path with origin url
  20376. !#zh
  20377. 通过原始 url 获取缓存后的路径
  20378. @param originUrl originUrl
  20379. */
  20380. getCache(originUrl: string): string;
  20381. /**
  20382. !#en
  20383. Get temporary path with origin url, this method only works on mini-game platforms
  20384. !#zh
  20385. 通过原始 url 获取临时文件的路径,此方法只在小游戏平台有效
  20386. @param originUrl originUrl
  20387. */
  20388. getTemp(originUrl: string): string;
  20389. /**
  20390. !#en
  20391. Clear all caches, please use with caution, If necessary, we recommend using it before the game is launched
  20392. !#zh
  20393. 清空所有缓存,请谨慎使用,如果必要的话,我们建议在游戏启动之前使用
  20394. */
  20395. clearCache(): void;
  20396. /**
  20397. !#en
  20398. Clear part of caches with LRU strategy
  20399. !#zh
  20400. 使用 LRU 策略清空部分缓存
  20401. */
  20402. clearLRU(): void;
  20403. /**
  20404. !#en
  20405. Remove cache with origin url
  20406. !#zh
  20407. 通过原始 url 移除缓存
  20408. @param originUrl originUrl
  20409. */
  20410. removeCache(originUrl: string): void;
  20411. }
  20412. /** !#en
  20413. use to cache something
  20414. !#zh
  20415. 用于缓存某些内容 */
  20416. export class Cache<T = any> {
  20417. /**
  20418. !#en
  20419. Create a cache
  20420. !#zh
  20421. 创建一个 cache
  20422. @param map An object used to initialize
  20423. */
  20424. constructor(map?: Record<string, T>);
  20425. /**
  20426. !#en
  20427. Add Key-Value to cache
  20428. !#zh
  20429. 增加键值对到缓存中
  20430. @param key The key
  20431. @param val The value
  20432. @example
  20433. ```js
  20434. var cache = new Cache();
  20435. cache.add('test', null);
  20436. ```
  20437. */
  20438. add(key: string, val: T): T;
  20439. /**
  20440. !#en
  20441. Get the cached content by key
  20442. !#zh
  20443. 通过 key 获取对应的 value
  20444. @param key The key
  20445. @example
  20446. ```js
  20447. var cache = new Cache();
  20448. var test = cache.get('test');
  20449. ```
  20450. */
  20451. get(key: string): T;
  20452. /**
  20453. !#en
  20454. Check whether or not content exists by key
  20455. !#zh
  20456. 通过 Key 判断是否存在对应的内容
  20457. @param key The key
  20458. @example
  20459. ```js
  20460. var cache = new Cache();
  20461. var exist = cache.has('test');
  20462. ```
  20463. */
  20464. has(key: string): boolean;
  20465. /**
  20466. !#en
  20467. Remove the cached content by key
  20468. !#zh
  20469. 通过 Key 移除对应的内容
  20470. @param key The key
  20471. @example
  20472. ```js
  20473. var cache = new Cache();
  20474. var content = cache.remove('test');
  20475. ```
  20476. */
  20477. remove(key: string): T;
  20478. /**
  20479. !#en
  20480. Clear all content
  20481. !#zh
  20482. 清除所有内容
  20483. @example
  20484. ```js
  20485. var cache = new Cache();
  20486. cache.clear();
  20487. ```
  20488. */
  20489. clear():void;
  20490. /**
  20491. !#en
  20492. Enumerate all content and invoke function
  20493. !#zh
  20494. 枚举所有内容并执行方法
  20495. @param func Function to be invoked
  20496. @example
  20497. ```js
  20498. var cache = new Cache();
  20499. cache.forEach((val, key) => console.log(key));
  20500. ```
  20501. */
  20502. forEach(func: (val: T, key: string) => void): void;
  20503. /**
  20504. !#en
  20505. Enumerate all content to find one element which can fulfill condition
  20506. !#zh
  20507. 枚举所有内容,找到一个可以满足条件的元素
  20508. @param predicate The condition
  20509. @example
  20510. ```js
  20511. var cache = new Cache();
  20512. var val = cache.find((val, key) => key === 'test');
  20513. ```
  20514. */
  20515. find(predicate: (val: T, key: string) => boolean): T;
  20516. /** !#en
  20517. The count of cached content
  20518. !#zh
  20519. 缓存数量 */
  20520. count: number;
  20521. /**
  20522. !#en
  20523. Destroy this cache
  20524. !#zh
  20525. 销毁这个 cache
  20526. */
  20527. destroy(): void;
  20528. }
  20529. /** !#en
  20530. Control asset's dependency list, it is a singleton. All member can be accessed with `cc.assetManager.dependUtil`
  20531. !#zh
  20532. 控制资源的依赖列表,这是一个单例, 所有成员能通过 `cc.assetManager.dependUtil` 访问 */
  20533. export class DependUtil {
  20534. /**
  20535. !#en
  20536. Get asset's native dependency. For example, Texture's native dependency is image.
  20537. !#zh
  20538. 获取资源的原生依赖,例如 Texture 的原生依赖是图片
  20539. @param uuid asset's uuid
  20540. @example
  20541. ```js
  20542. var dep = dependUtil.getNativeDep('fcmR3XADNLgJ1ByKhqcC5Z');
  20543. ```
  20544. */
  20545. getNativeDep(uuid: string): Record<string, any>;
  20546. /**
  20547. !#en
  20548. Get asset's direct referencing non-native dependency list. For example, Material's non-native dependencies are Texture.
  20549. !#zh
  20550. 获取资源直接引用的非原生依赖列表,例如,材质的非原生依赖是 Texture
  20551. @param uuid asset's uuid
  20552. @example
  20553. ```js
  20554. var deps = dependUtil.getDeps('fcmR3XADNLgJ1ByKhqcC5Z');
  20555. ```
  20556. */
  20557. getDeps(uuid: string): string[];
  20558. /**
  20559. !#en
  20560. Get non-native dependency list of the loaded asset, include indirect reference.
  20561. The returned array stores the dependencies with their uuid, after retrieve dependencies,
  20562. !#zh
  20563. 获取某个已经加载好的资源的所有非原生依赖资源列表,包括间接引用的资源,并保存在数组中返回。
  20564. 返回的数组将仅保存依赖资源的 uuid。
  20565. @param uuid The asset's uuid
  20566. @example
  20567. ```js
  20568. var deps = dependUtil.getDepsRecursively('fcmR3XADNLgJ1ByKhqcC5Z');
  20569. ```
  20570. */
  20571. getDepsRecursively(uuid: string): string[];
  20572. }
  20573. /** !#en
  20574. Control all download process, it is a singleton. All member can be accessed with `cc.assetManager.downloader` , it can download several types of files:
  20575. 1. Text
  20576. 2. Image
  20577. 3. Audio
  20578. 4. Assets
  20579. 5. Scripts
  20580. !#zh
  20581. 管理所有下载过程,downloader 是个单例,所有成员能通过 `cc.assetManager.downloader` 访问,它能下载以下几种类型的文件:
  20582. 1. 文本
  20583. 2. 图片
  20584. 3. 音频
  20585. 4. 资源
  20586. 5. 脚本 */
  20587. export class Downloader {
  20588. /** !#en
  20589. The address of remote server
  20590. !#zh
  20591. 远程服务器地址 */
  20592. remoteServerAddress: string;
  20593. /** !#en
  20594. The maximum number of concurrent when downloading
  20595. !#zh
  20596. 下载时的最大并发数 */
  20597. maxConcurrency: number;
  20598. /** !#en
  20599. The maximum number of request can be launched per frame when downloading
  20600. !#zh
  20601. 下载时每帧可以启动的最大请求数 */
  20602. maxRequestsPerFrame: number;
  20603. /** !#en
  20604. The max number of retries when fail
  20605. !#zh
  20606. 失败重试次数 */
  20607. maxRetryCount: number;
  20608. /** !#en
  20609. Wait for while before another retry, unit: ms
  20610. !#zh
  20611. 重试的间隔时间 */
  20612. retryInterval: number;
  20613. /**
  20614. !#en
  20615. Register custom handler if you want to change default behavior or extend downloader to download other format file
  20616. !#zh
  20617. 当你想修改默认行为或者拓展 downloader 来下载其他格式文件时可以注册自定义的 handler
  20618. @param type Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler}
  20619. @param handler handler
  20620. @example
  20621. ```js
  20622. downloader.register('.tga', (url, options, onComplete) => onComplete(null, null));
  20623. downloader.register({'.tga': (url, options, onComplete) => onComplete(null, null), '.ext': (url, options, onComplete) => onComplete(null, null)});
  20624. ```
  20625. */
  20626. register(type: string, handler: (url: string, options: Record<string, any>, onComplete: (err: Error, content: any) => void) => void): void;
  20627. register(map: Record<string, (url: string, options: Record<string, any>, onComplete: (err: Error, content: any) => void) => void>): void;
  20628. /**
  20629. !#en
  20630. Use corresponding handler to download file under limitation
  20631. !#zh
  20632. 在限制下使用对应的 handler 来下载文件
  20633. @param url The url should be downloaded
  20634. @param type The type indicates that which handler should be used to download, such as '.jpg'
  20635. @param options some optional paramters will be transferred to the corresponding handler.
  20636. @param onComplete callback when finishing downloading
  20637. @example
  20638. ```js
  20639. download('http://example.com/test.tga', '.tga', {onFileProgress: (loaded, total) => console.lgo(loaded/total)}, onComplete: (err) => console.log(err));
  20640. ```
  20641. */
  20642. download(id: string, url: string, type: string, options: Record<string, any>, onComplete: (err: Error, content: any) => void): void;
  20643. }
  20644. /** !#en
  20645. Handle the packed asset, include unpacking, loading, cache and so on. It is a singleton. All member can be accessed with `cc.assetManager.packManager`
  20646. !#zh
  20647. 处理打包资源,包括拆包,加载,缓存等等,这是一个单例, 所有成员能通过 `cc.assetManager.packManager` 访问 */
  20648. export class PackManager {
  20649. /**
  20650. !#en
  20651. Unpack the json, revert to what it was before packing
  20652. !#zh
  20653. 拆解 json 包,恢复为打包之前的内容
  20654. @param pack The pack
  20655. @param json The content of pack
  20656. @param options Some optional parameters
  20657. @param onComplete Callback when finish unpacking
  20658. @example
  20659. ```js
  20660. downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => {
  20661. packManager.unpackJson(['a', 'b'], file, null, (err, data) => console.log(err));
  20662. });
  20663. ```
  20664. */
  20665. unpackJson(pack: string[], json: any, options: Record<string, any>, onComplete?: (err: Error, content: any) => void): void;
  20666. /**
  20667. !#en
  20668. Register custom handler if you want to change default behavior or extend packManager to unpack other format pack
  20669. !#zh
  20670. 当你想修改默认行为或者拓展 packManager 来拆分其他格式的包时可以注册自定义的 handler
  20671. @param type Extension likes '.bin' or map likes {'.bin': binHandler, '.ab': abHandler}
  20672. @param handler handler
  20673. @example
  20674. ```js
  20675. packManager.register('.bin', (packUuid, file, options, onComplete) => onComplete(null, null));
  20676. packManager.register({'.bin': (packUuid, file, options, onComplete) => onComplete(null, null), '.ab': (packUuid, file, options, onComplete) => onComplete(null, null)});
  20677. ```
  20678. */
  20679. register(type: string, handler: (packUuid: string, data: any, options: Record<string, any>, onComplete: (err: Error, content: any) => void) => void): void;
  20680. register(map: Record<string, (packUuid: string, data: any, options: Record<string, any>, onComplete: (err: Error, content: any) => void) => void>): void;
  20681. /**
  20682. !#en
  20683. Use corresponding handler to unpack package
  20684. !#zh
  20685. 用对应的 handler 来进行解包
  20686. @param pack The uuid of packed assets
  20687. @param data The packed data
  20688. @param type The type indicates that which handler should be used to download, such as '.jpg'
  20689. @param options Some optional parameter
  20690. @param onComplete callback when finishing unpacking
  20691. @example
  20692. ```js
  20693. downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => {
  20694. packManager.unpack(['2fawq123d', '1zsweq23f'], file, '.json', null, (err, data) => console.log(err));
  20695. });
  20696. ```
  20697. */
  20698. unpack(pack: string[], data: any, type: string, options: Record<string, any>, onComplete?: (err: Error, data: any) => void): void;
  20699. /**
  20700. !#en
  20701. Download request item, If item is not in any package, download as usual. Otherwise, download the corresponding package and unpack it.
  20702. And then retrieve the corresponding content form it.
  20703. !#zh
  20704. 下载请求对象,如果请求对象不在任何包内,则正常下载,否则下载对应的 package 并进行拆解,并取回包内对应的内容
  20705. @param item Some item you want to download
  20706. @param options Some optional parameters
  20707. @param onComplete Callback when finished
  20708. @example
  20709. ```js
  20710. var requestItem = cc.AssetManager.RequestItem.create();
  20711. requestItem.uuid = 'fcmR3XADNLgJ1ByKhqcC5Z';
  20712. requestItem.info = config.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z');
  20713. packManager.load(requestItem, null, (err, data) => console.log(err));
  20714. ```
  20715. */
  20716. load(item: RequestItem, options: Record<string, any>, onComplete: (err: Error, data: any) => void): void;
  20717. }
  20718. /** !#en
  20719. Provide some helpful function, it is a singleton. All member can be accessed with `cc.assetManager.utils`
  20720. !#zh
  20721. 提供一些辅助方法,helper 是一个单例, 所有成员能通过 `cc.assetManager.utils` 访问 */
  20722. export class Helper {
  20723. /**
  20724. !#en
  20725. Decode uuid, returns the original uuid
  20726. !#zh
  20727. 解码 uuid,返回原始 uuid
  20728. @param base64 the encoded uuid
  20729. @example
  20730. ```js
  20731. var uuid = 'fcmR3XADNLgJ1ByKhqcC5Z';
  20732. var originalUuid = decodeUuid(uuid); // fc991dd7-0033-4b80-9d41-c8a86a702e59
  20733. ```
  20734. */
  20735. decodeUuid(base64: string): string;
  20736. /**
  20737. !#en
  20738. Extract uuid from url
  20739. !#zh
  20740. 从 url 中提取 uuid
  20741. @param url url
  20742. @example
  20743. ```js
  20744. var url = 'assets/main/import/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.json';
  20745. var uuid = getUuidFromURL(url); // fc991dd7-0033-4b80-9d41-c8a86a702e59
  20746. ```
  20747. */
  20748. getUuidFromURL(url: string): string;
  20749. /**
  20750. !#en
  20751. Transform uuid to url
  20752. !#zh
  20753. 转换 uuid 为 url
  20754. @param uuid The uuid of asset
  20755. @param options Some optional parameters
  20756. @example
  20757. ```js
  20758. // json path, 'assets/main/import/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.json';
  20759. var url = getUrlWithUuid('fcmR3XADNLgJ1ByKhqcC5Z', {isNative: false});
  20760. // png path, 'assets/main/native/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.png';
  20761. var url = getUrlWithUuid('fcmR3XADNLgJ1ByKhqcC5Z', {isNative: true, nativeExt: '.png'});
  20762. ```
  20763. */
  20764. getUrlWithUuid(uuid: string, options?: Record<string, any>): string;
  20765. /**
  20766. !#en
  20767. Check if the type of asset is scene
  20768. !#zh
  20769. 检查资源类型是否是场景
  20770. @param asset asset
  20771. */
  20772. isScene(asset: any): boolean;
  20773. /**
  20774. !#en
  20775. Normalize url, strip './' and '/'
  20776. !#zh
  20777. 标准化 url ,去除 './' 和 '/'
  20778. @param url url
  20779. */
  20780. normalize(url: string): string;
  20781. }
  20782. /** !#en
  20783. Parse the downloaded file, it's a singleton, all member can be accessed with `cc.assetManager.parser`
  20784. !#zh
  20785. 解析已下载的文件,parser 是一个单例, 所有成员能通过 `cc.assetManaager.parser` 访问 */
  20786. export class Parser {
  20787. /**
  20788. !#en
  20789. Register custom handler if you want to change default behavior or extend parser to parse other format file
  20790. !#zh
  20791. 当你想修改默认行为或者拓展 parser 来解析其他格式文件时可以注册自定义的handler
  20792. @param type Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler}
  20793. @param handler The corresponding handler
  20794. @example
  20795. ```js
  20796. parser.register('.tga', (file, options, onComplete) => onComplete(null, null));
  20797. parser.register({'.tga': (file, options, onComplete) => onComplete(null, null), '.ext': (file, options, onComplete) => onComplete(null, null)});
  20798. ```
  20799. */
  20800. register(type: string, handler: (file: any, options: Record<string, any>, onComplete: (err: Error, data: any) => void) => void): void;
  20801. register(map: Record<string, (file: any, options: Record<string, any>, onComplete: (err: Error, data: any) => void) => void>): void;
  20802. /**
  20803. !#en
  20804. Use corresponding handler to parse file
  20805. !#zh
  20806. 使用对应的handler来解析文件
  20807. @param id The id of file
  20808. @param file File
  20809. @param type The corresponding type of file, likes '.jpg'.
  20810. @param options Some optional paramters will be transferred to the corresponding handler.
  20811. @param onComplete callback when finishing downloading
  20812. @example
  20813. ```js
  20814. downloader.downloadFile('test.jpg', {responseType: 'blob'}, null, (err, file) => {
  20815. parser.parse('test.jpg', file, '.jpg', null, (err, img) => console.log(err));
  20816. });
  20817. ```
  20818. */
  20819. parse(id: string, file: any, type: string, options: Record<string, any>, onComplete: (err: Error, content: any) => void): void;
  20820. }
  20821. /** !#en
  20822. Pipeline can execute the task for some effect.
  20823. !#zh
  20824. 管线能执行任务达到某个效果 */
  20825. export class Pipeline {
  20826. /** !#en
  20827. The id of pipeline
  20828. !#zh
  20829. 管线的 id */
  20830. id: number;
  20831. /** !#en
  20832. The name of pipeline
  20833. !#zh
  20834. 管线的名字 */
  20835. name: string;
  20836. /** !#en
  20837. All pipes of pipeline
  20838. !#zh
  20839. 所有的管道 */
  20840. pipes: Function[];
  20841. /**
  20842. !#en
  20843. Create a new pipeline
  20844. !#zh
  20845. 创建一个管线
  20846. @param name The name of pipeline
  20847. @param funcs The array of pipe, every pipe must be function which take two parameters, the first is a `Task` flowed in pipeline, the second is complete callback
  20848. @example
  20849. ```js
  20850. var pipeline = new Pipeline('download', [
  20851. (task, done) => {
  20852. var url = task.input;
  20853. cc.assetManager.downloader.downloadFile(url, null, null, (err, result) => {
  20854. task.output = result;
  20855. done(err);
  20856. });
  20857. },
  20858. (task, done) => {
  20859. var text = task.input;
  20860. var json = JSON.stringify(text);
  20861. task.output = json;
  20862. done();
  20863. }
  20864. ]);
  20865. ```
  20866. */
  20867. constructor(name: string, funcs: Array<(task: Task, done?: (err: Error) => void) => void>);
  20868. /**
  20869. !#en
  20870. At specific point insert a new pipe to pipeline
  20871. !#zh
  20872. 在某个特定的点为管线插入一个新的 pipe
  20873. @param func The new pipe
  20874. @param index The specific point you want to insert at.
  20875. @example
  20876. ```js
  20877. var pipeline = new Pipeline('test', []);
  20878. pipeline.insert((task, done) => {
  20879. // do something
  20880. done();
  20881. }, 0);
  20882. ```
  20883. */
  20884. insert(func: (task: Task, callback?: (err: Error) => void) => void, index: number): Pipeline;
  20885. /**
  20886. !#en
  20887. Append a new pipe to the pipeline
  20888. !#zh
  20889. 添加一个管道到管线中
  20890. @param func The new pipe
  20891. @example
  20892. ```js
  20893. var pipeline = new Pipeline('test', []);
  20894. pipeline.append((task, done) => {
  20895. // do something
  20896. done();
  20897. });
  20898. ```
  20899. */
  20900. append(func: (task: Task, callback?: (err: Error) => void) => void): Pipeline;
  20901. /**
  20902. !#en
  20903. Remove pipe which at specific point
  20904. !#zh
  20905. 移除特定位置的管道
  20906. @param index The specific point
  20907. @example
  20908. ```js
  20909. var pipeline = new Pipeline('test', (task, done) => {
  20910. // do something
  20911. done();
  20912. });
  20913. pipeline.remove(0);
  20914. ```
  20915. */
  20916. remove(index: number): Pipeline;
  20917. /**
  20918. !#en
  20919. Execute task synchronously
  20920. !#zh
  20921. 同步执行任务
  20922. @param task The task will be executed
  20923. @example
  20924. ```js
  20925. var pipeline = new Pipeline('sync', [(task) => {
  20926. let input = task.input;
  20927. task.output = doSomething(task.input);
  20928. }]);
  20929. var task = new Task({input: 'test'});
  20930. console.log(pipeline.sync(task));
  20931. ```
  20932. */
  20933. sync(task: Task): any;
  20934. /**
  20935. !#en
  20936. Execute task asynchronously
  20937. !#zh
  20938. 异步执行任务
  20939. @param task The task will be executed
  20940. @example
  20941. ```js
  20942. var pipeline = new Pipeline('sync', [(task, done) => {
  20943. let input = task.input;
  20944. task.output = doSomething(task.input);
  20945. done();
  20946. }]);
  20947. var task = new Task({input: 'test', onComplete: (err, result) => console.log(result)});
  20948. pipeline.async(task);
  20949. ```
  20950. */
  20951. async(task: Task): void;
  20952. }
  20953. /** !#en
  20954. The builtin bundles
  20955. !#zh
  20956. 内置 bundle */
  20957. export enum BuiltinBundleName {
  20958. RESOURCES = 0,
  20959. INTERNAL = 0,
  20960. MAIN = 0,
  20961. START_SCENE = 0,
  20962. }
  20963. /** !#en
  20964. A collection of information about a request
  20965. !#zh
  20966. 请求的相关信息集合 */
  20967. export class RequestItem {
  20968. /** !#en
  20969. The uuid of request
  20970. !#zh
  20971. 请求资源的uuid */
  20972. uuid: string;
  20973. /** !#en
  20974. The final url of request
  20975. !#zh
  20976. 请求的最终url */
  20977. url: string;
  20978. /** !#en
  20979. The extension name of asset
  20980. !#zh
  20981. 资源的扩展名 */
  20982. ext: string;
  20983. /** !#en
  20984. The content of asset
  20985. !#zh
  20986. 资源的内容 */
  20987. content: any;
  20988. /** !#en
  20989. The file of asset
  20990. !#zh
  20991. 资源的文件 */
  20992. file: any;
  20993. /** !#en
  20994. The information of asset
  20995. !#zh
  20996. 资源的相关信息 */
  20997. info: any;
  20998. /** !#en
  20999. Whether or not it is native asset
  21000. !#zh
  21001. 资源是否是原生资源 */
  21002. isNative: boolean;
  21003. /** !#en
  21004. Custom options
  21005. !#zh
  21006. 自定义参数 */
  21007. options: any;
  21008. /**
  21009. !#en
  21010. Create a request item
  21011. !#zh
  21012. 创建一个 request item
  21013. */
  21014. constructor();
  21015. /** !#en
  21016. The id of request, combined from uuid and isNative
  21017. !#zh
  21018. 请求的 id, 由 uuid 和 isNative 组合而成 */
  21019. id: string;
  21020. /**
  21021. !#en
  21022. Recycle this for reuse
  21023. !#zh
  21024. 回收 requestItem 用于复用
  21025. */
  21026. recycle(): void;
  21027. /**
  21028. !#en
  21029. Create a new request item from pool
  21030. !#zh
  21031. 从对象池中创建 requestItem
  21032. */
  21033. static create(): RequestItem;
  21034. }
  21035. /** !#en
  21036. Task is used to run in the pipeline for some effect
  21037. !#zh
  21038. 任务用于在管线中运行以达成某种效果 */
  21039. export class Task {
  21040. /** !#en
  21041. The id of task
  21042. !#zh
  21043. 任务id */
  21044. id: number;
  21045. /** !#en
  21046. The callback when task is completed
  21047. !#zh
  21048. 完成回调 */
  21049. onComplete: Function;
  21050. /** !#en
  21051. The callback of progression
  21052. !#zh
  21053. 进度回调 */
  21054. onProgress: Function;
  21055. /** !#en
  21056. The callback when something goes wrong
  21057. !#zh
  21058. 错误回调 */
  21059. onError: Function;
  21060. /** !#en
  21061. The source of task
  21062. !#zh
  21063. 任务的源 */
  21064. source: any;
  21065. /** !#en
  21066. The output of task
  21067. !#zh
  21068. 任务的输出 */
  21069. output: any;
  21070. /** !#en
  21071. The input of task
  21072. !#zh
  21073. 任务的输入 */
  21074. input: any;
  21075. /** !#en
  21076. The progression of task
  21077. !#zh
  21078. 任务的进度 */
  21079. progress: any;
  21080. /** !#en
  21081. Custom options
  21082. !#zh
  21083. 自定义参数 */
  21084. options: any;
  21085. /**
  21086. !#en
  21087. Create a new Task
  21088. !#zh
  21089. 创建一个任务
  21090. @param options Some optional paramters
  21091. */
  21092. constructor(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record<string, any>});
  21093. /**
  21094. !#en
  21095. Set paramters of this task
  21096. !#zh
  21097. 设置任务的参数
  21098. @param options Some optional paramters
  21099. @example
  21100. ```js
  21101. var task = new Task();
  21102. task.set({input: ['test'], onComplete: (err, result) => console.log(err), onProgress: (finish, total) => console.log(finish / total)});
  21103. ```
  21104. */
  21105. set(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record<string, any>}): void;
  21106. /**
  21107. !#en
  21108. Dispatch event
  21109. !#zh
  21110. 发布事件
  21111. @param event The event name
  21112. @param param1 Parameter 1
  21113. @param param2 Parameter 2
  21114. @param param3 Parameter 3
  21115. @param param4 Parameter 4
  21116. @example
  21117. ```js
  21118. var task = Task.create();
  21119. Task.onComplete = (msg) => console.log(msg);
  21120. Task.dispatch('complete', 'hello world');
  21121. ```
  21122. */
  21123. dispatch(event: string, param1?: any, param2?: any, param3?: any, param4?: any): void;
  21124. /**
  21125. !#en
  21126. Recycle this for reuse
  21127. !#zh
  21128. 回收 task 用于复用
  21129. */
  21130. recycle(): void;
  21131. /** !#en
  21132. Whether or not this task is completed
  21133. !#zh
  21134. 此任务是否已经完成 */
  21135. isFinish: boolean;
  21136. /**
  21137. !#en
  21138. Create a new task from pool
  21139. !#zh
  21140. 从对象池中创建 task
  21141. @param options Some optional paramters
  21142. */
  21143. static create(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record<string, any>}): Task;
  21144. }
  21145. }
  21146. /** !#en Some JavaScript decorators which can be accessed with "cc._decorator".
  21147. !#zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。
  21148. (这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整) */
  21149. declare namespace cc._decorator {
  21150. /**
  21151. !#en
  21152. Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes)
  21153. as CCClass, please see [Class](../../../manual/en/scripting/class.html) for details.
  21154. !#zh
  21155. 将标准写法的 [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass,具体用法请参阅[类型定义](../../../manual/zh/scripting/class.html)。
  21156. @param name The class name used for serialization.
  21157. @example
  21158. ```js
  21159. const {ccclass} = cc._decorator;
  21160. // define a CCClass, omit the name
  21161. &#64;ccclass
  21162. class NewScript extends cc.Component {
  21163. // ...
  21164. }
  21165. // define a CCClass with a name
  21166. &#64;ccclass('LoginData')
  21167. class LoginData {
  21168. // ...
  21169. }
  21170. ```
  21171. */
  21172. export function ccclass(name?: string): Function;
  21173. export function ccclass(_class?: Function): void;
  21174. /**
  21175. !#en
  21176. Declare property for [CCClass](../../../manual/en/scripting/reference/attributes.html).
  21177. !#zh
  21178. 定义 [CCClass](../../../manual/zh/scripting/reference/attributes.html) 所用的属性。
  21179. @param options an object with some property attributes
  21180. @example
  21181. ```js
  21182. const {ccclass, property} = cc._decorator;
  21183. &#64;ccclass
  21184. class NewScript extends cc.Component {
  21185. &#64;property({
  21186. type: cc.Node
  21187. })
  21188. targetNode1 = null;
  21189. &#64;property(cc.Node)
  21190. targetNode2 = null;
  21191. &#64;property(cc.Button)
  21192. targetButton = null;
  21193. &#64;property
  21194. _width = 100;
  21195. &#64;property
  21196. get width () {
  21197. return this._width;
  21198. }
  21199. &#64;property
  21200. set width (value) {
  21201. this._width = value;
  21202. }
  21203. &#64;property
  21204. offset = new cc.Vec2(100, 100);
  21205. &#64;property(cc.Vec2)
  21206. offsets = [];
  21207. &#64;property(cc.SpriteFrame)
  21208. frame = null;
  21209. }
  21210. // above is equivalent to (上面的代码相当于):
  21211. var NewScript = cc.Class({
  21212. properties: {
  21213. targetNode1: {
  21214. default: null,
  21215. type: cc.Node
  21216. },
  21217. targetNode2: {
  21218. default: null,
  21219. type: cc.Node
  21220. },
  21221. targetButton: {
  21222. default: null,
  21223. type: cc.Button
  21224. },
  21225. _width: 100,
  21226. width: {
  21227. get () {
  21228. return this._width;
  21229. },
  21230. set (value) {
  21231. this._width = value;
  21232. }
  21233. },
  21234. offset: new cc.Vec2(100, 100)
  21235. offsets: {
  21236. default: [],
  21237. type: cc.Vec2
  21238. }
  21239. frame: {
  21240. default: null,
  21241. type: cc.SpriteFrame
  21242. },
  21243. }
  21244. });
  21245. ```
  21246. */
  21247. export function property(options?: {type?: any; 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, userData?: Record<string, any> } | any[]|Function|cc.ValueType|number|string|boolean): Function;
  21248. export function property(_target: Object, _key: any, _desc?: any): void;
  21249. /**
  21250. !#en
  21251. Makes a CCClass that inherit from component execute in edit mode.<br>
  21252. By default, all components are only executed in play mode,
  21253. which means they will not have their callback functions executed while the Editor is in edit mode.
  21254. !#zh
  21255. 允许继承自 Component 的 CCClass 在编辑器里执行。<br>
  21256. 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。
  21257. @example
  21258. ```js
  21259. const {ccclass, executeInEditMode} = cc._decorator;
  21260. &#64;ccclass
  21261. &#64;executeInEditMode
  21262. class NewScript extends cc.Component {
  21263. // ...
  21264. }
  21265. ```
  21266. */
  21267. export function executeInEditMode(): Function;
  21268. export function executeInEditMode(_class: Function): void;
  21269. /**
  21270. !#en
  21271. Automatically add required component as a dependency for the CCClass that inherit from component.
  21272. !#zh
  21273. 为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。
  21274. @param requiredComponent requiredComponent
  21275. @example
  21276. ```js
  21277. const {ccclass, requireComponent} = cc._decorator;
  21278. &#64;ccclass
  21279. &#64;requireComponent(cc.Sprite)
  21280. class SpriteCtrl extends cc.Component {
  21281. // ...
  21282. }
  21283. ```
  21284. */
  21285. export function requireComponent(requiredComponent: typeof cc.Component): Function;
  21286. /**
  21287. !#en
  21288. The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl".
  21289. !#zh
  21290. 将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。
  21291. @param path The path is the menu represented like a pathname.
  21292. For example the menu could be "Rendering/CameraCtrl".
  21293. @example
  21294. ```js
  21295. const {ccclass, menu} = cc._decorator;
  21296. &#64;ccclass
  21297. &#64;menu("Rendering/CameraCtrl")
  21298. class NewScript extends cc.Component {
  21299. // ...
  21300. }
  21301. ```
  21302. */
  21303. export function menu(path: string): Function;
  21304. /**
  21305. !#en
  21306. The execution order of lifecycle methods for Component.
  21307. Those less than 0 will execute before while those greater than 0 will execute after.
  21308. The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected.
  21309. !#zh
  21310. 设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。
  21311. @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.
  21312. @example
  21313. ```js
  21314. const {ccclass, executionOrder} = cc._decorator;
  21315. &#64;ccclass
  21316. &#64;executionOrder(1)
  21317. class CameraCtrl extends cc.Component {
  21318. // ...
  21319. }
  21320. ```
  21321. */
  21322. export function executionOrder(order: number): Function;
  21323. /**
  21324. !#en
  21325. Prevents Component of the same type (or subtype) to be added more than once to a Node.
  21326. !#zh
  21327. 防止多个相同类型(或子类型)的组件被添加到同一个节点。
  21328. @example
  21329. ```js
  21330. const {ccclass, disallowMultiple} = cc._decorator;
  21331. &#64;ccclass
  21332. &#64;disallowMultiple
  21333. class CameraCtrl extends cc.Component {
  21334. // ...
  21335. }
  21336. ```
  21337. */
  21338. export function disallowMultiple(): Function;
  21339. export function disallowMultiple(_class: Function): void;
  21340. /**
  21341. !#en
  21342. 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>
  21343. This property is only available if executeInEditMode is true.
  21344. !#zh
  21345. 当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。
  21346. @example
  21347. ```js
  21348. const {ccclass, playOnFocus, executeInEditMode} = cc._decorator;
  21349. &#64;ccclass
  21350. &#64;executeInEditMode
  21351. &#64;playOnFocus
  21352. class CameraCtrl extends cc.Component {
  21353. // ...
  21354. }
  21355. ```
  21356. */
  21357. export function playOnFocus(): Function;
  21358. export function playOnFocus(_class: Function): void;
  21359. /**
  21360. !#en
  21361. Specifying the url of the custom html to draw the component in **Properties**.
  21362. !#zh
  21363. 自定义当前组件在 **属性检查器** 中渲染时所用的网页 url。
  21364. @param url url
  21365. @example
  21366. ```js
  21367. const {ccclass, inspector} = cc._decorator;
  21368. &#64;ccclass
  21369. &#64;inspector("packages://inspector/inspectors/comps/camera-ctrl.js")
  21370. class NewScript extends cc.Component {
  21371. // ...
  21372. }
  21373. ```
  21374. */
  21375. export function inspector(path: string): Function;
  21376. /**
  21377. !#en
  21378. The custom documentation URL.
  21379. !#zh
  21380. 指定当前组件的帮助文档的 url,设置过后,在 **属性检查器** 中就会出现一个帮助图标,用户点击将打开指定的网页。
  21381. @param url url
  21382. @example
  21383. ```js
  21384. const {ccclass, help} = cc._decorator;
  21385. &#64;ccclass
  21386. &#64;help("app://docs/html/components/spine.html")
  21387. class NewScript extends cc.Component {
  21388. // ...
  21389. }
  21390. ```
  21391. */
  21392. export function help(path: string): Function;
  21393. /**
  21394. NOTE:<br>
  21395. The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance.
  21396. But since ES6, class constructor can't be function-called and class methods become non-enumerable,
  21397. so we can not mix in ES6 Classes.<br>
  21398. See:<br>
  21399. [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>
  21400. One possible solution (but IDE unfriendly):<br>
  21401. [http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)<br>
  21402. <br>
  21403. NOTE:<br>
  21404. You must manually call mixins constructor, this is different from cc.Class(ES5).
  21405. @param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`,
  21406. not support ES6 Classes.
  21407. @example
  21408. ```js
  21409. const {ccclass, mixins} = cc._decorator;
  21410. class Animal { ... }
  21411. const Fly = cc.Class({
  21412. constructor () { ... }
  21413. });
  21414. &#64;ccclass
  21415. &#64;mixins(cc.EventTarget, Fly)
  21416. class Bird extends Animal {
  21417. constructor () {
  21418. super();
  21419. // You must manually call mixins constructor, this is different from cc.Class(ES5)
  21420. cc.EventTarget.call(this);
  21421. Fly.call(this);
  21422. }
  21423. // ...
  21424. }
  21425. ```
  21426. */
  21427. export function mixins(ctor: Function, ...rest: Function[]): Function;
  21428. }
  21429. /** !#en This module provides some JavaScript utilities. All members can be accessed with `cc.js`.
  21430. !#zh 这个模块封装了 JavaScript 相关的一些实用函数,你可以通过 `cc.js` 来访问这个模块。 */
  21431. declare namespace cc.js {
  21432. /**
  21433. Check the obj whether is number or not
  21434. If a number is created by using 'new Number(10086)', the typeof it will be "object"...
  21435. Then you can use this function if you care about this case.
  21436. @param obj obj
  21437. */
  21438. export function isNumber(obj: any): boolean;
  21439. /**
  21440. Check the obj whether is string or not.
  21441. If a string is created by using 'new String("blabla")', the typeof it will be "object"...
  21442. Then you can use this function if you care about this case.
  21443. @param obj obj
  21444. */
  21445. export function isString(obj: any): boolean;
  21446. /**
  21447. Copy all properties not defined in obj from arguments[1...n]
  21448. @param obj object to extend its properties
  21449. @param sourceObj source object to copy properties from
  21450. */
  21451. export function addon(obj: any, ...sourceObj: any[]): any;
  21452. /**
  21453. copy all properties from arguments[1...n] to obj
  21454. @param obj obj
  21455. @param sourceObj sourceObj
  21456. */
  21457. export function mixin(obj: any, ...sourceObj: any[]): any;
  21458. /**
  21459. Derive the class from the supplied base class.
  21460. Both classes are just native javascript constructors, not created by cc.Class, so
  21461. usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead.
  21462. @param cls cls
  21463. @param base the baseclass to inherit
  21464. */
  21465. export function extend(cls: Function, base: Function): Function;
  21466. /**
  21467. Get super class
  21468. @param ctor the constructor of subclass
  21469. */
  21470. export function getSuper(ctor: Function): Function;
  21471. /**
  21472. Checks whether subclass is child of superclass or equals to superclass
  21473. @param subclass subclass
  21474. @param superclass superclass
  21475. */
  21476. export function isChildClassOf(subclass: Function, superclass: Function): boolean;
  21477. /**
  21478. Removes all enumerable properties from object
  21479. @param obj obj
  21480. */
  21481. export function clear(obj: any): void;
  21482. /**
  21483. Checks whether obj is an empty object
  21484. @param obj obj
  21485. */
  21486. export function isEmptyObject(obj: any): boolean;
  21487. /**
  21488. Get property descriptor in object and all its ancestors
  21489. @param obj obj
  21490. @param name name
  21491. */
  21492. export function getPropertyDescriptor(obj: any, name: string): any;
  21493. /**
  21494. Define value, just help to call Object.defineProperty.<br>
  21495. The configurable will be true.
  21496. @param obj obj
  21497. @param prop prop
  21498. @param value value
  21499. @param writable writable
  21500. @param enumerable enumerable
  21501. */
  21502. export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void;
  21503. /**
  21504. Define get set accessor, just help to call Object.defineProperty(...)
  21505. @param obj obj
  21506. @param prop prop
  21507. @param getter getter
  21508. @param setter setter
  21509. @param enumerable enumerable
  21510. @param configurable configurable
  21511. */
  21512. export function getset(obj: any, prop: string, getter: Function, setter?: Function, enumerable?: boolean, configurable?: boolean): void;
  21513. /**
  21514. Define get accessor, just help to call Object.defineProperty(...)
  21515. @param obj obj
  21516. @param prop prop
  21517. @param getter getter
  21518. @param enumerable enumerable
  21519. @param configurable configurable
  21520. */
  21521. export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void;
  21522. /**
  21523. Define set accessor, just help to call Object.defineProperty(...)
  21524. @param obj obj
  21525. @param prop prop
  21526. @param setter setter
  21527. @param enumerable enumerable
  21528. @param configurable configurable
  21529. */
  21530. export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void;
  21531. /**
  21532. Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "".
  21533. (modified from <a href="http://stackoverflow.com/questions/1249531/how-to-get-a-javascript-objects-class">the code from this stackoverflow post</a>)
  21534. @param objOrCtor instance or constructor
  21535. */
  21536. export function getClassName(objOrCtor: any|Function): string;
  21537. /** !#en All classes registered in the engine, indexed by ID.
  21538. !#zh 引擎中已注册的所有类型,通过 ID 进行索引。 */
  21539. export var _registeredClassIds: any;
  21540. /** !#en All classes registered in the engine, indexed by name.
  21541. !#zh 引擎中已注册的所有类型,通过名称进行索引。 */
  21542. export var _registeredClassNames: any;
  21543. /**
  21544. Register the class by specified name manually
  21545. @param className className
  21546. @param constructor constructor
  21547. */
  21548. export function setClassName(className: string, constructor: Function): void;
  21549. /**
  21550. Unregister a class from fireball.
  21551. If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore.
  21552. Please note that its still your responsibility to free other references to the class.
  21553. @param constructor the class you will want to unregister, any number of classes can be added
  21554. */
  21555. export function unregisterClass(...constructor: Function[]): void;
  21556. /**
  21557. Get the registered class by name
  21558. @param classname classname
  21559. */
  21560. export function getClassByName(classname: string): Function;
  21561. /**
  21562. Defines a polyfill field for deprecated codes.
  21563. @param obj YourObject or YourClass.prototype
  21564. @param obsoleted "OldParam" or "YourClass.OldParam"
  21565. @param newExpr "NewParam" or "YourClass.NewParam"
  21566. @param writable writable
  21567. */
  21568. export function obsolete(obj: any, obsoleted: string, newExpr: string, writable?: boolean): void;
  21569. /**
  21570. Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props.
  21571. @param obj YourObject or YourClass.prototype
  21572. @param objName "YourObject" or "YourClass"
  21573. @param props props
  21574. @param writable writable
  21575. */
  21576. export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void;
  21577. /**
  21578. A string tool to construct a string with format string.
  21579. @param msg A JavaScript string containing zero or more substitution strings (%s).
  21580. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  21581. @example
  21582. ```js
  21583. cc.js.formatStr("a: %s, b: %s", a, b);
  21584. cc.js.formatStr(a, b, c);
  21585. ```
  21586. */
  21587. export function formatStr(msg: string|any, ...subst: any[]): string;
  21588. /**
  21589. !#en
  21590. 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.
  21591. !#zh
  21592. 该方法是对 `Object.create(null)` 的简单封装。`Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断。在需要频繁判断 `hasOwnProperty` 时,使用这个方法性能会比 `{}` 更高。
  21593. @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.
  21594. */
  21595. export function createMap(forceDictMode?: boolean): any;
  21596. /** undefined */
  21597. export class array {
  21598. /**
  21599. Removes the array item at the specified index.
  21600. @param array array
  21601. @param index index
  21602. */
  21603. static removeAt(array: any[], index: number): void;
  21604. /**
  21605. Removes the array item at the specified index.
  21606. It's faster but the order of the array will be changed.
  21607. @param array array
  21608. @param index index
  21609. */
  21610. static fastRemoveAt(array: any[], index: number): void;
  21611. /**
  21612. Removes the first occurrence of a specific object from the array.
  21613. @param array array
  21614. @param value value
  21615. */
  21616. static remove(array: any[], value: any): boolean;
  21617. /**
  21618. Removes the first occurrence of a specific object from the array.
  21619. It's faster but the order of the array will be changed.
  21620. @param array array
  21621. @param value value
  21622. */
  21623. static fastRemove(array: any[], value: number): void;
  21624. /**
  21625. Verify array's Type
  21626. @param array array
  21627. @param type type
  21628. */
  21629. static verifyType(array: any[], type: Function): boolean;
  21630. /**
  21631. Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed.
  21632. @param array Source Array
  21633. @param minusArr minus Array
  21634. */
  21635. static removeArray(array: any[], minusArr: any[]): void;
  21636. /**
  21637. Inserts some objects at index
  21638. @param array array
  21639. @param addObjs addObjs
  21640. @param index index
  21641. */
  21642. static appendObjectsAt(array: any[], addObjs: any[], index: number): any[];
  21643. /**
  21644. Determines whether the array contains a specific value.
  21645. @param array array
  21646. @param value value
  21647. */
  21648. static contains(array: any[], value: any): boolean;
  21649. /**
  21650. Copy an array's item to a new array (its performance is better than Array.slice)
  21651. @param array array
  21652. */
  21653. static copy(array: any[]): any[];
  21654. }
  21655. /** !#en
  21656. A fixed-length object pool designed for general type.<br>
  21657. The implementation of this object pool is very simple,
  21658. it can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  21659. !#zh
  21660. 长度固定的对象缓存池,可以用来缓存各种对象类型。<br/>
  21661. 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 */
  21662. export class Pool {
  21663. /**
  21664. !#en
  21665. Constructor for creating an object pool for the specific object type.
  21666. You can pass a callback argument for process the cleanup logic when the object is recycled.
  21667. !#zh
  21668. 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。
  21669. @param cleanupFunc the callback method used to process the cleanup logic when the object is recycled.
  21670. @param size initializes the length of the array
  21671. */
  21672. constructor(cleanupFunc: (obj: any) => void, size: number);
  21673. constructor(size: number);
  21674. /**
  21675. !#en
  21676. Get and initialize an object from pool. This method defaults to null and requires the user to implement it.
  21677. !#zh
  21678. 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。
  21679. @param params parameters to used to initialize the object
  21680. */
  21681. get(...params: any[]): any;
  21682. /** !#en
  21683. The current number of available objects, the default is 0, it will gradually increase with the recycle of the object,
  21684. the maximum will not exceed the size specified when the constructor is called.
  21685. !#zh
  21686. 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 */
  21687. count: number;
  21688. /**
  21689. !#en
  21690. Get an object from pool, if no available object in the pool, null will be returned.
  21691. !#zh
  21692. 获取对象池中的对象,如果对象池没有可用对象,则返回空。
  21693. */
  21694. _get(): any;
  21695. /**
  21696. !#en Put an object into the pool.
  21697. !#zh 向对象池返还一个不再需要的对象。
  21698. */
  21699. put(): void;
  21700. /**
  21701. !#en Resize the pool.
  21702. !#zh 设置对象池容量。
  21703. */
  21704. resize(): void;
  21705. }
  21706. }
  21707. /** Some helpful utilities */
  21708. declare namespace cc.geomUtils {
  21709. /**
  21710. !#en
  21711. the distance between a point and a plane
  21712. !#zh
  21713. 计算点和平面之间的距离。
  21714. @param point point
  21715. @param plane plane
  21716. */
  21717. export function point_plane(point: cc.Vec3, plane: cc.Plane): number;
  21718. /**
  21719. !#en
  21720. the closest point on plane to a given point
  21721. !#zh
  21722. 计算平面上最接近给定点的点。
  21723. @param out Closest point
  21724. @param point Given point
  21725. @param plane plane
  21726. */
  21727. export function pt_point_plane(out: cc.Vec3, point: cc.Vec3, plane: cc.Plane): cc.Vec3;
  21728. /**
  21729. !#en
  21730. the closest point on aabb to a given point
  21731. !#zh
  21732. 计算 aabb 上最接近给定点的点。
  21733. @param out Closest point.
  21734. @param point Given point.
  21735. @param aabb Align the axis around the box.
  21736. */
  21737. export function pt_point_aabb(out: cc.Vec3, point: cc.Vec3, aabb: cc.Aabb): cc.Vec3;
  21738. /**
  21739. !#en
  21740. the closest point on obb to a given point
  21741. !#zh
  21742. 计算 obb 上最接近给定点的点。
  21743. @param out Closest point
  21744. @param point Given point
  21745. @param obb Direction box
  21746. */
  21747. export function pt_point_obb(out: cc.Vec3, point: cc.Vec3, obb: cc.Obb): cc.Vec3;
  21748. }
  21749. /** !#en A basic module for creating vertex data for 3D objects. You can access this module by `cc.primitive`.
  21750. !#zh 一个创建 3D 物体顶点数据的基础模块,你可以通过 `cc.primitive` 来访问这个模块。 */
  21751. declare namespace cc.primitive {
  21752. /**
  21753. !#en Create box vertex data
  21754. !#zh 创建长方体顶点数据
  21755. @param width width
  21756. @param height height
  21757. @param length length
  21758. @param opts opts
  21759. */
  21760. export function box(width: number, height: number, length: number, opts: {widthSegments: number; heightSegments: number; lengthSegments: number; }): cc.VertexData;
  21761. /**
  21762. !#en Create cone vertex data
  21763. !#zh 创建圆锥体顶点数据
  21764. @param radius radius
  21765. @param height height
  21766. @param opts opts
  21767. */
  21768. export function cone(radius: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData;
  21769. /**
  21770. !#en Create cylinder vertex data
  21771. !#zh 创建圆柱体顶点数据
  21772. @param radiusTop radiusTop
  21773. @param radiusBottom radiusBottom
  21774. @param height height
  21775. @param opts opts
  21776. */
  21777. export function cylinder(radiusTop: number, radiusBottom: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData;
  21778. /**
  21779. !#en Create plane vertex data
  21780. !#zh 创建平台顶点数据
  21781. @param width width
  21782. @param length length
  21783. @param opts opts
  21784. */
  21785. export function plane(width: number, length: number, opts: {widthSegments: number; lengthSegments: number; }): cc.VertexData;
  21786. /**
  21787. !#en Create quad vertex data
  21788. !#zh 创建面片顶点数据
  21789. */
  21790. export function quad(): cc.VertexData;
  21791. /**
  21792. !#en Create sphere vertex data
  21793. !#zh 创建球体顶点数据
  21794. @param radius radius
  21795. @param opts opts
  21796. */
  21797. export function sphere(radius: number, opts: {segments: number; }): cc.VertexData;
  21798. /**
  21799. !#en Create torus vertex data
  21800. !#zh 创建圆环顶点数据
  21801. @param radius radius
  21802. @param tube tube
  21803. @param opts opts
  21804. */
  21805. export function torus(radius: number, tube: number, opts: {radialSegments: number; tubularSegments: number; arc: number; }): cc.VertexData;
  21806. /**
  21807. !#en Create capsule vertex data
  21808. !#zh 创建胶囊体顶点数据
  21809. @param radiusTop radiusTop
  21810. @param radiusBottom radiusBottom
  21811. @param height height
  21812. @param opts opts
  21813. */
  21814. export function capsule(radiusTop: number, radiusBottom: number, height: number, opts: {sides: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData;
  21815. /**
  21816. !#en Create polyhedron vertex data
  21817. !#zh 创建多面体顶点数据
  21818. @param type type
  21819. @param Size Size
  21820. @param opts opts
  21821. */
  21822. export function polyhedron(type: cc.primitive.PolyhedronType, Size: number, opts: {sizeX: number; sizeY: number; sizeZ: number; }): cc.VertexData;
  21823. }
  21824. /** Running in the editor. */
  21825. declare const CC_EDITOR: boolean;
  21826. /** Preview in browser or simulator. */
  21827. declare const CC_PREVIEW: boolean;
  21828. /** Running in the editor or preview. */
  21829. declare const CC_DEV: boolean;
  21830. /** Running in the editor or preview, or build in debug mode. */
  21831. declare const CC_DEBUG: boolean;
  21832. /** Running in published project. */
  21833. declare const CC_BUILD: boolean;
  21834. /** Running in native platforms (mobile app, desktop app, or simulator). */
  21835. declare const CC_JSB: boolean;
  21836. /** Running in runtime environments. */
  21837. declare const CC_RUNTIME: boolean;
  21838. /** Running in the engine's unit test. */
  21839. declare const CC_TEST: boolean;
  21840. /** Running in the WeChat Mini Game. */
  21841. declare const CC_WECHATGAME: boolean;
  21842. declare let cc: {
  21843. // polyfills: {
  21844. // destroyObject? (object: any): void;
  21845. // };
  21846. [x: string]: any;
  21847. }
  21848. declare let Editor: any;
  21849. // https://medium.com/dailyjs/typescript-create-a-condition-based-subset-types-9d902cea5b8c
  21850. type FlagExcludedType<Base, Type> = { [Key in keyof Base]: Base[Key] extends Type ? never : Key };
  21851. type AllowedNames<Base, Type> = FlagExcludedType<Base, Type>[keyof Base];
  21852. type KeyPartial<T, K extends keyof T> = { [P in K]?: T[P] };
  21853. type OmitType<Base, Type> = KeyPartial<Base, AllowedNames<Base, Type>>;
  21854. type ConstructorType<T> = OmitType<T, Function>;
  21855. declare interface IWritableArrayLike<T> {
  21856. readonly length: number;
  21857. [index: number]: T;
  21858. }
  21859. declare let module: {
  21860. exports: object
  21861. }
  21862. declare interface Math {
  21863. sign(v: number);
  21864. }
  21865. declare interface Object {
  21866. assign(target: {}, source: {});
  21867. }
  21868. type FloatArray = Float64Array | Float32Array;
  21869. interface IColorLike {
  21870. r: number;
  21871. g: number;
  21872. b: number;
  21873. a: number;
  21874. _val: number;
  21875. }
  21876. interface IMat3Like {
  21877. m: FloatArray
  21878. }
  21879. interface IMat4Like {
  21880. m: FloatArray
  21881. }
  21882. interface IQuatLike {
  21883. x: number;
  21884. y: number;
  21885. z: number;
  21886. w: number;
  21887. }
  21888. interface IRectLike {
  21889. x: number;
  21890. y: number;
  21891. width: number;
  21892. height: number;
  21893. }
  21894. interface ISizeLike {
  21895. width: number;
  21896. height: number;
  21897. }
  21898. interface IVec2Like {
  21899. x: number;
  21900. y: number;
  21901. }
  21902. interface IVec3Like {
  21903. x: number;
  21904. y: number;
  21905. z: number;
  21906. }
  21907. interface IVec4Like {
  21908. x: number;
  21909. y: number;
  21910. z: number;
  21911. w: number;
  21912. }
  21913. declare namespace dragonBones {
  21914. /**
  21915. * @internal
  21916. * @private
  21917. */
  21918. const webAssemblyModule: {
  21919. HEAP16: Int16Array;
  21920. _malloc(byteSize: number): number;
  21921. _free(pointer: number): void;
  21922. setDataBinary(data: DragonBonesData, binaryPointer: number, intBytesLength: number, floatBytesLength: number, frameIntBytesLength: number, frameFloatBytesLength: number, frameBytesLength: number, timelineBytesLength: number): void;
  21923. };
  21924. }
  21925. /**
  21926. * The MIT License (MIT)
  21927. *
  21928. * Copyright (c) 2012-2017 DragonBones team and other contributors
  21929. *
  21930. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  21931. * this software and associated documentation files (the "Software"), to deal in
  21932. * the Software without restriction, including without limitation the rights to
  21933. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  21934. * the Software, and to permit persons to whom the Software is furnished to do so,
  21935. * subject to the following conditions:
  21936. *
  21937. * The above copyright notice and this permission notice shall be included in all
  21938. * copies or substantial portions of the Software.
  21939. *
  21940. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21941. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  21942. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  21943. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  21944. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21945. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21946. */
  21947. declare namespace dragonBones {
  21948. /**
  21949. * @internal
  21950. * @private
  21951. */
  21952. const enum BinaryOffset {
  21953. WeigthBoneCount = 0,
  21954. WeigthFloatOffset = 1,
  21955. WeigthBoneIndices = 2,
  21956. MeshVertexCount = 0,
  21957. MeshTriangleCount = 1,
  21958. MeshFloatOffset = 2,
  21959. MeshWeightOffset = 3,
  21960. MeshVertexIndices = 4,
  21961. TimelineScale = 0,
  21962. TimelineOffset = 1,
  21963. TimelineKeyFrameCount = 2,
  21964. TimelineFrameValueCount = 3,
  21965. TimelineFrameValueOffset = 4,
  21966. TimelineFrameOffset = 5,
  21967. FramePosition = 0,
  21968. FrameTweenType = 1,
  21969. FrameTweenEasingOrCurveSampleCount = 2,
  21970. FrameCurveSamples = 3,
  21971. DeformMeshOffset = 0,
  21972. DeformCount = 1,
  21973. DeformValueCount = 2,
  21974. DeformValueOffset = 3,
  21975. DeformFloatOffset = 4,
  21976. }
  21977. /**
  21978. * @internal
  21979. * @private
  21980. */
  21981. const enum ArmatureType {
  21982. Armature = 0,
  21983. MovieClip = 1,
  21984. Stage = 2,
  21985. }
  21986. /**
  21987. * @internal
  21988. * @private
  21989. */
  21990. const enum BoneType {
  21991. Bone = 0,
  21992. Surface = 1,
  21993. }
  21994. /**
  21995. * @private
  21996. */
  21997. const enum DisplayType {
  21998. Image = 0,
  21999. Armature = 1,
  22000. Mesh = 2,
  22001. BoundingBox = 3,
  22002. }
  22003. /**
  22004. * - Bounding box type.
  22005. * @version DragonBones 5.0
  22006. * @language en_US
  22007. */
  22008. /**
  22009. * - 边界框类型。
  22010. * @version DragonBones 5.0
  22011. * @language zh_CN
  22012. */
  22013. const enum BoundingBoxType {
  22014. Rectangle = 0,
  22015. Ellipse = 1,
  22016. Polygon = 2,
  22017. }
  22018. /**
  22019. * @internal
  22020. * @private
  22021. */
  22022. const enum ActionType {
  22023. Play = 0,
  22024. Frame = 10,
  22025. Sound = 11,
  22026. }
  22027. /**
  22028. * @internal
  22029. * @private
  22030. */
  22031. const enum BlendMode {
  22032. Normal = 0,
  22033. Add = 1,
  22034. Alpha = 2,
  22035. Darken = 3,
  22036. Difference = 4,
  22037. Erase = 5,
  22038. HardLight = 6,
  22039. Invert = 7,
  22040. Layer = 8,
  22041. Lighten = 9,
  22042. Multiply = 10,
  22043. Overlay = 11,
  22044. Screen = 12,
  22045. Subtract = 13,
  22046. }
  22047. /**
  22048. * @internal
  22049. * @private
  22050. */
  22051. const enum TweenType {
  22052. None = 0,
  22053. Line = 1,
  22054. Curve = 2,
  22055. QuadIn = 3,
  22056. QuadOut = 4,
  22057. QuadInOut = 5,
  22058. }
  22059. /**
  22060. * @internal
  22061. * @private
  22062. */
  22063. const enum TimelineType {
  22064. Action = 0,
  22065. ZOrder = 1,
  22066. BoneAll = 10,
  22067. BoneTranslate = 11,
  22068. BoneRotate = 12,
  22069. BoneScale = 13,
  22070. Surface = 50,
  22071. SlotDisplay = 20,
  22072. SlotColor = 21,
  22073. SlotFFD = 22,
  22074. IKConstraint = 30,
  22075. AnimationTime = 40,
  22076. AnimationWeight = 41,
  22077. }
  22078. /**
  22079. * - Offset mode.
  22080. * @version DragonBones 5.5
  22081. * @language en_US
  22082. */
  22083. /**
  22084. * - 偏移模式。
  22085. * @version DragonBones 5.5
  22086. * @language zh_CN
  22087. */
  22088. const enum OffsetMode {
  22089. None = 0,
  22090. Additive = 1,
  22091. Override = 2,
  22092. }
  22093. /**
  22094. * - Animation fade out mode.
  22095. * @version DragonBones 4.5
  22096. * @language en_US
  22097. */
  22098. /**
  22099. * - 动画淡出模式。
  22100. * @version DragonBones 4.5
  22101. * @language zh_CN
  22102. */
  22103. const enum AnimationFadeOutMode {
  22104. /**
  22105. * - Do not fade out of any animation states.
  22106. * @language en_US
  22107. */
  22108. /**
  22109. * - 不淡出任何的动画状态。
  22110. * @language zh_CN
  22111. */
  22112. None = 0,
  22113. /**
  22114. * - Fade out the animation states of the same layer.
  22115. * @language en_US
  22116. */
  22117. /**
  22118. * - 淡出同层的动画状态。
  22119. * @language zh_CN
  22120. */
  22121. SameLayer = 1,
  22122. /**
  22123. * - Fade out the animation states of the same group.
  22124. * @language en_US
  22125. */
  22126. /**
  22127. * - 淡出同组的动画状态。
  22128. * @language zh_CN
  22129. */
  22130. SameGroup = 2,
  22131. /**
  22132. * - Fade out the animation states of the same layer and group.
  22133. * @language en_US
  22134. */
  22135. /**
  22136. * - 淡出同层并且同组的动画状态。
  22137. * @language zh_CN
  22138. */
  22139. SameLayerAndGroup = 3,
  22140. /**
  22141. * - Fade out of all animation states.
  22142. * @language en_US
  22143. */
  22144. /**
  22145. * - 淡出所有的动画状态。
  22146. * @language zh_CN
  22147. */
  22148. All = 4,
  22149. /**
  22150. * - Does not replace the animation state with the same name.
  22151. * @language en_US
  22152. */
  22153. /**
  22154. * - 不替换同名的动画状态。
  22155. * @language zh_CN
  22156. */
  22157. Single = 5,
  22158. }
  22159. /**
  22160. * @private
  22161. */
  22162. interface Map<T> {
  22163. [key: string]: T;
  22164. }
  22165. /**
  22166. * @private
  22167. */
  22168. class DragonBones {
  22169. static readonly VERSION: string;
  22170. static yDown: boolean;
  22171. static debug: boolean;
  22172. static debugDraw: boolean;
  22173. static webAssembly: boolean;
  22174. private readonly _clock;
  22175. private readonly _events;
  22176. private readonly _objects;
  22177. private _eventManager;
  22178. constructor(eventManager: IEventDispatcher);
  22179. advanceTime(passedTime: number): void;
  22180. bufferEvent(value: EventObject): void;
  22181. bufferObject(object: BaseObject): void;
  22182. readonly clock: WorldClock;
  22183. readonly eventManager: IEventDispatcher;
  22184. }
  22185. }
  22186. /**
  22187. * The MIT License (MIT)
  22188. *
  22189. * Copyright (c) 2012-2017 DragonBones team and other contributors
  22190. *
  22191. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  22192. * this software and associated documentation files (the "Software"), to deal in
  22193. * the Software without restriction, including without limitation the rights to
  22194. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  22195. * the Software, and to permit persons to whom the Software is furnished to do so,
  22196. * subject to the following conditions:
  22197. *
  22198. * The above copyright notice and this permission notice shall be included in all
  22199. * copies or substantial portions of the Software.
  22200. *
  22201. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22202. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  22203. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  22204. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  22205. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22206. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22207. */
  22208. declare namespace dragonBones {
  22209. /**
  22210. * - The BaseObject is the base class for all objects in the DragonBones framework.
  22211. * All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery.
  22212. * @version DragonBones 4.5
  22213. * @language en_US
  22214. */
  22215. /**
  22216. * - 基础对象,通常 DragonBones 的对象都继承自该类。
  22217. * 所有基础对象的实例都会缓存到对象池,以减少频繁申请内存或内存回收的性能消耗。
  22218. * @version DragonBones 4.5
  22219. * @language zh_CN
  22220. */
  22221. abstract class BaseObject {
  22222. private static _hashCode;
  22223. private static _defaultMaxCount;
  22224. private static readonly _maxCountMap;
  22225. private static readonly _poolsMap;
  22226. private static _returnObject(object);
  22227. static toString(): string;
  22228. /**
  22229. * - Set the maximum cache count of the specify object pool.
  22230. * @param objectConstructor - The specify class. (Set all object pools max cache count if not set)
  22231. * @param maxCount - Max count.
  22232. * @version DragonBones 4.5
  22233. * @language en_US
  22234. */
  22235. /**
  22236. * - 设置特定对象池的最大缓存数量。
  22237. * @param objectConstructor - 特定的类。 (不设置则设置所有对象池的最大缓存数量)
  22238. * @param maxCount - 最大缓存数量。
  22239. * @version DragonBones 4.5
  22240. * @language zh_CN
  22241. */
  22242. static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void;
  22243. /**
  22244. * - Clear the cached instances of a specify object pool.
  22245. * @param objectConstructor - Specify class. (Clear all cached instances if not set)
  22246. * @version DragonBones 4.5
  22247. * @language en_US
  22248. */
  22249. /**
  22250. * - 清除特定对象池的缓存实例。
  22251. * @param objectConstructor - 特定的类。 (不设置则清除所有缓存的实例)
  22252. * @version DragonBones 4.5
  22253. * @language zh_CN
  22254. */
  22255. static clearPool(objectConstructor?: (typeof BaseObject) | null): void;
  22256. /**
  22257. * - Get an instance of the specify class from object pool.
  22258. * @param objectConstructor - The specify class.
  22259. * @version DragonBones 4.5
  22260. * @language en_US
  22261. */
  22262. /**
  22263. * - 从对象池中获取特定类的实例。
  22264. * @param objectConstructor - 特定的类。
  22265. * @version DragonBones 4.5
  22266. * @language zh_CN
  22267. */
  22268. static borrowObject<T extends BaseObject>(objectConstructor: {
  22269. new (): T;
  22270. }): T;
  22271. /**
  22272. * - A unique identification number assigned to the object.
  22273. * @version DragonBones 4.5
  22274. * @language en_US
  22275. */
  22276. /**
  22277. * - 分配给此实例的唯一标识号。
  22278. * @version DragonBones 4.5
  22279. * @language zh_CN
  22280. */
  22281. readonly hashCode: number;
  22282. private _isInPool;
  22283. /**
  22284. * @private
  22285. */
  22286. protected abstract _onClear(): void;
  22287. /**
  22288. * - Clear the object and return it back to object pool。
  22289. * @version DragonBones 4.5
  22290. * @language en_US
  22291. */
  22292. /**
  22293. * - 清除该实例的所有数据并将其返还对象池。
  22294. * @version DragonBones 4.5
  22295. * @language zh_CN
  22296. */
  22297. returnToPool(): void;
  22298. }
  22299. }
  22300. /**
  22301. * The MIT License (MIT)
  22302. *
  22303. * Copyright (c) 2012-2017 DragonBones team and other contributors
  22304. *
  22305. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  22306. * this software and associated documentation files (the "Software"), to deal in
  22307. * the Software without restriction, including without limitation the rights to
  22308. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  22309. * the Software, and to permit persons to whom the Software is furnished to do so,
  22310. * subject to the following conditions:
  22311. *
  22312. * The above copyright notice and this permission notice shall be included in all
  22313. * copies or substantial portions of the Software.
  22314. *
  22315. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22316. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  22317. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  22318. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  22319. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22320. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22321. */
  22322. declare namespace dragonBones {
  22323. /**
  22324. * - 2D Transform matrix.
  22325. * @version DragonBones 3.0
  22326. * @language en_US
  22327. */
  22328. /**
  22329. * - 2D 转换矩阵。
  22330. * @version DragonBones 3.0
  22331. * @language zh_CN
  22332. */
  22333. class Matrix {
  22334. /**
  22335. * - The value that affects the positioning of pixels along the x axis when scaling or rotating an image.
  22336. * @default 1.0
  22337. * @version DragonBones 3.0
  22338. * @language en_US
  22339. */
  22340. /**
  22341. * - 缩放或旋转图像时影响像素沿 x 轴定位的值。
  22342. * @default 1.0
  22343. * @version DragonBones 3.0
  22344. * @language zh_CN
  22345. */
  22346. a: number;
  22347. /**
  22348. * - The value that affects the positioning of pixels along the y axis when rotating or skewing an image.
  22349. * @default 0.0
  22350. * @version DragonBones 3.0
  22351. * @language en_US
  22352. */
  22353. /**
  22354. * - 旋转或倾斜图像时影响像素沿 y 轴定位的值。
  22355. * @default 0.0
  22356. * @version DragonBones 3.0
  22357. * @language zh_CN
  22358. */
  22359. b: number;
  22360. /**
  22361. * - The value that affects the positioning of pixels along the x axis when rotating or skewing an image.
  22362. * @default 0.0
  22363. * @version DragonBones 3.0
  22364. * @language en_US
  22365. */
  22366. /**
  22367. * - 旋转或倾斜图像时影响像素沿 x 轴定位的值。
  22368. * @default 0.0
  22369. * @version DragonBones 3.0
  22370. * @language zh_CN
  22371. */
  22372. c: number;
  22373. /**
  22374. * - The value that affects the positioning of pixels along the y axis when scaling or rotating an image.
  22375. * @default 1.0
  22376. * @version DragonBones 3.0
  22377. * @language en_US
  22378. */
  22379. /**
  22380. * - 缩放或旋转图像时影响像素沿 y 轴定位的值。
  22381. * @default 1.0
  22382. * @version DragonBones 3.0
  22383. * @language zh_CN
  22384. */
  22385. d: number;
  22386. /**
  22387. * - The distance by which to translate each point along the x axis.
  22388. * @default 0.0
  22389. * @version DragonBones 3.0
  22390. * @language en_US
  22391. */
  22392. /**
  22393. * - 沿 x 轴平移每个点的距离。
  22394. * @default 0.0
  22395. * @version DragonBones 3.0
  22396. * @language zh_CN
  22397. */
  22398. tx: number;
  22399. /**
  22400. * - The distance by which to translate each point along the y axis.
  22401. * @default 0.0
  22402. * @version DragonBones 3.0
  22403. * @language en_US
  22404. */
  22405. /**
  22406. * - 沿 y 轴平移每个点的距离。
  22407. * @default 0.0
  22408. * @version DragonBones 3.0
  22409. * @language zh_CN
  22410. */
  22411. ty: number;
  22412. /**
  22413. * @private
  22414. */
  22415. constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number);
  22416. toString(): string;
  22417. /**
  22418. * @private
  22419. */
  22420. copyFrom(value: Matrix): Matrix;
  22421. /**
  22422. * @private
  22423. */
  22424. copyFromArray(value: Array<number>, offset?: number): Matrix;
  22425. /**
  22426. * - Convert to unit matrix.
  22427. * The resulting matrix has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0.
  22428. * @version DragonBones 3.0
  22429. * @language en_US
  22430. */
  22431. /**
  22432. * - 转换为单位矩阵。
  22433. * 该矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0、ty=0。
  22434. * @version DragonBones 3.0
  22435. * @language zh_CN
  22436. */
  22437. identity(): Matrix;
  22438. /**
  22439. * - Multiplies the current matrix with another matrix.
  22440. * @param value - The matrix that needs to be multiplied.
  22441. * @version DragonBones 3.0
  22442. * @language en_US
  22443. */
  22444. /**
  22445. * - 将当前矩阵与另一个矩阵相乘。
  22446. * @param value - 需要相乘的矩阵。
  22447. * @version DragonBones 3.0
  22448. * @language zh_CN
  22449. */
  22450. concat(value: Matrix): Matrix;
  22451. /**
  22452. * - Convert to inverse matrix.
  22453. * @version DragonBones 3.0
  22454. * @language en_US
  22455. */
  22456. /**
  22457. * - 转换为逆矩阵。
  22458. * @version DragonBones 3.0
  22459. * @language zh_CN
  22460. */
  22461. invert(): Matrix;
  22462. /**
  22463. * - Apply a matrix transformation to a specific point.
  22464. * @param x - X coordinate.
  22465. * @param y - Y coordinate.
  22466. * @param result - The point after the transformation is applied.
  22467. * @param delta - Whether to ignore tx, ty's conversion to point.
  22468. * @version DragonBones 3.0
  22469. * @language en_US
  22470. */
  22471. /**
  22472. * - 将矩阵转换应用于特定点。
  22473. * @param x - 横坐标。
  22474. * @param y - 纵坐标。
  22475. * @param result - 应用转换之后的点。
  22476. * @param delta - 是否忽略 tx,ty 对点的转换。
  22477. * @version DragonBones 3.0
  22478. * @language zh_CN
  22479. */
  22480. transformPoint(x: number, y: number, result: {
  22481. x: number;
  22482. y: number;
  22483. }, delta?: boolean): void;
  22484. /**
  22485. * @private
  22486. */
  22487. transformRectangle(rectangle: {
  22488. x: number;
  22489. y: number;
  22490. width: number;
  22491. height: number;
  22492. }, delta?: boolean): void;
  22493. }
  22494. }
  22495. /**
  22496. * The MIT License (MIT)
  22497. *
  22498. * Copyright (c) 2012-2017 DragonBones team and other contributors
  22499. *
  22500. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  22501. * this software and associated documentation files (the "Software"), to deal in
  22502. * the Software without restriction, including without limitation the rights to
  22503. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  22504. * the Software, and to permit persons to whom the Software is furnished to do so,
  22505. * subject to the following conditions:
  22506. *
  22507. * The above copyright notice and this permission notice shall be included in all
  22508. * copies or substantial portions of the Software.
  22509. *
  22510. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22511. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  22512. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  22513. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  22514. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22515. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22516. */
  22517. declare namespace dragonBones {
  22518. /**
  22519. * - 2D Transform.
  22520. * @version DragonBones 3.0
  22521. * @language en_US
  22522. */
  22523. /**
  22524. * - 2D 变换。
  22525. * @version DragonBones 3.0
  22526. * @language zh_CN
  22527. */
  22528. class Transform {
  22529. /**
  22530. * @private
  22531. */
  22532. static readonly PI: number;
  22533. /**
  22534. * @private
  22535. */
  22536. static readonly PI_D: number;
  22537. /**
  22538. * @private
  22539. */
  22540. static readonly PI_H: number;
  22541. /**
  22542. * @private
  22543. */
  22544. static readonly PI_Q: number;
  22545. /**
  22546. * @private
  22547. */
  22548. static readonly RAD_DEG: number;
  22549. /**
  22550. * @private
  22551. */
  22552. static readonly DEG_RAD: number;
  22553. /**
  22554. * @private
  22555. */
  22556. static normalizeRadian(value: number): number;
  22557. /**
  22558. * - Horizontal translate.
  22559. * @version DragonBones 3.0
  22560. * @language en_US
  22561. */
  22562. /**
  22563. * - 水平位移。
  22564. * @version DragonBones 3.0
  22565. * @language zh_CN
  22566. */
  22567. x: number;
  22568. /**
  22569. * - Vertical translate.
  22570. * @version DragonBones 3.0
  22571. * @language en_US
  22572. */
  22573. /**
  22574. * - 垂直位移。
  22575. * @version DragonBones 3.0
  22576. * @language zh_CN
  22577. */
  22578. y: number;
  22579. /**
  22580. * - Skew. (In radians)
  22581. * @version DragonBones 3.0
  22582. * @language en_US
  22583. */
  22584. /**
  22585. * - 倾斜。 (以弧度为单位)
  22586. * @version DragonBones 3.0
  22587. * @language zh_CN
  22588. */
  22589. skew: number;
  22590. /**
  22591. * - rotation. (In radians)
  22592. * @version DragonBones 3.0
  22593. * @language en_US
  22594. */
  22595. /**
  22596. * - 旋转。 (以弧度为单位)
  22597. * @version DragonBones 3.0
  22598. * @language zh_CN
  22599. */
  22600. rotation: number;
  22601. /**
  22602. * - Horizontal Scaling.
  22603. * @version DragonBones 3.0
  22604. * @language en_US
  22605. */
  22606. /**
  22607. * - 水平缩放。
  22608. * @version DragonBones 3.0
  22609. * @language zh_CN
  22610. */
  22611. scaleX: number;
  22612. /**
  22613. * - Vertical scaling.
  22614. * @version DragonBones 3.0
  22615. * @language en_US
  22616. */
  22617. /**
  22618. * - 垂直缩放。
  22619. * @version DragonBones 3.0
  22620. * @language zh_CN
  22621. */
  22622. scaleY: number;
  22623. /**
  22624. * @private
  22625. */
  22626. constructor(x?: number, y?: number, skew?: number, rotation?: number, scaleX?: number, scaleY?: number);
  22627. toString(): string;
  22628. /**
  22629. * @private
  22630. */
  22631. copyFrom(value: Transform): Transform;
  22632. /**
  22633. * @private
  22634. */
  22635. identity(): Transform;
  22636. /**
  22637. * @private
  22638. */
  22639. add(value: Transform): Transform;
  22640. /**
  22641. * @private
  22642. */
  22643. minus(value: Transform): Transform;
  22644. /**
  22645. * @private
  22646. */
  22647. fromMatrix(matrix: Matrix): Transform;
  22648. /**
  22649. * @private
  22650. */
  22651. toMatrix(matrix: Matrix): Transform;
  22652. }
  22653. }
  22654. /**
  22655. * The MIT License (MIT)
  22656. *
  22657. * Copyright (c) 2012-2017 DragonBones team and other contributors
  22658. *
  22659. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  22660. * this software and associated documentation files (the "Software"), to deal in
  22661. * the Software without restriction, including without limitation the rights to
  22662. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  22663. * the Software, and to permit persons to whom the Software is furnished to do so,
  22664. * subject to the following conditions:
  22665. *
  22666. * The above copyright notice and this permission notice shall be included in all
  22667. * copies or substantial portions of the Software.
  22668. *
  22669. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22670. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  22671. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  22672. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  22673. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22674. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22675. */
  22676. declare namespace dragonBones {
  22677. /**
  22678. * @internal
  22679. * @private
  22680. */
  22681. class ColorTransform {
  22682. alphaMultiplier: number;
  22683. redMultiplier: number;
  22684. greenMultiplier: number;
  22685. blueMultiplier: number;
  22686. alphaOffset: number;
  22687. redOffset: number;
  22688. greenOffset: number;
  22689. blueOffset: number;
  22690. constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number);
  22691. copyFrom(value: ColorTransform): void;
  22692. identity(): void;
  22693. }
  22694. }
  22695. /**
  22696. * The MIT License (MIT)
  22697. *
  22698. * Copyright (c) 2012-2017 DragonBones team and other contributors
  22699. *
  22700. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  22701. * this software and associated documentation files (the "Software"), to deal in
  22702. * the Software without restriction, including without limitation the rights to
  22703. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  22704. * the Software, and to permit persons to whom the Software is furnished to do so,
  22705. * subject to the following conditions:
  22706. *
  22707. * The above copyright notice and this permission notice shall be included in all
  22708. * copies or substantial portions of the Software.
  22709. *
  22710. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22711. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  22712. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  22713. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  22714. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22715. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22716. */
  22717. declare namespace dragonBones {
  22718. /**
  22719. * - The Point object represents a location in a two-dimensional coordinate system.
  22720. * @version DragonBones 3.0
  22721. * @language en_US
  22722. */
  22723. /**
  22724. * - Point 对象表示二维坐标系统中的某个位置。
  22725. * @version DragonBones 3.0
  22726. * @language zh_CN
  22727. */
  22728. class Point {
  22729. /**
  22730. * - The horizontal coordinate.
  22731. * @default 0.0
  22732. * @version DragonBones 3.0
  22733. * @language en_US
  22734. */
  22735. /**
  22736. * - 该点的水平坐标。
  22737. * @default 0.0
  22738. * @version DragonBones 3.0
  22739. * @language zh_CN
  22740. */
  22741. x: number;
  22742. /**
  22743. * - The vertical coordinate.
  22744. * @default 0.0
  22745. * @version DragonBones 3.0
  22746. * @language en_US
  22747. */
  22748. /**
  22749. * - 该点的垂直坐标。
  22750. * @default 0.0
  22751. * @version DragonBones 3.0
  22752. * @language zh_CN
  22753. */
  22754. y: number;
  22755. /**
  22756. * - Creates a new point. If you pass no parameters to this method, a point is created at (0,0).
  22757. * @param x - The horizontal coordinate.
  22758. * @param y - The vertical coordinate.
  22759. * @version DragonBones 3.0
  22760. * @language en_US
  22761. */
  22762. /**
  22763. * - 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。
  22764. * @param x - 该对象的x属性值,默认为 0.0。
  22765. * @param y - 该对象的y属性值,默认为 0.0。
  22766. * @version DragonBones 3.0
  22767. * @language zh_CN
  22768. */
  22769. constructor(x?: number, y?: number);
  22770. /**
  22771. * @private
  22772. */
  22773. copyFrom(value: Point): void;
  22774. /**
  22775. * @private
  22776. */
  22777. clear(): void;
  22778. }
  22779. }
  22780. /**
  22781. * The MIT License (MIT)
  22782. *
  22783. * Copyright (c) 2012-2017 DragonBones team and other contributors
  22784. *
  22785. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  22786. * this software and associated documentation files (the "Software"), to deal in
  22787. * the Software without restriction, including without limitation the rights to
  22788. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  22789. * the Software, and to permit persons to whom the Software is furnished to do so,
  22790. * subject to the following conditions:
  22791. *
  22792. * The above copyright notice and this permission notice shall be included in all
  22793. * copies or substantial portions of the Software.
  22794. *
  22795. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22796. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  22797. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  22798. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  22799. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22800. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22801. */
  22802. declare namespace dragonBones {
  22803. /**
  22804. * - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its
  22805. * width and its height.<br/>
  22806. * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of
  22807. * one property has no effect on the others. However, the right and bottom properties are integrally related to those
  22808. * four properties. For example, if you change the value of the right property, the value of the width property changes;
  22809. * if you change the bottom property, the value of the height property changes.
  22810. * @version DragonBones 3.0
  22811. * @language en_US
  22812. */
  22813. /**
  22814. * - Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。<br/>
  22815. * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。
  22816. * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width
  22817. * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。
  22818. * @version DragonBones 3.0
  22819. * @language zh_CN
  22820. */
  22821. class Rectangle {
  22822. /**
  22823. * - The x coordinate of the top-left corner of the rectangle.
  22824. * @default 0.0
  22825. * @version DragonBones 3.0
  22826. * @language en_US
  22827. */
  22828. /**
  22829. * - 矩形左上角的 x 坐标。
  22830. * @default 0.0
  22831. * @version DragonBones 3.0
  22832. * @language zh_CN
  22833. */
  22834. x: number;
  22835. /**
  22836. * - The y coordinate of the top-left corner of the rectangle.
  22837. * @default 0.0
  22838. * @version DragonBones 3.0
  22839. * @language en_US
  22840. */
  22841. /**
  22842. * - 矩形左上角的 y 坐标。
  22843. * @default 0.0
  22844. * @version DragonBones 3.0
  22845. * @language zh_CN
  22846. */
  22847. y: number;
  22848. /**
  22849. * - The width of the rectangle, in pixels.
  22850. * @default 0.0
  22851. * @version DragonBones 3.0
  22852. * @language en_US
  22853. */
  22854. /**
  22855. * - 矩形的宽度(以像素为单位)。
  22856. * @default 0.0
  22857. * @version DragonBones 3.0
  22858. * @language zh_CN
  22859. */
  22860. width: number;
  22861. /**
  22862. * - The height of the rectangle, in pixels.
  22863. * @default 0.0
  22864. * @version DragonBones 3.0
  22865. * @language en_US
  22866. */
  22867. /**
  22868. * - 矩形的高度(以像素为单位)。
  22869. * @default 0.0
  22870. * @version DragonBones 3.0
  22871. * @language zh_CN
  22872. */
  22873. height: number;
  22874. /**
  22875. * @private
  22876. */
  22877. constructor(x?: number, y?: number, width?: number, height?: number);
  22878. /**
  22879. * @private
  22880. */
  22881. copyFrom(value: Rectangle): void;
  22882. /**
  22883. * @private
  22884. */
  22885. clear(): void;
  22886. }
  22887. }
  22888. /**
  22889. * The MIT License (MIT)
  22890. *
  22891. * Copyright (c) 2012-2017 DragonBones team and other contributors
  22892. *
  22893. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  22894. * this software and associated documentation files (the "Software"), to deal in
  22895. * the Software without restriction, including without limitation the rights to
  22896. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  22897. * the Software, and to permit persons to whom the Software is furnished to do so,
  22898. * subject to the following conditions:
  22899. *
  22900. * The above copyright notice and this permission notice shall be included in all
  22901. * copies or substantial portions of the Software.
  22902. *
  22903. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22904. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  22905. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  22906. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  22907. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22908. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22909. */
  22910. declare namespace dragonBones {
  22911. /**
  22912. * - The user custom data.
  22913. * @version DragonBones 5.0
  22914. * @language en_US
  22915. */
  22916. /**
  22917. * - 用户自定义数据。
  22918. * @version DragonBones 5.0
  22919. * @language zh_CN
  22920. */
  22921. class UserData extends BaseObject {
  22922. static toString(): string;
  22923. /**
  22924. * - The custom int numbers.
  22925. * @version DragonBones 5.0
  22926. * @language en_US
  22927. */
  22928. /**
  22929. * - 自定义整数。
  22930. * @version DragonBones 5.0
  22931. * @language zh_CN
  22932. */
  22933. readonly ints: Array<number>;
  22934. /**
  22935. * - The custom float numbers.
  22936. * @version DragonBones 5.0
  22937. * @language en_US
  22938. */
  22939. /**
  22940. * - 自定义浮点数。
  22941. * @version DragonBones 5.0
  22942. * @language zh_CN
  22943. */
  22944. readonly floats: Array<number>;
  22945. /**
  22946. * - The custom strings.
  22947. * @version DragonBones 5.0
  22948. * @language en_US
  22949. */
  22950. /**
  22951. * - 自定义字符串。
  22952. * @version DragonBones 5.0
  22953. * @language zh_CN
  22954. */
  22955. readonly strings: Array<string>;
  22956. /**
  22957. * @inheritDoc
  22958. */
  22959. protected _onClear(): void;
  22960. /**
  22961. * @internal
  22962. * @private
  22963. */
  22964. addInt(value: number): void;
  22965. /**
  22966. * @internal
  22967. * @private
  22968. */
  22969. addFloat(value: number): void;
  22970. /**
  22971. * @internal
  22972. * @private
  22973. */
  22974. addString(value: string): void;
  22975. /**
  22976. * - Get the custom int number.
  22977. * @version DragonBones 5.0
  22978. * @language en_US
  22979. */
  22980. /**
  22981. * - 获取自定义整数。
  22982. * @version DragonBones 5.0
  22983. * @language zh_CN
  22984. */
  22985. getInt(index?: number): number;
  22986. /**
  22987. * - Get the custom float number.
  22988. * @version DragonBones 5.0
  22989. * @language en_US
  22990. */
  22991. /**
  22992. * - 获取自定义浮点数。
  22993. * @version DragonBones 5.0
  22994. * @language zh_CN
  22995. */
  22996. getFloat(index?: number): number;
  22997. /**
  22998. * - Get the custom string.
  22999. * @version DragonBones 5.0
  23000. * @language en_US
  23001. */
  23002. /**
  23003. * - 获取自定义字符串。
  23004. * @version DragonBones 5.0
  23005. * @language zh_CN
  23006. */
  23007. getString(index?: number): string;
  23008. }
  23009. /**
  23010. * @internal
  23011. * @private
  23012. */
  23013. class ActionData extends BaseObject {
  23014. static toString(): string;
  23015. type: ActionType;
  23016. name: string;
  23017. bone: BoneData | null;
  23018. slot: SlotData | null;
  23019. data: UserData | null;
  23020. protected _onClear(): void;
  23021. }
  23022. }
  23023. /**
  23024. * The MIT License (MIT)
  23025. *
  23026. * Copyright (c) 2012-2017 DragonBones team and other contributors
  23027. *
  23028. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  23029. * this software and associated documentation files (the "Software"), to deal in
  23030. * the Software without restriction, including without limitation the rights to
  23031. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  23032. * the Software, and to permit persons to whom the Software is furnished to do so,
  23033. * subject to the following conditions:
  23034. *
  23035. * The above copyright notice and this permission notice shall be included in all
  23036. * copies or substantial portions of the Software.
  23037. *
  23038. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23039. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  23040. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  23041. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  23042. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23043. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23044. */
  23045. declare namespace dragonBones {
  23046. /**
  23047. * - The DragonBones data.
  23048. * A DragonBones data contains multiple armature data.
  23049. * @see dragonBones.ArmatureData
  23050. * @version DragonBones 3.0
  23051. * @language en_US
  23052. */
  23053. /**
  23054. * - 龙骨数据。
  23055. * 一个龙骨数据包含多个骨架数据。
  23056. * @see dragonBones.ArmatureData
  23057. * @version DragonBones 3.0
  23058. * @language zh_CN
  23059. */
  23060. class DragonBonesData extends BaseObject {
  23061. static toString(): string;
  23062. /**
  23063. * @private
  23064. */
  23065. autoSearch: boolean;
  23066. /**
  23067. * - The animation frame rate.
  23068. * @version DragonBones 3.0
  23069. * @language en_US
  23070. */
  23071. /**
  23072. * - 动画帧频。
  23073. * @version DragonBones 3.0
  23074. * @language zh_CN
  23075. */
  23076. frameRate: number;
  23077. /**
  23078. * - The data version.
  23079. * @version DragonBones 3.0
  23080. * @language en_US
  23081. */
  23082. /**
  23083. * - 数据版本。
  23084. * @version DragonBones 3.0
  23085. * @language zh_CN
  23086. */
  23087. version: string;
  23088. /**
  23089. * - The DragonBones data name.
  23090. * The name is consistent with the DragonBones project name.
  23091. * @version DragonBones 3.0
  23092. * @language en_US
  23093. */
  23094. /**
  23095. * - 龙骨数据名称。
  23096. * 该名称与龙骨项目名保持一致。
  23097. * @version DragonBones 3.0
  23098. * @language zh_CN
  23099. */
  23100. name: string;
  23101. /**
  23102. * @private
  23103. */
  23104. stage: ArmatureData | null;
  23105. /**
  23106. * @internal
  23107. * @private
  23108. */
  23109. readonly frameIndices: Array<number>;
  23110. /**
  23111. * @internal
  23112. * @private
  23113. */
  23114. readonly cachedFrames: Array<number>;
  23115. /**
  23116. * - All armature data names.
  23117. * @version DragonBones 3.0
  23118. * @language en_US
  23119. */
  23120. /**
  23121. * - 所有的骨架数据名称。
  23122. * @version DragonBones 3.0
  23123. * @language zh_CN
  23124. */
  23125. readonly armatureNames: Array<string>;
  23126. /**
  23127. * @private
  23128. */
  23129. readonly armatures: Map<ArmatureData>;
  23130. /**
  23131. * @internal
  23132. * @private
  23133. */
  23134. binary: ArrayBuffer;
  23135. /**
  23136. * @internal
  23137. * @private
  23138. */
  23139. intArray: Int16Array;
  23140. /**
  23141. * @internal
  23142. * @private
  23143. */
  23144. floatArray: Float32Array;
  23145. /**
  23146. * @internal
  23147. * @private
  23148. */
  23149. frameIntArray: Int16Array;
  23150. /**
  23151. * @internal
  23152. * @private
  23153. */
  23154. frameFloatArray: Float32Array;
  23155. /**
  23156. * @internal
  23157. * @private
  23158. */
  23159. frameArray: Int16Array;
  23160. /**
  23161. * @internal
  23162. * @private
  23163. */
  23164. timelineArray: Uint16Array;
  23165. /**
  23166. * @private
  23167. */
  23168. userData: UserData | null;
  23169. /**
  23170. * @inheritDoc
  23171. */
  23172. protected _onClear(): void;
  23173. /**
  23174. * @internal
  23175. * @private
  23176. */
  23177. addArmature(value: ArmatureData): void;
  23178. /**
  23179. * - Get a specific armature data.
  23180. * @param name - The armature data name.
  23181. * @version DragonBones 3.0
  23182. * @language en_US
  23183. */
  23184. /**
  23185. * - 获取特定的骨架数据。
  23186. * @param name - 骨架数据名称。
  23187. * @version DragonBones 3.0
  23188. * @language zh_CN
  23189. */
  23190. getArmature(name: string): ArmatureData | null;
  23191. /**
  23192. * - Deprecated, please refer to {@link #dragonBones.BaseFactory#removeDragonBonesData()}.
  23193. * @deprecated
  23194. * @language en_US
  23195. */
  23196. /**
  23197. * - 已废弃,请参考 {@link #dragonBones.BaseFactory#removeDragonBonesData()}。
  23198. * @deprecated
  23199. * @language zh_CN
  23200. */
  23201. dispose(): void;
  23202. }
  23203. }
  23204. /**
  23205. * The MIT License (MIT)
  23206. *
  23207. * Copyright (c) 2012-2017 DragonBones team and other contributors
  23208. *
  23209. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  23210. * this software and associated documentation files (the "Software"), to deal in
  23211. * the Software without restriction, including without limitation the rights to
  23212. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  23213. * the Software, and to permit persons to whom the Software is furnished to do so,
  23214. * subject to the following conditions:
  23215. *
  23216. * The above copyright notice and this permission notice shall be included in all
  23217. * copies or substantial portions of the Software.
  23218. *
  23219. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23220. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  23221. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  23222. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  23223. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23224. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23225. */
  23226. declare namespace dragonBones {
  23227. /**
  23228. * - The armature data.
  23229. * @version DragonBones 3.0
  23230. * @language en_US
  23231. */
  23232. /**
  23233. * - 骨架数据。
  23234. * @version DragonBones 3.0
  23235. * @language zh_CN
  23236. */
  23237. class ArmatureData extends BaseObject {
  23238. static toString(): string;
  23239. /**
  23240. * @private
  23241. */
  23242. type: ArmatureType;
  23243. /**
  23244. * - The animation frame rate.
  23245. * @version DragonBones 3.0
  23246. * @language en_US
  23247. */
  23248. /**
  23249. * - 动画帧率。
  23250. * @version DragonBones 3.0
  23251. * @language zh_CN
  23252. */
  23253. frameRate: number;
  23254. /**
  23255. * @private
  23256. */
  23257. cacheFrameRate: number;
  23258. /**
  23259. * @private
  23260. */
  23261. scale: number;
  23262. /**
  23263. * - The armature name.
  23264. * @version DragonBones 3.0
  23265. * @language en_US
  23266. */
  23267. /**
  23268. * - 骨架名称。
  23269. * @version DragonBones 3.0
  23270. * @language zh_CN
  23271. */
  23272. name: string;
  23273. /**
  23274. * @private
  23275. */
  23276. readonly aabb: Rectangle;
  23277. /**
  23278. * - The names of all the animation data.
  23279. * @version DragonBones 3.0
  23280. * @language en_US
  23281. */
  23282. /**
  23283. * - 所有的动画数据名称。
  23284. * @version DragonBones 3.0
  23285. * @language zh_CN
  23286. */
  23287. readonly animationNames: Array<string>;
  23288. /**
  23289. * @private
  23290. */
  23291. readonly sortedBones: Array<BoneData>;
  23292. /**
  23293. * @private
  23294. */
  23295. readonly sortedSlots: Array<SlotData>;
  23296. /**
  23297. * @private
  23298. */
  23299. readonly defaultActions: Array<ActionData>;
  23300. /**
  23301. * @private
  23302. */
  23303. readonly actions: Array<ActionData>;
  23304. /**
  23305. * @private
  23306. */
  23307. readonly bones: Map<BoneData>;
  23308. /**
  23309. * @private
  23310. */
  23311. readonly slots: Map<SlotData>;
  23312. /**
  23313. * @private
  23314. */
  23315. readonly constraints: Map<ConstraintData>;
  23316. /**
  23317. * @private
  23318. */
  23319. readonly skins: Map<SkinData>;
  23320. /**
  23321. * @private
  23322. */
  23323. readonly animations: Map<AnimationData>;
  23324. /**
  23325. * - The default skin data.
  23326. * @version DragonBones 4.5
  23327. * @language en_US
  23328. */
  23329. /**
  23330. * - 默认插槽数据。
  23331. * @version DragonBones 4.5
  23332. * @language zh_CN
  23333. */
  23334. defaultSkin: SkinData | null;
  23335. /**
  23336. * - The default animation data.
  23337. * @version DragonBones 4.5
  23338. * @language en_US
  23339. */
  23340. /**
  23341. * - 默认动画数据。
  23342. * @version DragonBones 4.5
  23343. * @language zh_CN
  23344. */
  23345. defaultAnimation: AnimationData | null;
  23346. /**
  23347. * @private
  23348. */
  23349. canvas: CanvasData | null;
  23350. /**
  23351. * @private
  23352. */
  23353. userData: UserData | null;
  23354. /**
  23355. * @private
  23356. */
  23357. parent: DragonBonesData;
  23358. /**
  23359. * @inheritDoc
  23360. */
  23361. protected _onClear(): void;
  23362. /**
  23363. * @internal
  23364. * @private
  23365. */
  23366. sortBones(): void;
  23367. /**
  23368. * @internal
  23369. * @private
  23370. */
  23371. cacheFrames(frameRate: number): void;
  23372. /**
  23373. * @internal
  23374. * @private
  23375. */
  23376. setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number;
  23377. /**
  23378. * @internal
  23379. * @private
  23380. */
  23381. getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void;
  23382. /**
  23383. * @internal
  23384. * @private
  23385. */
  23386. addBone(value: BoneData): void;
  23387. /**
  23388. * @internal
  23389. * @private
  23390. */
  23391. addSlot(value: SlotData): void;
  23392. /**
  23393. * @internal
  23394. * @private
  23395. */
  23396. addConstraint(value: ConstraintData): void;
  23397. /**
  23398. * @internal
  23399. * @private
  23400. */
  23401. addSkin(value: SkinData): void;
  23402. /**
  23403. * @internal
  23404. * @private
  23405. */
  23406. addAnimation(value: AnimationData): void;
  23407. /**
  23408. * @internal
  23409. * @private
  23410. */
  23411. addAction(value: ActionData, isDefault: boolean): void;
  23412. /**
  23413. * - Get a specific done data.
  23414. * @param name - The bone name.
  23415. * @version DragonBones 3.0
  23416. * @language en_US
  23417. */
  23418. /**
  23419. * - 获取特定的骨骼数据。
  23420. * @param name - 骨骼名称。
  23421. * @version DragonBones 3.0
  23422. * @language zh_CN
  23423. */
  23424. getBone(name: string): BoneData | null;
  23425. /**
  23426. * - Get a specific slot data.
  23427. * @param name - The slot name.
  23428. * @version DragonBones 3.0
  23429. * @language en_US
  23430. */
  23431. /**
  23432. * - 获取特定的插槽数据。
  23433. * @param name - 插槽名称。
  23434. * @version DragonBones 3.0
  23435. * @language zh_CN
  23436. */
  23437. getSlot(name: string): SlotData | null;
  23438. /**
  23439. * @private
  23440. */
  23441. getConstraint(name: string): ConstraintData | null;
  23442. /**
  23443. * - Get a specific skin data.
  23444. * @param name - The skin name.
  23445. * @version DragonBones 3.0
  23446. * @language en_US
  23447. */
  23448. /**
  23449. * - 获取特定皮肤数据。
  23450. * @param name - 皮肤名称。
  23451. * @version DragonBones 3.0
  23452. * @language zh_CN
  23453. */
  23454. getSkin(name: string): SkinData | null;
  23455. /**
  23456. * @internal
  23457. * @private
  23458. */
  23459. getMesh(skinName: string, slotName: string, meshName: string): MeshDisplayData | null;
  23460. /**
  23461. * - Get a specific animation data.
  23462. * @param name - The animation name.
  23463. * @version DragonBones 3.0
  23464. * @language en_US
  23465. */
  23466. /**
  23467. * - 获取特定的动画数据。
  23468. * @param name - 动画名称。
  23469. * @version DragonBones 3.0
  23470. * @language zh_CN
  23471. */
  23472. getAnimation(name: string): AnimationData | null;
  23473. }
  23474. /**
  23475. * - The bone data.
  23476. * @version DragonBones 3.0
  23477. * @language en_US
  23478. */
  23479. /**
  23480. * - 骨骼数据。
  23481. * @version DragonBones 3.0
  23482. * @language zh_CN
  23483. */
  23484. class BoneData extends BaseObject {
  23485. static toString(): string;
  23486. /**
  23487. * @private
  23488. */
  23489. inheritTranslation: boolean;
  23490. /**
  23491. * @private
  23492. */
  23493. inheritRotation: boolean;
  23494. /**
  23495. * @private
  23496. */
  23497. inheritScale: boolean;
  23498. /**
  23499. * @private
  23500. */
  23501. inheritReflection: boolean;
  23502. /**
  23503. * @private
  23504. */
  23505. type: BoneType;
  23506. /**
  23507. * - The bone length.
  23508. * @version DragonBones 3.0
  23509. * @language en_US
  23510. */
  23511. /**
  23512. * - 骨骼长度。
  23513. * @version DragonBones 3.0
  23514. * @language zh_CN
  23515. */
  23516. length: number;
  23517. /**
  23518. * - The bone name.
  23519. * @version DragonBones 3.0
  23520. * @language en_US
  23521. */
  23522. /**
  23523. * - 骨骼名称。
  23524. * @version DragonBones 3.0
  23525. * @language zh_CN
  23526. */
  23527. name: string;
  23528. /**
  23529. * @private
  23530. */
  23531. readonly transform: Transform;
  23532. /**
  23533. * @private
  23534. */
  23535. userData: UserData | null;
  23536. /**
  23537. * - The parent bone data.
  23538. * @version DragonBones 3.0
  23539. * @language en_US
  23540. */
  23541. /**
  23542. * - 父骨骼数据。
  23543. * @version DragonBones 3.0
  23544. * @language zh_CN
  23545. */
  23546. parent: BoneData | null;
  23547. /**
  23548. * @inheritDoc
  23549. */
  23550. protected _onClear(): void;
  23551. }
  23552. /**
  23553. * @internal
  23554. * @private
  23555. */
  23556. class SurfaceData extends BoneData {
  23557. static toString(): string;
  23558. segmentX: number;
  23559. segmentY: number;
  23560. readonly vertices: Array<number>;
  23561. /**
  23562. * @inheritDoc
  23563. */
  23564. protected _onClear(): void;
  23565. }
  23566. /**
  23567. * - The slot data.
  23568. * @version DragonBones 3.0
  23569. * @language en_US
  23570. */
  23571. /**
  23572. * - 插槽数据。
  23573. * @version DragonBones 3.0
  23574. * @language zh_CN
  23575. */
  23576. class SlotData extends BaseObject {
  23577. /**
  23578. * @internal
  23579. * @private
  23580. */
  23581. static readonly DEFAULT_COLOR: ColorTransform;
  23582. /**
  23583. * @internal
  23584. * @private
  23585. */
  23586. static createColor(): ColorTransform;
  23587. static toString(): string;
  23588. /**
  23589. * @private
  23590. */
  23591. blendMode: BlendMode;
  23592. /**
  23593. * @private
  23594. */
  23595. displayIndex: number;
  23596. /**
  23597. * @private
  23598. */
  23599. zOrder: number;
  23600. /**
  23601. * - The slot name.
  23602. * @version DragonBones 3.0
  23603. * @language en_US
  23604. */
  23605. /**
  23606. * - 插槽名称。
  23607. * @version DragonBones 3.0
  23608. * @language zh_CN
  23609. */
  23610. name: string;
  23611. /**
  23612. * @private
  23613. */
  23614. color: ColorTransform;
  23615. /**
  23616. * @private
  23617. */
  23618. userData: UserData | null;
  23619. /**
  23620. * - The parent bone data.
  23621. * @version DragonBones 3.0
  23622. * @language en_US
  23623. */
  23624. /**
  23625. * - 父骨骼数据。
  23626. * @version DragonBones 3.0
  23627. * @language zh_CN
  23628. */
  23629. parent: BoneData;
  23630. /**
  23631. * @inheritDoc
  23632. */
  23633. protected _onClear(): void;
  23634. }
  23635. }
  23636. /**
  23637. * The MIT License (MIT)
  23638. *
  23639. * Copyright (c) 2012-2017 DragonBones team and other contributors
  23640. *
  23641. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  23642. * this software and associated documentation files (the "Software"), to deal in
  23643. * the Software without restriction, including without limitation the rights to
  23644. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  23645. * the Software, and to permit persons to whom the Software is furnished to do so,
  23646. * subject to the following conditions:
  23647. *
  23648. * The above copyright notice and this permission notice shall be included in all
  23649. * copies or substantial portions of the Software.
  23650. *
  23651. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23652. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  23653. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  23654. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  23655. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23656. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23657. */
  23658. declare namespace dragonBones {
  23659. /**
  23660. * @internal
  23661. * @private
  23662. */
  23663. abstract class ConstraintData extends BaseObject {
  23664. order: number;
  23665. name: string;
  23666. target: BoneData;
  23667. root: BoneData;
  23668. bone: BoneData | null;
  23669. protected _onClear(): void;
  23670. }
  23671. /**
  23672. * @internal
  23673. * @private
  23674. */
  23675. class IKConstraintData extends ConstraintData {
  23676. static toString(): string;
  23677. scaleEnabled: boolean;
  23678. bendPositive: boolean;
  23679. weight: number;
  23680. protected _onClear(): void;
  23681. }
  23682. }
  23683. /**
  23684. * The MIT License (MIT)
  23685. *
  23686. * Copyright (c) 2012-2017 DragonBones team and other contributors
  23687. *
  23688. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  23689. * this software and associated documentation files (the "Software"), to deal in
  23690. * the Software without restriction, including without limitation the rights to
  23691. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  23692. * the Software, and to permit persons to whom the Software is furnished to do so,
  23693. * subject to the following conditions:
  23694. *
  23695. * The above copyright notice and this permission notice shall be included in all
  23696. * copies or substantial portions of the Software.
  23697. *
  23698. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23699. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  23700. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  23701. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  23702. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23703. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23704. */
  23705. declare namespace dragonBones {
  23706. /**
  23707. * @internal
  23708. * @private
  23709. */
  23710. class CanvasData extends BaseObject {
  23711. static toString(): string;
  23712. hasBackground: boolean;
  23713. color: number;
  23714. x: number;
  23715. y: number;
  23716. width: number;
  23717. height: number;
  23718. protected _onClear(): void;
  23719. }
  23720. }
  23721. /**
  23722. * The MIT License (MIT)
  23723. *
  23724. * Copyright (c) 2012-2017 DragonBones team and other contributors
  23725. *
  23726. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  23727. * this software and associated documentation files (the "Software"), to deal in
  23728. * the Software without restriction, including without limitation the rights to
  23729. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  23730. * the Software, and to permit persons to whom the Software is furnished to do so,
  23731. * subject to the following conditions:
  23732. *
  23733. * The above copyright notice and this permission notice shall be included in all
  23734. * copies or substantial portions of the Software.
  23735. *
  23736. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23737. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  23738. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  23739. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  23740. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23741. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23742. */
  23743. declare namespace dragonBones {
  23744. /**
  23745. * - The skin data, typically a armature data instance contains at least one skinData.
  23746. * @version DragonBones 3.0
  23747. * @language en_US
  23748. */
  23749. /**
  23750. * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。
  23751. * @version DragonBones 3.0
  23752. * @language zh_CN
  23753. */
  23754. class SkinData extends BaseObject {
  23755. static toString(): string;
  23756. /**
  23757. * - The skin name.
  23758. * @version DragonBones 3.0
  23759. * @language en_US
  23760. */
  23761. /**
  23762. * - 皮肤名称。
  23763. * @version DragonBones 3.0
  23764. * @language zh_CN
  23765. */
  23766. name: string;
  23767. /**
  23768. * @private
  23769. */
  23770. readonly displays: Map<Array<DisplayData | null>>;
  23771. /**
  23772. * @private
  23773. */
  23774. parent: ArmatureData;
  23775. /**
  23776. * @inheritDoc
  23777. */
  23778. protected _onClear(): void;
  23779. /**
  23780. * @internal
  23781. * @private
  23782. */
  23783. addDisplay(slotName: string, value: DisplayData | null): void;
  23784. /**
  23785. * @private
  23786. */
  23787. getDisplay(slotName: string, displayName: string): DisplayData | null;
  23788. /**
  23789. * @private
  23790. */
  23791. getDisplays(slotName: string): Array<DisplayData | null> | null;
  23792. }
  23793. }
  23794. /**
  23795. * The MIT License (MIT)
  23796. *
  23797. * Copyright (c) 2012-2017 DragonBones team and other contributors
  23798. *
  23799. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  23800. * this software and associated documentation files (the "Software"), to deal in
  23801. * the Software without restriction, including without limitation the rights to
  23802. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  23803. * the Software, and to permit persons to whom the Software is furnished to do so,
  23804. * subject to the following conditions:
  23805. *
  23806. * The above copyright notice and this permission notice shall be included in all
  23807. * copies or substantial portions of the Software.
  23808. *
  23809. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23810. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  23811. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  23812. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  23813. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23814. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23815. */
  23816. declare namespace dragonBones {
  23817. /**
  23818. * @internal
  23819. * @private
  23820. */
  23821. abstract class DisplayData extends BaseObject {
  23822. type: DisplayType;
  23823. name: string;
  23824. path: string;
  23825. parent: SkinData;
  23826. readonly transform: Transform;
  23827. protected _onClear(): void;
  23828. }
  23829. /**
  23830. * @internal
  23831. * @private
  23832. */
  23833. class ImageDisplayData extends DisplayData {
  23834. static toString(): string;
  23835. readonly pivot: Point;
  23836. texture: TextureData | null;
  23837. protected _onClear(): void;
  23838. }
  23839. /**
  23840. * @internal
  23841. * @private
  23842. */
  23843. class ArmatureDisplayData extends DisplayData {
  23844. static toString(): string;
  23845. inheritAnimation: boolean;
  23846. readonly actions: Array<ActionData>;
  23847. armature: ArmatureData | null;
  23848. protected _onClear(): void;
  23849. /**
  23850. * @private
  23851. */
  23852. addAction(value: ActionData): void;
  23853. }
  23854. /**
  23855. * @internal
  23856. * @private
  23857. */
  23858. class MeshDisplayData extends DisplayData {
  23859. static toString(): string;
  23860. inheritDeform: boolean;
  23861. offset: number;
  23862. weight: WeightData | null;
  23863. glue: GlueData | null;
  23864. texture: TextureData | null;
  23865. protected _onClear(): void;
  23866. }
  23867. /**
  23868. * @internal
  23869. * @private
  23870. */
  23871. class BoundingBoxDisplayData extends DisplayData {
  23872. static toString(): string;
  23873. boundingBox: BoundingBoxData | null;
  23874. protected _onClear(): void;
  23875. }
  23876. /**
  23877. * @internal
  23878. * @private
  23879. */
  23880. class WeightData extends BaseObject {
  23881. static toString(): string;
  23882. count: number;
  23883. offset: number;
  23884. readonly bones: Array<BoneData>;
  23885. protected _onClear(): void;
  23886. addBone(value: BoneData): void;
  23887. }
  23888. /**
  23889. * @internal
  23890. * @private
  23891. */
  23892. class GlueData extends BaseObject {
  23893. static toString(): string;
  23894. readonly weights: Array<number>;
  23895. readonly meshes: Array<MeshDisplayData | null>;
  23896. protected _onClear(): void;
  23897. addMesh(value: MeshDisplayData | null): void;
  23898. }
  23899. }
  23900. /**
  23901. * The MIT License (MIT)
  23902. *
  23903. * Copyright (c) 2012-2017 DragonBones team and other contributors
  23904. *
  23905. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  23906. * this software and associated documentation files (the "Software"), to deal in
  23907. * the Software without restriction, including without limitation the rights to
  23908. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  23909. * the Software, and to permit persons to whom the Software is furnished to do so,
  23910. * subject to the following conditions:
  23911. *
  23912. * The above copyright notice and this permission notice shall be included in all
  23913. * copies or substantial portions of the Software.
  23914. *
  23915. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23916. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  23917. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  23918. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  23919. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23920. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23921. */
  23922. declare namespace dragonBones {
  23923. /**
  23924. * - The base class of bounding box data.
  23925. * @see dragonBones.RectangleData
  23926. * @see dragonBones.EllipseData
  23927. * @see dragonBones.PolygonData
  23928. * @version DragonBones 5.0
  23929. * @language en_US
  23930. */
  23931. /**
  23932. * - 边界框数据基类。
  23933. * @see dragonBones.RectangleData
  23934. * @see dragonBones.EllipseData
  23935. * @see dragonBones.PolygonData
  23936. * @version DragonBones 5.0
  23937. * @language zh_CN
  23938. */
  23939. abstract class BoundingBoxData extends BaseObject {
  23940. /**
  23941. * - The bounding box type.
  23942. * @version DragonBones 5.0
  23943. * @language en_US
  23944. */
  23945. /**
  23946. * - 边界框类型。
  23947. * @version DragonBones 5.0
  23948. * @language zh_CN
  23949. */
  23950. type: BoundingBoxType;
  23951. /**
  23952. * @private
  23953. */
  23954. color: number;
  23955. /**
  23956. * @private
  23957. */
  23958. width: number;
  23959. /**
  23960. * @private
  23961. */
  23962. height: number;
  23963. /**
  23964. * @private
  23965. */
  23966. protected _onClear(): void;
  23967. /**
  23968. * - Check whether the bounding box contains a specific point. (Local coordinate system)
  23969. * @version DragonBones 5.0
  23970. * @language en_US
  23971. */
  23972. /**
  23973. * - 检查边界框是否包含特定点。(本地坐标系)
  23974. * @version DragonBones 5.0
  23975. * @language zh_CN
  23976. */
  23977. abstract containsPoint(pX: number, pY: number): boolean;
  23978. /**
  23979. * - Check whether the bounding box intersects a specific segment. (Local coordinate system)
  23980. * @version DragonBones 5.0
  23981. * @language en_US
  23982. */
  23983. /**
  23984. * - 检查边界框是否与特定线段相交。(本地坐标系)
  23985. * @version DragonBones 5.0
  23986. * @language zh_CN
  23987. */
  23988. abstract intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA: {
  23989. x: number;
  23990. y: number;
  23991. } | null, intersectionPointB: {
  23992. x: number;
  23993. y: number;
  23994. } | null, normalRadians: {
  23995. x: number;
  23996. y: number;
  23997. } | null): number;
  23998. }
  23999. /**
  24000. * - The rectangle bounding box data.
  24001. * @version DragonBones 5.1
  24002. * @language en_US
  24003. */
  24004. /**
  24005. * - 矩形边界框数据。
  24006. * @version DragonBones 5.1
  24007. * @language zh_CN
  24008. */
  24009. class RectangleBoundingBoxData extends BoundingBoxData {
  24010. static toString(): string;
  24011. /**
  24012. * - Compute the bit code for a point (x, y) using the clip rectangle
  24013. */
  24014. private static _computeOutCode(x, y, xMin, yMin, xMax, yMax);
  24015. /**
  24016. * @private
  24017. */
  24018. static rectangleIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xMin: number, yMin: number, xMax: number, yMax: number, intersectionPointA?: {
  24019. x: number;
  24020. y: number;
  24021. } | null, intersectionPointB?: {
  24022. x: number;
  24023. y: number;
  24024. } | null, normalRadians?: {
  24025. x: number;
  24026. y: number;
  24027. } | null): number;
  24028. /**
  24029. * @inheritDoc
  24030. * @private
  24031. */
  24032. protected _onClear(): void;
  24033. /**
  24034. * @inheritDoc
  24035. */
  24036. containsPoint(pX: number, pY: number): boolean;
  24037. /**
  24038. * @inheritDoc
  24039. */
  24040. intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: {
  24041. x: number;
  24042. y: number;
  24043. } | null, intersectionPointB?: {
  24044. x: number;
  24045. y: number;
  24046. } | null, normalRadians?: {
  24047. x: number;
  24048. y: number;
  24049. } | null): number;
  24050. }
  24051. /**
  24052. * - The ellipse bounding box data.
  24053. * @version DragonBones 5.1
  24054. * @language en_US
  24055. */
  24056. /**
  24057. * - 椭圆边界框数据。
  24058. * @version DragonBones 5.1
  24059. * @language zh_CN
  24060. */
  24061. class EllipseBoundingBoxData extends BoundingBoxData {
  24062. static toString(): string;
  24063. /**
  24064. * @private
  24065. */
  24066. static ellipseIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xC: number, yC: number, widthH: number, heightH: number, intersectionPointA?: {
  24067. x: number;
  24068. y: number;
  24069. } | null, intersectionPointB?: {
  24070. x: number;
  24071. y: number;
  24072. } | null, normalRadians?: {
  24073. x: number;
  24074. y: number;
  24075. } | null): number;
  24076. /**
  24077. * @inheritDoc
  24078. * @private
  24079. */
  24080. protected _onClear(): void;
  24081. /**
  24082. * @inheritDoc
  24083. */
  24084. containsPoint(pX: number, pY: number): boolean;
  24085. /**
  24086. * @inheritDoc
  24087. */
  24088. intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: {
  24089. x: number;
  24090. y: number;
  24091. } | null, intersectionPointB?: {
  24092. x: number;
  24093. y: number;
  24094. } | null, normalRadians?: {
  24095. x: number;
  24096. y: number;
  24097. } | null): number;
  24098. }
  24099. /**
  24100. * - The polygon bounding box data.
  24101. * @version DragonBones 5.1
  24102. * @language en_US
  24103. */
  24104. /**
  24105. * - 多边形边界框数据。
  24106. * @version DragonBones 5.1
  24107. * @language zh_CN
  24108. */
  24109. class PolygonBoundingBoxData extends BoundingBoxData {
  24110. static toString(): string;
  24111. /**
  24112. * @private
  24113. */
  24114. static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array<number>, intersectionPointA?: {
  24115. x: number;
  24116. y: number;
  24117. } | null, intersectionPointB?: {
  24118. x: number;
  24119. y: number;
  24120. } | null, normalRadians?: {
  24121. x: number;
  24122. y: number;
  24123. } | null): number;
  24124. /**
  24125. * @private
  24126. */
  24127. x: number;
  24128. /**
  24129. * @private
  24130. */
  24131. y: number;
  24132. /**
  24133. * - The polygon vertices.
  24134. * @version DragonBones 5.1
  24135. * @language en_US
  24136. */
  24137. /**
  24138. * - 多边形顶点。
  24139. * @version DragonBones 5.1
  24140. * @language zh_CN
  24141. */
  24142. readonly vertices: Array<number>;
  24143. /**
  24144. * @private
  24145. */
  24146. weight: WeightData | null;
  24147. /**
  24148. * @inheritDoc
  24149. * @private
  24150. */
  24151. protected _onClear(): void;
  24152. /**
  24153. * @inheritDoc
  24154. */
  24155. containsPoint(pX: number, pY: number): boolean;
  24156. /**
  24157. * @inheritDoc
  24158. */
  24159. intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: {
  24160. x: number;
  24161. y: number;
  24162. } | null, intersectionPointB?: {
  24163. x: number;
  24164. y: number;
  24165. } | null, normalRadians?: {
  24166. x: number;
  24167. y: number;
  24168. } | null): number;
  24169. }
  24170. }
  24171. /**
  24172. * The MIT License (MIT)
  24173. *
  24174. * Copyright (c) 2012-2017 DragonBones team and other contributors
  24175. *
  24176. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  24177. * this software and associated documentation files (the "Software"), to deal in
  24178. * the Software without restriction, including without limitation the rights to
  24179. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  24180. * the Software, and to permit persons to whom the Software is furnished to do so,
  24181. * subject to the following conditions:
  24182. *
  24183. * The above copyright notice and this permission notice shall be included in all
  24184. * copies or substantial portions of the Software.
  24185. *
  24186. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24187. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  24188. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  24189. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  24190. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  24191. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24192. */
  24193. declare namespace dragonBones {
  24194. /**
  24195. * - The animation data.
  24196. * @version DragonBones 3.0
  24197. * @language en_US
  24198. */
  24199. /**
  24200. * - 动画数据。
  24201. * @version DragonBones 3.0
  24202. * @language zh_CN
  24203. */
  24204. class AnimationData extends BaseObject {
  24205. static toString(): string;
  24206. /**
  24207. * - FrameIntArray.
  24208. * @internal
  24209. * @private
  24210. */
  24211. frameIntOffset: number;
  24212. /**
  24213. * - FrameFloatArray.
  24214. * @internal
  24215. * @private
  24216. */
  24217. frameFloatOffset: number;
  24218. /**
  24219. * - FrameArray.
  24220. * @internal
  24221. * @private
  24222. */
  24223. frameOffset: number;
  24224. /**
  24225. * - The frame count of the animation.
  24226. * @version DragonBones 3.0
  24227. * @language en_US
  24228. */
  24229. /**
  24230. * - 动画的帧数。
  24231. * @version DragonBones 3.0
  24232. * @language zh_CN
  24233. */
  24234. frameCount: number;
  24235. /**
  24236. * - The play times of the animation. [0: Loop play, [1~N]: Play N times]
  24237. * @version DragonBones 3.0
  24238. * @language en_US
  24239. */
  24240. /**
  24241. * - 动画的播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次]
  24242. * @version DragonBones 3.0
  24243. * @language zh_CN
  24244. */
  24245. playTimes: number;
  24246. /**
  24247. * - The duration of the animation. (In seconds)
  24248. * @version DragonBones 3.0
  24249. * @language en_US
  24250. */
  24251. /**
  24252. * - 动画的持续时间。 (以秒为单位)
  24253. * @version DragonBones 3.0
  24254. * @language zh_CN
  24255. */
  24256. duration: number;
  24257. /**
  24258. * @private
  24259. */
  24260. scale: number;
  24261. /**
  24262. * - The fade in time of the animation. (In seconds)
  24263. * @version DragonBones 3.0
  24264. * @language en_US
  24265. */
  24266. /**
  24267. * - 动画的淡入时间。 (以秒为单位)
  24268. * @version DragonBones 3.0
  24269. * @language zh_CN
  24270. */
  24271. fadeInTime: number;
  24272. /**
  24273. * @private
  24274. */
  24275. cacheFrameRate: number;
  24276. /**
  24277. * - The animation name.
  24278. * @version DragonBones 3.0
  24279. * @language en_US
  24280. */
  24281. /**
  24282. * - 动画名称。
  24283. * @version DragonBones 3.0
  24284. * @language zh_CN
  24285. */
  24286. name: string;
  24287. /**
  24288. * @private
  24289. */
  24290. readonly cachedFrames: Array<boolean>;
  24291. /**
  24292. * @private
  24293. */
  24294. readonly boneTimelines: Map<Array<TimelineData>>;
  24295. /**
  24296. * @private
  24297. */
  24298. readonly surfaceTimelines: Map<Array<TimelineData>>;
  24299. /**
  24300. * @private
  24301. */
  24302. readonly slotTimelines: Map<Array<TimelineData>>;
  24303. /**
  24304. * @private
  24305. */
  24306. readonly constraintTimelines: Map<Array<TimelineData>>;
  24307. /**
  24308. * @private
  24309. */
  24310. readonly animationTimelines: Map<Array<TimelineData>>;
  24311. /**
  24312. * @private
  24313. */
  24314. readonly boneCachedFrameIndices: Map<Array<number>>;
  24315. /**
  24316. * @private
  24317. */
  24318. readonly slotCachedFrameIndices: Map<Array<number>>;
  24319. /**
  24320. * @private
  24321. */
  24322. actionTimeline: TimelineData | null;
  24323. /**
  24324. * @private
  24325. */
  24326. zOrderTimeline: TimelineData | null;
  24327. /**
  24328. * @private
  24329. */
  24330. parent: ArmatureData;
  24331. /**
  24332. * @inheritDoc
  24333. */
  24334. protected _onClear(): void;
  24335. /**
  24336. * @internal
  24337. * @private
  24338. */
  24339. cacheFrames(frameRate: number): void;
  24340. /**
  24341. * @private
  24342. */
  24343. addBoneTimeline(bone: BoneData, timeline: TimelineData): void;
  24344. /**
  24345. * @private
  24346. */
  24347. addSurfaceTimeline(surface: SurfaceData, timeline: TimelineData): void;
  24348. /**
  24349. * @private
  24350. */
  24351. addSlotTimeline(slot: SlotData, timeline: TimelineData): void;
  24352. /**
  24353. * @private
  24354. */
  24355. addConstraintTimeline(constraint: ConstraintData, timeline: TimelineData): void;
  24356. /**
  24357. * @private
  24358. */
  24359. addAnimationTimeline(name: string, timeline: TimelineData): void;
  24360. /**
  24361. * @private
  24362. */
  24363. getBoneTimelines(name: string): Array<TimelineData> | null;
  24364. /**
  24365. * @private
  24366. */
  24367. getSurfaceTimelines(name: string): Array<TimelineData> | null;
  24368. /**
  24369. * @private
  24370. */
  24371. getSlotTimelines(name: string): Array<TimelineData> | null;
  24372. /**
  24373. * @private
  24374. */
  24375. getConstraintTimelines(name: string): Array<TimelineData> | null;
  24376. /**
  24377. * @private
  24378. */
  24379. getAnimationTimelines(name: string): Array<TimelineData> | null;
  24380. /**
  24381. * @private
  24382. */
  24383. getBoneCachedFrameIndices(name: string): Array<number> | null;
  24384. /**
  24385. * @private
  24386. */
  24387. getSlotCachedFrameIndices(name: string): Array<number> | null;
  24388. }
  24389. /**
  24390. * @internal
  24391. * @private
  24392. */
  24393. class TimelineData extends BaseObject {
  24394. static toString(): string;
  24395. type: TimelineType;
  24396. offset: number;
  24397. frameIndicesOffset: number;
  24398. protected _onClear(): void;
  24399. }
  24400. }
  24401. /**
  24402. * The MIT License (MIT)
  24403. *
  24404. * Copyright (c) 2012-2017 DragonBones team and other contributors
  24405. *
  24406. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  24407. * this software and associated documentation files (the "Software"), to deal in
  24408. * the Software without restriction, including without limitation the rights to
  24409. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  24410. * the Software, and to permit persons to whom the Software is furnished to do so,
  24411. * subject to the following conditions:
  24412. *
  24413. * The above copyright notice and this permission notice shall be included in all
  24414. * copies or substantial portions of the Software.
  24415. *
  24416. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24417. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  24418. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  24419. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  24420. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  24421. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24422. */
  24423. declare namespace dragonBones {
  24424. /**
  24425. * - The animation config is used to describe all the information needed to play an animation state.
  24426. * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used.
  24427. * @see dragonBones.AnimationState
  24428. * @beta
  24429. * @version DragonBones 5.0
  24430. * @language en_US
  24431. */
  24432. /**
  24433. * - 动画配置用来描述播放一个动画状态所需要的全部信息。
  24434. * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。
  24435. * @see dragonBones.AnimationState
  24436. * @beta
  24437. * @version DragonBones 5.0
  24438. * @language zh_CN
  24439. */
  24440. class AnimationConfig extends BaseObject {
  24441. static toString(): string;
  24442. /**
  24443. * @private
  24444. */
  24445. pauseFadeOut: boolean;
  24446. /**
  24447. * - Fade out the pattern of other animation states when the animation state is fade in.
  24448. * This property is typically used to specify the substitution of multiple animation states blend.
  24449. * @default dragonBones.AnimationFadeOutMode.All
  24450. * @version DragonBones 5.0
  24451. * @language en_US
  24452. */
  24453. /**
  24454. * - 淡入动画状态时淡出其他动画状态的模式。
  24455. * 该属性通常用来指定多个动画状态混合时的相互替换关系。
  24456. * @default dragonBones.AnimationFadeOutMode.All
  24457. * @version DragonBones 5.0
  24458. * @language zh_CN
  24459. */
  24460. fadeOutMode: AnimationFadeOutMode;
  24461. /**
  24462. * @private
  24463. */
  24464. fadeOutTweenType: TweenType;
  24465. /**
  24466. * @private
  24467. */
  24468. fadeOutTime: number;
  24469. /**
  24470. * @private
  24471. */
  24472. pauseFadeIn: boolean;
  24473. /**
  24474. * @private
  24475. */
  24476. actionEnabled: boolean;
  24477. /**
  24478. * @private
  24479. */
  24480. additiveBlending: boolean;
  24481. /**
  24482. * - Whether the animation state has control over the display property of the slots.
  24483. * Sometimes blend a animation state does not want it to control the display properties of the slots,
  24484. * especially if other animation state are controlling the display properties of the slots.
  24485. * @default true
  24486. * @version DragonBones 5.0
  24487. * @language en_US
  24488. */
  24489. /**
  24490. * - 动画状态是否对插槽的显示对象属性有控制权。
  24491. * 有时混合一个动画状态并不希望其控制插槽的显示对象属性,
  24492. * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。
  24493. * @default true
  24494. * @version DragonBones 5.0
  24495. * @language zh_CN
  24496. */
  24497. displayControl: boolean;
  24498. /**
  24499. * - Whether to reset the objects without animation to the armature pose when the animation state is start to play.
  24500. * This property should usually be set to false when blend multiple animation states.
  24501. * @default true
  24502. * @version DragonBones 5.1
  24503. * @language en_US
  24504. */
  24505. /**
  24506. * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。
  24507. * 通常在混合多个动画状态时应该将该属性设置为 false。
  24508. * @default true
  24509. * @version DragonBones 5.1
  24510. * @language zh_CN
  24511. */
  24512. resetToPose: boolean;
  24513. /**
  24514. * @private
  24515. */
  24516. fadeInTweenType: TweenType;
  24517. /**
  24518. * - The play times. [0: Loop play, [1~N]: Play N times]
  24519. * @version DragonBones 3.0
  24520. * @language en_US
  24521. */
  24522. /**
  24523. * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次]
  24524. * @version DragonBones 3.0
  24525. * @language zh_CN
  24526. */
  24527. playTimes: number;
  24528. /**
  24529. * - The blend layer.
  24530. * High layer animation state will get the blend weight first.
  24531. * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned.
  24532. * @readonly
  24533. * @version DragonBones 5.0
  24534. * @language en_US
  24535. */
  24536. /**
  24537. * - 混合图层。
  24538. * 图层高的动画状态会优先获取混合权重。
  24539. * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。
  24540. * @readonly
  24541. * @version DragonBones 5.0
  24542. * @language zh_CN
  24543. */
  24544. layer: number;
  24545. /**
  24546. * - The start time of play. (In seconds)
  24547. * @default 0.0
  24548. * @version DragonBones 5.0
  24549. * @language en_US
  24550. */
  24551. /**
  24552. * - 播放的开始时间。 (以秒为单位)
  24553. * @default 0.0
  24554. * @version DragonBones 5.0
  24555. * @language zh_CN
  24556. */
  24557. position: number;
  24558. /**
  24559. * - The duration of play.
  24560. * [-1: Use the default value of the animation data, 0: Stop play, (0~N]: The duration] (In seconds)
  24561. * @default -1.0
  24562. * @version DragonBones 5.0
  24563. * @language en_US
  24564. */
  24565. /**
  24566. * - 播放的持续时间。
  24567. * [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位)
  24568. * @default -1.0
  24569. * @version DragonBones 5.0
  24570. * @language zh_CN
  24571. */
  24572. duration: number;
  24573. /**
  24574. * - The play speed.
  24575. * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}.
  24576. * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play]
  24577. * @default 1.0
  24578. * @version DragonBones 3.0
  24579. * @language en_US
  24580. */
  24581. /**
  24582. * - 播放速度。
  24583. * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。
  24584. * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  24585. * @default 1.0
  24586. * @version DragonBones 3.0
  24587. * @language zh_CN
  24588. */
  24589. timeScale: number;
  24590. /**
  24591. * - The blend weight.
  24592. * @default 1.0
  24593. * @version DragonBones 5.0
  24594. * @language en_US
  24595. */
  24596. /**
  24597. * - 混合权重。
  24598. * @default 1.0
  24599. * @version DragonBones 5.0
  24600. * @language zh_CN
  24601. */
  24602. weight: number;
  24603. /**
  24604. * - The fade in time.
  24605. * [-1: Use the default value of the animation data, [0~N]: The fade in time] (In seconds)
  24606. * @default -1.0
  24607. * @version DragonBones 5.0
  24608. * @language en_US
  24609. */
  24610. /**
  24611. * - 淡入时间。
  24612. * [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位)
  24613. * @default -1.0
  24614. * @version DragonBones 5.0
  24615. * @language zh_CN
  24616. */
  24617. fadeInTime: number;
  24618. /**
  24619. * - The auto fade out time when the animation state play completed.
  24620. * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds)
  24621. * @default -1.0
  24622. * @version DragonBones 5.0
  24623. * @language en_US
  24624. */
  24625. /**
  24626. * - 动画状态播放完成后的自动淡出时间。
  24627. * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位)
  24628. * @default -1.0
  24629. * @version DragonBones 5.0
  24630. * @language zh_CN
  24631. */
  24632. autoFadeOutTime: number;
  24633. /**
  24634. * - The name of the animation state. (Can be different from the name of the animation data)
  24635. * @version DragonBones 5.0
  24636. * @language en_US
  24637. */
  24638. /**
  24639. * - 动画状态名称。 (可以不同于动画数据)
  24640. * @version DragonBones 5.0
  24641. * @language zh_CN
  24642. */
  24643. name: string;
  24644. /**
  24645. * - The animation data name.
  24646. * @version DragonBones 5.0
  24647. * @language en_US
  24648. */
  24649. /**
  24650. * - 动画数据名称。
  24651. * @version DragonBones 5.0
  24652. * @language zh_CN
  24653. */
  24654. animation: string;
  24655. /**
  24656. * - The blend group name of the animation state.
  24657. * This property is typically used to specify the substitution of multiple animation states blend.
  24658. * @readonly
  24659. * @version DragonBones 5.0
  24660. * @language en_US
  24661. */
  24662. /**
  24663. * - 混合组名称。
  24664. * 该属性通常用来指定多个动画状态混合时的相互替换关系。
  24665. * @readonly
  24666. * @version DragonBones 5.0
  24667. * @language zh_CN
  24668. */
  24669. group: string;
  24670. /**
  24671. * @private
  24672. */
  24673. readonly boneMask: Array<string>;
  24674. /**
  24675. * @private
  24676. */
  24677. protected _onClear(): void;
  24678. /**
  24679. * @private
  24680. */
  24681. clear(): void;
  24682. /**
  24683. * @private
  24684. */
  24685. copyFrom(value: AnimationConfig): void;
  24686. /**
  24687. * @private
  24688. */
  24689. containsBoneMask(name: string): boolean;
  24690. /**
  24691. * @private
  24692. */
  24693. addBoneMask(armature: Armature, name: string, recursive?: boolean): void;
  24694. /**
  24695. * @private
  24696. */
  24697. removeBoneMask(armature: Armature, name: string, recursive?: boolean): void;
  24698. }
  24699. }
  24700. /**
  24701. * The MIT License (MIT)
  24702. *
  24703. * Copyright (c) 2012-2017 DragonBones team and other contributors
  24704. *
  24705. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  24706. * this software and associated documentation files (the "Software"), to deal in
  24707. * the Software without restriction, including without limitation the rights to
  24708. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  24709. * the Software, and to permit persons to whom the Software is furnished to do so,
  24710. * subject to the following conditions:
  24711. *
  24712. * The above copyright notice and this permission notice shall be included in all
  24713. * copies or substantial portions of the Software.
  24714. *
  24715. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24716. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  24717. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  24718. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  24719. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  24720. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24721. */
  24722. declare namespace dragonBones {
  24723. /**
  24724. * - The texture atlas data.
  24725. * @version DragonBones 3.0
  24726. * @language en_US
  24727. */
  24728. /**
  24729. * - 贴图集数据。
  24730. * @version DragonBones 3.0
  24731. * @language zh_CN
  24732. */
  24733. abstract class TextureAtlasData extends BaseObject {
  24734. /**
  24735. * @private
  24736. */
  24737. autoSearch: boolean;
  24738. /**
  24739. * @private
  24740. */
  24741. width: number;
  24742. /**
  24743. * @private
  24744. */
  24745. height: number;
  24746. /**
  24747. * @private
  24748. */
  24749. scale: number;
  24750. /**
  24751. * - The texture atlas name.
  24752. * @version DragonBones 3.0
  24753. * @language en_US
  24754. */
  24755. /**
  24756. * - 贴图集名称。
  24757. * @version DragonBones 3.0
  24758. * @language zh_CN
  24759. */
  24760. name: string;
  24761. /**
  24762. * - The image path of the texture atlas.
  24763. * @version DragonBones 3.0
  24764. * @language en_US
  24765. */
  24766. /**
  24767. * - 贴图集图片路径。
  24768. * @version DragonBones 3.0
  24769. * @language zh_CN
  24770. */
  24771. imagePath: string;
  24772. /**
  24773. * @private
  24774. */
  24775. readonly textures: Map<TextureData>;
  24776. /**
  24777. * @inheritDoc
  24778. */
  24779. protected _onClear(): void;
  24780. /**
  24781. * @private
  24782. */
  24783. copyFrom(value: TextureAtlasData): void;
  24784. /**
  24785. * @internal
  24786. * @private
  24787. */
  24788. abstract createTexture(): TextureData;
  24789. /**
  24790. * @internal
  24791. * @private
  24792. */
  24793. addTexture(value: TextureData): void;
  24794. /**
  24795. * @private
  24796. */
  24797. getTexture(name: string): TextureData | null;
  24798. }
  24799. /**
  24800. * @internal
  24801. * @private
  24802. */
  24803. abstract class TextureData extends BaseObject {
  24804. static createRectangle(): Rectangle;
  24805. rotated: boolean;
  24806. name: string;
  24807. readonly region: Rectangle;
  24808. parent: TextureAtlasData;
  24809. frame: Rectangle | null;
  24810. protected _onClear(): void;
  24811. copyFrom(value: TextureData): void;
  24812. }
  24813. }
  24814. /**
  24815. * The MIT License (MIT)
  24816. *
  24817. * Copyright (c) 2012-2017 DragonBones team and other contributors
  24818. *
  24819. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  24820. * this software and associated documentation files (the "Software"), to deal in
  24821. * the Software without restriction, including without limitation the rights to
  24822. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  24823. * the Software, and to permit persons to whom the Software is furnished to do so,
  24824. * subject to the following conditions:
  24825. *
  24826. * The above copyright notice and this permission notice shall be included in all
  24827. * copies or substantial portions of the Software.
  24828. *
  24829. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24830. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  24831. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  24832. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  24833. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  24834. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24835. */
  24836. declare namespace dragonBones {
  24837. /**
  24838. * - The armature proxy interface, the docking engine needs to implement it concretely.
  24839. * @see dragonBones.Armature
  24840. * @version DragonBones 5.0
  24841. * @language en_US
  24842. */
  24843. /**
  24844. * - 骨架代理接口,对接的引擎需要对其进行具体实现。
  24845. * @see dragonBones.Armature
  24846. * @version DragonBones 5.0
  24847. * @language zh_CN
  24848. */
  24849. interface IArmatureProxy extends IEventDispatcher {
  24850. /**
  24851. * @internal
  24852. * @private
  24853. */
  24854. dbInit(armature: Armature): void;
  24855. /**
  24856. * @internal
  24857. * @private
  24858. */
  24859. dbClear(): void;
  24860. /**
  24861. * @internal
  24862. * @private
  24863. */
  24864. dbUpdate(): void;
  24865. /**
  24866. * - Dispose the instance and the Armature instance. (The Armature instance will return to the object pool)
  24867. * @example
  24868. * <pre>
  24869. * removeChild(armatureDisplay);
  24870. * armatureDisplay.dispose();
  24871. * </pre>
  24872. * @version DragonBones 4.5
  24873. * @language en_US
  24874. */
  24875. /**
  24876. * - 释放该实例和骨架。 (骨架会回收到对象池)
  24877. * @example
  24878. * <pre>
  24879. * removeChild(armatureDisplay);
  24880. * armatureDisplay.dispose();
  24881. * </pre>
  24882. * @version DragonBones 4.5
  24883. * @language zh_CN
  24884. */
  24885. dispose(disposeProxy: boolean): void;
  24886. /**
  24887. * - The armature.
  24888. * @version DragonBones 4.5
  24889. * @language en_US
  24890. */
  24891. /**
  24892. * - 骨架。
  24893. * @version DragonBones 4.5
  24894. * @language zh_CN
  24895. */
  24896. readonly armature: Armature;
  24897. /**
  24898. * - The animation player.
  24899. * @version DragonBones 3.0
  24900. * @language en_US
  24901. */
  24902. /**
  24903. * - 动画播放器。
  24904. * @version DragonBones 3.0
  24905. * @language zh_CN
  24906. */
  24907. readonly animation: Animation;
  24908. }
  24909. }
  24910. /**
  24911. * The MIT License (MIT)
  24912. *
  24913. * Copyright (c) 2012-2017 DragonBones team and other contributors
  24914. *
  24915. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  24916. * this software and associated documentation files (the "Software"), to deal in
  24917. * the Software without restriction, including without limitation the rights to
  24918. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  24919. * the Software, and to permit persons to whom the Software is furnished to do so,
  24920. * subject to the following conditions:
  24921. *
  24922. * The above copyright notice and this permission notice shall be included in all
  24923. * copies or substantial portions of the Software.
  24924. *
  24925. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24926. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  24927. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  24928. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  24929. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  24930. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24931. */
  24932. declare namespace dragonBones {
  24933. /**
  24934. * - Armature is the core of the skeleton animation system.
  24935. * @see dragonBones.ArmatureData
  24936. * @see dragonBones.Bone
  24937. * @see dragonBones.Slot
  24938. * @see dragonBones.Animation
  24939. * @version DragonBones 3.0
  24940. * @language en_US
  24941. */
  24942. /**
  24943. * - 骨架是骨骼动画系统的核心。
  24944. * @see dragonBones.ArmatureData
  24945. * @see dragonBones.Bone
  24946. * @see dragonBones.Slot
  24947. * @see dragonBones.Animation
  24948. * @version DragonBones 3.0
  24949. * @language zh_CN
  24950. */
  24951. class Armature extends BaseObject implements IAnimatable {
  24952. static toString(): string;
  24953. private static _onSortSlots(a, b);
  24954. /**
  24955. * - Whether to inherit the animation control of the parent armature.
  24956. * True to try to have the child armature play an animation with the same name when the parent armature play the animation.
  24957. * @default true
  24958. * @version DragonBones 4.5
  24959. * @language en_US
  24960. */
  24961. /**
  24962. * - 是否继承父骨架的动画控制。
  24963. * 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。
  24964. * @default true
  24965. * @version DragonBones 4.5
  24966. * @language zh_CN
  24967. */
  24968. inheritAnimation: boolean;
  24969. /**
  24970. * @private
  24971. */
  24972. userData: any;
  24973. private _lockUpdate;
  24974. private _bonesDirty;
  24975. private _slotsDirty;
  24976. private _zOrderDirty;
  24977. private _flipX;
  24978. private _flipY;
  24979. /**
  24980. * @internal
  24981. * @private
  24982. */
  24983. _cacheFrameIndex: number;
  24984. private readonly _bones;
  24985. private readonly _slots;
  24986. /**
  24987. * @internal
  24988. * @private
  24989. */
  24990. readonly _glueSlots: Array<Slot>;
  24991. /**
  24992. * @internal
  24993. * @private
  24994. */
  24995. readonly _constraints: Array<Constraint>;
  24996. private readonly _actions;
  24997. /**
  24998. * @internal
  24999. * @private
  25000. */
  25001. _armatureData: ArmatureData;
  25002. private _animation;
  25003. private _proxy;
  25004. private _display;
  25005. /**
  25006. * @internal
  25007. * @private
  25008. */
  25009. _replaceTextureAtlasData: TextureAtlasData | null;
  25010. private _replacedTexture;
  25011. /**
  25012. * @internal
  25013. * @private
  25014. */
  25015. _dragonBones: DragonBones;
  25016. private _clock;
  25017. /**
  25018. * @internal
  25019. * @private
  25020. */
  25021. _parent: Slot | null;
  25022. /**
  25023. * @private
  25024. */
  25025. protected _onClear(): void;
  25026. private _sortBones();
  25027. private _sortSlots();
  25028. /**
  25029. * @internal
  25030. * @private
  25031. */
  25032. _sortZOrder(slotIndices: Array<number> | Int16Array | null, offset: number): void;
  25033. /**
  25034. * @internal
  25035. * @private
  25036. */
  25037. _addBoneToBoneList(value: Bone): void;
  25038. /**
  25039. * @internal
  25040. * @private
  25041. */
  25042. _removeBoneFromBoneList(value: Bone): void;
  25043. /**
  25044. * @internal
  25045. * @private
  25046. */
  25047. _addSlotToSlotList(value: Slot): void;
  25048. /**
  25049. * @internal
  25050. * @private
  25051. */
  25052. _removeSlotFromSlotList(value: Slot): void;
  25053. /**
  25054. * @internal
  25055. * @private
  25056. */
  25057. _bufferAction(action: ActionData, append: boolean): void;
  25058. /**
  25059. * - Dispose the armature. (Return to the object pool)
  25060. * @example
  25061. * <pre>
  25062. * removeChild(armature.display);
  25063. * armature.dispose();
  25064. * </pre>
  25065. * @version DragonBones 3.0
  25066. * @language en_US
  25067. */
  25068. /**
  25069. * - 释放骨架。 (回收到对象池)
  25070. * @example
  25071. * <pre>
  25072. * removeChild(armature.display);
  25073. * armature.dispose();
  25074. * </pre>
  25075. * @version DragonBones 3.0
  25076. * @language zh_CN
  25077. */
  25078. dispose(): void;
  25079. /**
  25080. * @internal
  25081. * @private
  25082. */
  25083. init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void;
  25084. /**
  25085. * @inheritDoc
  25086. */
  25087. advanceTime(passedTime: number): void;
  25088. /**
  25089. * - Forces a specific bone or its owning slot to update the transform or display property in the next frame.
  25090. * @param boneName - The bone name. (If not set, all bones will be update)
  25091. * @param updateSlot - Whether to update the bone's slots. (Default: false)
  25092. * @see dragonBones.Bone#invalidUpdate()
  25093. * @see dragonBones.Slot#invalidUpdate()
  25094. * @version DragonBones 3.0
  25095. * @language en_US
  25096. */
  25097. /**
  25098. * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。
  25099. * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼)
  25100. * @param updateSlot - 是否更新骨骼的插槽。 (默认: false)
  25101. * @see dragonBones.Bone#invalidUpdate()
  25102. * @see dragonBones.Slot#invalidUpdate()
  25103. * @version DragonBones 3.0
  25104. * @language zh_CN
  25105. */
  25106. invalidUpdate(boneName?: string | null, updateSlot?: boolean): void;
  25107. /**
  25108. * - Check whether a specific point is inside a custom bounding box in a slot.
  25109. * The coordinate system of the point is the inner coordinate system of the armature.
  25110. * Custom bounding boxes need to be customized in Dragonbones Pro.
  25111. * @param x - The horizontal coordinate of the point.
  25112. * @param y - The vertical coordinate of the point.
  25113. * @version DragonBones 5.0
  25114. * @language en_US
  25115. */
  25116. /**
  25117. * - 检查特定点是否在某个插槽的自定义边界框内。
  25118. * 点的坐标系为骨架内坐标系。
  25119. * 自定义边界框需要在 DragonBones Pro 中自定义。
  25120. * @param x - 点的水平坐标。
  25121. * @param y - 点的垂直坐标。
  25122. * @version DragonBones 5.0
  25123. * @language zh_CN
  25124. */
  25125. containsPoint(x: number, y: number): Slot | null;
  25126. /**
  25127. * - Check whether a specific segment intersects a custom bounding box for a slot in the armature.
  25128. * The coordinate system of the segment and intersection is the inner coordinate system of the armature.
  25129. * Custom bounding boxes need to be customized in Dragonbones Pro.
  25130. * @param xA - The horizontal coordinate of the beginning of the segment.
  25131. * @param yA - The vertical coordinate of the beginning of the segment.
  25132. * @param xB - The horizontal coordinate of the end point of the segment.
  25133. * @param yB - The vertical coordinate of the end point of the segment.
  25134. * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated)
  25135. * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated)
  25136. * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated)
  25137. * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point.
  25138. * @version DragonBones 5.0
  25139. * @language en_US
  25140. */
  25141. /**
  25142. * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。
  25143. * 线段和交点的坐标系均为骨架内坐标系。
  25144. * 自定义边界框需要在 DragonBones Pro 中自定义。
  25145. * @param xA - 线段起点的水平坐标。
  25146. * @param yA - 线段起点的垂直坐标。
  25147. * @param xB - 线段终点的水平坐标。
  25148. * @param yB - 线段终点的垂直坐标。
  25149. * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点)
  25150. * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点)
  25151. * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线)
  25152. * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。
  25153. * @version DragonBones 5.0
  25154. * @language zh_CN
  25155. */
  25156. intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: {
  25157. x: number;
  25158. y: number;
  25159. } | null, intersectionPointB?: {
  25160. x: number;
  25161. y: number;
  25162. } | null, normalRadians?: {
  25163. x: number;
  25164. y: number;
  25165. } | null): Slot | null;
  25166. /**
  25167. * - Get a specific bone.
  25168. * @param name - The bone name.
  25169. * @see dragonBones.Bone
  25170. * @version DragonBones 3.0
  25171. * @language en_US
  25172. */
  25173. /**
  25174. * - 获取特定的骨骼。
  25175. * @param name - 骨骼名称。
  25176. * @see dragonBones.Bone
  25177. * @version DragonBones 3.0
  25178. * @language zh_CN
  25179. */
  25180. getBone(name: string): Bone | null;
  25181. /**
  25182. * - Get a specific bone by the display.
  25183. * @param display - The display object.
  25184. * @see dragonBones.Bone
  25185. * @version DragonBones 3.0
  25186. * @language en_US
  25187. */
  25188. /**
  25189. * - 通过显示对象获取特定的骨骼。
  25190. * @param display - 显示对象。
  25191. * @see dragonBones.Bone
  25192. * @version DragonBones 3.0
  25193. * @language zh_CN
  25194. */
  25195. getBoneByDisplay(display: any): Bone | null;
  25196. /**
  25197. * - Get a specific slot.
  25198. * @param name - The slot name.
  25199. * @see dragonBones.Slot
  25200. * @version DragonBones 3.0
  25201. * @language en_US
  25202. */
  25203. /**
  25204. * - 获取特定的插槽。
  25205. * @param name - 插槽名称。
  25206. * @see dragonBones.Slot
  25207. * @version DragonBones 3.0
  25208. * @language zh_CN
  25209. */
  25210. getSlot(name: string): Slot | null;
  25211. /**
  25212. * - Get a specific slot by the display.
  25213. * @param display - The display object.
  25214. * @see dragonBones.Slot
  25215. * @version DragonBones 3.0
  25216. * @language en_US
  25217. */
  25218. /**
  25219. * - 通过显示对象获取特定的插槽。
  25220. * @param display - 显示对象。
  25221. * @see dragonBones.Slot
  25222. * @version DragonBones 3.0
  25223. * @language zh_CN
  25224. */
  25225. getSlotByDisplay(display: any): Slot | null;
  25226. /**
  25227. * @deprecated
  25228. */
  25229. addBone(value: Bone, parentName: string): void;
  25230. /**
  25231. * @deprecated
  25232. */
  25233. addSlot(value: Slot, parentName: string): void;
  25234. /**
  25235. * @private
  25236. */
  25237. addConstraint(value: Constraint): void;
  25238. /**
  25239. * @deprecated
  25240. */
  25241. removeBone(value: Bone): void;
  25242. /**
  25243. * @deprecated
  25244. */
  25245. removeSlot(value: Slot): void;
  25246. /**
  25247. * - Get all bones.
  25248. * @see dragonBones.Bone
  25249. * @version DragonBones 3.0
  25250. * @language en_US
  25251. */
  25252. /**
  25253. * - 获取所有的骨骼。
  25254. * @see dragonBones.Bone
  25255. * @version DragonBones 3.0
  25256. * @language zh_CN
  25257. */
  25258. getBones(): Array<Bone>;
  25259. /**
  25260. * - Get all slots.
  25261. * @see dragonBones.Slot
  25262. * @version DragonBones 3.0
  25263. * @language en_US
  25264. */
  25265. /**
  25266. * - 获取所有的插槽。
  25267. * @see dragonBones.Slot
  25268. * @version DragonBones 3.0
  25269. * @language zh_CN
  25270. */
  25271. getSlots(): Array<Slot>;
  25272. /**
  25273. * - Whether to flip the armature horizontally.
  25274. * @version DragonBones 5.5
  25275. * @language en_US
  25276. */
  25277. /**
  25278. * - 是否将骨架水平翻转。
  25279. * @version DragonBones 5.5
  25280. * @language zh_CN
  25281. */
  25282. flipX: boolean;
  25283. /**
  25284. * - Whether to flip the armature vertically.
  25285. * @version DragonBones 5.5
  25286. * @language en_US
  25287. */
  25288. /**
  25289. * - 是否将骨架垂直翻转。
  25290. * @version DragonBones 5.5
  25291. * @language zh_CN
  25292. */
  25293. flipY: boolean;
  25294. /**
  25295. * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0.
  25296. * There is a certain amount of memory overhead to improve performance by caching animation data in memory.
  25297. * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate.
  25298. * When the animation cache is turned on, some features will fail, such as the offset property of bone.
  25299. * @example
  25300. * <pre>
  25301. * armature.cacheFrameRate = 24;
  25302. * </pre>
  25303. * @see dragonBones.DragonBonesData#frameRate
  25304. * @see dragonBones.ArmatureData#frameRate
  25305. * @version DragonBones 4.5
  25306. * @language en_US
  25307. */
  25308. /**
  25309. * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。
  25310. * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。
  25311. * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。
  25312. * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。
  25313. * @example
  25314. * <pre>
  25315. * armature.cacheFrameRate = 24;
  25316. * </pre>
  25317. * @see dragonBones.DragonBonesData#frameRate
  25318. * @see dragonBones.ArmatureData#frameRate
  25319. * @version DragonBones 4.5
  25320. * @language zh_CN
  25321. */
  25322. cacheFrameRate: number;
  25323. /**
  25324. * - The armature name.
  25325. * @version DragonBones 3.0
  25326. * @language en_US
  25327. */
  25328. /**
  25329. * - 骨架名称。
  25330. * @version DragonBones 3.0
  25331. * @language zh_CN
  25332. */
  25333. readonly name: string;
  25334. /**
  25335. * - The armature data.
  25336. * @see dragonBones.ArmatureData
  25337. * @version DragonBones 4.5
  25338. * @language en_US
  25339. */
  25340. /**
  25341. * - 骨架数据。
  25342. * @see dragonBones.ArmatureData
  25343. * @version DragonBones 4.5
  25344. * @language zh_CN
  25345. */
  25346. readonly armatureData: ArmatureData;
  25347. /**
  25348. * - The animation player.
  25349. * @see dragonBones.Animation
  25350. * @version DragonBones 3.0
  25351. * @language en_US
  25352. */
  25353. /**
  25354. * - 动画播放器。
  25355. * @see dragonBones.Animation
  25356. * @version DragonBones 3.0
  25357. * @language zh_CN
  25358. */
  25359. readonly animation: Animation;
  25360. /**
  25361. * @pivate
  25362. */
  25363. readonly proxy: IArmatureProxy;
  25364. /**
  25365. * - The EventDispatcher instance of the armature.
  25366. * @version DragonBones 4.5
  25367. * @language en_US
  25368. */
  25369. /**
  25370. * - 该骨架的 EventDispatcher 实例。
  25371. * @version DragonBones 4.5
  25372. * @language zh_CN
  25373. */
  25374. readonly eventDispatcher: IEventDispatcher;
  25375. /**
  25376. * - The display container.
  25377. * The display of the slot is displayed as the parent.
  25378. * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type.
  25379. * @version DragonBones 3.0
  25380. * @language en_US
  25381. */
  25382. /**
  25383. * - 显示容器实例。
  25384. * 插槽的显示对象都会以此显示容器为父级。
  25385. * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。
  25386. * @version DragonBones 3.0
  25387. * @language zh_CN
  25388. */
  25389. readonly display: any;
  25390. /**
  25391. * @private
  25392. */
  25393. replacedTexture: any;
  25394. /**
  25395. * @inheritDoc
  25396. */
  25397. clock: WorldClock | null;
  25398. /**
  25399. * - Get the parent slot which the armature belongs to.
  25400. * @see dragonBones.Slot
  25401. * @version DragonBones 4.5
  25402. * @language en_US
  25403. */
  25404. /**
  25405. * - 该骨架所属的父插槽。
  25406. * @see dragonBones.Slot
  25407. * @version DragonBones 4.5
  25408. * @language zh_CN
  25409. */
  25410. readonly parent: Slot | null;
  25411. /**
  25412. * @deprecated
  25413. * @private
  25414. */
  25415. replaceTexture(texture: any): void;
  25416. /**
  25417. * - Deprecated, please refer to {@link #eventDispatcher}.
  25418. * @deprecated
  25419. * @language en_US
  25420. */
  25421. /**
  25422. * - 已废弃,请参考 {@link #eventDispatcher}。
  25423. * @deprecated
  25424. * @language zh_CN
  25425. */
  25426. hasEventListener(type: EventStringType): boolean;
  25427. /**
  25428. * - Deprecated, please refer to {@link #eventDispatcher}.
  25429. * @deprecated
  25430. * @language en_US
  25431. */
  25432. /**
  25433. * - 已废弃,请参考 {@link #eventDispatcher}。
  25434. * @deprecated
  25435. * @language zh_CN
  25436. */
  25437. addEventListener(type: EventStringType, listener: Function, target: any): void;
  25438. /**
  25439. * - Deprecated, please refer to {@link #eventDispatcher}.
  25440. * @deprecated
  25441. * @language en_US
  25442. */
  25443. /**
  25444. * - 已废弃,请参考 {@link #eventDispatcher}。
  25445. * @deprecated
  25446. * @language zh_CN
  25447. */
  25448. removeEventListener(type: EventStringType, listener: Function, target: any): void;
  25449. /**
  25450. * - Deprecated, please refer to {@link #cacheFrameRate}.
  25451. * @deprecated
  25452. * @language en_US
  25453. */
  25454. /**
  25455. * - 已废弃,请参考 {@link #cacheFrameRate}。
  25456. * @deprecated
  25457. * @language zh_CN
  25458. */
  25459. enableAnimationCache(frameRate: number): void;
  25460. /**
  25461. * - Deprecated, please refer to {@link #display}.
  25462. * @deprecated
  25463. * @language en_US
  25464. */
  25465. /**
  25466. * - 已废弃,请参考 {@link #display}。
  25467. * @deprecated
  25468. * @language zh_CN
  25469. */
  25470. getDisplay(): any;
  25471. }
  25472. }
  25473. /**
  25474. * The MIT License (MIT)
  25475. *
  25476. * Copyright (c) 2012-2017 DragonBones team and other contributors
  25477. *
  25478. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  25479. * this software and associated documentation files (the "Software"), to deal in
  25480. * the Software without restriction, including without limitation the rights to
  25481. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  25482. * the Software, and to permit persons to whom the Software is furnished to do so,
  25483. * subject to the following conditions:
  25484. *
  25485. * The above copyright notice and this permission notice shall be included in all
  25486. * copies or substantial portions of the Software.
  25487. *
  25488. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25489. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  25490. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  25491. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  25492. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  25493. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25494. */
  25495. declare namespace dragonBones {
  25496. /**
  25497. * - The base class of the transform object.
  25498. * @see dragonBones.Transform
  25499. * @version DragonBones 4.5
  25500. * @language en_US
  25501. */
  25502. /**
  25503. * - 变换对象的基类。
  25504. * @see dragonBones.Transform
  25505. * @version DragonBones 4.5
  25506. * @language zh_CN
  25507. */
  25508. abstract class TransformObject extends BaseObject {
  25509. /**
  25510. * @private
  25511. */
  25512. protected static readonly _helpMatrix: Matrix;
  25513. /**
  25514. * @private
  25515. */
  25516. protected static readonly _helpTransform: Transform;
  25517. /**
  25518. * @private
  25519. */
  25520. protected static readonly _helpPoint: Point;
  25521. /**
  25522. * - A matrix relative to the armature coordinate system.
  25523. * @version DragonBones 3.0
  25524. * @language en_US
  25525. */
  25526. /**
  25527. * - 相对于骨架坐标系的矩阵。
  25528. * @version DragonBones 3.0
  25529. * @language zh_CN
  25530. */
  25531. readonly globalTransformMatrix: Matrix;
  25532. /**
  25533. * - A transform relative to the armature coordinate system.
  25534. * @see #updateGlobalTransform()
  25535. * @version DragonBones 3.0
  25536. * @language en_US
  25537. */
  25538. /**
  25539. * - 相对于骨架坐标系的变换。
  25540. * @see #updateGlobalTransform()
  25541. * @version DragonBones 3.0
  25542. * @language zh_CN
  25543. */
  25544. readonly global: Transform;
  25545. /**
  25546. * - The offset transform relative to the armature or the parent bone coordinate system.
  25547. * @see #dragonBones.Bone#invalidUpdate()
  25548. * @version DragonBones 3.0
  25549. * @language en_US
  25550. */
  25551. /**
  25552. * - 相对于骨架或父骨骼坐标系的偏移变换。
  25553. * @see #dragonBones.Bone#invalidUpdate()
  25554. * @version DragonBones 3.0
  25555. * @language zh_CN
  25556. */
  25557. readonly offset: Transform;
  25558. /**
  25559. * @private
  25560. */
  25561. origin: Transform | null;
  25562. /**
  25563. * @private
  25564. */
  25565. userData: any;
  25566. /**
  25567. * @private
  25568. */
  25569. protected _globalDirty: boolean;
  25570. /**
  25571. * @internal
  25572. * @private
  25573. */
  25574. _armature: Armature;
  25575. /**
  25576. * @internal
  25577. * @private
  25578. */
  25579. _parent: Bone;
  25580. /**
  25581. * @private
  25582. */
  25583. protected _onClear(): void;
  25584. /**
  25585. * @internal
  25586. * @private
  25587. */
  25588. _setArmature(value: Armature | null): void;
  25589. /**
  25590. * @internal
  25591. * @private
  25592. */
  25593. _setParent(value: Bone | null): void;
  25594. /**
  25595. * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible,
  25596. * some engines do not rely on these attributes to update rendering, such as Egret.
  25597. * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale.
  25598. * @example
  25599. * <pre>
  25600. * bone.updateGlobalTransform();
  25601. * let rotation = bone.global.rotation;
  25602. * </pre>
  25603. * @version DragonBones 3.0
  25604. * @language en_US
  25605. */
  25606. /**
  25607. * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。
  25608. * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。
  25609. * @example
  25610. * <pre>
  25611. * bone.updateGlobalTransform();
  25612. * let rotation = bone.global.rotation;
  25613. * </pre>
  25614. * @version DragonBones 3.0
  25615. * @language zh_CN
  25616. */
  25617. updateGlobalTransform(): void;
  25618. /**
  25619. * - The armature to which it belongs.
  25620. * @version DragonBones 3.0
  25621. * @language en_US
  25622. */
  25623. /**
  25624. * - 所属的骨架。
  25625. * @version DragonBones 3.0
  25626. * @language zh_CN
  25627. */
  25628. readonly armature: Armature;
  25629. /**
  25630. * - The parent bone to which it belongs.
  25631. * @version DragonBones 3.0
  25632. * @language en_US
  25633. */
  25634. /**
  25635. * - 所属的父骨骼。
  25636. * @version DragonBones 3.0
  25637. * @language zh_CN
  25638. */
  25639. readonly parent: Bone;
  25640. }
  25641. }
  25642. /**
  25643. * The MIT License (MIT)
  25644. *
  25645. * Copyright (c) 2012-2017 DragonBones team and other contributors
  25646. *
  25647. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  25648. * this software and associated documentation files (the "Software"), to deal in
  25649. * the Software without restriction, including without limitation the rights to
  25650. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  25651. * the Software, and to permit persons to whom the Software is furnished to do so,
  25652. * subject to the following conditions:
  25653. *
  25654. * The above copyright notice and this permission notice shall be included in all
  25655. * copies or substantial portions of the Software.
  25656. *
  25657. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25658. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  25659. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  25660. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  25661. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  25662. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25663. */
  25664. declare namespace dragonBones {
  25665. /**
  25666. * - Bone is one of the most important logical units in the armature animation system,
  25667. * and is responsible for the realization of translate, rotation, scaling in the animations.
  25668. * A armature can contain multiple bones.
  25669. * @see dragonBones.BoneData
  25670. * @see dragonBones.Armature
  25671. * @see dragonBones.Slot
  25672. * @version DragonBones 3.0
  25673. * @language en_US
  25674. */
  25675. /**
  25676. * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。
  25677. * 一个骨架中可以包含多个骨骼。
  25678. * @see dragonBones.BoneData
  25679. * @see dragonBones.Armature
  25680. * @see dragonBones.Slot
  25681. * @version DragonBones 3.0
  25682. * @language zh_CN
  25683. */
  25684. class Bone extends TransformObject {
  25685. static toString(): string;
  25686. /**
  25687. * - The offset mode.
  25688. * @see #offset
  25689. * @version DragonBones 5.5
  25690. * @language en_US
  25691. */
  25692. /**
  25693. * - 偏移模式。
  25694. * @see #offset
  25695. * @version DragonBones 5.5
  25696. * @language zh_CN
  25697. */
  25698. offsetMode: OffsetMode;
  25699. /**
  25700. * @internal
  25701. * @private
  25702. */
  25703. readonly animationPose: Transform;
  25704. /**
  25705. * @internal
  25706. * @private
  25707. */
  25708. _transformDirty: boolean;
  25709. /**
  25710. * @internal
  25711. * @private
  25712. */
  25713. _childrenTransformDirty: boolean;
  25714. protected _localDirty: boolean;
  25715. /**
  25716. * @internal
  25717. * @private
  25718. */
  25719. _hasConstraint: boolean;
  25720. private _visible;
  25721. protected _cachedFrameIndex: number;
  25722. /**
  25723. * @internal
  25724. * @private
  25725. */
  25726. readonly _blendState: BlendState;
  25727. /**
  25728. * @internal
  25729. * @private
  25730. */
  25731. _boneData: BoneData;
  25732. /**
  25733. * @internal
  25734. * @private
  25735. */
  25736. _cachedFrameIndices: Array<number> | null;
  25737. /**
  25738. * @inheritDoc
  25739. */
  25740. protected _onClear(): void;
  25741. /**
  25742. * @private
  25743. */
  25744. protected _updateGlobalTransformMatrix(isCache: boolean): void;
  25745. /**
  25746. * @inheritDoc
  25747. */
  25748. _setArmature(value: Armature | null): void;
  25749. /**
  25750. * @internal
  25751. * @private
  25752. */
  25753. init(boneData: BoneData): void;
  25754. /**
  25755. * @internal
  25756. * @private
  25757. */
  25758. update(cacheFrameIndex: number): void;
  25759. /**
  25760. * @internal
  25761. * @private
  25762. */
  25763. updateByConstraint(): void;
  25764. /**
  25765. * - Forces the bone to update the transform in the next frame.
  25766. * When the bone is not animated or its animation state is finished, the bone will not continue to update,
  25767. * and when the skeleton must be updated for some reason, the method needs to be called explicitly.
  25768. * @example
  25769. * <pre>
  25770. * let bone = armature.getBone("arm");
  25771. * bone.offset.scaleX = 2.0;
  25772. * bone.invalidUpdate();
  25773. * </pre>
  25774. * @version DragonBones 3.0
  25775. * @language en_US
  25776. */
  25777. /**
  25778. * - 强制骨骼在下一帧更新变换。
  25779. * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。
  25780. * @example
  25781. * <pre>
  25782. * let bone = armature.getBone("arm");
  25783. * bone.offset.scaleX = 2.0;
  25784. * bone.invalidUpdate();
  25785. * </pre>
  25786. * @version DragonBones 3.0
  25787. * @language zh_CN
  25788. */
  25789. invalidUpdate(): void;
  25790. /**
  25791. * - Check whether the bone contains a specific bone or slot.
  25792. * @see dragonBones.Bone
  25793. * @see dragonBones.Slot
  25794. * @version DragonBones 3.0
  25795. * @language en_US
  25796. */
  25797. /**
  25798. * - 检查该骨骼是否包含特定的骨骼或插槽。
  25799. * @see dragonBones.Bone
  25800. * @see dragonBones.Slot
  25801. * @version DragonBones 3.0
  25802. * @language zh_CN
  25803. */
  25804. contains(value: TransformObject): boolean;
  25805. /**
  25806. * - The bone data.
  25807. * @version DragonBones 4.5
  25808. * @language en_US
  25809. */
  25810. /**
  25811. * - 骨骼数据。
  25812. * @version DragonBones 4.5
  25813. * @language zh_CN
  25814. */
  25815. readonly boneData: BoneData;
  25816. /**
  25817. * - The visible of all slots in the bone.
  25818. * @default true
  25819. * @see dragonBones.Slot#visible
  25820. * @version DragonBones 3.0
  25821. * @language en_US
  25822. */
  25823. /**
  25824. * - 此骨骼所有插槽的可见。
  25825. * @default true
  25826. * @see dragonBones.Slot#visible
  25827. * @version DragonBones 3.0
  25828. * @language zh_CN
  25829. */
  25830. visible: boolean;
  25831. /**
  25832. * - The bone name.
  25833. * @version DragonBones 3.0
  25834. * @language en_US
  25835. */
  25836. /**
  25837. * - 骨骼名称。
  25838. * @version DragonBones 3.0
  25839. * @language zh_CN
  25840. */
  25841. readonly name: string;
  25842. /**
  25843. * - Deprecated, please refer to {@link dragonBones.Armature#getBones()}.
  25844. * @deprecated
  25845. * @language en_US
  25846. */
  25847. /**
  25848. * - 已废弃,请参考 {@link dragonBones.Armature#getBones()}。
  25849. * @deprecated
  25850. * @language zh_CN
  25851. */
  25852. getBones(): Array<Bone>;
  25853. /**
  25854. * - Deprecated, please refer to {@link dragonBones.Armature#getSlots()}.
  25855. * @deprecated
  25856. * @language en_US
  25857. */
  25858. /**
  25859. * - 已废弃,请参考 {@link dragonBones.Armature#getSlots()}。
  25860. * @deprecated
  25861. * @language zh_CN
  25862. */
  25863. getSlots(): Array<Slot>;
  25864. /**
  25865. * - Deprecated, please refer to {@link dragonBones.Armature#getSlot()}.
  25866. * @deprecated
  25867. * @language en_US
  25868. */
  25869. /**
  25870. * - 已废弃,请参考 {@link dragonBones.Armature#getSlot()}。
  25871. * @deprecated
  25872. * @language zh_CN
  25873. */
  25874. readonly slot: Slot | null;
  25875. }
  25876. }
  25877. /**
  25878. * The MIT License (MIT)
  25879. *
  25880. * Copyright (c) 2012-2017 DragonBones team and other contributors
  25881. *
  25882. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  25883. * this software and associated documentation files (the "Software"), to deal in
  25884. * the Software without restriction, including without limitation the rights to
  25885. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  25886. * the Software, and to permit persons to whom the Software is furnished to do so,
  25887. * subject to the following conditions:
  25888. *
  25889. * The above copyright notice and this permission notice shall be included in all
  25890. * copies or substantial portions of the Software.
  25891. *
  25892. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25893. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  25894. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  25895. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  25896. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  25897. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25898. */
  25899. declare namespace dragonBones {
  25900. /**
  25901. * @internal
  25902. * @private
  25903. */
  25904. class Surface extends Bone {
  25905. static toString(): string;
  25906. private _dX;
  25907. private _dY;
  25908. private _k;
  25909. private _kX;
  25910. private _kY;
  25911. /**
  25912. * For debug draw.
  25913. * @internal
  25914. * @private
  25915. */
  25916. readonly _vertices: Array<number>;
  25917. /**
  25918. * For timeline state.
  25919. * @internal
  25920. * @private
  25921. */
  25922. readonly _deformVertices: Array<number>;
  25923. /**
  25924. * x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y
  25925. */
  25926. private readonly _hullCache;
  25927. /**
  25928. * Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty]
  25929. */
  25930. private readonly _matrixCahce;
  25931. /**
  25932. * @inheritDoc
  25933. */
  25934. protected _onClear(): void;
  25935. private _getAffineTransform(x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown);
  25936. private _updateVertices();
  25937. /**
  25938. * @private
  25939. */
  25940. protected _updateGlobalTransformMatrix(isCache: boolean): void;
  25941. _getGlobalTransformMatrix(x: number, y: number): Matrix;
  25942. init(surfaceData: SurfaceData): void;
  25943. /**
  25944. * @internal
  25945. * @private
  25946. */
  25947. update(cacheFrameIndex: number): void;
  25948. }
  25949. }
  25950. /**
  25951. * The MIT License (MIT)
  25952. *
  25953. * Copyright (c) 2012-2017 DragonBones team and other contributors
  25954. *
  25955. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  25956. * this software and associated documentation files (the "Software"), to deal in
  25957. * the Software without restriction, including without limitation the rights to
  25958. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  25959. * the Software, and to permit persons to whom the Software is furnished to do so,
  25960. * subject to the following conditions:
  25961. *
  25962. * The above copyright notice and this permission notice shall be included in all
  25963. * copies or substantial portions of the Software.
  25964. *
  25965. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25966. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  25967. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  25968. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  25969. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  25970. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25971. */
  25972. declare namespace dragonBones {
  25973. /**
  25974. * - The slot attached to the armature, controls the display status and properties of the display object.
  25975. * A bone can contain multiple slots.
  25976. * A slot can contain multiple display objects, displaying only one of the display objects at a time,
  25977. * but you can toggle the display object into frame animation while the animation is playing.
  25978. * The display object can be a normal texture, or it can be a display of a child armature, a grid display object,
  25979. * and a custom other display object.
  25980. * @see dragonBones.Armature
  25981. * @see dragonBones.Bone
  25982. * @see dragonBones.SlotData
  25983. * @version DragonBones 3.0
  25984. * @language en_US
  25985. */
  25986. /**
  25987. * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。
  25988. * 一个骨骼上可以包含多个插槽。
  25989. * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。
  25990. * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。
  25991. * @see dragonBones.Armature
  25992. * @see dragonBones.Bone
  25993. * @see dragonBones.SlotData
  25994. * @version DragonBones 3.0
  25995. * @language zh_CN
  25996. */
  25997. abstract class Slot extends TransformObject {
  25998. /**
  25999. * - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states.
  26000. * @default null
  26001. * @see dragonBones.AnimationState#displayControl
  26002. * @see dragonBones.AnimationState#name
  26003. * @see dragonBones.AnimationState#group
  26004. * @version DragonBones 4.5
  26005. * @language en_US
  26006. */
  26007. /**
  26008. * - 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。
  26009. * @default null
  26010. * @see dragonBones.AnimationState#displayControl
  26011. * @see dragonBones.AnimationState#name
  26012. * @see dragonBones.AnimationState#group
  26013. * @version DragonBones 4.5
  26014. * @language zh_CN
  26015. */
  26016. displayController: string | null;
  26017. /**
  26018. * @private
  26019. */
  26020. protected _displayDirty: boolean;
  26021. /**
  26022. * @private
  26023. */
  26024. protected _zOrderDirty: boolean;
  26025. /**
  26026. * @private
  26027. */
  26028. protected _visibleDirty: boolean;
  26029. /**
  26030. * @private
  26031. */
  26032. protected _blendModeDirty: boolean;
  26033. /**
  26034. * @internal
  26035. * @private
  26036. */
  26037. _colorDirty: boolean;
  26038. /**
  26039. * @internal
  26040. * @private
  26041. */
  26042. _meshDirty: boolean;
  26043. /**
  26044. * @private
  26045. */
  26046. protected _transformDirty: boolean;
  26047. /**
  26048. * @private
  26049. */
  26050. protected _visible: boolean;
  26051. /**
  26052. * @private
  26053. */
  26054. protected _blendMode: BlendMode;
  26055. /**
  26056. * @private
  26057. */
  26058. protected _displayIndex: number;
  26059. /**
  26060. * @private
  26061. */
  26062. protected _animationDisplayIndex: number;
  26063. /**
  26064. * @internal
  26065. * @private
  26066. */
  26067. _zOrder: number;
  26068. /**
  26069. * @private
  26070. */
  26071. protected _cachedFrameIndex: number;
  26072. /**
  26073. * @internal
  26074. * @private
  26075. */
  26076. _pivotX: number;
  26077. /**
  26078. * @internal
  26079. * @private
  26080. */
  26081. _pivotY: number;
  26082. /**
  26083. * @private
  26084. */
  26085. protected readonly _localMatrix: Matrix;
  26086. /**
  26087. * @internal
  26088. * @private
  26089. */
  26090. readonly _colorTransform: ColorTransform;
  26091. /**
  26092. * @internal
  26093. * @private
  26094. */
  26095. readonly _deformVertices: Array<number>;
  26096. /**
  26097. * @private
  26098. */
  26099. readonly _displayDatas: Array<DisplayData | null>;
  26100. /**
  26101. * @private
  26102. */
  26103. protected readonly _displayList: Array<any | Armature>;
  26104. /**
  26105. * @private
  26106. */
  26107. protected readonly _meshBones: Array<Bone | null>;
  26108. /**
  26109. * @private
  26110. */
  26111. protected readonly _meshSlots: Array<Slot | null>;
  26112. /**
  26113. * @internal
  26114. * @private
  26115. */
  26116. _slotData: SlotData;
  26117. /**
  26118. * @private
  26119. */
  26120. protected _rawDisplayDatas: Array<DisplayData | null> | null;
  26121. /**
  26122. * @private
  26123. */
  26124. protected _displayData: DisplayData | null;
  26125. /**
  26126. * @private
  26127. */
  26128. protected _textureData: TextureData | null;
  26129. /**
  26130. * @internal
  26131. * @private
  26132. */
  26133. _meshData: MeshDisplayData | null;
  26134. /**
  26135. * @private
  26136. */
  26137. protected _boundingBoxData: BoundingBoxData | null;
  26138. /**
  26139. * @private
  26140. */
  26141. protected _rawDisplay: any;
  26142. /**
  26143. * @private
  26144. */
  26145. protected _meshDisplay: any;
  26146. /**
  26147. * @private
  26148. */
  26149. protected _display: any;
  26150. /**
  26151. * @private
  26152. */
  26153. protected _childArmature: Armature | null;
  26154. /**
  26155. * @internal
  26156. * @private
  26157. */
  26158. _cachedFrameIndices: Array<number> | null;
  26159. /**
  26160. * @inheritDoc
  26161. */
  26162. protected _onClear(): void;
  26163. /**
  26164. * @private
  26165. */
  26166. protected abstract _initDisplay(value: any, isRetain: boolean): void;
  26167. /**
  26168. * @private
  26169. */
  26170. protected abstract _disposeDisplay(value: any, isRelease: boolean): void;
  26171. /**
  26172. * @private
  26173. */
  26174. protected abstract _onUpdateDisplay(): void;
  26175. /**
  26176. * @private
  26177. */
  26178. protected abstract _addDisplay(): void;
  26179. /**
  26180. * @private
  26181. */
  26182. protected abstract _replaceDisplay(value: any): void;
  26183. /**
  26184. * @private
  26185. */
  26186. protected abstract _removeDisplay(): void;
  26187. /**
  26188. * @private
  26189. */
  26190. protected abstract _updateZOrder(): void;
  26191. /**
  26192. * @private
  26193. */
  26194. abstract _updateVisible(): void;
  26195. /**
  26196. * @private
  26197. */
  26198. protected abstract _updateBlendMode(): void;
  26199. /**
  26200. * @private
  26201. */
  26202. protected abstract _updateColor(): void;
  26203. /**
  26204. * @private
  26205. */
  26206. protected abstract _updateFrame(): void;
  26207. /**
  26208. * @private
  26209. */
  26210. protected abstract _updateMesh(): void;
  26211. /**
  26212. * @internal
  26213. * @private
  26214. */
  26215. abstract _updateGlueMesh(): void;
  26216. /**
  26217. * @private
  26218. */
  26219. protected abstract _updateTransform(): void;
  26220. /**
  26221. * @private
  26222. */
  26223. protected abstract _identityTransform(): void;
  26224. /**
  26225. * @private
  26226. */
  26227. protected _getDefaultRawDisplayData(): DisplayData | null;
  26228. /**
  26229. * @private
  26230. */
  26231. protected _updateDisplayData(): void;
  26232. /**
  26233. * @private
  26234. */
  26235. protected _updateDisplay(): void;
  26236. /**
  26237. * @private
  26238. */
  26239. protected _updateGlobalTransformMatrix(isCache: boolean): void;
  26240. /**
  26241. * @private
  26242. */
  26243. protected _isMeshBonesUpdate(): boolean;
  26244. /**
  26245. * @inheritDoc
  26246. */
  26247. _setArmature(value: Armature | null): void;
  26248. /**
  26249. * @internal
  26250. * @private
  26251. */
  26252. _setDisplayIndex(value: number, isAnimation?: boolean): boolean;
  26253. /**
  26254. * @internal
  26255. * @private
  26256. */
  26257. _setZorder(value: number): boolean;
  26258. /**
  26259. * @internal
  26260. * @private
  26261. */
  26262. _setColor(value: ColorTransform): boolean;
  26263. /**
  26264. * @internal
  26265. * @private
  26266. */
  26267. _setDisplayList(value: Array<any> | null): boolean;
  26268. /**
  26269. * @internal
  26270. * @private
  26271. */
  26272. init(slotData: SlotData, displayDatas: Array<DisplayData | null> | null, rawDisplay: any, meshDisplay: any): void;
  26273. /**
  26274. * @internal
  26275. * @private
  26276. */
  26277. update(cacheFrameIndex: number): void;
  26278. /**
  26279. * @private
  26280. */
  26281. updateTransformAndMatrix(): void;
  26282. /**
  26283. * @private
  26284. */
  26285. replaceDisplayData(value: DisplayData | null, displayIndex?: number): void;
  26286. /**
  26287. * - Check whether a specific point is inside a custom bounding box in the slot.
  26288. * The coordinate system of the point is the inner coordinate system of the armature.
  26289. * Custom bounding boxes need to be customized in Dragonbones Pro.
  26290. * @param x - The horizontal coordinate of the point.
  26291. * @param y - The vertical coordinate of the point.
  26292. * @version DragonBones 5.0
  26293. * @language en_US
  26294. */
  26295. /**
  26296. * - 检查特定点是否在插槽的自定义边界框内。
  26297. * 点的坐标系为骨架内坐标系。
  26298. * 自定义边界框需要在 DragonBones Pro 中自定义。
  26299. * @param x - 点的水平坐标。
  26300. * @param y - 点的垂直坐标。
  26301. * @version DragonBones 5.0
  26302. * @language zh_CN
  26303. */
  26304. containsPoint(x: number, y: number): boolean;
  26305. /**
  26306. * - Check whether a specific segment intersects a custom bounding box for the slot.
  26307. * The coordinate system of the segment and intersection is the inner coordinate system of the armature.
  26308. * Custom bounding boxes need to be customized in Dragonbones Pro.
  26309. * @param xA - The horizontal coordinate of the beginning of the segment.
  26310. * @param yA - The vertical coordinate of the beginning of the segment.
  26311. * @param xB - The horizontal coordinate of the end point of the segment.
  26312. * @param yB - The vertical coordinate of the end point of the segment.
  26313. * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated)
  26314. * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated)
  26315. * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated)
  26316. * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections]
  26317. * @version DragonBones 5.0
  26318. * @language en_US
  26319. */
  26320. /**
  26321. * - 检查特定线段是否与插槽的自定义边界框相交。
  26322. * 线段和交点的坐标系均为骨架内坐标系。
  26323. * 自定义边界框需要在 DragonBones Pro 中自定义。
  26324. * @param xA - 线段起点的水平坐标。
  26325. * @param yA - 线段起点的垂直坐标。
  26326. * @param xB - 线段终点的水平坐标。
  26327. * @param yB - 线段终点的垂直坐标。
  26328. * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点)
  26329. * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点)
  26330. * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线)
  26331. * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点]
  26332. * @version DragonBones 5.0
  26333. * @language zh_CN
  26334. */
  26335. intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: {
  26336. x: number;
  26337. y: number;
  26338. } | null, intersectionPointB?: {
  26339. x: number;
  26340. y: number;
  26341. } | null, normalRadians?: {
  26342. x: number;
  26343. y: number;
  26344. } | null): number;
  26345. /**
  26346. * - Forces the slot to update the state of the display object in the next frame.
  26347. * @version DragonBones 4.5
  26348. * @language en_US
  26349. */
  26350. /**
  26351. * - 强制插槽在下一帧更新显示对象的状态。
  26352. * @version DragonBones 4.5
  26353. * @language zh_CN
  26354. */
  26355. invalidUpdate(): void;
  26356. /**
  26357. * - The visible of slot's display object.
  26358. * @default true
  26359. * @version DragonBones 5.6
  26360. * @language en_US
  26361. */
  26362. /**
  26363. * - 插槽的显示对象的可见。
  26364. * @default true
  26365. * @version DragonBones 5.6
  26366. * @language zh_CN
  26367. */
  26368. visible: boolean;
  26369. /**
  26370. * - The index of the display object displayed in the display list.
  26371. * @example
  26372. * <pre>
  26373. * let slot = armature.getSlot("weapon");
  26374. * slot.displayIndex = 3;
  26375. * slot.displayController = "none";
  26376. * </pre>
  26377. * @version DragonBones 4.5
  26378. * @language en_US
  26379. */
  26380. /**
  26381. * - 此时显示的显示对象在显示列表中的索引。
  26382. * @example
  26383. * <pre>
  26384. * let slot = armature.getSlot("weapon");
  26385. * slot.displayIndex = 3;
  26386. * slot.displayController = "none";
  26387. * </pre>
  26388. * @version DragonBones 4.5
  26389. * @language zh_CN
  26390. */
  26391. displayIndex: number;
  26392. /**
  26393. * - The slot name.
  26394. * @see dragonBones.SlotData#name
  26395. * @version DragonBones 3.0
  26396. * @language en_US
  26397. */
  26398. /**
  26399. * - 插槽名称。
  26400. * @see dragonBones.SlotData#name
  26401. * @version DragonBones 3.0
  26402. * @language zh_CN
  26403. */
  26404. readonly name: string;
  26405. /**
  26406. * - Contains a display list of display objects or child armatures.
  26407. * @version DragonBones 3.0
  26408. * @language en_US
  26409. */
  26410. /**
  26411. * - 包含显示对象或子骨架的显示列表。
  26412. * @version DragonBones 3.0
  26413. * @language zh_CN
  26414. */
  26415. displayList: Array<any>;
  26416. /**
  26417. * - The slot data.
  26418. * @see dragonBones.SlotData
  26419. * @version DragonBones 4.5
  26420. * @language en_US
  26421. */
  26422. /**
  26423. * - 插槽数据。
  26424. * @see dragonBones.SlotData
  26425. * @version DragonBones 4.5
  26426. * @language zh_CN
  26427. */
  26428. readonly slotData: SlotData;
  26429. /**
  26430. * @private
  26431. */
  26432. rawDisplayDatas: Array<DisplayData | null> | null;
  26433. /**
  26434. * - The custom bounding box data for the slot at current time.
  26435. * @version DragonBones 5.0
  26436. * @language en_US
  26437. */
  26438. /**
  26439. * - 插槽此时的自定义包围盒数据。
  26440. * @version DragonBones 5.0
  26441. * @language zh_CN
  26442. */
  26443. readonly boundingBoxData: BoundingBoxData | null;
  26444. /**
  26445. * @private
  26446. */
  26447. readonly rawDisplay: any;
  26448. /**
  26449. * @private
  26450. */
  26451. readonly meshDisplay: any;
  26452. /**
  26453. * - The display object that the slot displays at this time.
  26454. * @example
  26455. * <pre>
  26456. * let slot = armature.getSlot("text");
  26457. * slot.display = new yourEngine.TextField();
  26458. * </pre>
  26459. * @version DragonBones 3.0
  26460. * @language en_US
  26461. */
  26462. /**
  26463. * - 插槽此时显示的显示对象。
  26464. * @example
  26465. * <pre>
  26466. * let slot = armature.getSlot("text");
  26467. * slot.display = new yourEngine.TextField();
  26468. * </pre>
  26469. * @version DragonBones 3.0
  26470. * @language zh_CN
  26471. */
  26472. display: any;
  26473. /**
  26474. * - The child armature that the slot displayed at current time.
  26475. * @example
  26476. * <pre>
  26477. * let slot = armature.getSlot("weapon");
  26478. * slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
  26479. * </pre>
  26480. * @version DragonBones 3.0
  26481. * @language en_US
  26482. */
  26483. /**
  26484. * - 插槽此时显示的子骨架。
  26485. * @example
  26486. * <pre>
  26487. * let slot = armature.getSlot("weapon");
  26488. * slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
  26489. * </pre>
  26490. * @version DragonBones 3.0
  26491. * @language zh_CN
  26492. */
  26493. childArmature: Armature | null;
  26494. /**
  26495. * - Deprecated, please refer to {@link #display}.
  26496. * @deprecated
  26497. * @language en_US
  26498. */
  26499. /**
  26500. * - 已废弃,请参考 {@link #display}。
  26501. * @deprecated
  26502. * @language zh_CN
  26503. */
  26504. getDisplay(): any;
  26505. /**
  26506. * - Deprecated, please refer to {@link #display}.
  26507. * @deprecated
  26508. * @language en_US
  26509. */
  26510. /**
  26511. * - 已废弃,请参考 {@link #display}。
  26512. * @deprecated
  26513. * @language zh_CN
  26514. */
  26515. setDisplay(value: any): void;
  26516. }
  26517. }
  26518. /**
  26519. * The MIT License (MIT)
  26520. *
  26521. * Copyright (c) 2012-2017 DragonBones team and other contributors
  26522. *
  26523. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  26524. * this software and associated documentation files (the "Software"), to deal in
  26525. * the Software without restriction, including without limitation the rights to
  26526. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  26527. * the Software, and to permit persons to whom the Software is furnished to do so,
  26528. * subject to the following conditions:
  26529. *
  26530. * The above copyright notice and this permission notice shall be included in all
  26531. * copies or substantial portions of the Software.
  26532. *
  26533. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26534. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  26535. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  26536. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  26537. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  26538. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26539. */
  26540. declare namespace dragonBones {
  26541. /**
  26542. * @internal
  26543. * @private
  26544. */
  26545. abstract class Constraint extends BaseObject {
  26546. protected static readonly _helpMatrix: Matrix;
  26547. protected static readonly _helpTransform: Transform;
  26548. protected static readonly _helpPoint: Point;
  26549. /**
  26550. * - For timeline state.
  26551. * @internal
  26552. */
  26553. _constraintData: ConstraintData;
  26554. protected _armature: Armature;
  26555. /**
  26556. * - For sort bones.
  26557. * @internal
  26558. */
  26559. _target: Bone;
  26560. /**
  26561. * - For sort bones.
  26562. * @internal
  26563. */
  26564. _root: Bone;
  26565. protected _bone: Bone | null;
  26566. protected _onClear(): void;
  26567. abstract init(constraintData: ConstraintData, armature: Armature): void;
  26568. abstract update(): void;
  26569. abstract invalidUpdate(): void;
  26570. readonly name: string;
  26571. }
  26572. /**
  26573. * @internal
  26574. * @private
  26575. */
  26576. class IKConstraint extends Constraint {
  26577. static toString(): string;
  26578. private _scaleEnabled;
  26579. /**
  26580. * - For timeline state.
  26581. * @internal
  26582. */
  26583. _bendPositive: boolean;
  26584. /**
  26585. * - For timeline state.
  26586. * @internal
  26587. */
  26588. _weight: number;
  26589. protected _onClear(): void;
  26590. private _computeA();
  26591. private _computeB();
  26592. init(constraintData: ConstraintData, armature: Armature): void;
  26593. update(): void;
  26594. invalidUpdate(): void;
  26595. }
  26596. }
  26597. /**
  26598. * The MIT License (MIT)
  26599. *
  26600. * Copyright (c) 2012-2017 DragonBones team and other contributors
  26601. *
  26602. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  26603. * this software and associated documentation files (the "Software"), to deal in
  26604. * the Software without restriction, including without limitation the rights to
  26605. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  26606. * the Software, and to permit persons to whom the Software is furnished to do so,
  26607. * subject to the following conditions:
  26608. *
  26609. * The above copyright notice and this permission notice shall be included in all
  26610. * copies or substantial portions of the Software.
  26611. *
  26612. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26613. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  26614. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  26615. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  26616. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  26617. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26618. */
  26619. declare namespace dragonBones {
  26620. /**
  26621. * - Play animation interface. (Both Armature and Wordclock implement the interface)
  26622. * Any instance that implements the interface can be added to the Worldclock instance and advance time by Worldclock instance uniformly.
  26623. * @see dragonBones.WorldClock
  26624. * @see dragonBones.Armature
  26625. * @version DragonBones 3.0
  26626. * @language en_US
  26627. */
  26628. /**
  26629. * - 播放动画接口。 (Armature 和 WordClock 都实现了该接口)
  26630. * 任何实现了此接口的实例都可以添加到 WorldClock 实例中,由 WorldClock 实例统一更新时间。
  26631. * @see dragonBones.WorldClock
  26632. * @see dragonBones.Armature
  26633. * @version DragonBones 3.0
  26634. * @language zh_CN
  26635. */
  26636. interface IAnimatable {
  26637. /**
  26638. * - Advance time.
  26639. * @param passedTime - Passed time. (In seconds)
  26640. * @version DragonBones 3.0
  26641. * @language en_US
  26642. */
  26643. /**
  26644. * - 更新时间。
  26645. * @param passedTime - 前进的时间。 (以秒为单位)
  26646. * @version DragonBones 3.0
  26647. * @language zh_CN
  26648. */
  26649. advanceTime(passedTime: number): void;
  26650. /**
  26651. * - The Wordclock instance to which the current belongs.
  26652. * @example
  26653. * <pre>
  26654. * armature.clock = factory.clock; // Add armature to clock.
  26655. * armature.clock = null; // Remove armature from clock.
  26656. * </pre>
  26657. * @version DragonBones 5.0
  26658. * @language en_US
  26659. */
  26660. /**
  26661. * - 当前所属的 WordClock 实例。
  26662. * @example
  26663. * <pre>
  26664. * armature.clock = factory.clock; // 将骨架添加到时钟。
  26665. * armature.clock = null; // 将骨架从时钟移除。
  26666. * </pre>
  26667. * @version DragonBones 5.0
  26668. * @language zh_CN
  26669. */
  26670. clock: WorldClock | null;
  26671. }
  26672. }
  26673. /**
  26674. * The MIT License (MIT)
  26675. *
  26676. * Copyright (c) 2012-2017 DragonBones team and other contributors
  26677. *
  26678. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  26679. * this software and associated documentation files (the "Software"), to deal in
  26680. * the Software without restriction, including without limitation the rights to
  26681. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  26682. * the Software, and to permit persons to whom the Software is furnished to do so,
  26683. * subject to the following conditions:
  26684. *
  26685. * The above copyright notice and this permission notice shall be included in all
  26686. * copies or substantial portions of the Software.
  26687. *
  26688. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26689. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  26690. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  26691. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  26692. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  26693. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26694. */
  26695. declare namespace dragonBones {
  26696. /**
  26697. * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance.
  26698. * @see dragonBones.IAnimateble
  26699. * @see dragonBones.Armature
  26700. * @version DragonBones 3.0
  26701. * @language en_US
  26702. */
  26703. /**
  26704. * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。
  26705. * @see dragonBones.IAnimateble
  26706. * @see dragonBones.Armature
  26707. * @version DragonBones 3.0
  26708. * @language zh_CN
  26709. */
  26710. class WorldClock implements IAnimatable {
  26711. /**
  26712. * - Current time. (In seconds)
  26713. * @version DragonBones 3.0
  26714. * @language en_US
  26715. */
  26716. /**
  26717. * - 当前的时间。 (以秒为单位)
  26718. * @version DragonBones 3.0
  26719. * @language zh_CN
  26720. */
  26721. time: number;
  26722. /**
  26723. * - The play speed, used to control animation speed-shift play.
  26724. * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play]
  26725. * @default 1.0
  26726. * @version DragonBones 3.0
  26727. * @language en_US
  26728. */
  26729. /**
  26730. * - 播放速度,用于控制动画变速播放。
  26731. * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  26732. * @default 1.0
  26733. * @version DragonBones 3.0
  26734. * @language zh_CN
  26735. */
  26736. timeScale: number;
  26737. private readonly _animatebles;
  26738. private _clock;
  26739. /**
  26740. * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance.
  26741. * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time.
  26742. * @version DragonBones 3.0
  26743. * @language en_US
  26744. */
  26745. /**
  26746. * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。
  26747. * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。
  26748. * @version DragonBones 3.0
  26749. * @language zh_CN
  26750. */
  26751. constructor(time?: number);
  26752. /**
  26753. * - Advance time for all IAnimatable instances.
  26754. * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds)
  26755. * @version DragonBones 3.0
  26756. * @language en_US
  26757. */
  26758. /**
  26759. * - 为所有的 IAnimatable 实例更新时间。
  26760. * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位)
  26761. * @version DragonBones 3.0
  26762. * @language zh_CN
  26763. */
  26764. advanceTime(passedTime: number): void;
  26765. /**
  26766. * - Check whether contains a specific instance of IAnimatable.
  26767. * @param value - The IAnimatable instance.
  26768. * @version DragonBones 3.0
  26769. * @language en_US
  26770. */
  26771. /**
  26772. * - 检查是否包含特定的 IAnimatable 实例。
  26773. * @param value - IAnimatable 实例。
  26774. * @version DragonBones 3.0
  26775. * @language zh_CN
  26776. */
  26777. contains(value: IAnimatable): boolean;
  26778. /**
  26779. * - Add IAnimatable instance.
  26780. * @param value - The IAnimatable instance.
  26781. * @version DragonBones 3.0
  26782. * @language en_US
  26783. */
  26784. /**
  26785. * - 添加 IAnimatable 实例。
  26786. * @param value - IAnimatable 实例。
  26787. * @version DragonBones 3.0
  26788. * @language zh_CN
  26789. */
  26790. add(value: IAnimatable): void;
  26791. /**
  26792. * - Removes a specified IAnimatable instance.
  26793. * @param value - The IAnimatable instance.
  26794. * @version DragonBones 3.0
  26795. * @language en_US
  26796. */
  26797. /**
  26798. * - 移除特定的 IAnimatable 实例。
  26799. * @param value - IAnimatable 实例。
  26800. * @version DragonBones 3.0
  26801. * @language zh_CN
  26802. */
  26803. remove(value: IAnimatable): void;
  26804. /**
  26805. * - Clear all IAnimatable instances.
  26806. * @version DragonBones 3.0
  26807. * @language en_US
  26808. */
  26809. /**
  26810. * - 清除所有的 IAnimatable 实例。
  26811. * @version DragonBones 3.0
  26812. * @language zh_CN
  26813. */
  26814. clear(): void;
  26815. /**
  26816. * @inheritDoc
  26817. */
  26818. clock: WorldClock | null;
  26819. /**
  26820. * - Deprecated, please refer to {@link dragonBones.BaseFactory#clock}.
  26821. * @deprecated
  26822. * @language en_US
  26823. */
  26824. /**
  26825. * - 已废弃,请参考 {@link dragonBones.BaseFactory#clock}。
  26826. * @deprecated
  26827. * @language zh_CN
  26828. */
  26829. static readonly clock: WorldClock;
  26830. }
  26831. }
  26832. /**
  26833. * The MIT License (MIT)
  26834. *
  26835. * Copyright (c) 2012-2017 DragonBones team and other contributors
  26836. *
  26837. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  26838. * this software and associated documentation files (the "Software"), to deal in
  26839. * the Software without restriction, including without limitation the rights to
  26840. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  26841. * the Software, and to permit persons to whom the Software is furnished to do so,
  26842. * subject to the following conditions:
  26843. *
  26844. * The above copyright notice and this permission notice shall be included in all
  26845. * copies or substantial portions of the Software.
  26846. *
  26847. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26848. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  26849. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  26850. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  26851. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  26852. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26853. */
  26854. declare namespace dragonBones {
  26855. /**
  26856. * - The animation player is used to play the animation data and manage the animation states.
  26857. * @see dragonBones.AnimationData
  26858. * @see dragonBones.AnimationState
  26859. * @version DragonBones 3.0
  26860. * @language en_US
  26861. */
  26862. /**
  26863. * - 动画播放器用来播放动画数据和管理动画状态。
  26864. * @see dragonBones.AnimationData
  26865. * @see dragonBones.AnimationState
  26866. * @version DragonBones 3.0
  26867. * @language zh_CN
  26868. */
  26869. class Animation extends BaseObject {
  26870. static toString(): string;
  26871. /**
  26872. * - The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast]
  26873. * @default 1.0
  26874. * @version DragonBones 3.0
  26875. * @language en_US
  26876. */
  26877. /**
  26878. * - 所有动画的播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  26879. * @default 1.0
  26880. * @version DragonBones 3.0
  26881. * @language zh_CN
  26882. */
  26883. timeScale: number;
  26884. private _lockUpdate;
  26885. private _animationDirty;
  26886. private _inheritTimeScale;
  26887. private readonly _animationNames;
  26888. private readonly _animationStates;
  26889. private readonly _animations;
  26890. private _armature;
  26891. private _animationConfig;
  26892. private _lastAnimationState;
  26893. /**
  26894. * @private
  26895. */
  26896. protected _onClear(): void;
  26897. private _fadeOut(animationConfig);
  26898. /**
  26899. * @internal
  26900. * @private
  26901. */
  26902. init(armature: Armature): void;
  26903. /**
  26904. * @internal
  26905. * @private
  26906. */
  26907. advanceTime(passedTime: number): void;
  26908. /**
  26909. * - Clear all animations states.
  26910. * @see dragonBones.AnimationState
  26911. * @version DragonBones 4.5
  26912. * @language en_US
  26913. */
  26914. /**
  26915. * - 清除所有的动画状态。
  26916. * @see dragonBones.AnimationState
  26917. * @version DragonBones 4.5
  26918. * @language zh_CN
  26919. */
  26920. reset(): void;
  26921. /**
  26922. * - Pause a specific animation state.
  26923. * @param animationName - The name of animation state. (If not set, it will pause all animations)
  26924. * @see dragonBones.AnimationState
  26925. * @version DragonBones 3.0
  26926. * @language en_US
  26927. */
  26928. /**
  26929. * - 暂停指定动画状态的播放。
  26930. * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画)
  26931. * @see dragonBones.AnimationState
  26932. * @version DragonBones 3.0
  26933. * @language zh_CN
  26934. */
  26935. stop(animationName?: string | null): void;
  26936. /**
  26937. * - Play animation with a specific animation config.
  26938. * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used.
  26939. * @param animationConfig - The animation config.
  26940. * @returns The playing animation state.
  26941. * @see dragonBones.AnimationConfig
  26942. * @beta
  26943. * @version DragonBones 5.0
  26944. * @language en_US
  26945. */
  26946. /**
  26947. * - 通过指定的动画配置来播放动画。
  26948. * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。
  26949. * @param animationConfig - 动画配置。
  26950. * @returns 播放的动画状态。
  26951. * @see dragonBones.AnimationConfig
  26952. * @beta
  26953. * @version DragonBones 5.0
  26954. * @language zh_CN
  26955. */
  26956. playConfig(animationConfig: AnimationConfig): AnimationState | null;
  26957. /**
  26958. * - Play a specific animation.
  26959. * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation)
  26960. * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1)
  26961. * @returns The playing animation state.
  26962. * @example
  26963. * <pre>
  26964. * armature.animation.play("walk");
  26965. * </pre>
  26966. * @version DragonBones 3.0
  26967. * @language en_US
  26968. */
  26969. /**
  26970. * - 播放指定动画。
  26971. * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画)
  26972. * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1)
  26973. * @returns 播放的动画状态。
  26974. * @example
  26975. * <pre>
  26976. * armature.animation.play("walk");
  26977. * </pre>
  26978. * @version DragonBones 3.0
  26979. * @language zh_CN
  26980. */
  26981. play(animationName?: string | null, playTimes?: number): AnimationState | null;
  26982. /**
  26983. * - Fade in a specific animation.
  26984. * @param animationName - The name of animation data.
  26985. * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1)
  26986. * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1)
  26987. * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0)
  26988. * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null)
  26989. * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup)
  26990. * @returns The playing animation state.
  26991. * @example
  26992. * <pre>
  26993. * armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
  26994. * armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
  26995. * </pre>
  26996. * @version DragonBones 4.5
  26997. * @language en_US
  26998. */
  26999. /**
  27000. * - 淡入播放指定的动画。
  27001. * @param animationName - 动画数据名称。
  27002. * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1)
  27003. * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1)
  27004. * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0)
  27005. * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null)
  27006. * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup)
  27007. * @returns 播放的动画状态。
  27008. * @example
  27009. * <pre>
  27010. * armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
  27011. * armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
  27012. * </pre>
  27013. * @version DragonBones 4.5
  27014. * @language zh_CN
  27015. */
  27016. fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null;
  27017. /**
  27018. * - Play a specific animation from the specific time.
  27019. * @param animationName - The name of animation data.
  27020. * @param time - The start time point of playing. (In seconds)
  27021. * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1)
  27022. * @returns The played animation state.
  27023. * @version DragonBones 4.5
  27024. * @language en_US
  27025. */
  27026. /**
  27027. * - 从指定时间开始播放指定的动画。
  27028. * @param animationName - 动画数据名称。
  27029. * @param time - 播放开始的时间。 (以秒为单位)
  27030. * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1)
  27031. * @returns 播放的动画状态。
  27032. * @version DragonBones 4.5
  27033. * @language zh_CN
  27034. */
  27035. gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null;
  27036. /**
  27037. * - Play a specific animation from the specific frame.
  27038. * @param animationName - The name of animation data.
  27039. * @param frame - The start frame of playing.
  27040. * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1)
  27041. * @returns The played animation state.
  27042. * @version DragonBones 4.5
  27043. * @language en_US
  27044. */
  27045. /**
  27046. * - 从指定帧开始播放指定的动画。
  27047. * @param animationName - 动画数据名称。
  27048. * @param frame - 播放开始的帧数。
  27049. * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1)
  27050. * @returns 播放的动画状态。
  27051. * @version DragonBones 4.5
  27052. * @language zh_CN
  27053. */
  27054. gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null;
  27055. /**
  27056. * - Play a specific animation from the specific progress.
  27057. * @param animationName - The name of animation data.
  27058. * @param progress - The start progress value of playing.
  27059. * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1)
  27060. * @returns The played animation state.
  27061. * @version DragonBones 4.5
  27062. * @language en_US
  27063. */
  27064. /**
  27065. * - 从指定进度开始播放指定的动画。
  27066. * @param animationName - 动画数据名称。
  27067. * @param progress - 开始播放的进度。
  27068. * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1)
  27069. * @returns 播放的动画状态。
  27070. * @version DragonBones 4.5
  27071. * @language zh_CN
  27072. */
  27073. gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null;
  27074. /**
  27075. * - Stop a specific animation at the specific time.
  27076. * @param animationName - The name of animation data.
  27077. * @param time - The stop time. (In seconds)
  27078. * @returns The played animation state.
  27079. * @version DragonBones 4.5
  27080. * @language en_US
  27081. */
  27082. /**
  27083. * - 在指定时间停止指定动画播放
  27084. * @param animationName - 动画数据名称。
  27085. * @param time - 停止的时间。 (以秒为单位)
  27086. * @returns 播放的动画状态。
  27087. * @version DragonBones 4.5
  27088. * @language zh_CN
  27089. */
  27090. gotoAndStopByTime(animationName: string, time?: number): AnimationState | null;
  27091. /**
  27092. * - Stop a specific animation at the specific frame.
  27093. * @param animationName - The name of animation data.
  27094. * @param frame - The stop frame.
  27095. * @returns The played animation state.
  27096. * @version DragonBones 4.5
  27097. * @language en_US
  27098. */
  27099. /**
  27100. * - 在指定帧停止指定动画的播放
  27101. * @param animationName - 动画数据名称。
  27102. * @param frame - 停止的帧数。
  27103. * @returns 播放的动画状态。
  27104. * @version DragonBones 4.5
  27105. * @language zh_CN
  27106. */
  27107. gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null;
  27108. /**
  27109. * - Stop a specific animation at the specific progress.
  27110. * @param animationName - The name of animation data.
  27111. * @param progress - The stop progress value.
  27112. * @returns The played animation state.
  27113. * @version DragonBones 4.5
  27114. * @language en_US
  27115. */
  27116. /**
  27117. * - 在指定的进度停止指定的动画播放。
  27118. * @param animationName - 动画数据名称。
  27119. * @param progress - 停止进度。
  27120. * @returns 播放的动画状态。
  27121. * @version DragonBones 4.5
  27122. * @language zh_CN
  27123. */
  27124. gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null;
  27125. /**
  27126. * - Get a specific animation state.
  27127. * @param animationName - The name of animation state.
  27128. * @example
  27129. * <pre>
  27130. * armature.animation.play("walk");
  27131. * let walkState = armature.animation.getState("walk");
  27132. * walkState.timeScale = 0.5;
  27133. * </pre>
  27134. * @version DragonBones 3.0
  27135. * @language en_US
  27136. */
  27137. /**
  27138. * - 获取指定的动画状态
  27139. * @param animationName - 动画状态名称。
  27140. * @example
  27141. * <pre>
  27142. * armature.animation.play("walk");
  27143. * let walkState = armature.animation.getState("walk");
  27144. * walkState.timeScale = 0.5;
  27145. * </pre>
  27146. * @version DragonBones 3.0
  27147. * @language zh_CN
  27148. */
  27149. getState(animationName: string): AnimationState | null;
  27150. /**
  27151. * - Check whether a specific animation data is included.
  27152. * @param animationName - The name of animation data.
  27153. * @see dragonBones.AnimationData
  27154. * @version DragonBones 3.0
  27155. * @language en_US
  27156. */
  27157. /**
  27158. * - 检查是否包含指定的动画数据
  27159. * @param animationName - 动画数据名称。
  27160. * @see dragonBones.AnimationData
  27161. * @version DragonBones 3.0
  27162. * @language zh_CN
  27163. */
  27164. hasAnimation(animationName: string): boolean;
  27165. /**
  27166. * - Get all the animation states.
  27167. * @version DragonBones 5.1
  27168. * @language en_US
  27169. */
  27170. /**
  27171. * - 获取所有的动画状态
  27172. * @version DragonBones 5.1
  27173. * @language zh_CN
  27174. */
  27175. getStates(): Array<AnimationState>;
  27176. /**
  27177. * - Check whether there is an animation state is playing
  27178. * @see dragonBones.AnimationState
  27179. * @version DragonBones 3.0
  27180. * @language en_US
  27181. */
  27182. /**
  27183. * - 检查是否有动画状态正在播放
  27184. * @see dragonBones.AnimationState
  27185. * @version DragonBones 3.0
  27186. * @language zh_CN
  27187. */
  27188. readonly isPlaying: boolean;
  27189. /**
  27190. * - Check whether all the animation states' playing were finished.
  27191. * @see dragonBones.AnimationState
  27192. * @version DragonBones 3.0
  27193. * @language en_US
  27194. */
  27195. /**
  27196. * - 检查是否所有的动画状态均已播放完毕。
  27197. * @see dragonBones.AnimationState
  27198. * @version DragonBones 3.0
  27199. * @language zh_CN
  27200. */
  27201. readonly isCompleted: boolean;
  27202. /**
  27203. * - The name of the last playing animation state.
  27204. * @see #lastAnimationState
  27205. * @version DragonBones 3.0
  27206. * @language en_US
  27207. */
  27208. /**
  27209. * - 上一个播放的动画状态名称
  27210. * @see #lastAnimationState
  27211. * @version DragonBones 3.0
  27212. * @language zh_CN
  27213. */
  27214. readonly lastAnimationName: string;
  27215. /**
  27216. * - The name of all animation data
  27217. * @version DragonBones 4.5
  27218. * @language en_US
  27219. */
  27220. /**
  27221. * - 所有动画数据的名称
  27222. * @version DragonBones 4.5
  27223. * @language zh_CN
  27224. */
  27225. readonly animationNames: Array<string>;
  27226. /**
  27227. * - All animation data.
  27228. * @version DragonBones 4.5
  27229. * @language en_US
  27230. */
  27231. /**
  27232. * - 所有的动画数据。
  27233. * @version DragonBones 4.5
  27234. * @language zh_CN
  27235. */
  27236. animations: Map<AnimationData>;
  27237. /**
  27238. * - An AnimationConfig instance that can be used quickly.
  27239. * @see dragonBones.AnimationConfig
  27240. * @version DragonBones 5.0
  27241. * @language en_US
  27242. */
  27243. /**
  27244. * - 一个可以快速使用的动画配置实例。
  27245. * @see dragonBones.AnimationConfig
  27246. * @version DragonBones 5.0
  27247. * @language zh_CN
  27248. */
  27249. readonly animationConfig: AnimationConfig;
  27250. /**
  27251. * - The last playing animation state
  27252. * @see dragonBones.AnimationState
  27253. * @version DragonBones 3.0
  27254. * @language en_US
  27255. */
  27256. /**
  27257. * - 上一个播放的动画状态
  27258. * @see dragonBones.AnimationState
  27259. * @version DragonBones 3.0
  27260. * @language zh_CN
  27261. */
  27262. readonly lastAnimationState: AnimationState | null;
  27263. /**
  27264. * - Deprecated, please refer to {@link #play()} {@link #fadeIn()}.
  27265. * @deprecated
  27266. * @language en_US
  27267. */
  27268. /**
  27269. * - 已废弃,请参考 {@link #play()} {@link #fadeIn()}。
  27270. * @deprecated
  27271. * @language zh_CN
  27272. */
  27273. gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null;
  27274. /**
  27275. * - Deprecated, please refer to {@link #gotoAndStopByTime()}.
  27276. * @deprecated
  27277. * @language en_US
  27278. */
  27279. /**
  27280. * - 已废弃,请参考 {@link #gotoAndStopByTime()}。
  27281. * @deprecated
  27282. * @language zh_CN
  27283. */
  27284. gotoAndStop(animationName: string, time?: number): AnimationState | null;
  27285. /**
  27286. * - Deprecated, please refer to {@link #animationNames}.
  27287. * @deprecated
  27288. * @language en_US
  27289. */
  27290. /**
  27291. * - 已废弃,请参考 {@link #animationNames}。
  27292. * @deprecated
  27293. * @language zh_CN
  27294. */
  27295. readonly animationList: Array<string>;
  27296. /**
  27297. * - Deprecated, please refer to {@link #animationNames}.
  27298. * @deprecated
  27299. * @language en_US
  27300. */
  27301. /**
  27302. * - 已废弃,请参考 {@link #animationNames}。
  27303. * @deprecated
  27304. * @language zh_CN
  27305. */
  27306. readonly animationDataList: Array<AnimationData>;
  27307. }
  27308. }
  27309. /**
  27310. * The MIT License (MIT)
  27311. *
  27312. * Copyright (c) 2012-2017 DragonBones team and other contributors
  27313. *
  27314. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  27315. * this software and associated documentation files (the "Software"), to deal in
  27316. * the Software without restriction, including without limitation the rights to
  27317. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  27318. * the Software, and to permit persons to whom the Software is furnished to do so,
  27319. * subject to the following conditions:
  27320. *
  27321. * The above copyright notice and this permission notice shall be included in all
  27322. * copies or substantial portions of the Software.
  27323. *
  27324. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  27325. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  27326. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  27327. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  27328. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  27329. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27330. */
  27331. declare namespace dragonBones {
  27332. /**
  27333. * - The animation state is generated when the animation data is played.
  27334. * @see dragonBones.Animation
  27335. * @see dragonBones.AnimationData
  27336. * @version DragonBones 3.0
  27337. * @language en_US
  27338. */
  27339. /**
  27340. * - 动画状态由播放动画数据时产生。
  27341. * @see dragonBones.Animation
  27342. * @see dragonBones.AnimationData
  27343. * @version DragonBones 3.0
  27344. * @language zh_CN
  27345. */
  27346. class AnimationState extends BaseObject {
  27347. static toString(): string;
  27348. /**
  27349. * @private
  27350. */
  27351. actionEnabled: boolean;
  27352. /**
  27353. * @private
  27354. */
  27355. additiveBlending: boolean;
  27356. /**
  27357. * - Whether the animation state has control over the display object properties of the slots.
  27358. * Sometimes blend a animation state does not want it to control the display object properties of the slots,
  27359. * especially if other animation state are controlling the display object properties of the slots.
  27360. * @default true
  27361. * @version DragonBones 5.0
  27362. * @language en_US
  27363. */
  27364. /**
  27365. * - 动画状态是否对插槽的显示对象属性有控制权。
  27366. * 有时混合一个动画状态并不希望其控制插槽的显示对象属性,
  27367. * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。
  27368. * @default true
  27369. * @version DragonBones 5.0
  27370. * @language zh_CN
  27371. */
  27372. displayControl: boolean;
  27373. /**
  27374. * - Whether to reset the objects without animation to the armature pose when the animation state is start to play.
  27375. * This property should usually be set to false when blend multiple animation states.
  27376. * @default true
  27377. * @version DragonBones 5.1
  27378. * @language en_US
  27379. */
  27380. /**
  27381. * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。
  27382. * 通常在混合多个动画状态时应该将该属性设置为 false。
  27383. * @default true
  27384. * @version DragonBones 5.1
  27385. * @language zh_CN
  27386. */
  27387. resetToPose: boolean;
  27388. /**
  27389. * - The play times. [0: Loop play, [1~N]: Play N times]
  27390. * @version DragonBones 3.0
  27391. * @language en_US
  27392. */
  27393. /**
  27394. * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次]
  27395. * @version DragonBones 3.0
  27396. * @language zh_CN
  27397. */
  27398. playTimes: number;
  27399. /**
  27400. * - The blend layer.
  27401. * High layer animation state will get the blend weight first.
  27402. * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned.
  27403. * @readonly
  27404. * @version DragonBones 5.0
  27405. * @language en_US
  27406. */
  27407. /**
  27408. * - 混合图层。
  27409. * 图层高的动画状态会优先获取混合权重。
  27410. * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。
  27411. * @readonly
  27412. * @version DragonBones 5.0
  27413. * @language zh_CN
  27414. */
  27415. layer: number;
  27416. /**
  27417. * - The play speed.
  27418. * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}.
  27419. * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play]
  27420. * @default 1.0
  27421. * @version DragonBones 3.0
  27422. * @language en_US
  27423. */
  27424. /**
  27425. * - 播放速度。
  27426. * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。
  27427. * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  27428. * @default 1.0
  27429. * @version DragonBones 3.0
  27430. * @language zh_CN
  27431. */
  27432. timeScale: number;
  27433. /**
  27434. * - The blend weight.
  27435. * @default 1.0
  27436. * @version DragonBones 5.0
  27437. * @language en_US
  27438. */
  27439. /**
  27440. * - 混合权重。
  27441. * @default 1.0
  27442. * @version DragonBones 5.0
  27443. * @language zh_CN
  27444. */
  27445. weight: number;
  27446. /**
  27447. * - The auto fade out time when the animation state play completed.
  27448. * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds)
  27449. * @default -1.0
  27450. * @version DragonBones 5.0
  27451. * @language en_US
  27452. */
  27453. /**
  27454. * - 动画状态播放完成后的自动淡出时间。
  27455. * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位)
  27456. * @default -1.0
  27457. * @version DragonBones 5.0
  27458. * @language zh_CN
  27459. */
  27460. autoFadeOutTime: number;
  27461. /**
  27462. * @private
  27463. */
  27464. fadeTotalTime: number;
  27465. /**
  27466. * - The name of the animation state. (Can be different from the name of the animation data)
  27467. * @readonly
  27468. * @version DragonBones 5.0
  27469. * @language en_US
  27470. */
  27471. /**
  27472. * - 动画状态名称。 (可以不同于动画数据)
  27473. * @readonly
  27474. * @version DragonBones 5.0
  27475. * @language zh_CN
  27476. */
  27477. name: string;
  27478. /**
  27479. * - The blend group name of the animation state.
  27480. * This property is typically used to specify the substitution of multiple animation states blend.
  27481. * @readonly
  27482. * @version DragonBones 5.0
  27483. * @language en_US
  27484. */
  27485. /**
  27486. * - 混合组名称。
  27487. * 该属性通常用来指定多个动画状态混合时的相互替换关系。
  27488. * @readonly
  27489. * @version DragonBones 5.0
  27490. * @language zh_CN
  27491. */
  27492. group: string;
  27493. private _timelineDirty;
  27494. /**
  27495. * - xx: Play Enabled, Fade Play Enabled
  27496. * @internal
  27497. * @private
  27498. */
  27499. _playheadState: number;
  27500. /**
  27501. * -1: Fade in, 0: Fade complete, 1: Fade out;
  27502. * @internal
  27503. * @private
  27504. */
  27505. _fadeState: number;
  27506. /**
  27507. * -1: Fade start, 0: Fading, 1: Fade complete;
  27508. * @internal
  27509. * @private
  27510. */
  27511. _subFadeState: number;
  27512. /**
  27513. * @internal
  27514. * @private
  27515. */
  27516. _position: number;
  27517. /**
  27518. * @internal
  27519. * @private
  27520. */
  27521. _duration: number;
  27522. private _fadeTime;
  27523. private _time;
  27524. /**
  27525. * @internal
  27526. * @private
  27527. */
  27528. _fadeProgress: number;
  27529. /**
  27530. * @internal
  27531. * @private
  27532. */
  27533. _weightResult: number;
  27534. /**
  27535. * @internal
  27536. * @private
  27537. */
  27538. readonly _blendState: BlendState;
  27539. private readonly _boneMask;
  27540. private readonly _boneTimelines;
  27541. private readonly _surfaceTimelines;
  27542. private readonly _slotTimelines;
  27543. private readonly _constraintTimelines;
  27544. private readonly _animationTimelines;
  27545. private readonly _poseTimelines;
  27546. private readonly _bonePoses;
  27547. /**
  27548. * @internal
  27549. * @private
  27550. */
  27551. _animationData: AnimationData;
  27552. private _armature;
  27553. /**
  27554. * @internal
  27555. * @private
  27556. */
  27557. _actionTimeline: ActionTimelineState;
  27558. private _zOrderTimeline;
  27559. /**
  27560. * @internal
  27561. * @private
  27562. */
  27563. _parent: AnimationState;
  27564. /**
  27565. * @private
  27566. */
  27567. protected _onClear(): void;
  27568. private _updateTimelines();
  27569. private _updateBoneAndSlotTimelines();
  27570. private _advanceFadeTime(passedTime);
  27571. /**
  27572. * @internal
  27573. * @private
  27574. */
  27575. init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void;
  27576. /**
  27577. * @internal
  27578. * @private
  27579. */
  27580. advanceTime(passedTime: number, cacheFrameRate: number): void;
  27581. /**
  27582. * - Continue play.
  27583. * @version DragonBones 3.0
  27584. * @language en_US
  27585. */
  27586. /**
  27587. * - 继续播放。
  27588. * @version DragonBones 3.0
  27589. * @language zh_CN
  27590. */
  27591. play(): void;
  27592. /**
  27593. * - Stop play.
  27594. * @version DragonBones 3.0
  27595. * @language en_US
  27596. */
  27597. /**
  27598. * - 暂停播放。
  27599. * @version DragonBones 3.0
  27600. * @language zh_CN
  27601. */
  27602. stop(): void;
  27603. /**
  27604. * - Fade out the animation state.
  27605. * @param fadeOutTime - The fade out time. (In seconds)
  27606. * @param pausePlayhead - Whether to pause the animation playing when fade out.
  27607. * @version DragonBones 3.0
  27608. * @language en_US
  27609. */
  27610. /**
  27611. * - 淡出动画状态。
  27612. * @param fadeOutTime - 淡出时间。 (以秒为单位)
  27613. * @param pausePlayhead - 淡出时是否暂停播放。
  27614. * @version DragonBones 3.0
  27615. * @language zh_CN
  27616. */
  27617. fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void;
  27618. /**
  27619. * - Check if a specific bone mask is included.
  27620. * @param name - The bone name.
  27621. * @version DragonBones 3.0
  27622. * @language en_US
  27623. */
  27624. /**
  27625. * - 检查是否包含特定骨骼遮罩。
  27626. * @param name - 骨骼名称。
  27627. * @version DragonBones 3.0
  27628. * @language zh_CN
  27629. */
  27630. containsBoneMask(name: string): boolean;
  27631. /**
  27632. * - Add a specific bone mask.
  27633. * @param name - The bone name.
  27634. * @param recursive - Whether or not to add a mask to the bone's sub-bone.
  27635. * @version DragonBones 3.0
  27636. * @language en_US
  27637. */
  27638. /**
  27639. * - 添加特定的骨骼遮罩。
  27640. * @param name - 骨骼名称。
  27641. * @param recursive - 是否为该骨骼的子骨骼添加遮罩。
  27642. * @version DragonBones 3.0
  27643. * @language zh_CN
  27644. */
  27645. addBoneMask(name: string, recursive?: boolean): void;
  27646. /**
  27647. * - Remove the mask of a specific bone.
  27648. * @param name - The bone name.
  27649. * @param recursive - Whether to remove the bone's sub-bone mask.
  27650. * @version DragonBones 3.0
  27651. * @language en_US
  27652. */
  27653. /**
  27654. * - 删除特定骨骼的遮罩。
  27655. * @param name - 骨骼名称。
  27656. * @param recursive - 是否删除该骨骼的子骨骼遮罩。
  27657. * @version DragonBones 3.0
  27658. * @language zh_CN
  27659. */
  27660. removeBoneMask(name: string, recursive?: boolean): void;
  27661. /**
  27662. * - Remove all bone masks.
  27663. * @version DragonBones 3.0
  27664. * @language en_US
  27665. */
  27666. /**
  27667. * - 删除所有骨骼遮罩。
  27668. * @version DragonBones 3.0
  27669. * @language zh_CN
  27670. */
  27671. removeAllBoneMask(): void;
  27672. /**
  27673. * - Whether the animation state is fading in.
  27674. * @version DragonBones 5.1
  27675. * @language en_US
  27676. */
  27677. /**
  27678. * - 是否正在淡入。
  27679. * @version DragonBones 5.1
  27680. * @language zh_CN
  27681. */
  27682. readonly isFadeIn: boolean;
  27683. /**
  27684. * - Whether the animation state is fading out.
  27685. * @version DragonBones 5.1
  27686. * @language en_US
  27687. */
  27688. /**
  27689. * - 是否正在淡出。
  27690. * @version DragonBones 5.1
  27691. * @language zh_CN
  27692. */
  27693. readonly isFadeOut: boolean;
  27694. /**
  27695. * - Whether the animation state is fade completed.
  27696. * @version DragonBones 5.1
  27697. * @language en_US
  27698. */
  27699. /**
  27700. * - 是否淡入或淡出完毕。
  27701. * @version DragonBones 5.1
  27702. * @language zh_CN
  27703. */
  27704. readonly isFadeComplete: boolean;
  27705. /**
  27706. * - Whether the animation state is playing.
  27707. * @version DragonBones 3.0
  27708. * @language en_US
  27709. */
  27710. /**
  27711. * - 是否正在播放。
  27712. * @version DragonBones 3.0
  27713. * @language zh_CN
  27714. */
  27715. readonly isPlaying: boolean;
  27716. /**
  27717. * - Whether the animation state is play completed.
  27718. * @version DragonBones 3.0
  27719. * @language en_US
  27720. */
  27721. /**
  27722. * - 是否播放完毕。
  27723. * @version DragonBones 3.0
  27724. * @language zh_CN
  27725. */
  27726. readonly isCompleted: boolean;
  27727. /**
  27728. * - The times has been played.
  27729. * @version DragonBones 3.0
  27730. * @language en_US
  27731. */
  27732. /**
  27733. * - 已经循环播放的次数。
  27734. * @version DragonBones 3.0
  27735. * @language zh_CN
  27736. */
  27737. readonly currentPlayTimes: number;
  27738. /**
  27739. * - The total time. (In seconds)
  27740. * @version DragonBones 3.0
  27741. * @language en_US
  27742. */
  27743. /**
  27744. * - 总播放时间。 (以秒为单位)
  27745. * @version DragonBones 3.0
  27746. * @language zh_CN
  27747. */
  27748. readonly totalTime: number;
  27749. /**
  27750. * - The time is currently playing. (In seconds)
  27751. * @version DragonBones 3.0
  27752. * @language en_US
  27753. */
  27754. /**
  27755. * - 当前播放的时间。 (以秒为单位)
  27756. * @version DragonBones 3.0
  27757. * @language zh_CN
  27758. */
  27759. currentTime: number;
  27760. /**
  27761. * - The animation data.
  27762. * @see dragonBones.AnimationData
  27763. * @version DragonBones 3.0
  27764. * @language en_US
  27765. */
  27766. /**
  27767. * - 动画数据。
  27768. * @see dragonBones.AnimationData
  27769. * @version DragonBones 3.0
  27770. * @language zh_CN
  27771. */
  27772. readonly animationData: AnimationData;
  27773. }
  27774. /**
  27775. * @internal
  27776. * @private
  27777. */
  27778. class BonePose extends BaseObject {
  27779. static toString(): string;
  27780. readonly current: Transform;
  27781. readonly delta: Transform;
  27782. readonly result: Transform;
  27783. protected _onClear(): void;
  27784. }
  27785. /**
  27786. * @internal
  27787. * @private
  27788. */
  27789. class BlendState {
  27790. dirty: boolean;
  27791. layer: number;
  27792. leftWeight: number;
  27793. layerWeight: number;
  27794. blendWeight: number;
  27795. update(weight: number, layer: number): number;
  27796. clear(): void;
  27797. }
  27798. }
  27799. /**
  27800. * The MIT License (MIT)
  27801. *
  27802. * Copyright (c) 2012-2017 DragonBones team and other contributors
  27803. *
  27804. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  27805. * this software and associated documentation files (the "Software"), to deal in
  27806. * the Software without restriction, including without limitation the rights to
  27807. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  27808. * the Software, and to permit persons to whom the Software is furnished to do so,
  27809. * subject to the following conditions:
  27810. *
  27811. * The above copyright notice and this permission notice shall be included in all
  27812. * copies or substantial portions of the Software.
  27813. *
  27814. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  27815. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  27816. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  27817. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  27818. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  27819. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27820. */
  27821. declare namespace dragonBones {
  27822. /**
  27823. * @internal
  27824. * @private
  27825. */
  27826. const enum TweenState {
  27827. None = 0,
  27828. Once = 1,
  27829. Always = 2,
  27830. }
  27831. /**
  27832. * @internal
  27833. * @private
  27834. */
  27835. abstract class TimelineState extends BaseObject {
  27836. playState: number;
  27837. currentPlayTimes: number;
  27838. currentTime: number;
  27839. protected _tweenState: TweenState;
  27840. protected _frameRate: number;
  27841. protected _frameValueOffset: number;
  27842. protected _frameCount: number;
  27843. protected _frameOffset: number;
  27844. protected _frameIndex: number;
  27845. protected _frameRateR: number;
  27846. protected _position: number;
  27847. protected _duration: number;
  27848. protected _timeScale: number;
  27849. protected _timeOffset: number;
  27850. protected _dragonBonesData: DragonBonesData;
  27851. protected _animationData: AnimationData;
  27852. protected _timelineData: TimelineData | null;
  27853. protected _armature: Armature;
  27854. protected _animationState: AnimationState;
  27855. protected _actionTimeline: TimelineState;
  27856. protected _frameArray: Array<number> | Int16Array;
  27857. protected _frameIntArray: Array<number> | Int16Array;
  27858. protected _frameFloatArray: Array<number> | Int16Array;
  27859. protected _timelineArray: Array<number> | Uint16Array;
  27860. protected _frameIndices: Array<number>;
  27861. protected _onClear(): void;
  27862. protected abstract _onArriveAtFrame(): void;
  27863. protected abstract _onUpdateFrame(): void;
  27864. protected _setCurrentTime(passedTime: number): boolean;
  27865. init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void;
  27866. fadeOut(): void;
  27867. update(passedTime: number): void;
  27868. }
  27869. /**
  27870. * @internal
  27871. * @private
  27872. */
  27873. abstract class TweenTimelineState extends TimelineState {
  27874. private static _getEasingValue(tweenType, progress, easing);
  27875. private static _getEasingCurveValue(progress, samples, count, offset);
  27876. protected _tweenType: TweenType;
  27877. protected _curveCount: number;
  27878. protected _framePosition: number;
  27879. protected _frameDurationR: number;
  27880. protected _tweenProgress: number;
  27881. protected _tweenEasing: number;
  27882. protected _onClear(): void;
  27883. protected _onArriveAtFrame(): void;
  27884. protected _onUpdateFrame(): void;
  27885. }
  27886. /**
  27887. * @internal
  27888. * @private
  27889. */
  27890. abstract class BoneTimelineState extends TweenTimelineState {
  27891. bone: Bone;
  27892. bonePose: BonePose;
  27893. protected _onClear(): void;
  27894. blend(state: number): void;
  27895. }
  27896. /**
  27897. * @internal
  27898. * @private
  27899. */
  27900. abstract class SlotTimelineState extends TweenTimelineState {
  27901. slot: Slot;
  27902. protected _onClear(): void;
  27903. }
  27904. /**
  27905. * @internal
  27906. * @private
  27907. */
  27908. abstract class ConstraintTimelineState extends TweenTimelineState {
  27909. constraint: Constraint;
  27910. protected _onClear(): void;
  27911. }
  27912. }
  27913. /**
  27914. * The MIT License (MIT)
  27915. *
  27916. * Copyright (c) 2012-2017 DragonBones team and other contributors
  27917. *
  27918. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  27919. * this software and associated documentation files (the "Software"), to deal in
  27920. * the Software without restriction, including without limitation the rights to
  27921. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  27922. * the Software, and to permit persons to whom the Software is furnished to do so,
  27923. * subject to the following conditions:
  27924. *
  27925. * The above copyright notice and this permission notice shall be included in all
  27926. * copies or substantial portions of the Software.
  27927. *
  27928. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  27929. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  27930. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  27931. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  27932. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  27933. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27934. */
  27935. declare namespace dragonBones {
  27936. /**
  27937. * @internal
  27938. * @private
  27939. */
  27940. class ActionTimelineState extends TimelineState {
  27941. static toString(): string;
  27942. private _onCrossFrame(frameIndex);
  27943. protected _onArriveAtFrame(): void;
  27944. protected _onUpdateFrame(): void;
  27945. update(passedTime: number): void;
  27946. setCurrentTime(value: number): void;
  27947. }
  27948. /**
  27949. * @internal
  27950. * @private
  27951. */
  27952. class ZOrderTimelineState extends TimelineState {
  27953. static toString(): string;
  27954. protected _onArriveAtFrame(): void;
  27955. protected _onUpdateFrame(): void;
  27956. }
  27957. /**
  27958. * @internal
  27959. * @private
  27960. */
  27961. class BoneAllTimelineState extends BoneTimelineState {
  27962. static toString(): string;
  27963. protected _onArriveAtFrame(): void;
  27964. protected _onUpdateFrame(): void;
  27965. fadeOut(): void;
  27966. }
  27967. /**
  27968. * @internal
  27969. * @private
  27970. */
  27971. class BoneTranslateTimelineState extends BoneTimelineState {
  27972. static toString(): string;
  27973. protected _onArriveAtFrame(): void;
  27974. protected _onUpdateFrame(): void;
  27975. }
  27976. /**
  27977. * @internal
  27978. * @private
  27979. */
  27980. class BoneRotateTimelineState extends BoneTimelineState {
  27981. static toString(): string;
  27982. protected _onArriveAtFrame(): void;
  27983. protected _onUpdateFrame(): void;
  27984. fadeOut(): void;
  27985. }
  27986. /**
  27987. * @internal
  27988. * @private
  27989. */
  27990. class BoneScaleTimelineState extends BoneTimelineState {
  27991. static toString(): string;
  27992. protected _onArriveAtFrame(): void;
  27993. protected _onUpdateFrame(): void;
  27994. }
  27995. /**
  27996. * @internal
  27997. * @private
  27998. */
  27999. class SurfaceTimelineState extends TweenTimelineState {
  28000. static toString(): string;
  28001. surface: Surface;
  28002. private _frameFloatOffset;
  28003. private _valueCount;
  28004. private _deformCount;
  28005. private _valueOffset;
  28006. private readonly _current;
  28007. private readonly _delta;
  28008. private readonly _result;
  28009. protected _onClear(): void;
  28010. protected _onArriveAtFrame(): void;
  28011. protected _onUpdateFrame(): void;
  28012. init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void;
  28013. blend(state: number): void;
  28014. }
  28015. /**
  28016. * @internal
  28017. * @private
  28018. */
  28019. class SlotDislayTimelineState extends SlotTimelineState {
  28020. static toString(): string;
  28021. protected _onArriveAtFrame(): void;
  28022. }
  28023. /**
  28024. * @internal
  28025. * @private
  28026. */
  28027. class SlotColorTimelineState extends SlotTimelineState {
  28028. static toString(): string;
  28029. private _dirty;
  28030. private readonly _current;
  28031. private readonly _delta;
  28032. private readonly _result;
  28033. protected _onClear(): void;
  28034. protected _onArriveAtFrame(): void;
  28035. protected _onUpdateFrame(): void;
  28036. fadeOut(): void;
  28037. update(passedTime: number): void;
  28038. }
  28039. /**
  28040. * @internal
  28041. * @private
  28042. */
  28043. class SlotFFDTimelineState extends SlotTimelineState {
  28044. static toString(): string;
  28045. meshOffset: number;
  28046. private _dirty;
  28047. private _frameFloatOffset;
  28048. private _valueCount;
  28049. private _deformCount;
  28050. private _valueOffset;
  28051. private readonly _current;
  28052. private readonly _delta;
  28053. private readonly _result;
  28054. protected _onClear(): void;
  28055. protected _onArriveAtFrame(): void;
  28056. protected _onUpdateFrame(): void;
  28057. init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void;
  28058. fadeOut(): void;
  28059. update(passedTime: number): void;
  28060. }
  28061. /**
  28062. * @internal
  28063. * @private
  28064. */
  28065. class IKConstraintTimelineState extends ConstraintTimelineState {
  28066. static toString(): string;
  28067. private _current;
  28068. private _delta;
  28069. protected _onClear(): void;
  28070. protected _onArriveAtFrame(): void;
  28071. protected _onUpdateFrame(): void;
  28072. }
  28073. /**
  28074. * @internal
  28075. * @private
  28076. */
  28077. class AnimationTimelineState extends TweenTimelineState {
  28078. static toString(): string;
  28079. animationState: AnimationState;
  28080. private readonly _floats;
  28081. protected _onClear(): void;
  28082. protected _onArriveAtFrame(): void;
  28083. protected _onUpdateFrame(): void;
  28084. blend(state: number): void;
  28085. }
  28086. }
  28087. /**
  28088. * The MIT License (MIT)
  28089. *
  28090. * Copyright (c) 2012-2017 DragonBones team and other contributors
  28091. *
  28092. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  28093. * this software and associated documentation files (the "Software"), to deal in
  28094. * the Software without restriction, including without limitation the rights to
  28095. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  28096. * the Software, and to permit persons to whom the Software is furnished to do so,
  28097. * subject to the following conditions:
  28098. *
  28099. * The above copyright notice and this permission notice shall be included in all
  28100. * copies or substantial portions of the Software.
  28101. *
  28102. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  28103. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  28104. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  28105. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  28106. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  28107. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28108. */
  28109. declare namespace dragonBones {
  28110. /**
  28111. * - The properties of the object carry basic information about an event,
  28112. * which are passed as parameter or parameter's parameter to event listeners when an event occurs.
  28113. * @version DragonBones 4.5
  28114. * @language en_US
  28115. */
  28116. /**
  28117. * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。
  28118. * @version DragonBones 4.5
  28119. * @language zh_CN
  28120. */
  28121. class EventObject extends BaseObject {
  28122. /**
  28123. * - Animation start play.
  28124. * @version DragonBones 4.5
  28125. * @language en_US
  28126. */
  28127. /**
  28128. * - 动画开始播放。
  28129. * @version DragonBones 4.5
  28130. * @language zh_CN
  28131. */
  28132. static readonly START: string;
  28133. /**
  28134. * - Animation loop play complete once.
  28135. * @version DragonBones 4.5
  28136. * @language en_US
  28137. */
  28138. /**
  28139. * - 动画循环播放完成一次。
  28140. * @version DragonBones 4.5
  28141. * @language zh_CN
  28142. */
  28143. static readonly LOOP_COMPLETE: string;
  28144. /**
  28145. * - Animation play complete.
  28146. * @version DragonBones 4.5
  28147. * @language en_US
  28148. */
  28149. /**
  28150. * - 动画播放完成。
  28151. * @version DragonBones 4.5
  28152. * @language zh_CN
  28153. */
  28154. static readonly COMPLETE: string;
  28155. /**
  28156. * - Animation fade in start.
  28157. * @version DragonBones 4.5
  28158. * @language en_US
  28159. */
  28160. /**
  28161. * - 动画淡入开始。
  28162. * @version DragonBones 4.5
  28163. * @language zh_CN
  28164. */
  28165. static readonly FADE_IN: string;
  28166. /**
  28167. * - Animation fade in complete.
  28168. * @version DragonBones 4.5
  28169. * @language en_US
  28170. */
  28171. /**
  28172. * - 动画淡入完成。
  28173. * @version DragonBones 4.5
  28174. * @language zh_CN
  28175. */
  28176. static readonly FADE_IN_COMPLETE: string;
  28177. /**
  28178. * - Animation fade out start.
  28179. * @version DragonBones 4.5
  28180. * @language en_US
  28181. */
  28182. /**
  28183. * - 动画淡出开始。
  28184. * @version DragonBones 4.5
  28185. * @language zh_CN
  28186. */
  28187. static readonly FADE_OUT: string;
  28188. /**
  28189. * - Animation fade out complete.
  28190. * @version DragonBones 4.5
  28191. * @language en_US
  28192. */
  28193. /**
  28194. * - 动画淡出完成。
  28195. * @version DragonBones 4.5
  28196. * @language zh_CN
  28197. */
  28198. static readonly FADE_OUT_COMPLETE: string;
  28199. /**
  28200. * - Animation frame event.
  28201. * @version DragonBones 4.5
  28202. * @language en_US
  28203. */
  28204. /**
  28205. * - 动画帧事件。
  28206. * @version DragonBones 4.5
  28207. * @language zh_CN
  28208. */
  28209. static readonly FRAME_EVENT: string;
  28210. /**
  28211. * - Animation frame sound event.
  28212. * @version DragonBones 4.5
  28213. * @language en_US
  28214. */
  28215. /**
  28216. * - 动画帧声音事件。
  28217. * @version DragonBones 4.5
  28218. * @language zh_CN
  28219. */
  28220. static readonly SOUND_EVENT: string;
  28221. static toString(): string;
  28222. /**
  28223. * - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds)
  28224. * @version DragonBones 4.5
  28225. * @language en_US
  28226. */
  28227. /**
  28228. * - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位)
  28229. * @version DragonBones 4.5
  28230. * @language zh_CN
  28231. */
  28232. time: number;
  28233. /**
  28234. * - The event type。
  28235. * @version DragonBones 4.5
  28236. * @language en_US
  28237. */
  28238. /**
  28239. * - 事件类型。
  28240. * @version DragonBones 4.5
  28241. * @language zh_CN
  28242. */
  28243. type: EventStringType;
  28244. /**
  28245. * - The event name. (The frame event name or the frame sound name)
  28246. * @version DragonBones 4.5
  28247. * @language en_US
  28248. */
  28249. /**
  28250. * - 事件名称。 (帧事件的名称或帧声音的名称)
  28251. * @version DragonBones 4.5
  28252. * @language zh_CN
  28253. */
  28254. name: string;
  28255. /**
  28256. * - The armature that dispatch the event.
  28257. * @see dragonBones.Armature
  28258. * @version DragonBones 4.5
  28259. * @language en_US
  28260. */
  28261. /**
  28262. * - 发出该事件的骨架。
  28263. * @see dragonBones.Armature
  28264. * @version DragonBones 4.5
  28265. * @language zh_CN
  28266. */
  28267. armature: Armature;
  28268. /**
  28269. * - The bone that dispatch the event.
  28270. * @see dragonBones.Bone
  28271. * @version DragonBones 4.5
  28272. * @language en_US
  28273. */
  28274. /**
  28275. * - 发出该事件的骨骼。
  28276. * @see dragonBones.Bone
  28277. * @version DragonBones 4.5
  28278. * @language zh_CN
  28279. */
  28280. bone: Bone | null;
  28281. /**
  28282. * - The slot that dispatch the event.
  28283. * @see dragonBones.Slot
  28284. * @version DragonBones 4.5
  28285. * @language en_US
  28286. */
  28287. /**
  28288. * - 发出该事件的插槽。
  28289. * @see dragonBones.Slot
  28290. * @version DragonBones 4.5
  28291. * @language zh_CN
  28292. */
  28293. slot: Slot | null;
  28294. /**
  28295. * - The animation state that dispatch the event.
  28296. * @see dragonBones.AnimationState
  28297. * @version DragonBones 4.5
  28298. * @language en_US
  28299. */
  28300. /**
  28301. * - 发出该事件的动画状态。
  28302. * @see dragonBones.AnimationState
  28303. * @version DragonBones 4.5
  28304. * @language zh_CN
  28305. */
  28306. animationState: AnimationState;
  28307. /**
  28308. * - The custom data.
  28309. * @see dragonBones.CustomData
  28310. * @version DragonBones 5.0
  28311. * @language en_US
  28312. */
  28313. /**
  28314. * - 自定义数据。
  28315. * @see dragonBones.CustomData
  28316. * @version DragonBones 5.0
  28317. * @language zh_CN
  28318. */
  28319. data: UserData | null;
  28320. /**
  28321. * @private
  28322. */
  28323. protected _onClear(): void;
  28324. }
  28325. }
  28326. /**
  28327. * The MIT License (MIT)
  28328. *
  28329. * Copyright (c) 2012-2017 DragonBones team and other contributors
  28330. *
  28331. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  28332. * this software and associated documentation files (the "Software"), to deal in
  28333. * the Software without restriction, including without limitation the rights to
  28334. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  28335. * the Software, and to permit persons to whom the Software is furnished to do so,
  28336. * subject to the following conditions:
  28337. *
  28338. * The above copyright notice and this permission notice shall be included in all
  28339. * copies or substantial portions of the Software.
  28340. *
  28341. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  28342. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  28343. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  28344. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  28345. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  28346. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28347. */
  28348. declare namespace dragonBones {
  28349. /**
  28350. * @private
  28351. */
  28352. type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent";
  28353. /**
  28354. * - The event dispatcher interface.
  28355. * Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine.
  28356. * @version DragonBones 4.5
  28357. * @language en_US
  28358. */
  28359. /**
  28360. * - 事件派发接口。
  28361. * DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。
  28362. * @version DragonBones 4.5
  28363. * @language zh_CN
  28364. */
  28365. interface IEventDispatcher {
  28366. /**
  28367. * - Checks whether the object has any listeners registered for a specific type of event。
  28368. * @param type - Event type.
  28369. * @version DragonBones 4.5
  28370. * @language en_US
  28371. */
  28372. /**
  28373. * - 检查是否为特定的事件类型注册了任何侦听器。
  28374. * @param type - 事件类型。
  28375. * @version DragonBones 4.5
  28376. * @language zh_CN
  28377. */
  28378. hasDBEventListener(type: EventStringType): boolean;
  28379. /**
  28380. * - Dispatches an event into the event flow.
  28381. * @param type - Event type.
  28382. * @param eventObject - Event object.
  28383. * @see dragonBones.EventObject
  28384. * @version DragonBones 4.5
  28385. * @language en_US
  28386. */
  28387. /**
  28388. * - 分派特定的事件到事件流中。
  28389. * @param type - 事件类型。
  28390. * @param eventObject - 事件数据。
  28391. * @see dragonBones.EventObject
  28392. * @version DragonBones 4.5
  28393. * @language zh_CN
  28394. */
  28395. dispatchDBEvent(type: EventStringType, eventObject: EventObject): void;
  28396. /**
  28397. * - Add an event listener object so that the listener receives notification of an event.
  28398. * @param type - Event type.
  28399. * @param listener - Event listener.
  28400. * @param thisObject - The listener function's "this".
  28401. * @version DragonBones 4.5
  28402. * @language en_US
  28403. */
  28404. /**
  28405. * - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。
  28406. * @param type - 事件类型。
  28407. * @param listener - 事件侦听器。
  28408. * @param thisObject - 侦听函数绑定的 this 对象。
  28409. * @version DragonBones 4.5
  28410. * @language zh_CN
  28411. */
  28412. addDBEventListener(type: EventStringType, listener: Function, thisObject: any): void;
  28413. /**
  28414. * - Removes a listener from the object.
  28415. * @param type - Event type.
  28416. * @param listener - Event listener.
  28417. * @param thisObject - The listener function's "this".
  28418. * @version DragonBones 4.5
  28419. * @language en_US
  28420. */
  28421. /**
  28422. * - 删除特定事件类型的侦听器。
  28423. * @param type - 事件类型。
  28424. * @param listener - 事件侦听器。
  28425. * @param thisObject - 侦听函数绑定的 this 对象。
  28426. * @version DragonBones 4.5
  28427. * @language zh_CN
  28428. */
  28429. removeDBEventListener(type: EventStringType, listener: Function, thisObject: any): void;
  28430. /**
  28431. * - Deprecated, please refer to {@link #hasDBEventListener()}.
  28432. * @deprecated
  28433. * @language en_US
  28434. */
  28435. /**
  28436. * - 已废弃,请参考 {@link #hasDBEventListener()}。
  28437. * @deprecated
  28438. * @language zh_CN
  28439. */
  28440. hasEvent(type: EventStringType): boolean;
  28441. /**
  28442. * - Deprecated, please refer to {@link #addDBEventListener()}.
  28443. * @deprecated
  28444. * @language en_US
  28445. */
  28446. /**
  28447. * - 已废弃,请参考 {@link #addDBEventListener()}。
  28448. * @deprecated
  28449. * @language zh_CN
  28450. */
  28451. addEvent(type: EventStringType, listener: Function, thisObject: any): void;
  28452. /**
  28453. * - Deprecated, please refer to {@link #removeDBEventListener()}.
  28454. * @deprecated
  28455. * @language en_US
  28456. */
  28457. /**
  28458. * - 已废弃,请参考 {@link #removeDBEventListener()}。
  28459. * @deprecated
  28460. * @language zh_CN
  28461. */
  28462. removeEvent(type: EventStringType, listener: Function, thisObject: any): void;
  28463. }
  28464. }
  28465. /**
  28466. * The MIT License (MIT)
  28467. *
  28468. * Copyright (c) 2012-2017 DragonBones team and other contributors
  28469. *
  28470. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  28471. * this software and associated documentation files (the "Software"), to deal in
  28472. * the Software without restriction, including without limitation the rights to
  28473. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  28474. * the Software, and to permit persons to whom the Software is furnished to do so,
  28475. * subject to the following conditions:
  28476. *
  28477. * The above copyright notice and this permission notice shall be included in all
  28478. * copies or substantial portions of the Software.
  28479. *
  28480. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  28481. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  28482. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  28483. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  28484. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  28485. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28486. */
  28487. declare namespace dragonBones {
  28488. /**
  28489. * @internal
  28490. * @private
  28491. */
  28492. abstract class DataParser {
  28493. protected static readonly DATA_VERSION_2_3: string;
  28494. protected static readonly DATA_VERSION_3_0: string;
  28495. protected static readonly DATA_VERSION_4_0: string;
  28496. protected static readonly DATA_VERSION_4_5: string;
  28497. protected static readonly DATA_VERSION_5_0: string;
  28498. protected static readonly DATA_VERSION_5_5: string;
  28499. protected static readonly DATA_VERSION: string;
  28500. protected static readonly DATA_VERSIONS: Array<string>;
  28501. protected static readonly TEXTURE_ATLAS: string;
  28502. protected static readonly SUB_TEXTURE: string;
  28503. protected static readonly FORMAT: string;
  28504. protected static readonly IMAGE_PATH: string;
  28505. protected static readonly WIDTH: string;
  28506. protected static readonly HEIGHT: string;
  28507. protected static readonly ROTATED: string;
  28508. protected static readonly FRAME_X: string;
  28509. protected static readonly FRAME_Y: string;
  28510. protected static readonly FRAME_WIDTH: string;
  28511. protected static readonly FRAME_HEIGHT: string;
  28512. protected static readonly DRADON_BONES: string;
  28513. protected static readonly USER_DATA: string;
  28514. protected static readonly ARMATURE: string;
  28515. protected static readonly BONE: string;
  28516. protected static readonly SURFACE: string;
  28517. protected static readonly SLOT: string;
  28518. protected static readonly CONSTRAINT: string;
  28519. protected static readonly IK: string;
  28520. protected static readonly SKIN: string;
  28521. protected static readonly DISPLAY: string;
  28522. protected static readonly ANIMATION: string;
  28523. protected static readonly Z_ORDER: string;
  28524. protected static readonly FFD: string;
  28525. protected static readonly FRAME: string;
  28526. protected static readonly TRANSLATE_FRAME: string;
  28527. protected static readonly ROTATE_FRAME: string;
  28528. protected static readonly SCALE_FRAME: string;
  28529. protected static readonly DISPLAY_FRAME: string;
  28530. protected static readonly COLOR_FRAME: string;
  28531. protected static readonly DEFAULT_ACTIONS: string;
  28532. protected static readonly ACTIONS: string;
  28533. protected static readonly EVENTS: string;
  28534. protected static readonly INTS: string;
  28535. protected static readonly FLOATS: string;
  28536. protected static readonly STRINGS: string;
  28537. protected static readonly CANVAS: string;
  28538. protected static readonly TRANSFORM: string;
  28539. protected static readonly PIVOT: string;
  28540. protected static readonly AABB: string;
  28541. protected static readonly COLOR: string;
  28542. protected static readonly VERSION: string;
  28543. protected static readonly COMPATIBLE_VERSION: string;
  28544. protected static readonly FRAME_RATE: string;
  28545. protected static readonly TYPE: string;
  28546. protected static readonly SUB_TYPE: string;
  28547. protected static readonly NAME: string;
  28548. protected static readonly PARENT: string;
  28549. protected static readonly TARGET: string;
  28550. protected static readonly STAGE: string;
  28551. protected static readonly SHARE: string;
  28552. protected static readonly PATH: string;
  28553. protected static readonly LENGTH: string;
  28554. protected static readonly DISPLAY_INDEX: string;
  28555. protected static readonly BLEND_MODE: string;
  28556. protected static readonly INHERIT_TRANSLATION: string;
  28557. protected static readonly INHERIT_ROTATION: string;
  28558. protected static readonly INHERIT_SCALE: string;
  28559. protected static readonly INHERIT_REFLECTION: string;
  28560. protected static readonly INHERIT_ANIMATION: string;
  28561. protected static readonly INHERIT_DEFORM: string;
  28562. protected static readonly SEGMENT_X: string;
  28563. protected static readonly SEGMENT_Y: string;
  28564. protected static readonly BEND_POSITIVE: string;
  28565. protected static readonly CHAIN: string;
  28566. protected static readonly WEIGHT: string;
  28567. protected static readonly FADE_IN_TIME: string;
  28568. protected static readonly PLAY_TIMES: string;
  28569. protected static readonly SCALE: string;
  28570. protected static readonly OFFSET: string;
  28571. protected static readonly POSITION: string;
  28572. protected static readonly DURATION: string;
  28573. protected static readonly TWEEN_EASING: string;
  28574. protected static readonly TWEEN_ROTATE: string;
  28575. protected static readonly TWEEN_SCALE: string;
  28576. protected static readonly CLOCK_WISE: string;
  28577. protected static readonly CURVE: string;
  28578. protected static readonly SOUND: string;
  28579. protected static readonly EVENT: string;
  28580. protected static readonly ACTION: string;
  28581. protected static readonly X: string;
  28582. protected static readonly Y: string;
  28583. protected static readonly SKEW_X: string;
  28584. protected static readonly SKEW_Y: string;
  28585. protected static readonly SCALE_X: string;
  28586. protected static readonly SCALE_Y: string;
  28587. protected static readonly VALUE: string;
  28588. protected static readonly ROTATE: string;
  28589. protected static readonly SKEW: string;
  28590. protected static readonly ALPHA_OFFSET: string;
  28591. protected static readonly RED_OFFSET: string;
  28592. protected static readonly GREEN_OFFSET: string;
  28593. protected static readonly BLUE_OFFSET: string;
  28594. protected static readonly ALPHA_MULTIPLIER: string;
  28595. protected static readonly RED_MULTIPLIER: string;
  28596. protected static readonly GREEN_MULTIPLIER: string;
  28597. protected static readonly BLUE_MULTIPLIER: string;
  28598. protected static readonly UVS: string;
  28599. protected static readonly VERTICES: string;
  28600. protected static readonly TRIANGLES: string;
  28601. protected static readonly WEIGHTS: string;
  28602. protected static readonly SLOT_POSE: string;
  28603. protected static readonly BONE_POSE: string;
  28604. protected static readonly GLUE_WEIGHTS: string;
  28605. protected static readonly GLUE_MESHES: string;
  28606. protected static readonly GOTO_AND_PLAY: string;
  28607. protected static readonly DEFAULT_NAME: string;
  28608. protected static _getArmatureType(value: string): ArmatureType;
  28609. protected static _getBoneType(value: string): BoneType;
  28610. protected static _getDisplayType(value: string): DisplayType;
  28611. protected static _getBoundingBoxType(value: string): BoundingBoxType;
  28612. protected static _getActionType(value: string): ActionType;
  28613. protected static _getBlendMode(value: string): BlendMode;
  28614. abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null;
  28615. abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean;
  28616. /**
  28617. * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}.
  28618. * @deprecated
  28619. * @language en_US
  28620. */
  28621. /**
  28622. * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。
  28623. * @deprecated
  28624. * @language zh_CN
  28625. */
  28626. static parseDragonBonesData(rawData: any): DragonBonesData | null;
  28627. /**
  28628. * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}.
  28629. * @deprecated
  28630. * @language en_US
  28631. */
  28632. /**
  28633. * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。
  28634. * @deprecated
  28635. * @language zh_CN
  28636. */
  28637. static parseTextureAtlasData(rawData: any, scale?: number): any;
  28638. }
  28639. }
  28640. /**
  28641. * The MIT License (MIT)
  28642. *
  28643. * Copyright (c) 2012-2017 DragonBones team and other contributors
  28644. *
  28645. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  28646. * this software and associated documentation files (the "Software"), to deal in
  28647. * the Software without restriction, including without limitation the rights to
  28648. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  28649. * the Software, and to permit persons to whom the Software is furnished to do so,
  28650. * subject to the following conditions:
  28651. *
  28652. * The above copyright notice and this permission notice shall be included in all
  28653. * copies or substantial portions of the Software.
  28654. *
  28655. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  28656. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  28657. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  28658. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  28659. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  28660. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28661. */
  28662. declare namespace dragonBones {
  28663. /**
  28664. * @internal
  28665. * @private
  28666. */
  28667. class ObjectDataParser extends DataParser {
  28668. protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean;
  28669. protected static _getNumber(rawData: any, key: string, defaultValue: number): number;
  28670. protected static _getString(rawData: any, key: string, defaultValue: string): string;
  28671. protected _rawTextureAtlasIndex: number;
  28672. protected readonly _rawBones: Array<BoneData>;
  28673. protected _data: DragonBonesData;
  28674. protected _armature: ArmatureData;
  28675. protected _bone: BoneData;
  28676. protected _surface: SurfaceData;
  28677. protected _slot: SlotData;
  28678. protected _skin: SkinData;
  28679. protected _mesh: MeshDisplayData;
  28680. protected _animation: AnimationData;
  28681. protected _timeline: TimelineData;
  28682. protected _rawTextureAtlases: Array<any> | null;
  28683. private _defaultColorOffset;
  28684. private _prevClockwise;
  28685. private _prevRotation;
  28686. private readonly _helpMatrixA;
  28687. private readonly _helpMatrixB;
  28688. private readonly _helpTransform;
  28689. private readonly _helpColorTransform;
  28690. private readonly _helpPoint;
  28691. private readonly _helpArray;
  28692. private readonly _intArray;
  28693. private readonly _floatArray;
  28694. private readonly _frameIntArray;
  28695. private readonly _frameFloatArray;
  28696. private readonly _frameArray;
  28697. private readonly _timelineArray;
  28698. private readonly _cacheRawMeshes;
  28699. private readonly _cacheMeshes;
  28700. private readonly _actionFrames;
  28701. private readonly _weightSlotPose;
  28702. private readonly _weightBonePoses;
  28703. private readonly _cacheBones;
  28704. private readonly _slotChildActions;
  28705. private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result);
  28706. private _samplingEasingCurve(curve, samples);
  28707. private _parseActionDataInFrame(rawData, frameStart, bone, slot);
  28708. private _mergeActionFrame(rawData, frameStart, type, bone, slot);
  28709. protected _parseArmature(rawData: any, scale: number): ArmatureData;
  28710. protected _parseBone(rawData: any): BoneData;
  28711. protected _parseIKConstraint(rawData: any): ConstraintData | null;
  28712. protected _parseSlot(rawData: any, zOrder: number): SlotData;
  28713. protected _parseSkin(rawData: any): SkinData;
  28714. protected _parseDisplay(rawData: any): DisplayData | null;
  28715. protected _parsePivot(rawData: any, display: ImageDisplayData): void;
  28716. protected _parseMesh(rawData: any, mesh: MeshDisplayData): void;
  28717. protected _parseMeshGlue(rawData: any, mesh: MeshDisplayData): void;
  28718. protected _parseBoundingBox(rawData: any): BoundingBoxData | null;
  28719. protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData;
  28720. protected _parseAnimation(rawData: any): AnimationData;
  28721. protected _parseTimeline(rawData: any, rawFrames: Array<any> | null, framesKey: string, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null;
  28722. protected _parseBoneTimeline(rawData: any): void;
  28723. protected _parseSlotTimeline(rawData: any): void;
  28724. protected _parseFrame(rawData: any, frameStart: number, frameCount: number): number;
  28725. protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number): number;
  28726. protected _parseActionFrame(frame: ActionFrame, frameStart: number, frameCount: number): number;
  28727. protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number;
  28728. protected _parseBoneAllFrame(rawData: any, frameStart: number, frameCount: number): number;
  28729. protected _parseBoneTranslateFrame(rawData: any, frameStart: number, frameCount: number): number;
  28730. protected _parseBoneRotateFrame(rawData: any, frameStart: number, frameCount: number): number;
  28731. protected _parseBoneScaleFrame(rawData: any, frameStart: number, frameCount: number): number;
  28732. protected _parseSurfaceFrame(rawData: any, frameStart: number, frameCount: number): number;
  28733. protected _parseSlotDisplayFrame(rawData: any, frameStart: number, frameCount: number): number;
  28734. protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number;
  28735. protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number;
  28736. protected _parseIKConstraintFrame(rawData: any, frameStart: number, frameCount: number): number;
  28737. protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): number;
  28738. protected _parseActionData(rawData: any, type: ActionType, bone: BoneData | null, slot: SlotData | null): Array<ActionData>;
  28739. protected _parseTransform(rawData: any, transform: Transform, scale: number): void;
  28740. protected _parseColorTransform(rawData: any, color: ColorTransform): void;
  28741. protected _parseArray(rawData: any): void;
  28742. protected _modifyArray(): void;
  28743. parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null;
  28744. parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean;
  28745. private static _objectDataParserInstance;
  28746. /**
  28747. * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}.
  28748. * @deprecated
  28749. * @language en_US
  28750. */
  28751. /**
  28752. * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。
  28753. * @deprecated
  28754. * @language zh_CN
  28755. */
  28756. static getInstance(): ObjectDataParser;
  28757. }
  28758. /**
  28759. * @internal
  28760. * @private
  28761. */
  28762. class ActionFrame {
  28763. frameStart: number;
  28764. readonly actions: Array<number>;
  28765. }
  28766. }
  28767. /**
  28768. * The MIT License (MIT)
  28769. *
  28770. * Copyright (c) 2012-2017 DragonBones team and other contributors
  28771. *
  28772. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  28773. * this software and associated documentation files (the "Software"), to deal in
  28774. * the Software without restriction, including without limitation the rights to
  28775. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  28776. * the Software, and to permit persons to whom the Software is furnished to do so,
  28777. * subject to the following conditions:
  28778. *
  28779. * The above copyright notice and this permission notice shall be included in all
  28780. * copies or substantial portions of the Software.
  28781. *
  28782. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  28783. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  28784. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  28785. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  28786. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  28787. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28788. */
  28789. declare namespace dragonBones {
  28790. /**
  28791. * @internal
  28792. * @private
  28793. */
  28794. class BinaryDataParser extends ObjectDataParser {
  28795. private _binaryOffset;
  28796. private _binary;
  28797. private _intArrayBuffer;
  28798. private _floatArrayBuffer;
  28799. private _frameIntArrayBuffer;
  28800. private _frameFloatArrayBuffer;
  28801. private _frameArrayBuffer;
  28802. private _timelineArrayBuffer;
  28803. private _inRange(a, min, max);
  28804. private _decodeUTF8(data);
  28805. private _getUTF16Key(value);
  28806. private _parseBinaryTimeline(type, offset, timelineData?);
  28807. protected _parseMesh(rawData: any, mesh: MeshDisplayData): void;
  28808. protected _parseAnimation(rawData: any): AnimationData;
  28809. protected _parseArray(rawData: any): void;
  28810. parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null;
  28811. private static _binaryDataParserInstance;
  28812. /**
  28813. * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}.
  28814. * @deprecated
  28815. * @language en_US
  28816. */
  28817. /**
  28818. * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。
  28819. * @deprecated
  28820. * @language zh_CN
  28821. */
  28822. static getInstance(): BinaryDataParser;
  28823. }
  28824. }
  28825. /**
  28826. * The MIT License (MIT)
  28827. *
  28828. * Copyright (c) 2012-2017 DragonBones team and other contributors
  28829. *
  28830. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  28831. * this software and associated documentation files (the "Software"), to deal in
  28832. * the Software without restriction, including without limitation the rights to
  28833. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  28834. * the Software, and to permit persons to whom the Software is furnished to do so,
  28835. * subject to the following conditions:
  28836. *
  28837. * The above copyright notice and this permission notice shall be included in all
  28838. * copies or substantial portions of the Software.
  28839. *
  28840. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  28841. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  28842. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  28843. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  28844. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  28845. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28846. */
  28847. declare namespace dragonBones {
  28848. /**
  28849. * - Base class for the factory that create the armatures. (Typically only one global factory instance is required)
  28850. * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances.
  28851. * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance.
  28852. * @see dragonBones.DragonBonesData
  28853. * @see dragonBones.TextureAtlasData
  28854. * @see dragonBones.ArmatureData
  28855. * @see dragonBones.Armature
  28856. * @version DragonBones 3.0
  28857. * @language en_US
  28858. */
  28859. /**
  28860. * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例)
  28861. * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。
  28862. * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。
  28863. * @see dragonBones.DragonBonesData
  28864. * @see dragonBones.TextureAtlasData
  28865. * @see dragonBones.ArmatureData
  28866. * @see dragonBones.Armature
  28867. * @version DragonBones 3.0
  28868. * @language zh_CN
  28869. */
  28870. abstract class BaseFactory {
  28871. /**
  28872. * @private
  28873. */
  28874. protected static _objectParser: ObjectDataParser;
  28875. /**
  28876. * @private
  28877. */
  28878. protected static _binaryParser: BinaryDataParser;
  28879. /**
  28880. * @private
  28881. */
  28882. autoSearch: boolean;
  28883. /**
  28884. * @private
  28885. */
  28886. protected readonly _dragonBonesDataMap: Map<DragonBonesData>;
  28887. /**
  28888. * @private
  28889. */
  28890. protected readonly _textureAtlasDataMap: Map<Array<TextureAtlasData>>;
  28891. /**
  28892. * @private
  28893. */
  28894. protected _dragonBones: DragonBones;
  28895. /**
  28896. * @private
  28897. */
  28898. protected _dataParser: DataParser;
  28899. /**
  28900. * - Create a factory instance. (typically only one global factory instance is required)
  28901. * @version DragonBones 3.0
  28902. * @language en_US
  28903. */
  28904. /**
  28905. * - 创建一个工厂实例。 (通常只需要一个全局工厂实例)
  28906. * @version DragonBones 3.0
  28907. * @language zh_CN
  28908. */
  28909. constructor(dataParser?: DataParser | null);
  28910. /**
  28911. * @private
  28912. */
  28913. protected _isSupportMesh(): boolean;
  28914. /**
  28915. * @private
  28916. */
  28917. protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null;
  28918. /**
  28919. * @private
  28920. */
  28921. protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean;
  28922. /**
  28923. * @private
  28924. */
  28925. protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void;
  28926. /**
  28927. * @private
  28928. */
  28929. protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void;
  28930. /**
  28931. * @private
  28932. */
  28933. protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: DisplayData): Armature | null;
  28934. /**
  28935. * @private
  28936. */
  28937. protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any;
  28938. /**
  28939. * @private
  28940. */
  28941. protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData;
  28942. /**
  28943. * @private
  28944. */
  28945. protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature;
  28946. /**
  28947. * @private
  28948. */
  28949. protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array<DisplayData | null> | null, armature: Armature): Slot;
  28950. /**
  28951. * - Parse the raw data to a DragonBonesData instance and cache it to the factory.
  28952. * @param rawData - The raw data.
  28953. * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead)
  28954. * @param scale - Specify a scaling value for all armatures. (Default: 1.0)
  28955. * @returns DragonBonesData instance
  28956. * @see #getDragonBonesData()
  28957. * @see #addDragonBonesData()
  28958. * @see #removeDragonBonesData()
  28959. * @see dragonBones.DragonBonesData
  28960. * @version DragonBones 4.5
  28961. * @language en_US
  28962. */
  28963. /**
  28964. * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。
  28965. * @param rawData - 原始数据。
  28966. * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称)
  28967. * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0)
  28968. * @returns DragonBonesData 实例
  28969. * @see #getDragonBonesData()
  28970. * @see #addDragonBonesData()
  28971. * @see #removeDragonBonesData()
  28972. * @see dragonBones.DragonBonesData
  28973. * @version DragonBones 4.5
  28974. * @language zh_CN
  28975. */
  28976. parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null;
  28977. /**
  28978. * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory.
  28979. * @param rawData - The raw texture atlas data.
  28980. * @param textureAtlas - The texture atlas object.
  28981. * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead)
  28982. * @param scale - Specify a scaling value for the map set. (Default: 1.0)
  28983. * @returns TextureAtlasData instance
  28984. * @see #getTextureAtlasData()
  28985. * @see #addTextureAtlasData()
  28986. * @see #removeTextureAtlasData()
  28987. * @see dragonBones.TextureAtlasData
  28988. * @version DragonBones 4.5
  28989. * @language en_US
  28990. */
  28991. /**
  28992. * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。
  28993. * @param rawData - 原始贴图集数据。
  28994. * @param textureAtlas - 贴图集对象。
  28995. * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称)
  28996. * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0)
  28997. * @returns TextureAtlasData 实例
  28998. * @see #getTextureAtlasData()
  28999. * @see #addTextureAtlasData()
  29000. * @see #removeTextureAtlasData()
  29001. * @see dragonBones.TextureAtlasData
  29002. * @version DragonBones 4.5
  29003. * @language zh_CN
  29004. */
  29005. parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData;
  29006. /**
  29007. * @private
  29008. */
  29009. updateTextureAtlasData(name: string, textureAtlases: Array<any>): void;
  29010. /**
  29011. * - Get a specific DragonBonesData instance.
  29012. * @param name - The DragonBonesData instance cache name.
  29013. * @returns DragonBonesData instance
  29014. * @see #parseDragonBonesData()
  29015. * @see #addDragonBonesData()
  29016. * @see #removeDragonBonesData()
  29017. * @see dragonBones.DragonBonesData
  29018. * @version DragonBones 3.0
  29019. * @language en_US
  29020. */
  29021. /**
  29022. * - 获取特定的 DragonBonesData 实例。
  29023. * @param name - DragonBonesData 实例的缓存名称。
  29024. * @returns DragonBonesData 实例
  29025. * @see #parseDragonBonesData()
  29026. * @see #addDragonBonesData()
  29027. * @see #removeDragonBonesData()
  29028. * @see dragonBones.DragonBonesData
  29029. * @version DragonBones 3.0
  29030. * @language zh_CN
  29031. */
  29032. getDragonBonesData(name: string): DragonBonesData | null;
  29033. /**
  29034. * - Cache a DragonBonesData instance to the factory.
  29035. * @param data - The DragonBonesData instance.
  29036. * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead)
  29037. * @see #parseDragonBonesData()
  29038. * @see #getDragonBonesData()
  29039. * @see #removeDragonBonesData()
  29040. * @see dragonBones.DragonBonesData
  29041. * @version DragonBones 3.0
  29042. * @language en_US
  29043. */
  29044. /**
  29045. * - 将 DragonBonesData 实例缓存到工厂中。
  29046. * @param data - DragonBonesData 实例。
  29047. * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称)
  29048. * @see #parseDragonBonesData()
  29049. * @see #getDragonBonesData()
  29050. * @see #removeDragonBonesData()
  29051. * @see dragonBones.DragonBonesData
  29052. * @version DragonBones 3.0
  29053. * @language zh_CN
  29054. */
  29055. addDragonBonesData(data: DragonBonesData, name?: string | null): void;
  29056. /**
  29057. * - Remove a DragonBonesData instance.
  29058. * @param name - The DragonBonesData instance cache name.
  29059. * @param disposeData - Whether to dispose data. (Default: true)
  29060. * @see #parseDragonBonesData()
  29061. * @see #getDragonBonesData()
  29062. * @see #addDragonBonesData()
  29063. * @see dragonBones.DragonBonesData
  29064. * @version DragonBones 3.0
  29065. * @language en_US
  29066. */
  29067. /**
  29068. * - 移除 DragonBonesData 实例。
  29069. * @param name - DragonBonesData 实例缓存名称。
  29070. * @param disposeData - 是否释放数据。 (默认: true)
  29071. * @see #parseDragonBonesData()
  29072. * @see #getDragonBonesData()
  29073. * @see #addDragonBonesData()
  29074. * @see dragonBones.DragonBonesData
  29075. * @version DragonBones 3.0
  29076. * @language zh_CN
  29077. */
  29078. removeDragonBonesData(name: string, disposeData?: boolean): void;
  29079. /**
  29080. * - Get a list of specific TextureAtlasData instances.
  29081. * @param name - The TextureAtlasData cahce name.
  29082. * @see #parseTextureAtlasData()
  29083. * @see #addTextureAtlasData()
  29084. * @see #removeTextureAtlasData()
  29085. * @see dragonBones.TextureAtlasData
  29086. * @version DragonBones 3.0
  29087. * @language en_US
  29088. */
  29089. /**
  29090. * - 获取特定的 TextureAtlasData 实例列表。
  29091. * @param name - TextureAtlasData 实例缓存名称。
  29092. * @see #parseTextureAtlasData()
  29093. * @see #addTextureAtlasData()
  29094. * @see #removeTextureAtlasData()
  29095. * @see dragonBones.TextureAtlasData
  29096. * @version DragonBones 3.0
  29097. * @language zh_CN
  29098. */
  29099. getTextureAtlasData(name: string): Array<TextureAtlasData> | null;
  29100. /**
  29101. * - Cache a TextureAtlasData instance to the factory.
  29102. * @param data - The TextureAtlasData instance.
  29103. * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead)
  29104. * @see #parseTextureAtlasData()
  29105. * @see #getTextureAtlasData()
  29106. * @see #removeTextureAtlasData()
  29107. * @see dragonBones.TextureAtlasData
  29108. * @version DragonBones 3.0
  29109. * @language en_US
  29110. */
  29111. /**
  29112. * - 将 TextureAtlasData 实例缓存到工厂中。
  29113. * @param data - TextureAtlasData 实例。
  29114. * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称)
  29115. * @see #parseTextureAtlasData()
  29116. * @see #getTextureAtlasData()
  29117. * @see #removeTextureAtlasData()
  29118. * @see dragonBones.TextureAtlasData
  29119. * @version DragonBones 3.0
  29120. * @language zh_CN
  29121. */
  29122. addTextureAtlasData(data: TextureAtlasData, name?: string | null): void;
  29123. /**
  29124. * - Remove a TextureAtlasData instance.
  29125. * @param name - The TextureAtlasData instance cache name.
  29126. * @param disposeData - Whether to dispose data.
  29127. * @see #parseTextureAtlasData()
  29128. * @see #getTextureAtlasData()
  29129. * @see #addTextureAtlasData()
  29130. * @see dragonBones.TextureAtlasData
  29131. * @version DragonBones 3.0
  29132. * @language en_US
  29133. */
  29134. /**
  29135. * - 移除 TextureAtlasData 实例。
  29136. * @param name - TextureAtlasData 实例的缓存名称。
  29137. * @param disposeData - 是否释放数据。
  29138. * @see #parseTextureAtlasData()
  29139. * @see #getTextureAtlasData()
  29140. * @see #addTextureAtlasData()
  29141. * @see dragonBones.TextureAtlasData
  29142. * @version DragonBones 3.0
  29143. * @language zh_CN
  29144. */
  29145. removeTextureAtlasData(name: string, disposeData?: boolean): void;
  29146. /**
  29147. * - Get a specific armature data.
  29148. * @param name - The armature data name.
  29149. * @param dragonBonesName - The cached name for DragonbonesData instance.
  29150. * @see dragonBones.ArmatureData
  29151. * @version DragonBones 5.1
  29152. * @language en_US
  29153. */
  29154. /**
  29155. * - 获取特定的骨架数据。
  29156. * @param name - 骨架数据名称。
  29157. * @param dragonBonesName - DragonBonesData 实例的缓存名称。
  29158. * @see dragonBones.ArmatureData
  29159. * @version DragonBones 5.1
  29160. * @language zh_CN
  29161. */
  29162. getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null;
  29163. /**
  29164. * - Clear all cached DragonBonesData instances and TextureAtlasData instances.
  29165. * @param disposeData - Whether to dispose data.
  29166. * @version DragonBones 4.5
  29167. * @language en_US
  29168. */
  29169. /**
  29170. * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。
  29171. * @param disposeData - 是否释放数据。
  29172. * @version DragonBones 4.5
  29173. * @language zh_CN
  29174. */
  29175. clear(disposeData?: boolean): void;
  29176. /**
  29177. * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances.
  29178. * @param armatureName - The armature data name.
  29179. * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature)
  29180. * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data)
  29181. * @returns The armature.
  29182. * @example
  29183. * <pre>
  29184. * let armature = factory.buildArmature("armatureName", "dragonBonesName");
  29185. * armature.clock = factory.clock;
  29186. * </pre>
  29187. * @see dragonBones.DragonBonesData
  29188. * @see dragonBones.ArmatureData
  29189. * @see dragonBones.Armature
  29190. * @version DragonBones 3.0
  29191. * @language en_US
  29192. */
  29193. /**
  29194. * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。
  29195. * @param armatureName - 骨架数据名称。
  29196. * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架)
  29197. * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据(如果未设置,则使用默认的皮肤数据)。
  29198. * @returns 骨架。
  29199. * @example
  29200. * <pre>
  29201. * let armature = factory.buildArmature("armatureName", "dragonBonesName");
  29202. * armature.clock = factory.clock;
  29203. * </pre>
  29204. * @see dragonBones.DragonBonesData
  29205. * @see dragonBones.ArmatureData
  29206. * @see dragonBones.Armature
  29207. * @version DragonBones 3.0
  29208. * @language zh_CN
  29209. */
  29210. buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null;
  29211. /**
  29212. * @private
  29213. */
  29214. replaceDisplay(slot: Slot, displayData: DisplayData, displayIndex?: number): void;
  29215. /**
  29216. * - Replaces the current display data for a particular slot with a specific display data.
  29217. * Specify display data with "dragonBonesName/armatureName/slotName/displayName".
  29218. * @param dragonBonesName - The DragonBonesData instance cache name.
  29219. * @param armatureName - The armature data name.
  29220. * @param slotName - The slot data name.
  29221. * @param displayName - The display data name.
  29222. * @param slot - The slot.
  29223. * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data)
  29224. * @example
  29225. * <pre>
  29226. * let slot = armature.getSlot("weapon");
  29227. * factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
  29228. * </pre>
  29229. * @version DragonBones 4.5
  29230. * @language en_US
  29231. */
  29232. /**
  29233. * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。
  29234. * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。
  29235. * @param dragonBonesName - DragonBonesData 实例的缓存名称。
  29236. * @param armatureName - 骨架数据名称。
  29237. * @param slotName - 插槽数据名称。
  29238. * @param displayName - 显示对象数据名称。
  29239. * @param slot - 插槽。
  29240. * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据)
  29241. * @example
  29242. * <pre>
  29243. * let slot = armature.getSlot("weapon");
  29244. * factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
  29245. * </pre>
  29246. * @version DragonBones 4.5
  29247. * @language zh_CN
  29248. */
  29249. replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean;
  29250. /**
  29251. * @private
  29252. */
  29253. replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean;
  29254. /**
  29255. * - Share specific skin data with specific armature.
  29256. * @param armature - The armature.
  29257. * @param skin - The skin data.
  29258. * @param isOverride - Whether it completely override the original skin. (Default: false)
  29259. * @param exclude - A list of slot names that do not need to be replace.
  29260. * @example
  29261. * <pre>
  29262. * let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
  29263. * let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
  29264. * if (armatureDataB && armatureDataB.defaultSkin) {
  29265. * factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
  29266. * }
  29267. * </pre>
  29268. * @see dragonBones.Armature
  29269. * @see dragonBones.SkinData
  29270. * @version DragonBones 5.6
  29271. * @language en_US
  29272. */
  29273. /**
  29274. * - 将特定的皮肤数据共享给特定的骨架使用。
  29275. * @param armature - 骨架。
  29276. * @param skin - 皮肤数据。
  29277. * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false)
  29278. * @param exclude - 不需要被替换的插槽名称列表。
  29279. * @example
  29280. * <pre>
  29281. * let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
  29282. * let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
  29283. * if (armatureDataB && armatureDataB.defaultSkin) {
  29284. * factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
  29285. * }
  29286. * </pre>
  29287. * @see dragonBones.Armature
  29288. * @see dragonBones.SkinData
  29289. * @version DragonBones 5.6
  29290. * @language zh_CN
  29291. */
  29292. replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array<string> | null): boolean;
  29293. /**
  29294. * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data.
  29295. * This enables you to make a armature template so that other armature without animations can share it's animations.
  29296. * @param armature - The armtaure.
  29297. * @param armatureData - The armature data.
  29298. * @param isOverride - Whether to completely overwrite the original animation. (Default: false)
  29299. * @example
  29300. * <pre>
  29301. * let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
  29302. * let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
  29303. * if (armatureDataB) {
  29304. * factory.replaceAnimation(armatureA, armatureDataB);
  29305. * }
  29306. * </pre>
  29307. * @see dragonBones.Armature
  29308. * @see dragonBones.ArmatureData
  29309. * @version DragonBones 5.6
  29310. * @language en_US
  29311. */
  29312. /**
  29313. * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。
  29314. * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。
  29315. * @param armature - 骨架。
  29316. * @param armatureData - 骨架数据。
  29317. * @param isOverride - 是否完全覆盖原来的动画。(默认: false)。
  29318. * @example
  29319. * <pre>
  29320. * let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
  29321. * let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
  29322. * if (armatureDataB) {
  29323. * factory.replaceAnimation(armatureA, armatureDataB);
  29324. * }
  29325. * </pre>
  29326. * @see dragonBones.Armature
  29327. * @see dragonBones.ArmatureData
  29328. * @version DragonBones 5.6
  29329. * @language zh_CN
  29330. */
  29331. replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean;
  29332. /**
  29333. * @private
  29334. */
  29335. getAllDragonBonesData(): Map<DragonBonesData>;
  29336. /**
  29337. * @private
  29338. */
  29339. getAllTextureAtlasData(): Map<Array<TextureAtlasData>>;
  29340. /**
  29341. * - An Worldclock instance updated by engine.
  29342. * @version DragonBones 5.7
  29343. * @language en_US
  29344. */
  29345. /**
  29346. * - 由引擎驱动的 WorldClock 实例。
  29347. * @version DragonBones 5.7
  29348. * @language zh_CN
  29349. */
  29350. readonly clock: WorldClock;
  29351. /**
  29352. * @private
  29353. */
  29354. readonly dragonBones: DragonBones;
  29355. /**
  29356. * - Deprecated, please refer to {@link #replaceSkin}.
  29357. * @deprecated
  29358. * @language en_US
  29359. */
  29360. /**
  29361. * - 已废弃,请参考 {@link #replaceSkin}。
  29362. * @deprecated
  29363. * @language zh_CN
  29364. */
  29365. changeSkin(armature: Armature, skin: SkinData, exclude?: Array<string> | null): boolean;
  29366. /**
  29367. * - Deprecated, please refer to {@link #replaceAnimation}.
  29368. * @deprecated
  29369. * @language en_US
  29370. */
  29371. /**
  29372. * - 已废弃,请参考 {@link #replaceAnimation}。
  29373. * @deprecated
  29374. * @language zh_CN
  29375. */
  29376. copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, replaceOriginalAnimation?: boolean): boolean;
  29377. }
  29378. /**
  29379. * @internal
  29380. * @private
  29381. */
  29382. class BuildArmaturePackage {
  29383. dataName: string;
  29384. textureAtlasName: string;
  29385. data: DragonBonesData;
  29386. armature: ArmatureData;
  29387. skin: SkinData | null;
  29388. }
  29389. }
  29390. declare namespace sp.spine {
  29391. class Animation {
  29392. name: string;
  29393. timelines: Array<Timeline>;
  29394. timelineIds: Array<boolean>;
  29395. duration: number;
  29396. constructor(name: string, timelines: Array<Timeline>, duration: number);
  29397. hasTimeline(id: number): boolean;
  29398. apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29399. static binarySearch(values: ArrayLike<number>, target: number, step?: number): number;
  29400. static linearSearch(values: ArrayLike<number>, target: number, step: number): number;
  29401. }
  29402. interface Timeline {
  29403. apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29404. getPropertyId(): number;
  29405. }
  29406. enum MixBlend {
  29407. setup = 0,
  29408. first = 1,
  29409. replace = 2,
  29410. add = 3
  29411. }
  29412. enum MixDirection {
  29413. mixIn = 0,
  29414. mixOut = 1
  29415. }
  29416. enum TimelineType {
  29417. rotate = 0,
  29418. translate = 1,
  29419. scale = 2,
  29420. shear = 3,
  29421. attachment = 4,
  29422. color = 5,
  29423. deform = 6,
  29424. event = 7,
  29425. drawOrder = 8,
  29426. ikConstraint = 9,
  29427. transformConstraint = 10,
  29428. pathConstraintPosition = 11,
  29429. pathConstraintSpacing = 12,
  29430. pathConstraintMix = 13,
  29431. twoColor = 14
  29432. }
  29433. abstract class CurveTimeline implements Timeline {
  29434. static LINEAR: number;
  29435. static STEPPED: number;
  29436. static BEZIER: number;
  29437. static BEZIER_SIZE: number;
  29438. private curves;
  29439. abstract getPropertyId(): number;
  29440. constructor(frameCount: number);
  29441. getFrameCount(): number;
  29442. setLinear(frameIndex: number): void;
  29443. setStepped(frameIndex: number): void;
  29444. getCurveType(frameIndex: number): number;
  29445. setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
  29446. getCurvePercent(frameIndex: number, percent: number): number;
  29447. abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29448. }
  29449. class RotateTimeline extends CurveTimeline {
  29450. static ENTRIES: number;
  29451. static PREV_TIME: number;
  29452. static PREV_ROTATION: number;
  29453. static ROTATION: number;
  29454. boneIndex: number;
  29455. frames: ArrayLike<number>;
  29456. constructor(frameCount: number);
  29457. getPropertyId(): number;
  29458. setFrame(frameIndex: number, time: number, degrees: number): void;
  29459. apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29460. }
  29461. class TranslateTimeline extends CurveTimeline {
  29462. static ENTRIES: number;
  29463. static PREV_TIME: number;
  29464. static PREV_X: number;
  29465. static PREV_Y: number;
  29466. static X: number;
  29467. static Y: number;
  29468. boneIndex: number;
  29469. frames: ArrayLike<number>;
  29470. constructor(frameCount: number);
  29471. getPropertyId(): number;
  29472. setFrame(frameIndex: number, time: number, x: number, y: number): void;
  29473. apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29474. }
  29475. class ScaleTimeline extends TranslateTimeline {
  29476. constructor(frameCount: number);
  29477. getPropertyId(): number;
  29478. apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29479. }
  29480. class ShearTimeline extends TranslateTimeline {
  29481. constructor(frameCount: number);
  29482. getPropertyId(): number;
  29483. apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29484. }
  29485. class ColorTimeline extends CurveTimeline {
  29486. static ENTRIES: number;
  29487. static PREV_TIME: number;
  29488. static PREV_R: number;
  29489. static PREV_G: number;
  29490. static PREV_B: number;
  29491. static PREV_A: number;
  29492. static R: number;
  29493. static G: number;
  29494. static B: number;
  29495. static A: number;
  29496. slotIndex: number;
  29497. frames: ArrayLike<number>;
  29498. constructor(frameCount: number);
  29499. getPropertyId(): number;
  29500. setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void;
  29501. apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29502. }
  29503. class TwoColorTimeline extends CurveTimeline {
  29504. static ENTRIES: number;
  29505. static PREV_TIME: number;
  29506. static PREV_R: number;
  29507. static PREV_G: number;
  29508. static PREV_B: number;
  29509. static PREV_A: number;
  29510. static PREV_R2: number;
  29511. static PREV_G2: number;
  29512. static PREV_B2: number;
  29513. static R: number;
  29514. static G: number;
  29515. static B: number;
  29516. static A: number;
  29517. static R2: number;
  29518. static G2: number;
  29519. static B2: number;
  29520. slotIndex: number;
  29521. frames: ArrayLike<number>;
  29522. constructor(frameCount: number);
  29523. getPropertyId(): number;
  29524. setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number): void;
  29525. apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29526. }
  29527. class AttachmentTimeline implements Timeline {
  29528. slotIndex: number;
  29529. frames: ArrayLike<number>;
  29530. attachmentNames: Array<string>;
  29531. constructor(frameCount: number);
  29532. getPropertyId(): number;
  29533. getFrameCount(): number;
  29534. setFrame(frameIndex: number, time: number, attachmentName: string): void;
  29535. apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29536. }
  29537. class DeformTimeline extends CurveTimeline {
  29538. slotIndex: number;
  29539. attachment: VertexAttachment;
  29540. frames: ArrayLike<number>;
  29541. frameVertices: Array<ArrayLike<number>>;
  29542. constructor(frameCount: number);
  29543. getPropertyId(): number;
  29544. setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
  29545. apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29546. }
  29547. class EventTimeline implements Timeline {
  29548. frames: ArrayLike<number>;
  29549. events: Array<Event>;
  29550. constructor(frameCount: number);
  29551. getPropertyId(): number;
  29552. getFrameCount(): number;
  29553. setFrame(frameIndex: number, event: Event): void;
  29554. apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29555. }
  29556. class DrawOrderTimeline implements Timeline {
  29557. frames: ArrayLike<number>;
  29558. drawOrders: Array<Array<number>>;
  29559. constructor(frameCount: number);
  29560. getPropertyId(): number;
  29561. getFrameCount(): number;
  29562. setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
  29563. apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29564. }
  29565. class IkConstraintTimeline extends CurveTimeline {
  29566. static ENTRIES: number;
  29567. static PREV_TIME: number;
  29568. static PREV_MIX: number;
  29569. static PREV_SOFTNESS: number;
  29570. static PREV_BEND_DIRECTION: number;
  29571. static PREV_COMPRESS: number;
  29572. static PREV_STRETCH: number;
  29573. static MIX: number;
  29574. static SOFTNESS: number;
  29575. static BEND_DIRECTION: number;
  29576. static COMPRESS: number;
  29577. static STRETCH: number;
  29578. ikConstraintIndex: number;
  29579. frames: ArrayLike<number>;
  29580. constructor(frameCount: number);
  29581. getPropertyId(): number;
  29582. setFrame(frameIndex: number, time: number, mix: number, softness: number, bendDirection: number, compress: boolean, stretch: boolean): void;
  29583. apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29584. }
  29585. class TransformConstraintTimeline extends CurveTimeline {
  29586. static ENTRIES: number;
  29587. static PREV_TIME: number;
  29588. static PREV_ROTATE: number;
  29589. static PREV_TRANSLATE: number;
  29590. static PREV_SCALE: number;
  29591. static PREV_SHEAR: number;
  29592. static ROTATE: number;
  29593. static TRANSLATE: number;
  29594. static SCALE: number;
  29595. static SHEAR: number;
  29596. transformConstraintIndex: number;
  29597. frames: ArrayLike<number>;
  29598. constructor(frameCount: number);
  29599. getPropertyId(): number;
  29600. setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number, scaleMix: number, shearMix: number): void;
  29601. apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29602. }
  29603. class PathConstraintPositionTimeline extends CurveTimeline {
  29604. static ENTRIES: number;
  29605. static PREV_TIME: number;
  29606. static PREV_VALUE: number;
  29607. static VALUE: number;
  29608. pathConstraintIndex: number;
  29609. frames: ArrayLike<number>;
  29610. constructor(frameCount: number);
  29611. getPropertyId(): number;
  29612. setFrame(frameIndex: number, time: number, value: number): void;
  29613. apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29614. }
  29615. class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline {
  29616. constructor(frameCount: number);
  29617. getPropertyId(): number;
  29618. apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29619. }
  29620. class PathConstraintMixTimeline extends CurveTimeline {
  29621. static ENTRIES: number;
  29622. static PREV_TIME: number;
  29623. static PREV_ROTATE: number;
  29624. static PREV_TRANSLATE: number;
  29625. static ROTATE: number;
  29626. static TRANSLATE: number;
  29627. pathConstraintIndex: number;
  29628. frames: ArrayLike<number>;
  29629. constructor(frameCount: number);
  29630. getPropertyId(): number;
  29631. setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void;
  29632. apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
  29633. }
  29634. }
  29635. declare namespace sp.spine {
  29636. class AnimationState {
  29637. static emptyAnimation: Animation;
  29638. static SUBSEQUENT: number;
  29639. static FIRST: number;
  29640. static HOLD: number;
  29641. static HOLD_MIX: number;
  29642. static NOT_LAST: number;
  29643. data: AnimationStateData;
  29644. tracks: TrackEntry[];
  29645. timeScale: number;
  29646. events: Event[];
  29647. listeners: AnimationStateListener[];
  29648. queue: EventQueue;
  29649. propertyIDs: IntSet;
  29650. animationsChanged: boolean;
  29651. trackEntryPool: Pool<TrackEntry>;
  29652. constructor(data: AnimationStateData);
  29653. update(delta: number): void;
  29654. updateMixingFrom(to: TrackEntry, delta: number): boolean;
  29655. apply(skeleton: Skeleton): boolean;
  29656. applyMixingFrom(to: TrackEntry, skeleton: Skeleton, blend: MixBlend): number;
  29657. applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
  29658. queueEvents(entry: TrackEntry, animationTime: number): void;
  29659. clearTracks(): void;
  29660. clearTrack(trackIndex: number): void;
  29661. setCurrent(index: number, current: TrackEntry, interrupt: boolean): void;
  29662. setAnimation(trackIndex: number, animationName: string, loop: boolean): TrackEntry;
  29663. setAnimationWith(trackIndex: number, animation: Animation, loop: boolean): TrackEntry;
  29664. addAnimation(trackIndex: number, animationName: string, loop: boolean, delay: number): TrackEntry;
  29665. addAnimationWith(trackIndex: number, animation: Animation, loop: boolean, delay: number): TrackEntry;
  29666. setEmptyAnimation(trackIndex: number, mixDuration: number): TrackEntry;
  29667. addEmptyAnimation(trackIndex: number, mixDuration: number, delay: number): TrackEntry;
  29668. setEmptyAnimations(mixDuration: number): void;
  29669. expandToIndex(index: number): TrackEntry;
  29670. trackEntry(trackIndex: number, animation: Animation, loop: boolean, last: TrackEntry): TrackEntry;
  29671. disposeNext(entry: TrackEntry): void;
  29672. _animationsChanged(): void;
  29673. computeHold(entry: TrackEntry): void;
  29674. computeNotLast(entry: TrackEntry): void;
  29675. getCurrent(trackIndex: number): TrackEntry;
  29676. addListener(listener: AnimationStateListener): void;
  29677. removeListener(listener: AnimationStateListener): void;
  29678. clearListeners(): void;
  29679. clearListenerNotifications(): void;
  29680. }
  29681. class TrackEntry {
  29682. animation: Animation;
  29683. next: TrackEntry;
  29684. mixingFrom: TrackEntry;
  29685. mixingTo: TrackEntry;
  29686. listener: AnimationStateListener;
  29687. trackIndex: number;
  29688. loop: boolean;
  29689. holdPrevious: boolean;
  29690. eventThreshold: number;
  29691. attachmentThreshold: number;
  29692. drawOrderThreshold: number;
  29693. animationStart: number;
  29694. animationEnd: number;
  29695. animationLast: number;
  29696. nextAnimationLast: number;
  29697. delay: number;
  29698. trackTime: number;
  29699. trackLast: number;
  29700. nextTrackLast: number;
  29701. trackEnd: number;
  29702. timeScale: number;
  29703. alpha: number;
  29704. mixTime: number;
  29705. mixDuration: number;
  29706. interruptAlpha: number;
  29707. totalAlpha: number;
  29708. mixBlend: MixBlend;
  29709. timelineMode: number[];
  29710. timelineHoldMix: TrackEntry[];
  29711. timelinesRotation: number[];
  29712. reset(): void;
  29713. getAnimationTime(): number;
  29714. setAnimationLast(animationLast: number): void;
  29715. isComplete(): boolean;
  29716. resetRotationDirections(): void;
  29717. }
  29718. class EventQueue {
  29719. objects: Array<any>;
  29720. drainDisabled: boolean;
  29721. animState: AnimationState;
  29722. constructor(animState: AnimationState);
  29723. start(entry: TrackEntry): void;
  29724. interrupt(entry: TrackEntry): void;
  29725. end(entry: TrackEntry): void;
  29726. dispose(entry: TrackEntry): void;
  29727. complete(entry: TrackEntry): void;
  29728. event(entry: TrackEntry, event: Event): void;
  29729. drain(): void;
  29730. clear(): void;
  29731. }
  29732. enum EventType {
  29733. start = 0,
  29734. interrupt = 1,
  29735. end = 2,
  29736. dispose = 3,
  29737. complete = 4,
  29738. event = 5
  29739. }
  29740. interface AnimationStateListener {
  29741. start(entry: TrackEntry): void;
  29742. interrupt(entry: TrackEntry): void;
  29743. end(entry: TrackEntry): void;
  29744. dispose(entry: TrackEntry): void;
  29745. complete(entry: TrackEntry): void;
  29746. event(entry: TrackEntry, event: Event): void;
  29747. }
  29748. abstract class AnimationStateAdapter implements AnimationStateListener {
  29749. start(entry: TrackEntry): void;
  29750. interrupt(entry: TrackEntry): void;
  29751. end(entry: TrackEntry): void;
  29752. dispose(entry: TrackEntry): void;
  29753. complete(entry: TrackEntry): void;
  29754. event(entry: TrackEntry, event: Event): void;
  29755. }
  29756. }
  29757. declare namespace sp.spine {
  29758. class AnimationStateData {
  29759. skeletonData: SkeletonData;
  29760. animationToMixTime: Map<number>;
  29761. defaultMix: number;
  29762. constructor(skeletonData: SkeletonData);
  29763. setMix(fromName: string, toName: string, duration: number): void;
  29764. setMixWith(from: Animation, to: Animation, duration: number): void;
  29765. getMix(from: Animation, to: Animation): number;
  29766. }
  29767. }
  29768. declare namespace sp.spine {
  29769. class AssetManager implements Disposable {
  29770. private pathPrefix;
  29771. private textureLoader;
  29772. private assets;
  29773. private errors;
  29774. private toLoad;
  29775. private loaded;
  29776. constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string);
  29777. private static downloadText;
  29778. private static downloadBinary;
  29779. loadBinary(path: string, success?: (path: string, binary: Uint8Array) => void, error?: (path: string, error: string) => void): void;
  29780. loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
  29781. loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
  29782. loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
  29783. loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, error: string) => void): void;
  29784. get(path: string): any;
  29785. remove(path: string): void;
  29786. removeAll(): void;
  29787. isLoadingComplete(): boolean;
  29788. getToLoad(): number;
  29789. getLoaded(): number;
  29790. dispose(): void;
  29791. hasErrors(): boolean;
  29792. getErrors(): Map<string>;
  29793. }
  29794. }
  29795. declare namespace sp.spine {
  29796. class AtlasAttachmentLoader implements AttachmentLoader {
  29797. atlas: TextureAtlas;
  29798. constructor(atlas: TextureAtlas);
  29799. newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
  29800. newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
  29801. newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
  29802. newPathAttachment(skin: Skin, name: string): PathAttachment;
  29803. newPointAttachment(skin: Skin, name: string): PointAttachment;
  29804. newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
  29805. }
  29806. }
  29807. declare namespace sp.spine {
  29808. enum BlendMode {
  29809. Normal = 0,
  29810. Additive = 1,
  29811. Multiply = 2,
  29812. Screen = 3
  29813. }
  29814. }
  29815. declare namespace sp.spine {
  29816. class Bone implements Updatable {
  29817. data: BoneData;
  29818. skeleton: Skeleton;
  29819. parent: Bone;
  29820. children: Bone[];
  29821. x: number;
  29822. y: number;
  29823. rotation: number;
  29824. scaleX: number;
  29825. scaleY: number;
  29826. shearX: number;
  29827. shearY: number;
  29828. ax: number;
  29829. ay: number;
  29830. arotation: number;
  29831. ascaleX: number;
  29832. ascaleY: number;
  29833. ashearX: number;
  29834. ashearY: number;
  29835. appliedValid: boolean;
  29836. a: number;
  29837. b: number;
  29838. c: number;
  29839. d: number;
  29840. worldY: number;
  29841. worldX: number;
  29842. sorted: boolean;
  29843. active: boolean;
  29844. constructor(data: BoneData, skeleton: Skeleton, parent: Bone);
  29845. isActive(): boolean;
  29846. update(): void;
  29847. updateWorldTransform(): void;
  29848. updateWorldTransformWith(x: number, y: number, rotation: number, scaleX: number, scaleY: number, shearX: number, shearY: number): void;
  29849. setToSetupPose(): void;
  29850. getWorldRotationX(): number;
  29851. getWorldRotationY(): number;
  29852. getWorldScaleX(): number;
  29853. getWorldScaleY(): number;
  29854. updateAppliedTransform(): void;
  29855. worldToLocal(world: Vector2): Vector2;
  29856. localToWorld(local: Vector2): Vector2;
  29857. worldToLocalRotation(worldRotation: number): number;
  29858. localToWorldRotation(localRotation: number): number;
  29859. rotateWorld(degrees: number): void;
  29860. }
  29861. }
  29862. declare namespace sp.spine {
  29863. class BoneData {
  29864. index: number;
  29865. name: string;
  29866. parent: BoneData;
  29867. length: number;
  29868. x: number;
  29869. y: number;
  29870. rotation: number;
  29871. scaleX: number;
  29872. scaleY: number;
  29873. shearX: number;
  29874. shearY: number;
  29875. transformMode: TransformMode;
  29876. skinRequired: boolean;
  29877. color: Color;
  29878. constructor(index: number, name: string, parent: BoneData);
  29879. }
  29880. enum TransformMode {
  29881. Normal = 0,
  29882. OnlyTranslation = 1,
  29883. NoRotationOrReflection = 2,
  29884. NoScale = 3,
  29885. NoScaleOrReflection = 4
  29886. }
  29887. }
  29888. declare namespace sp.spine {
  29889. abstract class ConstraintData {
  29890. name: string;
  29891. order: number;
  29892. skinRequired: boolean;
  29893. constructor(name: string, order: number, skinRequired: boolean);
  29894. }
  29895. }
  29896. declare namespace sp.spine {
  29897. class Event {
  29898. data: EventData;
  29899. intValue: number;
  29900. floatValue: number;
  29901. stringValue: string;
  29902. time: number;
  29903. volume: number;
  29904. balance: number;
  29905. constructor(time: number, data: EventData);
  29906. }
  29907. }
  29908. declare namespace sp.spine {
  29909. class EventData {
  29910. name: string;
  29911. intValue: number;
  29912. floatValue: number;
  29913. stringValue: string;
  29914. audioPath: string;
  29915. volume: number;
  29916. balance: number;
  29917. constructor(name: string);
  29918. }
  29919. }
  29920. declare namespace sp.spine {
  29921. class IkConstraint implements Updatable {
  29922. data: IkConstraintData;
  29923. bones: Array<Bone>;
  29924. target: Bone;
  29925. bendDirection: number;
  29926. compress: boolean;
  29927. stretch: boolean;
  29928. mix: number;
  29929. softness: number;
  29930. active: boolean;
  29931. constructor(data: IkConstraintData, skeleton: Skeleton);
  29932. isActive(): boolean;
  29933. apply(): void;
  29934. update(): void;
  29935. apply1(bone: Bone, targetX: number, targetY: number, compress: boolean, stretch: boolean, uniform: boolean, alpha: number): void;
  29936. apply2(parent: Bone, child: Bone, targetX: number, targetY: number, bendDir: number, stretch: boolean, softness: number, alpha: number): void;
  29937. }
  29938. }
  29939. declare namespace sp.spine {
  29940. class IkConstraintData extends ConstraintData {
  29941. bones: BoneData[];
  29942. target: BoneData;
  29943. bendDirection: number;
  29944. compress: boolean;
  29945. stretch: boolean;
  29946. uniform: boolean;
  29947. mix: number;
  29948. softness: number;
  29949. constructor(name: string);
  29950. }
  29951. }
  29952. declare namespace sp.spine {
  29953. class PathConstraint implements Updatable {
  29954. static NONE: number;
  29955. static BEFORE: number;
  29956. static AFTER: number;
  29957. static epsilon: number;
  29958. data: PathConstraintData;
  29959. bones: Array<Bone>;
  29960. target: Slot;
  29961. position: number;
  29962. spacing: number;
  29963. rotateMix: number;
  29964. translateMix: number;
  29965. spaces: number[];
  29966. positions: number[];
  29967. world: number[];
  29968. curves: number[];
  29969. lengths: number[];
  29970. segments: number[];
  29971. active: boolean;
  29972. constructor(data: PathConstraintData, skeleton: Skeleton);
  29973. isActive(): boolean;
  29974. apply(): void;
  29975. update(): void;
  29976. computeWorldPositions(path: PathAttachment, spacesCount: number, tangents: boolean, percentPosition: boolean, percentSpacing: boolean): number[];
  29977. addBeforePosition(p: number, temp: Array<number>, i: number, out: Array<number>, o: number): void;
  29978. addAfterPosition(p: number, temp: Array<number>, i: number, out: Array<number>, o: number): void;
  29979. addCurvePosition(p: number, x1: number, y1: number, cx1: number, cy1: number, cx2: number, cy2: number, x2: number, y2: number, out: Array<number>, o: number, tangents: boolean): void;
  29980. }
  29981. }
  29982. declare namespace sp.spine {
  29983. class PathConstraintData extends ConstraintData {
  29984. bones: BoneData[];
  29985. target: SlotData;
  29986. positionMode: PositionMode;
  29987. spacingMode: SpacingMode;
  29988. rotateMode: RotateMode;
  29989. offsetRotation: number;
  29990. position: number;
  29991. spacing: number;
  29992. rotateMix: number;
  29993. translateMix: number;
  29994. constructor(name: string);
  29995. }
  29996. enum PositionMode {
  29997. Fixed = 0,
  29998. Percent = 1
  29999. }
  30000. enum SpacingMode {
  30001. Length = 0,
  30002. Fixed = 1,
  30003. Percent = 2
  30004. }
  30005. enum RotateMode {
  30006. Tangent = 0,
  30007. Chain = 1,
  30008. ChainScale = 2
  30009. }
  30010. }
  30011. declare namespace sp.spine {
  30012. class SharedAssetManager implements Disposable {
  30013. private pathPrefix;
  30014. private clientAssets;
  30015. private queuedAssets;
  30016. private rawAssets;
  30017. private errors;
  30018. constructor(pathPrefix?: string);
  30019. private queueAsset;
  30020. loadText(clientId: string, path: string): void;
  30021. loadJson(clientId: string, path: string): void;
  30022. loadTexture(clientId: string, textureLoader: (image: HTMLImageElement) => any, path: string): void;
  30023. get(clientId: string, path: string): any;
  30024. private updateClientAssets;
  30025. isLoadingComplete(clientId: string): boolean;
  30026. dispose(): void;
  30027. hasErrors(): boolean;
  30028. getErrors(): Map<string>;
  30029. }
  30030. }
  30031. declare namespace sp.spine {
  30032. class Skeleton {
  30033. data: SkeletonData;
  30034. bones: Array<Bone>;
  30035. slots: Array<Slot>;
  30036. drawOrder: Array<Slot>;
  30037. ikConstraints: Array<IkConstraint>;
  30038. transformConstraints: Array<TransformConstraint>;
  30039. pathConstraints: Array<PathConstraint>;
  30040. _updateCache: Updatable[];
  30041. updateCacheReset: Updatable[];
  30042. skin: Skin;
  30043. color: Color;
  30044. time: number;
  30045. scaleX: number;
  30046. scaleY: number;
  30047. x: number;
  30048. y: number;
  30049. constructor(data: SkeletonData);
  30050. updateCache(): void;
  30051. sortIkConstraint(constraint: IkConstraint): void;
  30052. sortPathConstraint(constraint: PathConstraint): void;
  30053. sortTransformConstraint(constraint: TransformConstraint): void;
  30054. sortPathConstraintAttachment(skin: Skin, slotIndex: number, slotBone: Bone): void;
  30055. sortPathConstraintAttachmentWith(attachment: Attachment, slotBone: Bone): void;
  30056. sortBone(bone: Bone): void;
  30057. sortReset(bones: Array<Bone>): void;
  30058. updateWorldTransform(): void;
  30059. setToSetupPose(): void;
  30060. setBonesToSetupPose(): void;
  30061. setSlotsToSetupPose(): void;
  30062. getRootBone(): Bone;
  30063. findBone(boneName: string): Bone;
  30064. findBoneIndex(boneName: string): number;
  30065. findSlot(slotName: string): Slot;
  30066. findSlotIndex(slotName: string): number;
  30067. setSkinByName(skinName: string): void;
  30068. setSkin(newSkin: Skin): void;
  30069. getAttachmentByName(slotName: string, attachmentName: string): Attachment;
  30070. getAttachment(slotIndex: number, attachmentName: string): Attachment;
  30071. setAttachment(slotName: string, attachmentName: string): void;
  30072. findIkConstraint(constraintName: string): IkConstraint;
  30073. findTransformConstraint(constraintName: string): TransformConstraint;
  30074. findPathConstraint(constraintName: string): PathConstraint;
  30075. getBounds(offset: Vector2, size: Vector2, temp?: Array<number>): void;
  30076. update(delta: number): void;
  30077. }
  30078. }
  30079. declare namespace sp.spine {
  30080. class SkeletonBinary {
  30081. static AttachmentTypeValues: number[];
  30082. static TransformModeValues: TransformMode[];
  30083. static PositionModeValues: PositionMode[];
  30084. static SpacingModeValues: SpacingMode[];
  30085. static RotateModeValues: RotateMode[];
  30086. static BlendModeValues: BlendMode[];
  30087. static BONE_ROTATE: number;
  30088. static BONE_TRANSLATE: number;
  30089. static BONE_SCALE: number;
  30090. static BONE_SHEAR: number;
  30091. static SLOT_ATTACHMENT: number;
  30092. static SLOT_COLOR: number;
  30093. static SLOT_TWO_COLOR: number;
  30094. static PATH_POSITION: number;
  30095. static PATH_SPACING: number;
  30096. static PATH_MIX: number;
  30097. static CURVE_LINEAR: number;
  30098. static CURVE_STEPPED: number;
  30099. static CURVE_BEZIER: number;
  30100. scale: number;
  30101. attachmentLoader: AttachmentLoader;
  30102. private linkedMeshes;
  30103. constructor(attachmentLoader: AttachmentLoader);
  30104. readSkeletonData(binary: Uint8Array): SkeletonData;
  30105. private readSkin;
  30106. private readAttachment;
  30107. private readVertices;
  30108. private readFloatArray;
  30109. private readShortArray;
  30110. private readAnimation;
  30111. private readCurve;
  30112. setCurve(timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
  30113. }
  30114. }
  30115. declare namespace sp.spine {
  30116. class SkeletonBounds {
  30117. minX: number;
  30118. minY: number;
  30119. maxX: number;
  30120. maxY: number;
  30121. boundingBoxes: BoundingBoxAttachment[];
  30122. polygons: ArrayLike<number>[];
  30123. private polygonPool;
  30124. update(skeleton: Skeleton, updateAabb: boolean): void;
  30125. aabbCompute(): void;
  30126. aabbContainsPoint(x: number, y: number): boolean;
  30127. aabbIntersectsSegment(x1: number, y1: number, x2: number, y2: number): boolean;
  30128. aabbIntersectsSkeleton(bounds: SkeletonBounds): boolean;
  30129. containsPoint(x: number, y: number): BoundingBoxAttachment;
  30130. containsPointPolygon(polygon: ArrayLike<number>, x: number, y: number): boolean;
  30131. intersectsSegment(x1: number, y1: number, x2: number, y2: number): BoundingBoxAttachment;
  30132. intersectsSegmentPolygon(polygon: ArrayLike<number>, x1: number, y1: number, x2: number, y2: number): boolean;
  30133. getPolygon(boundingBox: BoundingBoxAttachment): ArrayLike<number>;
  30134. getWidth(): number;
  30135. getHeight(): number;
  30136. }
  30137. }
  30138. declare namespace sp.spine {
  30139. class SkeletonClipping {
  30140. private triangulator;
  30141. private clippingPolygon;
  30142. private clipOutput;
  30143. clippedVertices: number[];
  30144. clippedTriangles: number[];
  30145. private scratch;
  30146. private clipAttachment;
  30147. private clippingPolygons;
  30148. clipStart(slot: Slot, clip: ClippingAttachment): number;
  30149. clipEndWithSlot(slot: Slot): void;
  30150. clipEnd(): void;
  30151. isClipping(): boolean;
  30152. clipTriangles(vertices: ArrayLike<number>, verticesLength: number, triangles: ArrayLike<number>, trianglesLength: number, uvs: ArrayLike<number>, light: Color, dark: Color, twoColor: boolean): void;
  30153. clip(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, clippingArea: Array<number>, output: Array<number>): boolean;
  30154. static makeClockwise(polygon: ArrayLike<number>): void;
  30155. }
  30156. }
  30157. declare namespace sp.spine {
  30158. class SkeletonData {
  30159. name: string;
  30160. bones: BoneData[];
  30161. slots: SlotData[];
  30162. skins: Skin[];
  30163. defaultSkin: Skin;
  30164. events: EventData[];
  30165. animations: Animation[];
  30166. ikConstraints: IkConstraintData[];
  30167. transformConstraints: TransformConstraintData[];
  30168. pathConstraints: PathConstraintData[];
  30169. x: number;
  30170. y: number;
  30171. width: number;
  30172. height: number;
  30173. version: string;
  30174. hash: string;
  30175. fps: number;
  30176. imagesPath: string;
  30177. audioPath: string;
  30178. findBone(boneName: string): BoneData;
  30179. findBoneIndex(boneName: string): number;
  30180. findSlot(slotName: string): SlotData;
  30181. findSlotIndex(slotName: string): number;
  30182. findSkin(skinName: string): Skin;
  30183. findEvent(eventDataName: string): EventData;
  30184. findAnimation(animationName: string): Animation;
  30185. findIkConstraint(constraintName: string): IkConstraintData;
  30186. findTransformConstraint(constraintName: string): TransformConstraintData;
  30187. findPathConstraint(constraintName: string): PathConstraintData;
  30188. findPathConstraintIndex(pathConstraintName: string): number;
  30189. }
  30190. }
  30191. declare namespace sp.spine {
  30192. class SkeletonJson {
  30193. attachmentLoader: AttachmentLoader;
  30194. scale: number;
  30195. private linkedMeshes;
  30196. constructor(attachmentLoader: AttachmentLoader);
  30197. readSkeletonData(json: string | any): SkeletonData;
  30198. readAttachment(map: any, skin: Skin, slotIndex: number, name: string, skeletonData: SkeletonData): Attachment;
  30199. readVertices(map: any, attachment: VertexAttachment, verticesLength: number): void;
  30200. readAnimation(map: any, name: string, skeletonData: SkeletonData): void;
  30201. readCurve(map: any, timeline: CurveTimeline, frameIndex: number): void;
  30202. getValue(map: any, prop: string, defaultValue: any): any;
  30203. static blendModeFromString(str: string): BlendMode;
  30204. static positionModeFromString(str: string): PositionMode;
  30205. static spacingModeFromString(str: string): SpacingMode;
  30206. static rotateModeFromString(str: string): RotateMode;
  30207. static transformModeFromString(str: string): TransformMode;
  30208. }
  30209. }
  30210. declare namespace sp.spine {
  30211. class SkinEntry {
  30212. slotIndex: number;
  30213. name: string;
  30214. attachment: Attachment;
  30215. constructor(slotIndex: number, name: string, attachment: Attachment);
  30216. }
  30217. class Skin {
  30218. name: string;
  30219. attachments: Map<Attachment>[];
  30220. bones: BoneData[];
  30221. constraints: ConstraintData[];
  30222. constructor(name: string);
  30223. setAttachment(slotIndex: number, name: string, attachment: Attachment): void;
  30224. addSkin(skin: Skin): void;
  30225. copySkin(skin: Skin): void;
  30226. getAttachment(slotIndex: number, name: string): Attachment;
  30227. removeAttachment(slotIndex: number, name: string): void;
  30228. getAttachments(): Array<SkinEntry>;
  30229. getAttachmentsForSlot(slotIndex: number, attachments: Array<SkinEntry>): void;
  30230. clear(): void;
  30231. attachAll(skeleton: Skeleton, oldSkin: Skin): void;
  30232. }
  30233. }
  30234. declare namespace sp.spine {
  30235. class Slot {
  30236. data: SlotData;
  30237. bone: Bone;
  30238. color: Color;
  30239. darkColor: Color;
  30240. private attachment;
  30241. private attachmentTime;
  30242. deform: number[];
  30243. constructor(data: SlotData, bone: Bone);
  30244. getSkeleton(): Skeleton;
  30245. getAttachment(): Attachment;
  30246. setAttachment(attachment: Attachment): void;
  30247. setAttachmentTime(time: number): void;
  30248. getAttachmentTime(): number;
  30249. setToSetupPose(): void;
  30250. }
  30251. }
  30252. declare namespace sp.spine {
  30253. class SlotData {
  30254. index: number;
  30255. name: string;
  30256. boneData: BoneData;
  30257. color: Color;
  30258. darkColor: Color;
  30259. attachmentName: string;
  30260. blendMode: BlendMode;
  30261. constructor(index: number, name: string, boneData: BoneData);
  30262. }
  30263. }
  30264. declare namespace sp.spine {
  30265. abstract class Texture {
  30266. protected _image: HTMLImageElement;
  30267. constructor(image: HTMLImageElement);
  30268. getImage(): HTMLImageElement;
  30269. abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
  30270. abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
  30271. abstract dispose(): void;
  30272. static filterFromString(text: string): TextureFilter;
  30273. static wrapFromString(text: string): TextureWrap;
  30274. }
  30275. enum TextureFilter {
  30276. Nearest = 9728,
  30277. Linear = 9729,
  30278. MipMap = 9987,
  30279. MipMapNearestNearest = 9984,
  30280. MipMapLinearNearest = 9985,
  30281. MipMapNearestLinear = 9986,
  30282. MipMapLinearLinear = 9987
  30283. }
  30284. enum TextureWrap {
  30285. MirroredRepeat = 33648,
  30286. ClampToEdge = 33071,
  30287. Repeat = 10497
  30288. }
  30289. class TextureRegion {
  30290. renderObject: any;
  30291. u: number;
  30292. v: number;
  30293. u2: number;
  30294. v2: number;
  30295. width: number;
  30296. height: number;
  30297. rotate: boolean;
  30298. offsetX: number;
  30299. offsetY: number;
  30300. originalWidth: number;
  30301. originalHeight: number;
  30302. }
  30303. class FakeTexture extends Texture {
  30304. setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
  30305. setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
  30306. dispose(): void;
  30307. }
  30308. }
  30309. declare namespace sp.spine {
  30310. class TextureAtlas implements Disposable {
  30311. pages: TextureAtlasPage[];
  30312. regions: TextureAtlasRegion[];
  30313. constructor(atlasText: string, textureLoader: (path: string) => any);
  30314. private load;
  30315. findRegion(name: string): TextureAtlasRegion;
  30316. dispose(): void;
  30317. }
  30318. class TextureAtlasPage {
  30319. name: string;
  30320. minFilter: TextureFilter;
  30321. magFilter: TextureFilter;
  30322. uWrap: TextureWrap;
  30323. vWrap: TextureWrap;
  30324. texture: Texture;
  30325. width: number;
  30326. height: number;
  30327. }
  30328. class TextureAtlasRegion extends TextureRegion {
  30329. page: TextureAtlasPage;
  30330. name: string;
  30331. x: number;
  30332. y: number;
  30333. index: number;
  30334. rotate: boolean;
  30335. degrees: number;
  30336. texture: Texture;
  30337. }
  30338. }
  30339. declare namespace sp.spine {
  30340. class TransformConstraint implements Updatable {
  30341. data: TransformConstraintData;
  30342. bones: Array<Bone>;
  30343. target: Bone;
  30344. rotateMix: number;
  30345. translateMix: number;
  30346. scaleMix: number;
  30347. shearMix: number;
  30348. temp: Vector2;
  30349. active: boolean;
  30350. constructor(data: TransformConstraintData, skeleton: Skeleton);
  30351. isActive(): boolean;
  30352. apply(): void;
  30353. update(): void;
  30354. applyAbsoluteWorld(): void;
  30355. applyRelativeWorld(): void;
  30356. applyAbsoluteLocal(): void;
  30357. applyRelativeLocal(): void;
  30358. }
  30359. }
  30360. declare namespace sp.spine {
  30361. class TransformConstraintData extends ConstraintData {
  30362. bones: BoneData[];
  30363. target: BoneData;
  30364. rotateMix: number;
  30365. translateMix: number;
  30366. scaleMix: number;
  30367. shearMix: number;
  30368. offsetRotation: number;
  30369. offsetX: number;
  30370. offsetY: number;
  30371. offsetScaleX: number;
  30372. offsetScaleY: number;
  30373. offsetShearY: number;
  30374. relative: boolean;
  30375. local: boolean;
  30376. constructor(name: string);
  30377. }
  30378. }
  30379. declare namespace sp.spine {
  30380. class Triangulator {
  30381. private convexPolygons;
  30382. private convexPolygonsIndices;
  30383. private indicesArray;
  30384. private isConcaveArray;
  30385. private triangles;
  30386. private polygonPool;
  30387. private polygonIndicesPool;
  30388. triangulate(verticesArray: ArrayLike<number>): Array<number>;
  30389. decompose(verticesArray: Array<number>, triangles: Array<number>): Array<Array<number>>;
  30390. private static isConcave;
  30391. private static positiveArea;
  30392. private static winding;
  30393. }
  30394. }
  30395. declare namespace sp.spine {
  30396. interface Updatable {
  30397. update(): void;
  30398. isActive(): boolean;
  30399. }
  30400. }
  30401. declare namespace sp.spine {
  30402. interface Map<T> {
  30403. [key: string]: T;
  30404. }
  30405. class IntSet {
  30406. array: number[];
  30407. add(value: number): boolean;
  30408. contains(value: number): boolean;
  30409. remove(value: number): void;
  30410. clear(): void;
  30411. }
  30412. interface Disposable {
  30413. dispose(): void;
  30414. }
  30415. interface Restorable {
  30416. restore(): void;
  30417. }
  30418. class Color {
  30419. r: number;
  30420. g: number;
  30421. b: number;
  30422. a: number;
  30423. static WHITE: Color;
  30424. static RED: Color;
  30425. static GREEN: Color;
  30426. static BLUE: Color;
  30427. static MAGENTA: Color;
  30428. constructor(r?: number, g?: number, b?: number, a?: number);
  30429. set(r: number, g: number, b: number, a: number): this;
  30430. setFromColor(c: Color): this;
  30431. setFromString(hex: string): this;
  30432. add(r: number, g: number, b: number, a: number): this;
  30433. clamp(): this;
  30434. static rgba8888ToColor(color: Color, value: number): void;
  30435. static rgb888ToColor(color: Color, value: number): void;
  30436. }
  30437. class MathUtils {
  30438. static PI: number;
  30439. static PI2: number;
  30440. static radiansToDegrees: number;
  30441. static radDeg: number;
  30442. static degreesToRadians: number;
  30443. static degRad: number;
  30444. static clamp(value: number, min: number, max: number): number;
  30445. static cosDeg(degrees: number): number;
  30446. static sinDeg(degrees: number): number;
  30447. static signum(value: number): number;
  30448. static toInt(x: number): number;
  30449. static cbrt(x: number): number;
  30450. static randomTriangular(min: number, max: number): number;
  30451. static randomTriangularWith(min: number, max: number, mode: number): number;
  30452. }
  30453. abstract class Interpolation {
  30454. protected abstract applyInternal(a: number): number;
  30455. apply(start: number, end: number, a: number): number;
  30456. }
  30457. class Pow extends Interpolation {
  30458. protected power: number;
  30459. constructor(power: number);
  30460. applyInternal(a: number): number;
  30461. }
  30462. class PowOut extends Pow {
  30463. constructor(power: number);
  30464. applyInternal(a: number): number;
  30465. }
  30466. class Utils {
  30467. static SUPPORTS_TYPED_ARRAYS: boolean;
  30468. static arrayCopy<T>(source: ArrayLike<T>, sourceStart: number, dest: ArrayLike<T>, destStart: number, numElements: number): void;
  30469. static setArraySize<T>(array: Array<T>, size: number, value?: any): Array<T>;
  30470. static ensureArrayCapacity<T>(array: Array<T>, size: number, value?: any): Array<T>;
  30471. static newArray<T>(size: number, defaultValue: T): Array<T>;
  30472. static newFloatArray(size: number): ArrayLike<number>;
  30473. static newShortArray(size: number): ArrayLike<number>;
  30474. static toFloatArray(array: Array<number>): number[] | Float32Array;
  30475. static toSinglePrecision(value: number): number;
  30476. static webkit602BugfixHelper(alpha: number, blend: MixBlend): void;
  30477. static contains<T>(array: Array<T>, element: T, identity?: boolean): boolean;
  30478. }
  30479. class DebugUtils {
  30480. static logBones(skeleton: Skeleton): void;
  30481. }
  30482. class Pool<T> {
  30483. private items;
  30484. private instantiator;
  30485. constructor(instantiator: () => T);
  30486. obtain(): T;
  30487. free(item: T): void;
  30488. freeAll(items: ArrayLike<T>): void;
  30489. clear(): void;
  30490. }
  30491. class Vector2 {
  30492. x: number;
  30493. y: number;
  30494. constructor(x?: number, y?: number);
  30495. set(x: number, y: number): Vector2;
  30496. length(): number;
  30497. normalize(): this;
  30498. }
  30499. class TimeKeeper {
  30500. maxDelta: number;
  30501. framesPerSecond: number;
  30502. delta: number;
  30503. totalTime: number;
  30504. private lastTime;
  30505. private frameCount;
  30506. private frameTime;
  30507. update(): void;
  30508. }
  30509. interface ArrayLike<T> {
  30510. length: number;
  30511. [n: number]: T;
  30512. }
  30513. class WindowedMean {
  30514. values: Array<number>;
  30515. addedValues: number;
  30516. lastValue: number;
  30517. mean: number;
  30518. dirty: boolean;
  30519. constructor(windowSize?: number);
  30520. hasEnoughData(): boolean;
  30521. addValue(value: number): void;
  30522. getMean(): number;
  30523. }
  30524. }
  30525. declare namespace sp.spine {
  30526. interface VertexEffect {
  30527. begin(skeleton: Skeleton): void;
  30528. transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
  30529. end(): void;
  30530. }
  30531. }
  30532. interface Math {
  30533. fround(n: number): number;
  30534. }
  30535. declare namespace sp.spine {
  30536. abstract class Attachment {
  30537. name: string;
  30538. constructor(name: string);
  30539. abstract copy(): Attachment;
  30540. }
  30541. abstract class VertexAttachment extends Attachment {
  30542. private static nextID;
  30543. id: number;
  30544. bones: Array<number>;
  30545. vertices: ArrayLike<number>;
  30546. worldVerticesLength: number;
  30547. deformAttachment: VertexAttachment;
  30548. constructor(name: string);
  30549. computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
  30550. copyTo(attachment: VertexAttachment): void;
  30551. }
  30552. }
  30553. declare namespace sp.spine {
  30554. interface AttachmentLoader {
  30555. newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
  30556. newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
  30557. newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
  30558. newPathAttachment(skin: Skin, name: string): PathAttachment;
  30559. newPointAttachment(skin: Skin, name: string): PointAttachment;
  30560. newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
  30561. }
  30562. }
  30563. declare namespace sp.spine {
  30564. enum AttachmentType {
  30565. Region = 0,
  30566. BoundingBox = 1,
  30567. Mesh = 2,
  30568. LinkedMesh = 3,
  30569. Path = 4,
  30570. Point = 5,
  30571. Clipping = 6
  30572. }
  30573. }
  30574. declare namespace sp.spine {
  30575. class BoundingBoxAttachment extends VertexAttachment {
  30576. color: Color;
  30577. constructor(name: string);
  30578. copy(): Attachment;
  30579. }
  30580. }
  30581. declare namespace sp.spine {
  30582. class ClippingAttachment extends VertexAttachment {
  30583. endSlot: SlotData;
  30584. color: Color;
  30585. constructor(name: string);
  30586. copy(): Attachment;
  30587. }
  30588. }
  30589. declare namespace sp.spine {
  30590. class MeshAttachment extends VertexAttachment {
  30591. region: TextureRegion;
  30592. path: string;
  30593. regionUVs: ArrayLike<number>;
  30594. uvs: ArrayLike<number>;
  30595. triangles: Array<number>;
  30596. color: Color;
  30597. width: number;
  30598. height: number;
  30599. hullLength: number;
  30600. edges: Array<number>;
  30601. private parentMesh;
  30602. tempColor: Color;
  30603. constructor(name: string);
  30604. updateUVs(): void;
  30605. getParentMesh(): MeshAttachment;
  30606. setParentMesh(parentMesh: MeshAttachment): void;
  30607. copy(): Attachment;
  30608. newLinkedMesh(): MeshAttachment;
  30609. }
  30610. }
  30611. declare namespace sp.spine {
  30612. class PathAttachment extends VertexAttachment {
  30613. lengths: Array<number>;
  30614. closed: boolean;
  30615. constantSpeed: boolean;
  30616. color: Color;
  30617. constructor(name: string);
  30618. copy(): Attachment;
  30619. }
  30620. }
  30621. declare namespace sp.spine {
  30622. class PointAttachment extends VertexAttachment {
  30623. x: number;
  30624. y: number;
  30625. rotation: number;
  30626. color: Color;
  30627. constructor(name: string);
  30628. computeWorldPosition(bone: Bone, point: Vector2): Vector2;
  30629. computeWorldRotation(bone: Bone): number;
  30630. copy(): Attachment;
  30631. }
  30632. }
  30633. declare namespace sp.spine {
  30634. class RegionAttachment extends Attachment {
  30635. static OX1: number;
  30636. static OY1: number;
  30637. static OX2: number;
  30638. static OY2: number;
  30639. static OX3: number;
  30640. static OY3: number;
  30641. static OX4: number;
  30642. static OY4: number;
  30643. static X1: number;
  30644. static Y1: number;
  30645. static C1R: number;
  30646. static C1G: number;
  30647. static C1B: number;
  30648. static C1A: number;
  30649. static U1: number;
  30650. static V1: number;
  30651. static X2: number;
  30652. static Y2: number;
  30653. static C2R: number;
  30654. static C2G: number;
  30655. static C2B: number;
  30656. static C2A: number;
  30657. static U2: number;
  30658. static V2: number;
  30659. static X3: number;
  30660. static Y3: number;
  30661. static C3R: number;
  30662. static C3G: number;
  30663. static C3B: number;
  30664. static C3A: number;
  30665. static U3: number;
  30666. static V3: number;
  30667. static X4: number;
  30668. static Y4: number;
  30669. static C4R: number;
  30670. static C4G: number;
  30671. static C4B: number;
  30672. static C4A: number;
  30673. static U4: number;
  30674. static V4: number;
  30675. x: number;
  30676. y: number;
  30677. scaleX: number;
  30678. scaleY: number;
  30679. rotation: number;
  30680. width: number;
  30681. height: number;
  30682. color: Color;
  30683. path: string;
  30684. rendererObject: any;
  30685. region: TextureRegion;
  30686. offset: ArrayLike<number>;
  30687. uvs: ArrayLike<number>;
  30688. tempColor: Color;
  30689. constructor(name: string);
  30690. updateOffset(): void;
  30691. setRegion(region: TextureRegion): void;
  30692. computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
  30693. copy(): Attachment;
  30694. }
  30695. }
  30696. declare namespace sp.spine {
  30697. class JitterEffect implements VertexEffect {
  30698. jitterX: number;
  30699. jitterY: number;
  30700. constructor(jitterX: number, jitterY: number);
  30701. begin(skeleton: Skeleton): void;
  30702. transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
  30703. end(): void;
  30704. }
  30705. }
  30706. declare namespace sp.spine {
  30707. class SwirlEffect implements VertexEffect {
  30708. static interpolation: PowOut;
  30709. centerX: number;
  30710. centerY: number;
  30711. radius: number;
  30712. angle: number;
  30713. private worldX;
  30714. private worldY;
  30715. constructor(radius: number);
  30716. begin(skeleton: Skeleton): void;
  30717. transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
  30718. end(): void;
  30719. }
  30720. }
  30721. /**
  30722. * API for jsb module
  30723. * Author: haroel
  30724. * Homepage: https://github.com/haroel/creatorexDTS
  30725. */
  30726. declare namespace jsb{
  30727. export module reflection{
  30728. /**
  30729. * https://docs.cocos.com/creator/manual/zh/advanced-topics/java-reflection.html
  30730. * call OBJC/Java static methods
  30731. *
  30732. * @param className
  30733. * @param methodName
  30734. * @param methodSignature
  30735. * @param parameters
  30736. */
  30737. export function callStaticMethod (className: string, methodName: string, methodSignature: string, ...parameters:any): any;
  30738. }
  30739. /**
  30740. * 下载任务对象
  30741. */
  30742. export type DownloaderTask = { requestURL: string, storagePath: string, identifier: string };
  30743. /**
  30744. * Http file downloader for jsb!
  30745. */
  30746. export class Downloader{
  30747. /**
  30748. * create a download task
  30749. * @param requestURL
  30750. * @param storagePath
  30751. * @param identifier
  30752. */
  30753. createDownloadFileTask (requestURL:string, storagePath:string, identifier?:string): DownloaderTask;
  30754. setOnFileTaskSuccess (onSucceed: (task: DownloaderTask) => void): void;
  30755. setOnTaskProgress (onProgress: (task: DownloaderTask, bytesReceived: number, totalBytesReceived: number, totalBytesExpected: number) => void): void;
  30756. setOnTaskError (onError: (task: DownloaderTask, errorCode: number, errorCodeInternal: number, errorStr: string) => void): void;
  30757. }
  30758. export interface ManifestAsset {
  30759. md5: string;
  30760. path: string;
  30761. compressed: boolean;
  30762. size: number;
  30763. downloadState: number;
  30764. }
  30765. export class Manifest {
  30766. constructor (manifestUrl: string);
  30767. constructor (content: string, manifestRoot: string);
  30768. parseFile (manifestUrl: string): void;
  30769. parseJSONString (content: string, manifestRoot: string): void;
  30770. getManifestRoot (): string;
  30771. getManifestFileUrl (): string;
  30772. getVersionFileUrl (): string;
  30773. getSearchPaths (): [string];
  30774. getVersion (): string;
  30775. getPackageUrl (): boolean;
  30776. setUpdating (isUpdating: boolean): void;
  30777. isUpdating (): boolean;
  30778. isVersionLoaded (): boolean;
  30779. isLoaded (): boolean;
  30780. }
  30781. export class EventAssetsManager {
  30782. // EventCode
  30783. static ERROR_NO_LOCAL_MANIFEST: number;
  30784. static ERROR_DOWNLOAD_MANIFEST: number;
  30785. static ERROR_PARSE_MANIFEST: number;
  30786. static NEW_VERSION_FOUND: number;
  30787. static ALREADY_UP_TO_DATE: number;
  30788. static UPDATE_PROGRESSION: number;
  30789. static ASSET_UPDATED: number;
  30790. static ERROR_UPDATING: number;
  30791. static UPDATE_FINISHED: number;
  30792. static UPDATE_FAILED: number;
  30793. static ERROR_DECOMPRESS: number;
  30794. constructor (eventName: string, manager: AssetsManager, eventCode: number,
  30795. assetId?: string, message?: string, curleCode?: number, curlmCode?: number);
  30796. getAssetsManagerEx (): AssetsManager;
  30797. isResuming (): boolean;
  30798. getDownloadedFiles (): number;
  30799. getDownloadedBytes (): number;
  30800. getTotalFiles (): number;
  30801. getTotalBytes (): number;
  30802. getPercent (): number;
  30803. getPercentByFile (): number;
  30804. getEventCode (): number;
  30805. getMessage (): string;
  30806. getAssetId (): string;
  30807. getCURLECode (): number;
  30808. getCURLMCode (): number;
  30809. }
  30810. export module AssetsManager {
  30811. export enum State {
  30812. UNINITED,
  30813. UNCHECKED,
  30814. PREDOWNLOAD_VERSION,
  30815. DOWNLOADING_VERSION,
  30816. VERSION_LOADED,
  30817. PREDOWNLOAD_MANIFEST,
  30818. DOWNLOADING_MANIFEST,
  30819. MANIFEST_LOADED,
  30820. NEED_UPDATE,
  30821. READY_TO_UPDATE,
  30822. UPDATING,
  30823. UNZIPPING,
  30824. UP_TO_DATE,
  30825. FAIL_TO_UPDATE,
  30826. }
  30827. }
  30828. export class AssetsManager {
  30829. constructor (manifestUrl: string, storagePath: string, versionCompareHandle?: (versionA: string, versionB: string) => number);
  30830. static create (manifestUrl: string, storagePath: string): AssetsManager;
  30831. getState (): AssetsManager.State;
  30832. getStoragePath (): string
  30833. getMaxConcurrentTask (): number;
  30834. // setMaxConcurrentTask (max: number): void; // actually not supported
  30835. checkUpdate (): void;
  30836. prepareUpdate (): void;
  30837. update (): void;
  30838. isResuming (): boolean;
  30839. getDownloadedFiles (): number;
  30840. getDownloadedBytes (): number;
  30841. getTotalFiles (): number;
  30842. getTotalBytes (): number;
  30843. downloadFailedAssets (): void;
  30844. getLocalManifest (): Manifest;
  30845. loadLocalManifest (manifestUrl: string): boolean;
  30846. loadLocalManifest (localManifest: Manifest, storagePath: string): boolean;
  30847. getRemoteManifest (): Manifest;
  30848. loadRemoteManifest (remoteManifest: Manifest): boolean;
  30849. /**
  30850. * Setup your own version compare handler, versionA and B is versions in string.
  30851. * if the return value greater than 0, versionA is greater than B,
  30852. * if the return value equals 0, versionA equals to B,
  30853. * if the return value smaller than 0, versionA is smaller than B.
  30854. */
  30855. setVersionCompareHandle (versionCompareHandle?: (versionA: string, versionB: string) => number): void;
  30856. /**
  30857. * Setup the verification callback, Return true if the verification passed, otherwise return false
  30858. */
  30859. setVerifyCallback (verifyCallback: (path: string, asset: ManifestAsset) => boolean): void;
  30860. setEventCallback (eventCallback: (event: EventAssetsManager) => void): void;
  30861. }
  30862. /**
  30863. * FileUtils Helper class to handle file operations.
  30864. */
  30865. export module fileUtils{
  30866. /**
  30867. * Checks whether the path is an absolute path.
  30868. *
  30869. * @note On Android, if the parameter passed in is relative to "@assets/", this method will treat it as an absolute path.
  30870. * Also on Blackberry, path starts with "app/native/Resources/" is treated as an absolute path.
  30871. *
  30872. * @param path The path that needs to be checked.
  30873. * @return True if it's an absolute path, false if not.
  30874. */
  30875. export function isAbsolutePath (path:string):boolean;
  30876. /** Returns the fullpath for a given filename.
  30877. First it will try to get a new filename from the "filenameLookup" dictionary.
  30878. If a new filename can't be found on the dictionary, it will use the original filename.
  30879. Then it will try to obtain the full path of the filename using the FileUtils search rules: resolutions, and search paths.
  30880. The file search is based on the array element order of search paths and resolution directories.
  30881. For instance:
  30882. We set two elements("/mnt/sdcard/", "internal_dir/") to search paths vector by setSearchPaths,
  30883. and set three elements("resources-ipadhd/", "resources-ipad/", "resources-iphonehd")
  30884. to resolutions vector by setSearchResolutionsOrder. The "internal_dir" is relative to "Resources/".
  30885. If we have a file named 'sprite.png', the mapping in fileLookup dictionary contains `key: sprite.png -> value: sprite.pvr.gz`.
  30886. Firstly, it will replace 'sprite.png' with 'sprite.pvr.gz', then searching the file sprite.pvr.gz as follows:
  30887. /mnt/sdcard/resources-ipadhd/sprite.pvr.gz (if not found, search next)
  30888. /mnt/sdcard/resources-ipad/sprite.pvr.gz (if not found, search next)
  30889. /mnt/sdcard/resources-iphonehd/sprite.pvr.gz (if not found, search next)
  30890. /mnt/sdcard/sprite.pvr.gz (if not found, search next)
  30891. internal_dir/resources-ipadhd/sprite.pvr.gz (if not found, search next)
  30892. internal_dir/resources-ipad/sprite.pvr.gz (if not found, search next)
  30893. internal_dir/resources-iphonehd/sprite.pvr.gz (if not found, search next)
  30894. internal_dir/sprite.pvr.gz (if not found, return "sprite.png")
  30895. If the filename contains relative path like "gamescene/uilayer/sprite.png",
  30896. and the mapping in fileLookup dictionary contains `key: gamescene/uilayer/sprite.png -> value: gamescene/uilayer/sprite.pvr.gz`.
  30897. The file search order will be:
  30898. /mnt/sdcard/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next)
  30899. /mnt/sdcard/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next)
  30900. /mnt/sdcard/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next)
  30901. /mnt/sdcard/gamescene/uilayer/sprite.pvr.gz (if not found, search next)
  30902. internal_dir/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next)
  30903. internal_dir/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next)
  30904. internal_dir/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next)
  30905. internal_dir/gamescene/uilayer/sprite.pvr.gz (if not found, return "gamescene/uilayer/sprite.png")
  30906. If the new file can't be found on the file system, it will return the parameter filename directly.
  30907. This method was added to simplify multiplatform support. Whether you are using cocos2d-js or any cross-compilation toolchain like StellaSDK or Apportable,
  30908. you might need to load different resources for a given file in the different platforms.
  30909. @since v2.1
  30910. */
  30911. export function fullPathForFilename (filename:string):string;
  30912. /**
  30913. * Gets string from a file.
  30914. */
  30915. export function getStringFromFile (filename:string):string;
  30916. /**
  30917. * Removes a file.
  30918. *
  30919. * @param filepath The full path of the file, it must be an absolute path.
  30920. * @return True if the file have been removed successfully, false if not.
  30921. */
  30922. export function removeFile (filepath:string):boolean;
  30923. /**
  30924. * Checks whether the path is a directory.
  30925. *
  30926. * @param dirPath The path of the directory, it could be a relative or an absolute path.
  30927. * @return True if the directory exists, false if not.
  30928. */
  30929. export function isDirectoryExist (dirPath:string):boolean;
  30930. /**
  30931. * Normalize: remove . and ..
  30932. * @param filepath
  30933. */
  30934. export function normalizePath (filepath:string):string;
  30935. /**
  30936. * Get default resource root path.
  30937. */
  30938. export function getDefaultResourceRootPath ():string;
  30939. /**
  30940. * Loads the filenameLookup dictionary from the contents of a filename.
  30941. *
  30942. * @note The plist file name should follow the format below:
  30943. *
  30944. * @code
  30945. * <?xml version="1.0" encoding="UTF-8"?>
  30946. * <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  30947. * <plist version="1.0">
  30948. * <dict>
  30949. * <key>filenames</key>
  30950. * <dict>
  30951. * <key>sounds/click.wav</key>
  30952. * <string>sounds/click.caf</string>
  30953. * <key>sounds/endgame.wav</key>
  30954. * <string>sounds/endgame.caf</string>
  30955. * <key>sounds/gem-0.wav</key>
  30956. * <string>sounds/gem-0.caf</string>
  30957. * </dict>
  30958. * <key>metadata</key>
  30959. * <dict>
  30960. * <key>version</key>
  30961. * <integer>1</integer>
  30962. * </dict>
  30963. * </dict>
  30964. * </plist>
  30965. * @endcode
  30966. * @param filename The plist file name.
  30967. *
  30968. @since v2.1
  30969. * @js loadFilenameLookup
  30970. * @lua loadFilenameLookup
  30971. */
  30972. export function loadFilenameLookup (filepath:string):void;
  30973. /** Checks whether to pop up a message box when failed to load an image.
  30974. * @return True if pop up a message box when failed to load an image, false if not.
  30975. */
  30976. export function isPopupNotify ():boolean;
  30977. /**
  30978. * Sets whether to pop-up a message box when failed to load an image.
  30979. */
  30980. export function setPopupNotify (notify:boolean):void;
  30981. // Converts the contents of a file to a ValueVector.
  30982. // This method is used internally.
  30983. export function getValueVectorFromFile (filepath:string):Array<any>;
  30984. /**
  30985. * Gets the array of search paths.
  30986. *
  30987. * @return The array of search paths which may contain the prefix of default resource root path.
  30988. * @note In best practise, getter function should return the value of setter function passes in.
  30989. * But since we should not break the compatibility, we keep using the old logic.
  30990. * Therefore, If you want to get the original search paths, please call 'getOriginalSearchPaths()' instead.
  30991. * @see fullPathForFilename(const char*).
  30992. * @lua NA
  30993. */
  30994. export function getSearchPaths ():Array<string>;
  30995. /**
  30996. *
  30997. * @param filepath
  30998. */
  30999. export function getFileDir (filepath:string):string;
  31000. /**
  31001. * write a ValueMap into a plist file
  31002. *
  31003. *@param dict the ValueMap want to save (key,value)
  31004. *@param fullPath The full path to the file you want to save a string
  31005. *@return bool
  31006. */
  31007. export function writeToFile ( valueMap:any ):boolean;
  31008. /**
  31009. * Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'.
  31010. * @return The array of the original search paths
  31011. */
  31012. export function getOriginalSearchPaths ():Array<string>;
  31013. /**
  31014. * List all files in a directory.
  31015. *
  31016. * @param dirPath The path of the directory, it could be a relative or an absolute path.
  31017. * @return File paths in a string vector
  31018. */
  31019. export function listFiles (filepath:string):Array<string>;
  31020. /**
  31021. * Converts the contents of a file to a ValueMap.
  31022. * @param filename The filename of the file to gets content.
  31023. * @return ValueMap of the file contents.
  31024. * @note This method is used internally.
  31025. */
  31026. export function getValueMapFromFile (filepath:string):any;
  31027. /**
  31028. * Retrieve the file size.
  31029. *
  31030. * @note If a relative path was passed in, it will be inserted a default root path at the beginning.
  31031. * @param filepath The path of the file, it could be a relative or absolute path.
  31032. * @return The file size.
  31033. */
  31034. export function getFileSize (filepath:string):number;
  31035. /** Converts the contents of a file to a ValueMap.
  31036. * This method is used internally.
  31037. */
  31038. export function getValueMapFromData (filedata:string,filesize:number):any;
  31039. /**
  31040. * Removes a directory.
  31041. *
  31042. * @param dirPath The full path of the directory, it must be an absolute path.
  31043. * @return True if the directory have been removed successfully, false if not.
  31044. */
  31045. export function removeDirectory (dirPath:string):boolean;
  31046. /**
  31047. * Sets the array of search paths.
  31048. *
  31049. * You can use this array to modify the search path of the resources.
  31050. * If you want to use "themes" or search resources in the "cache", you can do it easily by adding new entries in this array.
  31051. *
  31052. * @note This method could access relative path and absolute path.
  31053. * If the relative path was passed to the vector, FileUtils will add the default resource directory before the relative path.
  31054. * For instance:
  31055. * On Android, the default resource root path is "@assets/".
  31056. * If "/mnt/sdcard/" and "resources-large" were set to the search paths vector,
  31057. * "resources-large" will be converted to "@assets/resources-large" since it was a relative path.
  31058. *
  31059. * @param searchPaths The array contains search paths.
  31060. * @see fullPathForFilename(const char*)
  31061. * @since v2.1
  31062. * In js:var setSearchPaths(var jsval);
  31063. * @lua NA
  31064. */
  31065. export function setSearchPaths ( searchPath:Array<string>):void;
  31066. /**
  31067. * write a string into a file
  31068. *
  31069. * @param dataStr the string want to save
  31070. * @param fullPath The full path to the file you want to save a string
  31071. * @return bool True if write success
  31072. */
  31073. export function writeStringToFile (dataStr:string,fullPath:string):boolean;
  31074. /**
  31075. * Sets the array that contains the search order of the resources.
  31076. *
  31077. * @param searchResolutionsOrder The source array that contains the search order of the resources.
  31078. * @see getSearchResolutionsOrder(), fullPathForFilename(const char*).
  31079. * @since v2.1
  31080. * In js:var setSearchResolutionsOrder(var jsval)
  31081. * @lua NA
  31082. */
  31083. export function setSearchResolutionsOrder (searchResolutionsOrder:Array<string>):void;
  31084. /**
  31085. * Append search order of the resources.
  31086. *
  31087. * @see setSearchResolutionsOrder(), fullPathForFilename().
  31088. * @since v2.1
  31089. */
  31090. export function addSearchResolutionsOrder (order:string,front:boolean):void;
  31091. /**
  31092. * Add search path.
  31093. *
  31094. * @since v2.1
  31095. */
  31096. export function addSearchPath (path:string,front:boolean):void;
  31097. /**
  31098. * write ValueVector into a plist file
  31099. *
  31100. *@param vecData the ValueVector want to save
  31101. *@param fullPath The full path to the file you want to save a string
  31102. *@return bool
  31103. */
  31104. export function writeValueVectorToFile (vecData:Array<any>,fullPath:string):boolean;
  31105. /**
  31106. * Checks whether a file exists.
  31107. *
  31108. * @note If a relative path was passed in, it will be inserted a default root path at the beginning.
  31109. * @param filename The path of the file, it could be a relative or absolute path.
  31110. * @return True if the file exists, false if not.
  31111. */
  31112. export function isFileExist (filename:string):boolean;
  31113. /**©∫
  31114. * Purges full path caches.
  31115. */
  31116. export function purgeCachedEntries ():void;
  31117. /**
  31118. * Gets full path from a file name and the path of the relative file.
  31119. * @param filename The file name.
  31120. * @param relativeFile The path of the relative file.
  31121. * @return The full path.
  31122. * e.g. filename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist
  31123. * Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. )
  31124. *
  31125. */
  31126. export function fullPathFromRelativeFile (filename:string,relativeFile:string):string;
  31127. /**
  31128. * Windows fopen can't support UTF-8 filename
  31129. * Need convert all parameters fopen and other 3rd-party libs
  31130. *
  31131. * @param filenameUtf8 std::string name file for conversion from utf-8
  31132. * @return std::string ansi filename in current locale
  31133. */
  31134. export function getSuitableFOpen (filenameUtf8:string):string;
  31135. /**
  31136. * write ValueMap into a plist file
  31137. *
  31138. *@param dict the ValueMap want to save
  31139. *@param fullPath The full path to the file you want to save a string
  31140. *@return bool
  31141. */
  31142. export function writeValueMapToFile (dict:any,fullPath:string):string;
  31143. /**
  31144. * Gets filename extension is a suffix (separated from the base filename by a dot) in lower case.
  31145. * Examples of filename extensions are .png, .jpeg, .exe, .dmg and .txt.
  31146. * @param filePath The path of the file, it could be a relative or absolute path.
  31147. * @return suffix for filename in lower case or empty if a dot not found.
  31148. */
  31149. export function getFileExtension (filePath:string):string;
  31150. /**
  31151. * Sets writable path.
  31152. */
  31153. export function setWritablePath (writablePath:string):void;
  31154. /**
  31155. * Set default resource root path.
  31156. */
  31157. export function setDefaultResourceRootPath (filepath:string):void;
  31158. /**
  31159. * Gets the array that contains the search order of the resources.
  31160. *
  31161. * @see setSearchResolutionsOrder(const std::vector<std::string>&), fullPathForFilename(const char*).
  31162. * @since v2.1
  31163. * @lua NA
  31164. */
  31165. export function getSearchResolutionsOrder ():Array<string>;
  31166. /**
  31167. * Creates a directory.
  31168. *
  31169. * @param dirPath The path of the directory, it must be an absolute path.
  31170. * @return True if the directory have been created successfully, false if not.
  31171. */
  31172. export function createDirectory (dirPath:string):string;
  31173. /**
  31174. * List all files recursively in a directory.
  31175. *
  31176. * @param dirPath The path of the directory, it could be a relative or an absolute path.
  31177. * @return File paths in a string vector
  31178. */
  31179. export function listFilesRecursively (dirPath:string, files:Array<string>):void;
  31180. /**
  31181. * Gets the writable path.
  31182. * @return The path that can be write/read a file in
  31183. */
  31184. export function getWritablePath ():string;
  31185. }
  31186. }